@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.
Files changed (82) hide show
  1. package/LinaPaySdk.podspec +20 -0
  2. package/README.md +522 -0
  3. package/android/build.gradle +77 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/linapaysdk/LinaPaySdkModule.kt +18 -0
  7. package/android/src/main/java/com/linapaysdk/LinaPaySdkPackage.kt +17 -0
  8. package/ios/LinaPaySdk.h +5 -0
  9. package/ios/LinaPaySdk.mm +16 -0
  10. package/lib/module/config/environment.js +61 -0
  11. package/lib/module/config/environment.js.map +1 -0
  12. package/lib/module/index.js +142 -0
  13. package/lib/module/index.js.map +1 -0
  14. package/lib/module/package.json +1 -0
  15. package/lib/module/services/auth.service.js +73 -0
  16. package/lib/module/services/auth.service.js.map +1 -0
  17. package/lib/module/services/consent.service.js +49 -0
  18. package/lib/module/services/consent.service.js.map +1 -0
  19. package/lib/module/services/participants.service.js +71 -0
  20. package/lib/module/services/participants.service.js.map +1 -0
  21. package/lib/module/services/payment.service.js +39 -0
  22. package/lib/module/services/payment.service.js.map +1 -0
  23. package/lib/module/types/auth.types.js +2 -0
  24. package/lib/module/types/auth.types.js.map +1 -0
  25. package/lib/module/types/consent.types.js +2 -0
  26. package/lib/module/types/consent.types.js.map +1 -0
  27. package/lib/module/types/index.js +2 -0
  28. package/lib/module/types/index.js.map +1 -0
  29. package/lib/module/types/participants.types.js +2 -0
  30. package/lib/module/types/participants.types.js.map +1 -0
  31. package/lib/module/types/payment.types.js +2 -0
  32. package/lib/module/types/payment.types.js.map +1 -0
  33. package/lib/module/utils/consent.utils.js +168 -0
  34. package/lib/module/utils/consent.utils.js.map +1 -0
  35. package/lib/module/utils/http.utils.js +58 -0
  36. package/lib/module/utils/http.utils.js.map +1 -0
  37. package/lib/module/utils/payment.utils.js +27 -0
  38. package/lib/module/utils/payment.utils.js.map +1 -0
  39. package/lib/typescript/package.json +1 -0
  40. package/lib/typescript/src/config/environment.d.ts +38 -0
  41. package/lib/typescript/src/config/environment.d.ts.map +1 -0
  42. package/lib/typescript/src/index.d.ts +108 -0
  43. package/lib/typescript/src/index.d.ts.map +1 -0
  44. package/lib/typescript/src/services/auth.service.d.ts +13 -0
  45. package/lib/typescript/src/services/auth.service.d.ts.map +1 -0
  46. package/lib/typescript/src/services/consent.service.d.ts +9 -0
  47. package/lib/typescript/src/services/consent.service.d.ts.map +1 -0
  48. package/lib/typescript/src/services/participants.service.d.ts +9 -0
  49. package/lib/typescript/src/services/participants.service.d.ts.map +1 -0
  50. package/lib/typescript/src/services/payment.service.d.ts +9 -0
  51. package/lib/typescript/src/services/payment.service.d.ts.map +1 -0
  52. package/lib/typescript/src/types/auth.types.d.ts +23 -0
  53. package/lib/typescript/src/types/auth.types.d.ts.map +1 -0
  54. package/lib/typescript/src/types/consent.types.d.ts +129 -0
  55. package/lib/typescript/src/types/consent.types.d.ts.map +1 -0
  56. package/lib/typescript/src/types/index.d.ts +9 -0
  57. package/lib/typescript/src/types/index.d.ts.map +1 -0
  58. package/lib/typescript/src/types/participants.types.d.ts +50 -0
  59. package/lib/typescript/src/types/participants.types.d.ts.map +1 -0
  60. package/lib/typescript/src/types/payment.types.d.ts +107 -0
  61. package/lib/typescript/src/types/payment.types.d.ts.map +1 -0
  62. package/lib/typescript/src/utils/consent.utils.d.ts +10 -0
  63. package/lib/typescript/src/utils/consent.utils.d.ts.map +1 -0
  64. package/lib/typescript/src/utils/http.utils.d.ts +21 -0
  65. package/lib/typescript/src/utils/http.utils.d.ts.map +1 -0
  66. package/lib/typescript/src/utils/payment.utils.d.ts +10 -0
  67. package/lib/typescript/src/utils/payment.utils.d.ts.map +1 -0
  68. package/package.json +169 -0
  69. package/src/config/environment.ts +58 -0
  70. package/src/index.tsx +178 -0
  71. package/src/services/auth.service.ts +88 -0
  72. package/src/services/consent.service.ts +63 -0
  73. package/src/services/participants.service.ts +89 -0
  74. package/src/services/payment.service.ts +49 -0
  75. package/src/types/auth.types.ts +24 -0
  76. package/src/types/consent.types.ts +152 -0
  77. package/src/types/index.ts +34 -0
  78. package/src/types/participants.types.ts +53 -0
  79. package/src/types/payment.types.ts +141 -0
  80. package/src/utils/consent.utils.ts +225 -0
  81. package/src/utils/http.utils.ts +80 -0
  82. package/src/utils/payment.utils.ts +32 -0
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Authentication service for OAuth2 token management
3
+ */
4
+
5
+ import { getConfig, ENDPOINTS } from '../config/environment';
6
+ import type {
7
+ LinaPayCredentials,
8
+ TokenResponse,
9
+ CachedToken,
10
+ } from '../types/auth.types';
11
+ import {
12
+ handleHttpError,
13
+ handleNetworkError,
14
+ validateCredentials,
15
+ } from '../utils/http.utils';
16
+
17
+ // Token cache with 5-minute buffer before expiration
18
+ let tokenCache: CachedToken | null = null;
19
+ const EXPIRATION_BUFFER_MS = 5 * 60 * 1000; // 5 minutes
20
+
21
+ /**
22
+ * Get access token from cache or request new one
23
+ */
24
+ export async function getAccessToken(
25
+ credentials: LinaPayCredentials
26
+ ): Promise<string> {
27
+ // Validate credentials
28
+ validateCredentials(credentials.subtenantId, credentials.subtenantSecret);
29
+
30
+ // Check if cached token is still valid
31
+ if (tokenCache && Date.now() < tokenCache.expiresAt) {
32
+ return tokenCache.accessToken;
33
+ }
34
+
35
+ // Request new token
36
+ return await requestNewToken(credentials);
37
+ }
38
+
39
+ /**
40
+ * Request new OAuth2 token from IAM
41
+ */
42
+ async function requestNewToken(
43
+ credentials: LinaPayCredentials
44
+ ): Promise<string> {
45
+ const config = getConfig();
46
+ const url = `${config.iamBaseUrl}${ENDPOINTS.TOKEN}`;
47
+
48
+ // Prepare form data for OAuth2 token request
49
+ const formData = new URLSearchParams();
50
+ formData.append('client_id', credentials.subtenantId);
51
+ formData.append('client_secret', credentials.subtenantSecret);
52
+ formData.append('grant_type', 'client_credentials');
53
+
54
+ try {
55
+ const response = await fetch(url, {
56
+ method: 'POST',
57
+ headers: {
58
+ 'Content-Type': 'application/x-www-form-urlencoded',
59
+ },
60
+ body: formData.toString(),
61
+ });
62
+
63
+ if (!response.ok) {
64
+ await handleHttpError(response);
65
+ }
66
+
67
+ const data = (await response.json()) as TokenResponse;
68
+
69
+ // Cache token with expiration (subtract buffer to refresh before actual expiry)
70
+ const expiresAt =
71
+ Date.now() + data.expires_in * 1000 - EXPIRATION_BUFFER_MS;
72
+ tokenCache = {
73
+ accessToken: data.access_token,
74
+ expiresAt,
75
+ };
76
+
77
+ return data.access_token;
78
+ } catch (error) {
79
+ handleNetworkError(error);
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Clear token cache (useful for testing or manual logout)
85
+ */
86
+ export function clearTokenCache(): void {
87
+ tokenCache = null;
88
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Consent service for creating payment consents
3
+ */
4
+
5
+ import { getConfig, ENDPOINTS } from '../config/environment';
6
+ import type {
7
+ CreateConsentRequest,
8
+ CreateConsentResponse,
9
+ CreateConsentApiResponse,
10
+ } from '../types/consent.types';
11
+ import { handleHttpError, handleNetworkError } from '../utils/http.utils';
12
+ import { validateConsentPayload } from '../utils/consent.utils';
13
+
14
+ /**
15
+ * Create payment consent
16
+ */
17
+ export async function createConsent(
18
+ accessToken: string,
19
+ payload: CreateConsentRequest
20
+ ): Promise<CreateConsentResponse> {
21
+ // Validate payload before sending
22
+ validateConsentPayload(payload);
23
+
24
+ const config = getConfig();
25
+ const url = `${config.apiBaseUrl}${ENDPOINTS.CONSENTS}`;
26
+
27
+ // Normalize txId to array if it's a string
28
+ const normalizedPayload = {
29
+ ...payload,
30
+ redirectUri: payload.redirectUri || payload.payment.redirectUri,
31
+ payment: {
32
+ ...payload.payment,
33
+ txId: Array.isArray(payload.payment.txId)
34
+ ? payload.payment.txId
35
+ : payload.payment.txId
36
+ ? [payload.payment.txId]
37
+ : undefined,
38
+ },
39
+ };
40
+
41
+ try {
42
+ const response = await fetch(url, {
43
+ method: 'POST',
44
+ headers: {
45
+ 'Authorization': `Bearer ${accessToken}`,
46
+ 'Content-Type': 'application/json',
47
+ },
48
+ body: JSON.stringify(normalizedPayload),
49
+ });
50
+
51
+ if (!response.ok) {
52
+ await handleHttpError(response);
53
+ }
54
+
55
+ const apiResponse = (await response.json()) as CreateConsentApiResponse;
56
+
57
+ // Extract and return the data from the wrapper
58
+ return apiResponse.data;
59
+ } catch (error) {
60
+ handleNetworkError(error);
61
+ }
62
+ }
63
+
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Participants service for fetching and transforming participant data
3
+ */
4
+
5
+ import { getConfig, ENDPOINTS } from '../config/environment';
6
+ import type {
7
+ Participant,
8
+ ParticipantsApiResponse,
9
+ ParticipantFull,
10
+ AuthorisationServer,
11
+ } from '../types/participants.types';
12
+ import { handleHttpError, handleNetworkError } from '../utils/http.utils';
13
+
14
+ /**
15
+ * Fetch participants list from API
16
+ */
17
+ export async function fetchParticipants(
18
+ accessToken: string
19
+ ): Promise<Participant[]> {
20
+ const config = getConfig();
21
+ const url = `${config.apiBaseUrl}${ENDPOINTS.PARTICIPANTS}`;
22
+
23
+ try {
24
+ const response = await fetch(url, {
25
+ method: 'GET',
26
+ headers: {
27
+ 'Authorization': `Bearer ${accessToken}`,
28
+ 'Content-Type': 'application/json',
29
+ },
30
+ });
31
+
32
+ if (!response.ok) {
33
+ await handleHttpError(response);
34
+ }
35
+
36
+ const data = (await response.json()) as ParticipantsApiResponse;
37
+
38
+ // Transform and flatten participants
39
+ return transformParticipants(data.data);
40
+ } catch (error) {
41
+ handleNetworkError(error);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Transform full participants data to simplified format
47
+ * Flattens AuthorisationServers array - creates one Participant per AuthorisationServer
48
+ * Filters out participants without AuthorisationServers
49
+ */
50
+ function transformParticipants(
51
+ participantsFull: ParticipantFull[]
52
+ ): Participant[] {
53
+ const participants: Participant[] = [];
54
+
55
+ for (const participantFull of participantsFull) {
56
+ // Skip participants without AuthorisationServers
57
+ if (
58
+ !participantFull.AuthorisationServers ||
59
+ participantFull.AuthorisationServers.length === 0
60
+ ) {
61
+ continue;
62
+ }
63
+
64
+ // Create one Participant entry per AuthorisationServer
65
+ for (const authServer of participantFull.AuthorisationServers) {
66
+ participants.push(transformParticipant(participantFull, authServer));
67
+ }
68
+ }
69
+
70
+ return participants;
71
+ }
72
+
73
+ /**
74
+ * Transform a single participant with its authorisation server
75
+ */
76
+ function transformParticipant(
77
+ participantFull: ParticipantFull,
78
+ authServer: AuthorisationServer
79
+ ): Participant {
80
+ return {
81
+ organisationId: participantFull.OrganisationId,
82
+ organisationName: participantFull.OrganisationName,
83
+ legalEntityName: participantFull.LegalEntityName,
84
+ registrationNumber: participantFull.RegistrationNumber,
85
+ authorisationServerId: authServer.AuthorisationServerId,
86
+ customerFriendlyName: authServer.CustomerFriendlyName,
87
+ customerFriendlyLogoUri: authServer.CustomerFriendlyLogoUri,
88
+ };
89
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Payment service for creating payments
3
+ */
4
+
5
+ import { getConfig, ENDPOINTS } from '../config/environment';
6
+ import type {
7
+ CreatePaymentRequest,
8
+ CreatePaymentResponse,
9
+ CreatePaymentApiResponse,
10
+ } from '../types/payment.types';
11
+ import { handleHttpError, handleNetworkError } from '../utils/http.utils';
12
+ import { validatePaymentPayload } from '../utils/payment.utils';
13
+
14
+ /**
15
+ * Create payment
16
+ */
17
+ export async function createPayment(
18
+ accessToken: string,
19
+ payload: CreatePaymentRequest
20
+ ): Promise<CreatePaymentResponse> {
21
+ // Validate payload before sending
22
+ validatePaymentPayload(payload);
23
+
24
+ const config = getConfig();
25
+ const url = `${config.apiBaseUrl}${ENDPOINTS.PAYMENTS}`;
26
+
27
+ try {
28
+ const response = await fetch(url, {
29
+ method: 'POST',
30
+ headers: {
31
+ 'Authorization': `Bearer ${accessToken}`,
32
+ 'Content-Type': 'application/json',
33
+ },
34
+ body: JSON.stringify(payload),
35
+ });
36
+
37
+ if (!response.ok) {
38
+ await handleHttpError(response);
39
+ }
40
+
41
+ const apiResponse = (await response.json()) as CreatePaymentApiResponse;
42
+
43
+ // Extract and return the data from the wrapper
44
+ return apiResponse.data;
45
+ } catch (error) {
46
+ handleNetworkError(error);
47
+ }
48
+ }
49
+
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Credentials for Lina Pay SDK authentication
3
+ */
4
+ export interface LinaPayCredentials {
5
+ subtenantId: string;
6
+ subtenantSecret: string;
7
+ }
8
+
9
+ /**
10
+ * OAuth2 token response from IAM
11
+ */
12
+ export interface TokenResponse {
13
+ access_token: string;
14
+ token_type: string;
15
+ expires_in: number;
16
+ }
17
+
18
+ /**
19
+ * Cached token with expiration tracking
20
+ */
21
+ export interface CachedToken {
22
+ accessToken: string;
23
+ expiresAt: number; // timestamp in milliseconds
24
+ }
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Consent types for payment consent creation
3
+ */
4
+
5
+ /**
6
+ * Person type for creditor
7
+ */
8
+ export type PersonType = 'PESSOA_NATURAL' | 'PESSOA_JURIDICA';
9
+
10
+ /**
11
+ * Account type
12
+ */
13
+ export type AccountType = 'CACC' | 'SLRY' | 'SVGS' | 'TRAN';
14
+
15
+ /**
16
+ * Day of week for weekly schedule
17
+ */
18
+ export type DayOfWeek =
19
+ | 'SEGUNDA_FEIRA'
20
+ | 'TERCA_FEIRA'
21
+ | 'QUARTA_FEIRA'
22
+ | 'QUINTA_FEIRA'
23
+ | 'SEXTA_FEIRA'
24
+ | 'SABADO'
25
+ | 'DOMINGO';
26
+
27
+ /**
28
+ * Platform type
29
+ */
30
+ export type Platform = 'APP' | 'WEB';
31
+
32
+ /**
33
+ * Creditor information (payment recipient)
34
+ */
35
+ export interface Creditor {
36
+ name: string; // Required
37
+ personType: PersonType; // Required
38
+ cpfCnpj: string; // Required
39
+ accountNumber: string; // Required
40
+ accountIssuer: string; // Required
41
+ accountPixKey: string; // Required
42
+ accountIspb: string; // Required
43
+ accountType: AccountType; // Required
44
+ }
45
+
46
+ /**
47
+ * Debitor information (payment sender)
48
+ */
49
+ export interface Debitor {
50
+ accountNumber?: string;
51
+ accountIssuer?: string;
52
+ accountIspb?: string;
53
+ accountType?: AccountType;
54
+ }
55
+
56
+ /**
57
+ * Single payment schedule
58
+ */
59
+ export interface SingleSchedule {
60
+ date: string; // Format: YYYY-MM-DD
61
+ }
62
+
63
+ /**
64
+ * Daily recurring payment schedule
65
+ */
66
+ export interface DailySchedule {
67
+ startDate: string; // Format: YYYY-MM-DD
68
+ quantity: number;
69
+ }
70
+
71
+ /**
72
+ * Weekly recurring payment schedule
73
+ */
74
+ export interface WeeklySchedule {
75
+ dayOfWeek: DayOfWeek;
76
+ startDate: string; // Format: YYYY-MM-DD
77
+ quantity: number;
78
+ }
79
+
80
+ /**
81
+ * Monthly recurring payment schedule
82
+ */
83
+ export interface MonthlySchedule {
84
+ dayOfMonth: number; // 1-31
85
+ startDate: string; // Format: YYYY-MM-DD
86
+ quantity: number;
87
+ }
88
+
89
+ /**
90
+ * Custom payment schedule with specific dates
91
+ */
92
+ export interface CustomSchedule {
93
+ dates: string[]; // Array of dates in format YYYY-MM-DD
94
+ additionalInformation?: string;
95
+ }
96
+
97
+ /**
98
+ * Payment schedule (only one type should be provided)
99
+ */
100
+ export interface Schedule {
101
+ single?: SingleSchedule;
102
+ daily?: DailySchedule;
103
+ weekly?: WeeklySchedule;
104
+ monthly?: MonthlySchedule;
105
+ custom?: CustomSchedule;
106
+ }
107
+
108
+ /**
109
+ * Payment information
110
+ */
111
+ export interface Payment {
112
+ details?: string;
113
+ externalId?: string;
114
+ redirectUri: string; // Required
115
+ cpfCnpj?: string;
116
+ value: number; // Required - must be positive
117
+ creditor: Creditor; // Required
118
+ debitor?: Debitor;
119
+ originalRecurringPaymentId?: string;
120
+ schedule?: Schedule;
121
+ txId?: string | string[]; // Can be single string or array
122
+ }
123
+
124
+ /**
125
+ * Request payload for consent creation
126
+ */
127
+ export interface CreateConsentRequest {
128
+ organisationId: string; // Required
129
+ authorisationServerId: string; // Required
130
+ payment: Payment; // Required
131
+ redirectUri?: string;
132
+ platform?: Platform;
133
+ }
134
+
135
+ /**
136
+ * Response from consent creation API
137
+ */
138
+ export interface CreateConsentResponse {
139
+ consentId: string;
140
+ redirectUrl: string;
141
+ id: string;
142
+ }
143
+
144
+ /**
145
+ * API response wrapper
146
+ */
147
+ export interface CreateConsentApiResponse {
148
+ data: CreateConsentResponse;
149
+ message: string;
150
+ type: 'success' | 'error';
151
+ }
152
+
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Public types exported by Lina Pay SDK
3
+ */
4
+
5
+ export type { LinaPayCredentials } from './auth.types';
6
+ export type { Participant } from './participants.types';
7
+ export type { LinaPayConfig } from '../config/environment';
8
+ export type {
9
+ CreateConsentRequest,
10
+ CreateConsentResponse,
11
+ Payment,
12
+ Creditor,
13
+ Debitor,
14
+ Schedule,
15
+ SingleSchedule,
16
+ DailySchedule,
17
+ WeeklySchedule,
18
+ MonthlySchedule,
19
+ CustomSchedule,
20
+ PersonType,
21
+ AccountType,
22
+ DayOfWeek,
23
+ Platform,
24
+ } from './consent.types';
25
+ export type {
26
+ CreatePaymentRequest,
27
+ CreatePaymentResponse,
28
+ PaymentItem,
29
+ PaymentCreditor,
30
+ PaymentDebitor,
31
+ PaymentType,
32
+ PaymentStatus,
33
+ PaymentItemStatus,
34
+ } from './payment.types';
@@ -0,0 +1,53 @@
1
+ /**
2
+ * API Resource information
3
+ */
4
+ export interface ApiResource {
5
+ ApiFamilyType: string;
6
+ ApiVersion: string;
7
+ ApiDiscoveryEndpoints: string[];
8
+ }
9
+
10
+ /**
11
+ * Authorisation Server (from API response)
12
+ */
13
+ export interface AuthorisationServer {
14
+ AuthorisationServerId: string;
15
+ CustomerFriendlyName: string;
16
+ CustomerFriendlyDescription: string;
17
+ CustomerFriendlyLogoUri: string;
18
+ OpenIDDiscoveryDocument: string;
19
+ ApiResources: ApiResource[];
20
+ }
21
+
22
+ /**
23
+ * Full participant data from API
24
+ */
25
+ export interface ParticipantFull {
26
+ OrganisationName: string;
27
+ OrganisationId: string;
28
+ LegalEntityName: string;
29
+ RegistrationNumber: string;
30
+ ParentOrganisationReference: string;
31
+ AuthorisationServers: AuthorisationServer[];
32
+ }
33
+
34
+ /**
35
+ * API response for participants list
36
+ */
37
+ export interface ParticipantsApiResponse {
38
+ data: ParticipantFull[];
39
+ }
40
+
41
+ /**
42
+ * Simplified participant data returned by SDK
43
+ * One entry per AuthorisationServer (flattened from API response)
44
+ */
45
+ export interface Participant {
46
+ organisationId: string;
47
+ organisationName: string;
48
+ legalEntityName: string;
49
+ registrationNumber: string;
50
+ authorisationServerId: string;
51
+ customerFriendlyName: string;
52
+ customerFriendlyLogoUri: string;
53
+ }
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Payment types for payment creation
3
+ */
4
+
5
+ /**
6
+ * Payment type
7
+ */
8
+ export type PaymentType =
9
+ | 'NOW'
10
+ | 'SINGLE'
11
+ | 'DAILY'
12
+ | 'WEEKLY'
13
+ | 'MONTHLY'
14
+ | 'CUSTOM';
15
+
16
+ /**
17
+ * Payment status
18
+ */
19
+ export type PaymentStatus =
20
+ | 'PENDENTE'
21
+ | 'EM_PROCESSAMENTO'
22
+ | 'CONSUMIDO'
23
+ | 'EXPIRADO'
24
+ | 'CANCELADO'
25
+ | 'ERRO_NA_DETENTORA'
26
+ | 'ERRO';
27
+
28
+ /**
29
+ * Payment item status
30
+ */
31
+ export type PaymentItemStatus =
32
+ | 'PENDENTE'
33
+ | 'REJEITADO'
34
+ | 'EM_PROCESSAMENTO'
35
+ | 'PAGO'
36
+ | 'EXPIRADO'
37
+ | 'CANCELADO'
38
+ | 'ERRO_NA_DETENTORA'
39
+ | 'ERRO'
40
+ | 'PROGRAMADO'
41
+ | 'AGUARDANDO_VALOR'
42
+ | 'PRONTO_PARA_ENVIO';
43
+
44
+ /**
45
+ * Payment item in the payments array
46
+ */
47
+ export interface PaymentItem {
48
+ endToEndId: string;
49
+ id: string;
50
+ dueDate: string; // ISO 8601 date
51
+ externalComment?: string;
52
+ txId: string | null;
53
+ status: PaymentItemStatus;
54
+ externalPaymentId: string;
55
+ }
56
+
57
+ /**
58
+ * Creditor information in payment response
59
+ */
60
+ export interface PaymentCreditor {
61
+ name: string;
62
+ personType: 'PESSOA_NATURAL' | 'PESSOA_JURIDICA';
63
+ cpfCnpj: string;
64
+ accountIspb: string;
65
+ accountIssuer: string;
66
+ accountNumber: string;
67
+ accountPixKey: string | null;
68
+ accountType: 'CACC' | 'SLRY' | 'SVGS' | 'TRAN';
69
+ }
70
+
71
+ /**
72
+ * Debitor information in payment response
73
+ */
74
+ export interface PaymentDebitor {
75
+ accountIspb: string;
76
+ accountIssuer: string;
77
+ accountNumber: string;
78
+ accountType: 'CACC' | 'SLRY' | 'SVGS' | 'TRAN';
79
+ }
80
+
81
+ /**
82
+ * Payment data from API
83
+ */
84
+ export interface PaymentData {
85
+ id: string;
86
+ type: PaymentType;
87
+ createDateTime: string; // ISO 8601 date
88
+ externalId?: string;
89
+ externalComment?: string;
90
+ lastChangedDateTime: string; // ISO 8601 date
91
+ status: PaymentStatus;
92
+ tenantId: string;
93
+ cpfCnpj: string;
94
+ redirectUri: string;
95
+ value: string; // Value as string from API
96
+ consentId: string;
97
+ creditor: PaymentCreditor;
98
+ debitor?: PaymentDebitor;
99
+ payments: PaymentItem[];
100
+ }
101
+
102
+ /**
103
+ * Request payload for payment creation
104
+ */
105
+ export interface CreatePaymentRequest {
106
+ state: string;
107
+ code: string;
108
+ idToken: string;
109
+ tenantId: string;
110
+ }
111
+
112
+ /**
113
+ * Response from payment creation API (with wrapper)
114
+ */
115
+ export interface CreatePaymentApiResponse {
116
+ data: PaymentData;
117
+ message: string;
118
+ type: 'success' | 'error';
119
+ }
120
+
121
+ /**
122
+ * Response from payment creation (transformed, without wrapper)
123
+ */
124
+ export interface CreatePaymentResponse {
125
+ id: string;
126
+ type: PaymentType;
127
+ createDateTime: string;
128
+ externalId?: string;
129
+ externalComment?: string;
130
+ lastChangedDateTime: string;
131
+ status: PaymentStatus;
132
+ tenantId: string;
133
+ cpfCnpj: string;
134
+ redirectUri: string;
135
+ value: string;
136
+ consentId: string;
137
+ creditor: PaymentCreditor;
138
+ debitor?: PaymentDebitor;
139
+ payments: PaymentItem[];
140
+ }
141
+