@lina-openx/react-native-lina-pay-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LinaPaySdk.podspec +20 -0
- package/README.md +522 -0
- package/android/build.gradle +77 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/linapaysdk/LinaPaySdkModule.kt +18 -0
- package/android/src/main/java/com/linapaysdk/LinaPaySdkPackage.kt +17 -0
- package/ios/LinaPaySdk.h +5 -0
- package/ios/LinaPaySdk.mm +16 -0
- package/lib/module/config/environment.js +61 -0
- package/lib/module/config/environment.js.map +1 -0
- package/lib/module/index.js +142 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/services/auth.service.js +73 -0
- package/lib/module/services/auth.service.js.map +1 -0
- package/lib/module/services/consent.service.js +49 -0
- package/lib/module/services/consent.service.js.map +1 -0
- package/lib/module/services/participants.service.js +71 -0
- package/lib/module/services/participants.service.js.map +1 -0
- package/lib/module/services/payment.service.js +39 -0
- package/lib/module/services/payment.service.js.map +1 -0
- package/lib/module/types/auth.types.js +2 -0
- package/lib/module/types/auth.types.js.map +1 -0
- package/lib/module/types/consent.types.js +2 -0
- package/lib/module/types/consent.types.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/participants.types.js +2 -0
- package/lib/module/types/participants.types.js.map +1 -0
- package/lib/module/types/payment.types.js +2 -0
- package/lib/module/types/payment.types.js.map +1 -0
- package/lib/module/utils/consent.utils.js +168 -0
- package/lib/module/utils/consent.utils.js.map +1 -0
- package/lib/module/utils/http.utils.js +58 -0
- package/lib/module/utils/http.utils.js.map +1 -0
- package/lib/module/utils/payment.utils.js +27 -0
- package/lib/module/utils/payment.utils.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/config/environment.d.ts +38 -0
- package/lib/typescript/src/config/environment.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +108 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/services/auth.service.d.ts +13 -0
- package/lib/typescript/src/services/auth.service.d.ts.map +1 -0
- package/lib/typescript/src/services/consent.service.d.ts +9 -0
- package/lib/typescript/src/services/consent.service.d.ts.map +1 -0
- package/lib/typescript/src/services/participants.service.d.ts +9 -0
- package/lib/typescript/src/services/participants.service.d.ts.map +1 -0
- package/lib/typescript/src/services/payment.service.d.ts +9 -0
- package/lib/typescript/src/services/payment.service.d.ts.map +1 -0
- package/lib/typescript/src/types/auth.types.d.ts +23 -0
- package/lib/typescript/src/types/auth.types.d.ts.map +1 -0
- package/lib/typescript/src/types/consent.types.d.ts +129 -0
- package/lib/typescript/src/types/consent.types.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +9 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/participants.types.d.ts +50 -0
- package/lib/typescript/src/types/participants.types.d.ts.map +1 -0
- package/lib/typescript/src/types/payment.types.d.ts +107 -0
- package/lib/typescript/src/types/payment.types.d.ts.map +1 -0
- package/lib/typescript/src/utils/consent.utils.d.ts +10 -0
- package/lib/typescript/src/utils/consent.utils.d.ts.map +1 -0
- package/lib/typescript/src/utils/http.utils.d.ts +21 -0
- package/lib/typescript/src/utils/http.utils.d.ts.map +1 -0
- package/lib/typescript/src/utils/payment.utils.d.ts +10 -0
- package/lib/typescript/src/utils/payment.utils.d.ts.map +1 -0
- package/package.json +169 -0
- package/src/config/environment.ts +58 -0
- package/src/index.tsx +178 -0
- package/src/services/auth.service.ts +88 -0
- package/src/services/consent.service.ts +63 -0
- package/src/services/participants.service.ts +89 -0
- package/src/services/payment.service.ts +49 -0
- package/src/types/auth.types.ts +24 -0
- package/src/types/consent.types.ts +152 -0
- package/src/types/index.ts +34 -0
- package/src/types/participants.types.ts +53 -0
- package/src/types/payment.types.ts +141 -0
- package/src/utils/consent.utils.ts +225 -0
- package/src/utils/http.utils.ts +80 -0
- package/src/utils/payment.utils.ts +32 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types exported by Lina Pay SDK
|
|
3
|
+
*/
|
|
4
|
+
export type { LinaPayCredentials } from './auth.types';
|
|
5
|
+
export type { Participant } from './participants.types';
|
|
6
|
+
export type { LinaPayConfig } from '../config/environment';
|
|
7
|
+
export type { CreateConsentRequest, CreateConsentResponse, Payment, Creditor, Debitor, Schedule, SingleSchedule, DailySchedule, WeeklySchedule, MonthlySchedule, CustomSchedule, PersonType, AccountType, DayOfWeek, Platform, } from './consent.types';
|
|
8
|
+
export type { CreatePaymentRequest, CreatePaymentResponse, PaymentItem, PaymentCreditor, PaymentDebitor, PaymentType, PaymentStatus, PaymentItemStatus, } from './payment.types';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,OAAO,EACP,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,UAAU,EACV,WAAW,EACX,SAAS,EACT,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,cAAc,EACd,WAAW,EACX,aAAa,EACb,iBAAiB,GAClB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Resource information
|
|
3
|
+
*/
|
|
4
|
+
export interface ApiResource {
|
|
5
|
+
ApiFamilyType: string;
|
|
6
|
+
ApiVersion: string;
|
|
7
|
+
ApiDiscoveryEndpoints: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Authorisation Server (from API response)
|
|
11
|
+
*/
|
|
12
|
+
export interface AuthorisationServer {
|
|
13
|
+
AuthorisationServerId: string;
|
|
14
|
+
CustomerFriendlyName: string;
|
|
15
|
+
CustomerFriendlyDescription: string;
|
|
16
|
+
CustomerFriendlyLogoUri: string;
|
|
17
|
+
OpenIDDiscoveryDocument: string;
|
|
18
|
+
ApiResources: ApiResource[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Full participant data from API
|
|
22
|
+
*/
|
|
23
|
+
export interface ParticipantFull {
|
|
24
|
+
OrganisationName: string;
|
|
25
|
+
OrganisationId: string;
|
|
26
|
+
LegalEntityName: string;
|
|
27
|
+
RegistrationNumber: string;
|
|
28
|
+
ParentOrganisationReference: string;
|
|
29
|
+
AuthorisationServers: AuthorisationServer[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* API response for participants list
|
|
33
|
+
*/
|
|
34
|
+
export interface ParticipantsApiResponse {
|
|
35
|
+
data: ParticipantFull[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Simplified participant data returned by SDK
|
|
39
|
+
* One entry per AuthorisationServer (flattened from API response)
|
|
40
|
+
*/
|
|
41
|
+
export interface Participant {
|
|
42
|
+
organisationId: string;
|
|
43
|
+
organisationName: string;
|
|
44
|
+
legalEntityName: string;
|
|
45
|
+
registrationNumber: string;
|
|
46
|
+
authorisationServerId: string;
|
|
47
|
+
customerFriendlyName: string;
|
|
48
|
+
customerFriendlyLogoUri: string;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=participants.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"participants.types.d.ts","sourceRoot":"","sources":["../../../../src/types/participants.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,EAAE,MAAM,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,2BAA2B,EAAE,MAAM,CAAC;IACpC,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,2BAA2B,EAAE,MAAM,CAAC;IACpC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,eAAe,EAAE,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,CAAC;CACjC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payment types for payment creation
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Payment type
|
|
6
|
+
*/
|
|
7
|
+
export type PaymentType = 'NOW' | 'SINGLE' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'CUSTOM';
|
|
8
|
+
/**
|
|
9
|
+
* Payment status
|
|
10
|
+
*/
|
|
11
|
+
export type PaymentStatus = 'PENDENTE' | 'EM_PROCESSAMENTO' | 'CONSUMIDO' | 'EXPIRADO' | 'CANCELADO' | 'ERRO_NA_DETENTORA' | 'ERRO';
|
|
12
|
+
/**
|
|
13
|
+
* Payment item status
|
|
14
|
+
*/
|
|
15
|
+
export type PaymentItemStatus = 'PENDENTE' | 'REJEITADO' | 'EM_PROCESSAMENTO' | 'PAGO' | 'EXPIRADO' | 'CANCELADO' | 'ERRO_NA_DETENTORA' | 'ERRO' | 'PROGRAMADO' | 'AGUARDANDO_VALOR' | 'PRONTO_PARA_ENVIO';
|
|
16
|
+
/**
|
|
17
|
+
* Payment item in the payments array
|
|
18
|
+
*/
|
|
19
|
+
export interface PaymentItem {
|
|
20
|
+
endToEndId: string;
|
|
21
|
+
id: string;
|
|
22
|
+
dueDate: string;
|
|
23
|
+
externalComment?: string;
|
|
24
|
+
txId: string | null;
|
|
25
|
+
status: PaymentItemStatus;
|
|
26
|
+
externalPaymentId: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creditor information in payment response
|
|
30
|
+
*/
|
|
31
|
+
export interface PaymentCreditor {
|
|
32
|
+
name: string;
|
|
33
|
+
personType: 'PESSOA_NATURAL' | 'PESSOA_JURIDICA';
|
|
34
|
+
cpfCnpj: string;
|
|
35
|
+
accountIspb: string;
|
|
36
|
+
accountIssuer: string;
|
|
37
|
+
accountNumber: string;
|
|
38
|
+
accountPixKey: string | null;
|
|
39
|
+
accountType: 'CACC' | 'SLRY' | 'SVGS' | 'TRAN';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Debitor information in payment response
|
|
43
|
+
*/
|
|
44
|
+
export interface PaymentDebitor {
|
|
45
|
+
accountIspb: string;
|
|
46
|
+
accountIssuer: string;
|
|
47
|
+
accountNumber: string;
|
|
48
|
+
accountType: 'CACC' | 'SLRY' | 'SVGS' | 'TRAN';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Payment data from API
|
|
52
|
+
*/
|
|
53
|
+
export interface PaymentData {
|
|
54
|
+
id: string;
|
|
55
|
+
type: PaymentType;
|
|
56
|
+
createDateTime: string;
|
|
57
|
+
externalId?: string;
|
|
58
|
+
externalComment?: string;
|
|
59
|
+
lastChangedDateTime: string;
|
|
60
|
+
status: PaymentStatus;
|
|
61
|
+
tenantId: string;
|
|
62
|
+
cpfCnpj: string;
|
|
63
|
+
redirectUri: string;
|
|
64
|
+
value: string;
|
|
65
|
+
consentId: string;
|
|
66
|
+
creditor: PaymentCreditor;
|
|
67
|
+
debitor?: PaymentDebitor;
|
|
68
|
+
payments: PaymentItem[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Request payload for payment creation
|
|
72
|
+
*/
|
|
73
|
+
export interface CreatePaymentRequest {
|
|
74
|
+
state: string;
|
|
75
|
+
code: string;
|
|
76
|
+
idToken: string;
|
|
77
|
+
tenantId: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Response from payment creation API (with wrapper)
|
|
81
|
+
*/
|
|
82
|
+
export interface CreatePaymentApiResponse {
|
|
83
|
+
data: PaymentData;
|
|
84
|
+
message: string;
|
|
85
|
+
type: 'success' | 'error';
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Response from payment creation (transformed, without wrapper)
|
|
89
|
+
*/
|
|
90
|
+
export interface CreatePaymentResponse {
|
|
91
|
+
id: string;
|
|
92
|
+
type: PaymentType;
|
|
93
|
+
createDateTime: string;
|
|
94
|
+
externalId?: string;
|
|
95
|
+
externalComment?: string;
|
|
96
|
+
lastChangedDateTime: string;
|
|
97
|
+
status: PaymentStatus;
|
|
98
|
+
tenantId: string;
|
|
99
|
+
cpfCnpj: string;
|
|
100
|
+
redirectUri: string;
|
|
101
|
+
value: string;
|
|
102
|
+
consentId: string;
|
|
103
|
+
creditor: PaymentCreditor;
|
|
104
|
+
debitor?: PaymentDebitor;
|
|
105
|
+
payments: PaymentItem[];
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=payment.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.types.d.ts","sourceRoot":"","sources":["../../../../src/types/payment.types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent utilities for payload validation
|
|
3
|
+
*/
|
|
4
|
+
import type { CreateConsentRequest } from '../types/consent.types';
|
|
5
|
+
/**
|
|
6
|
+
* Validate consent payload before sending to API
|
|
7
|
+
* Throws LinaPayError if validation fails
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateConsentPayload(payload: CreateConsentRequest): void;
|
|
10
|
+
//# sourceMappingURL=consent.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent.utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/consent.utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAmFnE;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,oBAAoB,GAC5B,IAAI,CAsDN"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP utilities for error handling and request management
|
|
3
|
+
*/
|
|
4
|
+
export declare class LinaPayError extends Error {
|
|
5
|
+
statusCode?: number | undefined;
|
|
6
|
+
originalError?: unknown | undefined;
|
|
7
|
+
constructor(message: string, statusCode?: number | undefined, originalError?: unknown | undefined);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Handle HTTP response errors
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleHttpError(response: Response): Promise<never>;
|
|
13
|
+
/**
|
|
14
|
+
* Validate credentials before making requests
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateCredentials(subtenantId: string, subtenantSecret: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Handle network errors
|
|
19
|
+
*/
|
|
20
|
+
export declare function handleNetworkError(error: unknown): never;
|
|
21
|
+
//# sourceMappingURL=http.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/http.utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,YAAa,SAAQ,KAAK;IAG5B,UAAU,CAAC,EAAE,MAAM;IACnB,aAAa,CAAC,EAAE,OAAO;gBAF9B,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,aAAa,CAAC,EAAE,OAAO,YAAA;CAKjC;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CA6BxE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,GACtB,IAAI,CAQN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAWxD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payment utilities for payload validation
|
|
3
|
+
*/
|
|
4
|
+
import type { CreatePaymentRequest } from '../types/payment.types';
|
|
5
|
+
/**
|
|
6
|
+
* Validate payment payload before sending to API
|
|
7
|
+
* Throws LinaPayError if validation fails
|
|
8
|
+
*/
|
|
9
|
+
export declare function validatePaymentPayload(payload: CreatePaymentRequest): void;
|
|
10
|
+
//# sourceMappingURL=payment.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/payment.utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAcnE;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,oBAAoB,GAC5B,IAAI,CAKN"}
|
package/package.json
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lina-openx/react-native-lina-pay-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create Open Finance Payments EasilyCreate Open Finance Payments",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"example": "yarn workspace react-native-lina-pay-sdk-example",
|
|
36
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
37
|
+
"prepare": "bob build",
|
|
38
|
+
"typecheck": "tsc",
|
|
39
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
40
|
+
"test": "jest",
|
|
41
|
+
"release": "release-it --only-version"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"react-native",
|
|
45
|
+
"ios",
|
|
46
|
+
"android"
|
|
47
|
+
],
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://gitlab.com/lina-infratech/ob-data-pull/react-native-lina-pay-sdk.git"
|
|
51
|
+
},
|
|
52
|
+
"author": "Lina OpenX <suporte@linaopenx.com.br> (https://www.linaopenx.com.br/)",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://gitlab.com/lina-infratech/ob-data-pull/react-native-lina-pay-sdk/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://gitlab.com/lina-infratech/ob-data-pull/react-native-lina-pay-sdk#readme",
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
63
|
+
"@eslint/compat": "^1.3.2",
|
|
64
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
65
|
+
"@eslint/js": "^9.35.0",
|
|
66
|
+
"@react-native/babel-preset": "0.83.0",
|
|
67
|
+
"@react-native/eslint-config": "0.83.0",
|
|
68
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
69
|
+
"@types/jest": "^29.5.14",
|
|
70
|
+
"@types/react": "^19.2.0",
|
|
71
|
+
"commitlint": "^19.8.1",
|
|
72
|
+
"del-cli": "^6.0.0",
|
|
73
|
+
"eslint": "^9.35.0",
|
|
74
|
+
"eslint-config-prettier": "^10.1.8",
|
|
75
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
76
|
+
"jest": "^29.7.0",
|
|
77
|
+
"lefthook": "^2.0.3",
|
|
78
|
+
"prettier": "^2.8.8",
|
|
79
|
+
"react": "19.2.0",
|
|
80
|
+
"react-native": "0.83.0",
|
|
81
|
+
"react-native-builder-bob": "^0.40.13",
|
|
82
|
+
"release-it": "^19.0.4",
|
|
83
|
+
"turbo": "^2.5.6",
|
|
84
|
+
"typescript": "^5.9.2"
|
|
85
|
+
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"react": "*",
|
|
88
|
+
"react-native": "*"
|
|
89
|
+
},
|
|
90
|
+
"workspaces": [
|
|
91
|
+
"example"
|
|
92
|
+
],
|
|
93
|
+
"packageManager": "yarn@4.11.0",
|
|
94
|
+
"react-native-builder-bob": {
|
|
95
|
+
"source": "src",
|
|
96
|
+
"output": "lib",
|
|
97
|
+
"targets": [
|
|
98
|
+
[
|
|
99
|
+
"module",
|
|
100
|
+
{
|
|
101
|
+
"esm": true
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
"typescript",
|
|
106
|
+
{
|
|
107
|
+
"project": "tsconfig.build.json"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"codegenConfig": {
|
|
113
|
+
"name": "LinaPaySdkSpec",
|
|
114
|
+
"type": "modules",
|
|
115
|
+
"jsSrcsDir": "src",
|
|
116
|
+
"android": {
|
|
117
|
+
"javaPackageName": "com.linapaysdk"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"prettier": {
|
|
121
|
+
"quoteProps": "consistent",
|
|
122
|
+
"singleQuote": true,
|
|
123
|
+
"tabWidth": 2,
|
|
124
|
+
"trailingComma": "es5",
|
|
125
|
+
"useTabs": false
|
|
126
|
+
},
|
|
127
|
+
"jest": {
|
|
128
|
+
"preset": "react-native",
|
|
129
|
+
"modulePathIgnorePatterns": [
|
|
130
|
+
"<rootDir>/example/node_modules",
|
|
131
|
+
"<rootDir>/lib/"
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
"commitlint": {
|
|
135
|
+
"extends": [
|
|
136
|
+
"@commitlint/config-conventional"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"release-it": {
|
|
140
|
+
"git": {
|
|
141
|
+
"commitMessage": "chore: release ${version}",
|
|
142
|
+
"tagName": "v${version}"
|
|
143
|
+
},
|
|
144
|
+
"npm": {
|
|
145
|
+
"publish": true
|
|
146
|
+
},
|
|
147
|
+
"github": {
|
|
148
|
+
"release": true
|
|
149
|
+
},
|
|
150
|
+
"plugins": {
|
|
151
|
+
"@release-it/conventional-changelog": {
|
|
152
|
+
"preset": {
|
|
153
|
+
"name": "angular"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"create-react-native-library": {
|
|
159
|
+
"type": "turbo-module",
|
|
160
|
+
"languages": "kotlin-objc",
|
|
161
|
+
"tools": [
|
|
162
|
+
"eslint",
|
|
163
|
+
"jest",
|
|
164
|
+
"lefthook",
|
|
165
|
+
"release-it"
|
|
166
|
+
],
|
|
167
|
+
"version": "0.56.0"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment configuration for Lina Pay SDK
|
|
3
|
+
* Allows configuration of base URLs for different environments (HML, Production)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface LinaPayConfig {
|
|
7
|
+
iamBaseUrl: string;
|
|
8
|
+
apiBaseUrl: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const DEFAULT_CONFIG: LinaPayConfig = {
|
|
12
|
+
iamBaseUrl: 'https://iam.hml.linaob.com.br',
|
|
13
|
+
apiBaseUrl: 'https://embedded-payment-manager.hml.linaob.com.br',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let currentConfig: LinaPayConfig = { ...DEFAULT_CONFIG };
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Configure SDK with custom environment URLs
|
|
20
|
+
* @param config Partial configuration to override defaults
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* LinaPaySdk.configure({
|
|
24
|
+
* iamBaseUrl: 'https://iam.prod.linaob.com.br',
|
|
25
|
+
* apiBaseUrl: 'https://embedded-payment-manager.prod.linaob.com.br'
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function configure(config: Partial<LinaPayConfig>): void {
|
|
30
|
+
currentConfig = {
|
|
31
|
+
...currentConfig,
|
|
32
|
+
...config,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get current configuration
|
|
38
|
+
*/
|
|
39
|
+
export function getConfig(): LinaPayConfig {
|
|
40
|
+
return { ...currentConfig };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Reset configuration to defaults (useful for testing)
|
|
45
|
+
*/
|
|
46
|
+
export function resetConfig(): void {
|
|
47
|
+
currentConfig = { ...DEFAULT_CONFIG };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* API Endpoints
|
|
52
|
+
*/
|
|
53
|
+
export const ENDPOINTS = {
|
|
54
|
+
TOKEN: '/realms/ob-epp/protocol/openid-connect/token',
|
|
55
|
+
PARTICIPANTS: '/api/v1/open-integration/participants/registered',
|
|
56
|
+
CONSENTS: '/api/v1/open-integration/consents',
|
|
57
|
+
PAYMENTS: '/api/v1/open-integration/payments',
|
|
58
|
+
} as const;
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lina Pay SDK - React Native SDK for Open Finance Payments
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { getAccessToken } from './services/auth.service';
|
|
6
|
+
import { fetchParticipants } from './services/participants.service';
|
|
7
|
+
import { createConsent as createConsentService } from './services/consent.service';
|
|
8
|
+
import { createPayment as createPaymentService } from './services/payment.service';
|
|
9
|
+
import { configure as configureEnvironment } from './config/environment';
|
|
10
|
+
import type {
|
|
11
|
+
LinaPayCredentials,
|
|
12
|
+
Participant,
|
|
13
|
+
LinaPayConfig,
|
|
14
|
+
CreateConsentRequest,
|
|
15
|
+
CreateConsentResponse,
|
|
16
|
+
CreatePaymentRequest,
|
|
17
|
+
CreatePaymentResponse,
|
|
18
|
+
} from './types';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get list of registered participants from Lina Open Finance
|
|
22
|
+
*
|
|
23
|
+
* @param credentials Subtenant credentials (subtenantId and subtenantSecret)
|
|
24
|
+
* @returns Promise with array of participants
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const participants = await LinaPaySdk.getParticipants({
|
|
29
|
+
* subtenantId: 'your-subtenant-id',
|
|
30
|
+
* subtenantSecret: 'your-subtenant-secret'
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export async function getParticipants(
|
|
35
|
+
credentials: LinaPayCredentials
|
|
36
|
+
): Promise<Participant[]> {
|
|
37
|
+
// Get access token (uses cache if available)
|
|
38
|
+
const accessToken = await getAccessToken(credentials);
|
|
39
|
+
|
|
40
|
+
// Fetch and transform participants
|
|
41
|
+
return await fetchParticipants(accessToken);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Create payment consent
|
|
46
|
+
*
|
|
47
|
+
* @param credentials Subtenant credentials (subtenantId and subtenantSecret)
|
|
48
|
+
* @param payload Consent creation payload with payment details
|
|
49
|
+
* @returns Promise with consent creation response including consentId and status
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const consent = await LinaPaySdk.createConsent(
|
|
54
|
+
* {
|
|
55
|
+
* subtenantId: 'your-subtenant-id',
|
|
56
|
+
* subtenantSecret: 'your-subtenant-secret'
|
|
57
|
+
* },
|
|
58
|
+
* {
|
|
59
|
+
* organisationId: 'c8f0bf49-4744-4933-8960-7add6e590841',
|
|
60
|
+
* authorisationServerId: 'c8f0bf49-4744-4933-8960-7add6e590841',
|
|
61
|
+
* payment: {
|
|
62
|
+
* redirectUri: 'http://example.com/redirect',
|
|
63
|
+
* value: 1500.50,
|
|
64
|
+
* creditor: {
|
|
65
|
+
* name: 'John Doe',
|
|
66
|
+
* personType: 'PESSOA_NATURAL',
|
|
67
|
+
* cpfCnpj: '12345678901234',
|
|
68
|
+
* accountNumber: '1234567890',
|
|
69
|
+
* accountIssuer: '0001',
|
|
70
|
+
* accountPixKey: 'email@example.com',
|
|
71
|
+
* accountIspb: '12345678',
|
|
72
|
+
* accountType: 'CACC'
|
|
73
|
+
* }
|
|
74
|
+
* },
|
|
75
|
+
* platform: 'APP'
|
|
76
|
+
* }
|
|
77
|
+
* );
|
|
78
|
+
* console.log('Consent ID:', consent.consentId);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export async function createConsent(
|
|
82
|
+
credentials: LinaPayCredentials,
|
|
83
|
+
payload: CreateConsentRequest
|
|
84
|
+
): Promise<CreateConsentResponse> {
|
|
85
|
+
// Get access token (uses cache if available)
|
|
86
|
+
const accessToken = await getAccessToken(credentials);
|
|
87
|
+
|
|
88
|
+
// Create consent
|
|
89
|
+
return await createConsentService(accessToken, payload);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Create payment
|
|
94
|
+
*
|
|
95
|
+
* @param credentials Subtenant credentials (subtenantId and subtenantSecret)
|
|
96
|
+
* @param payload Payment creation payload with state, code, idToken, and tenantId
|
|
97
|
+
* @returns Promise with payment creation response including payment details
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const payment = await LinaPaySdk.createPayment(
|
|
102
|
+
* {
|
|
103
|
+
* subtenantId: 'your-subtenant-id',
|
|
104
|
+
* subtenantSecret: 'your-subtenant-secret'
|
|
105
|
+
* },
|
|
106
|
+
* {
|
|
107
|
+
* state: 'rumUP',
|
|
108
|
+
* code: '1RDYVFQnPn721',
|
|
109
|
+
* idToken: 'eyJhbGciOiJQUz',
|
|
110
|
+
* tenantId: 'tenantId'
|
|
111
|
+
* }
|
|
112
|
+
* );
|
|
113
|
+
* console.log('Payment ID:', payment.id);
|
|
114
|
+
* console.log('Status:', payment.status);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export async function createPayment(
|
|
118
|
+
credentials: LinaPayCredentials,
|
|
119
|
+
payload: CreatePaymentRequest
|
|
120
|
+
): Promise<CreatePaymentResponse> {
|
|
121
|
+
// Get access token (uses cache if available)
|
|
122
|
+
const accessToken = await getAccessToken(credentials);
|
|
123
|
+
|
|
124
|
+
// Create payment
|
|
125
|
+
return await createPaymentService(accessToken, payload);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Configure SDK environment (base URLs)
|
|
130
|
+
*
|
|
131
|
+
* @param config Partial configuration to override defaults
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* // Configure for production
|
|
136
|
+
* LinaPaySdk.configure({
|
|
137
|
+
* iamBaseUrl: 'https://iam.prod.linaob.com.br',
|
|
138
|
+
* apiBaseUrl: 'https://embedded-payment-manager.prod.linaob.com.br'
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export function configure(config: Partial<LinaPayConfig>): void {
|
|
143
|
+
configureEnvironment(config);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Export types
|
|
147
|
+
export type {
|
|
148
|
+
LinaPayCredentials,
|
|
149
|
+
Participant,
|
|
150
|
+
LinaPayConfig,
|
|
151
|
+
CreateConsentRequest,
|
|
152
|
+
CreateConsentResponse,
|
|
153
|
+
CreatePaymentRequest,
|
|
154
|
+
CreatePaymentResponse,
|
|
155
|
+
Payment,
|
|
156
|
+
Creditor,
|
|
157
|
+
Debitor,
|
|
158
|
+
Schedule,
|
|
159
|
+
PersonType,
|
|
160
|
+
AccountType,
|
|
161
|
+
Platform,
|
|
162
|
+
PaymentItem,
|
|
163
|
+
PaymentCreditor,
|
|
164
|
+
PaymentDebitor,
|
|
165
|
+
PaymentType,
|
|
166
|
+
PaymentStatus,
|
|
167
|
+
} from './types';
|
|
168
|
+
|
|
169
|
+
// Export error class for error handling
|
|
170
|
+
export { LinaPayError } from './utils/http.utils';
|
|
171
|
+
|
|
172
|
+
// Default export with all functions
|
|
173
|
+
export default {
|
|
174
|
+
getParticipants,
|
|
175
|
+
createConsent,
|
|
176
|
+
createPayment,
|
|
177
|
+
configure,
|
|
178
|
+
};
|