@tonder.io/ionic-lite-sdk 0.0.35-beta.22 → 0.0.35-beta.24
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/.idea/workspace.xml +20 -3
- package/README.md +403 -112
- package/dist/classes/BaseInlineCheckout.d.ts +4 -5
- package/dist/classes/liteCheckout.d.ts +6 -42
- package/dist/index.js +1 -1
- package/dist/types/commons.d.ts +2 -0
- package/dist/types/liteInlineCheckout.d.ts +147 -0
- package/package.json +1 -1
- package/src/classes/BaseInlineCheckout.ts +6 -5
- package/src/classes/liteCheckout.ts +7 -43
- package/src/types/commons.ts +3 -0
- package/src/types/{liteInlineCheckout.d.ts → liteInlineCheckout.ts} +4 -7
- package/tests/classes/liteCheckout.test.ts +2 -2
- package/tests/methods/createOrder.test.ts +3 -4
- package/tests/methods/createPayment.test.ts +2 -3
- package/tests/methods/customerRegister.test.ts +3 -4
- package/tests/methods/getBusiness.test.ts +2 -3
- package/tests/methods/getCustomerCards.test.ts +2 -3
- package/tests/methods/registerCustomerCard.test.ts +2 -2
- package/tests/methods/startCheckoutRouter.test.ts +2 -2
- package/tests/methods/startCheckoutRouterFull.test.ts +2 -2
package/.idea/workspace.xml
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
<component name="ChangeListManager">
|
|
7
7
|
<list default="true" id="49ce0c58-6ae2-4b0a-9ac0-48692c69c15e" name="Changes" comment="">
|
|
8
8
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
|
9
|
+
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
|
9
10
|
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
|
|
10
11
|
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
11
12
|
<change beforePath="$PROJECT_DIR$/src/classes/BaseInlineCheckout.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/classes/BaseInlineCheckout.ts" afterDir="false" />
|
|
@@ -23,6 +24,16 @@
|
|
|
23
24
|
<change beforePath="$PROJECT_DIR$/src/types/checkout.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/checkout.ts" afterDir="false" />
|
|
24
25
|
<change beforePath="$PROJECT_DIR$/src/types/commons.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/commons.ts" afterDir="false" />
|
|
25
26
|
<change beforePath="$PROJECT_DIR$/src/types/index.d.ts" beforeDir="false" />
|
|
27
|
+
<change beforePath="$PROJECT_DIR$/src/types/liteInlineCheckout.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/liteInlineCheckout.ts" afterDir="false" />
|
|
28
|
+
<change beforePath="$PROJECT_DIR$/tests/classes/liteCheckout.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/tests/classes/liteCheckout.test.ts" afterDir="false" />
|
|
29
|
+
<change beforePath="$PROJECT_DIR$/tests/methods/createOrder.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/tests/methods/createOrder.test.ts" afterDir="false" />
|
|
30
|
+
<change beforePath="$PROJECT_DIR$/tests/methods/createPayment.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/tests/methods/createPayment.test.ts" afterDir="false" />
|
|
31
|
+
<change beforePath="$PROJECT_DIR$/tests/methods/customerRegister.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/tests/methods/customerRegister.test.ts" afterDir="false" />
|
|
32
|
+
<change beforePath="$PROJECT_DIR$/tests/methods/getBusiness.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/tests/methods/getBusiness.test.ts" afterDir="false" />
|
|
33
|
+
<change beforePath="$PROJECT_DIR$/tests/methods/getCustomerCards.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/tests/methods/getCustomerCards.test.ts" afterDir="false" />
|
|
34
|
+
<change beforePath="$PROJECT_DIR$/tests/methods/registerCustomerCard.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/tests/methods/registerCustomerCard.test.ts" afterDir="false" />
|
|
35
|
+
<change beforePath="$PROJECT_DIR$/tests/methods/startCheckoutRouter.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/tests/methods/startCheckoutRouter.test.ts" afterDir="false" />
|
|
36
|
+
<change beforePath="$PROJECT_DIR$/tests/methods/startCheckoutRouterFull.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/tests/methods/startCheckoutRouterFull.test.ts" afterDir="false" />
|
|
26
37
|
</list>
|
|
27
38
|
<option name="SHOW_DIALOG" value="false" />
|
|
28
39
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -85,7 +96,7 @@
|
|
|
85
96
|
<workItem from="1725305433705" duration="21026000" />
|
|
86
97
|
<workItem from="1725333899382" duration="2939000" />
|
|
87
98
|
<workItem from="1725337022494" duration="3671000" />
|
|
88
|
-
<workItem from="1725378545854" duration="
|
|
99
|
+
<workItem from="1725378545854" duration="22151000" />
|
|
89
100
|
</task>
|
|
90
101
|
<servers />
|
|
91
102
|
</component>
|
|
@@ -108,7 +119,7 @@
|
|
|
108
119
|
<breakpoints>
|
|
109
120
|
<line-breakpoint enabled="true" type="javascript">
|
|
110
121
|
<url>file://$PROJECT_DIR$/src/classes/liteCheckout.ts</url>
|
|
111
|
-
<line>
|
|
122
|
+
<line>218</line>
|
|
112
123
|
<option name="timeStamp" value="16" />
|
|
113
124
|
</line-breakpoint>
|
|
114
125
|
<line-breakpoint enabled="true" type="javascript">
|
|
@@ -118,9 +129,15 @@
|
|
|
118
129
|
</line-breakpoint>
|
|
119
130
|
<line-breakpoint enabled="true" type="javascript">
|
|
120
131
|
<url>file://$PROJECT_DIR$/src/classes/liteCheckout.ts</url>
|
|
121
|
-
<line>
|
|
132
|
+
<line>222</line>
|
|
122
133
|
<option name="timeStamp" value="18" />
|
|
123
134
|
</line-breakpoint>
|
|
135
|
+
<line-breakpoint enabled="true" type="javascript">
|
|
136
|
+
<url>file://$PROJECT_DIR$/src/classes/liteCheckout.ts</url>
|
|
137
|
+
<line>304</line>
|
|
138
|
+
<properties lambdaOrdinal="-1" />
|
|
139
|
+
<option name="timeStamp" value="21" />
|
|
140
|
+
</line-breakpoint>
|
|
124
141
|
</breakpoints>
|
|
125
142
|
</breakpoint-manager>
|
|
126
143
|
</component>
|
package/README.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
# Tonder SDK
|
|
2
2
|
|
|
3
|
-
Tonder SDK
|
|
3
|
+
Tonder SDK helps to integrate the services Tonder offers in your own mobile app
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Table of Contents
|
|
7
|
+
|
|
8
|
+
1. [Installation](#installation)
|
|
9
|
+
2. [Usage](#usage)
|
|
10
|
+
3. [Configuration Options](#configuration-options)
|
|
11
|
+
4. [Styling InlineCheckout](#styling-inlinecheckout)
|
|
12
|
+
5. [Payment Data Structure](#payment-data-structure)
|
|
13
|
+
6. [Field Validation Functions](#field-validation-functions)
|
|
14
|
+
7. [API Reference](#api-reference)
|
|
15
|
+
8. [Examples](#examples)
|
|
16
|
+
9. [Deprecated Fields](#deprecated-fields)
|
|
17
|
+
10. [Deprecated Functions](#deprecated-functions)
|
|
18
|
+
11. [License](#license)
|
|
19
|
+
|
|
4
20
|
|
|
5
21
|
## Installation
|
|
6
22
|
|
|
@@ -16,6 +32,7 @@ Add dependencies to the root of the app (index.html)
|
|
|
16
32
|
```
|
|
17
33
|
|
|
18
34
|
## Usage
|
|
35
|
+
LiteCheckout allows you to build a custom checkout interface using Tonder's core functionality
|
|
19
36
|
## Import LiteCheckout class
|
|
20
37
|
```javascript
|
|
21
38
|
import { LiteCheckout } from "@tonder.io/ionic-lite-sdk"
|
|
@@ -29,172 +46,446 @@ const liteCheckout = new LiteCheckout({
|
|
|
29
46
|
apiKeyTonder
|
|
30
47
|
})
|
|
31
48
|
|
|
49
|
+
// The configureCheckout function allows you to set initial information,
|
|
50
|
+
// such as the customer's email, which is used to retrieve a list of saved cards, save new card, etc.
|
|
51
|
+
inlineCheckout.configureCheckout({ customer: { email: "example@email.com" } });
|
|
52
|
+
|
|
53
|
+
// Initialize the checkout
|
|
54
|
+
await liteCheckout.injectCheckout();
|
|
55
|
+
|
|
32
56
|
// To verify a 3ds transaction you can use the following method
|
|
33
57
|
// It should be called after the injectCheckout method
|
|
34
58
|
// The response status will be one of the following
|
|
35
59
|
// ['Declined', 'Cancelled', 'Failed', 'Success', 'Pending', 'Authorized']
|
|
36
60
|
|
|
37
61
|
inlineCheckout.verify3dsTransaction().then(response => {
|
|
38
|
-
|
|
62
|
+
console.log('Verify 3ds response', response)
|
|
39
63
|
})
|
|
40
64
|
```
|
|
41
65
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
| | | Mock Server: https://stoplight.io/mocks/tonder/tonder-api-v1-2/3152148 |
|
|
47
|
-
| apiKeyTonder | string | You can take this from you Tonder Dashboard |
|
|
48
|
-
| | | |
|
|
66
|
+
```javascript
|
|
67
|
+
// Retrieve customer's saved cards
|
|
68
|
+
const cards = await liteCheckout.getCustomerCards();
|
|
69
|
+
```
|
|
49
70
|
|
|
50
|
-
|
|
71
|
+
```javascript
|
|
72
|
+
// Save a new card
|
|
73
|
+
const newCard = await liteCheckout.saveCustomerCard(cardData);
|
|
74
|
+
```
|
|
51
75
|
|
|
52
|
-
|
|
76
|
+
```javascript
|
|
77
|
+
// Remove a saved card
|
|
78
|
+
await liteCheckout.removeCustomerCard(cardId);
|
|
79
|
+
```
|
|
53
80
|
|
|
54
|
-
```
|
|
81
|
+
```javascript
|
|
82
|
+
// Get available payment methods
|
|
83
|
+
const paymentMethods = await liteCheckout.getCustomerPaymentMethods();
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
// Process a payment
|
|
88
|
+
const paymentResponse = await liteCheckout.payment(paymentData);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Configuration Options
|
|
92
|
+
|
|
93
|
+
| Property | Type | Description |
|
|
94
|
+
|:---------:|:--------:|:--------------------------------------------------------------------------------------------:|
|
|
95
|
+
| mode | string | Environment mode. Options: 'stage', 'production', 'sandbox', 'development'. Default: 'stage' |
|
|
96
|
+
| apiKey | string | Your API key from the Tonder Dashboard |
|
|
97
|
+
| returnUrl | string | URL where the checkout form is mounted (used for 3DS) |
|
|
98
|
+
| callBack | function | Callback function to be invoked after the payment process ends successfully. |
|
|
99
|
+
|
|
100
|
+
## Payment Data Structure
|
|
101
|
+
|
|
102
|
+
When calling the `payment` method, use the following data structure:
|
|
103
|
+
|
|
104
|
+
### Field Descriptions
|
|
105
|
+
|
|
106
|
+
- **customer**: Object containing the customer's personal information to be registered in the transaction.
|
|
107
|
+
|
|
108
|
+
- **cart**: Object containing the total amount and an array of items to be registered in the Tonder order.
|
|
55
109
|
|
|
56
|
-
|
|
110
|
+
- **total**: The total amount of the transaction.
|
|
111
|
+
- **items**: An array of objects, each representing a product or service in the order.
|
|
112
|
+
- name: name of the product
|
|
113
|
+
- price_unit: valid float string with the price of the product
|
|
114
|
+
- quantity: valid integer string with the quantity of this product
|
|
57
115
|
|
|
58
|
-
|
|
116
|
+
- **currency**: String representing the currency code for the transaction (e.g., "MXN" for Mexican Peso).
|
|
117
|
+
|
|
118
|
+
- **metadata**: Object for including any additional information about the transaction. This can be used for internal references or tracking.
|
|
119
|
+
|
|
120
|
+
- **card**: (for LiteCheckout) Object containing card information. This is used differently depending on whether it's a new card or a saved card:
|
|
121
|
+
|
|
122
|
+
- For a new card: Include `card_number`, `cvv`, `expiration_month`, `expiration_year`, and `cardholder_name`.
|
|
123
|
+
- For a saved card: Include only the `skyflow_id` of the saved card.
|
|
124
|
+
- This is only used when not paying with a payment_method.
|
|
125
|
+
|
|
126
|
+
- **payment_method**: (for LiteCheckout) String indicating the alternative payment method to be used (e.g., "Spei"). This is only used when not paying with a card.
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
const paymentData = {
|
|
59
130
|
customer: {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
131
|
+
firstName: "John",
|
|
132
|
+
lastName: "Doe",
|
|
133
|
+
country: "USA",
|
|
134
|
+
address: "123 Main St",
|
|
135
|
+
city: "Anytown",
|
|
136
|
+
state: "CA",
|
|
137
|
+
postCode: "12345",
|
|
138
|
+
email: "john.doe@example.com",
|
|
139
|
+
phone: "1234567890",
|
|
64
140
|
},
|
|
65
|
-
|
|
141
|
+
cart: {
|
|
142
|
+
total: "100.00",
|
|
66
143
|
items: [
|
|
67
144
|
{
|
|
68
|
-
description: "
|
|
145
|
+
description: "Product description",
|
|
69
146
|
quantity: 1,
|
|
70
|
-
price_unit:
|
|
71
|
-
discount:
|
|
72
|
-
taxes:
|
|
73
|
-
product_reference:
|
|
74
|
-
name: "
|
|
75
|
-
amount_total:
|
|
76
|
-
}
|
|
77
|
-
]
|
|
147
|
+
price_unit: "100.00",
|
|
148
|
+
discount: "0.00",
|
|
149
|
+
taxes: "0.00",
|
|
150
|
+
product_reference: "PROD123",
|
|
151
|
+
name: "Product Name",
|
|
152
|
+
amount_total: "100.00",
|
|
153
|
+
},
|
|
154
|
+
],
|
|
78
155
|
},
|
|
79
|
-
return_url: returnUrl,
|
|
80
|
-
total: 25,
|
|
81
|
-
isSandbox: true,
|
|
82
|
-
metadata: {},
|
|
83
156
|
currency: "MXN",
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
157
|
+
metadata: {
|
|
158
|
+
order_id: "ORDER123",
|
|
159
|
+
},
|
|
160
|
+
// For a new card:
|
|
161
|
+
card: {
|
|
162
|
+
card_number: "4111111111111111",
|
|
163
|
+
cvv: "123",
|
|
164
|
+
expiration_month: "12",
|
|
165
|
+
expiration_year: "25",
|
|
166
|
+
cardholder_name: "John Doe",
|
|
167
|
+
},
|
|
168
|
+
// card: "skyflow_id" // for a selected saved card.
|
|
169
|
+
// payment_method: "Spei", // For the selected payment method.
|
|
170
|
+
};
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Field Validation Functions
|
|
174
|
+
|
|
175
|
+
For LiteCheckout implementations, the SDK provides validation functions to ensure the integrity of card data before submitting:
|
|
93
176
|
|
|
177
|
+
- `validateCardNumber(cardNumber)`: Validates the card number using the Luhn algorithm.
|
|
178
|
+
- `validateCardholderName(name)`: Checks if the cardholder name is valid.
|
|
179
|
+
- `validateCVV(cvv)`: Ensures the CVV is in the correct format.
|
|
180
|
+
- `validateExpirationDate(expirationDate)`: Validates the expiration date in MM/YY format.
|
|
181
|
+
- `validateExpirationMonth(month)`: Checks if the expiration month is valid.
|
|
182
|
+
- `validateExpirationYear(year)`: Validates the expiration year.
|
|
183
|
+
|
|
184
|
+
Example usage:
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
import {
|
|
188
|
+
validateCardNumber,
|
|
189
|
+
validateCardholderName,
|
|
190
|
+
validateCVV,
|
|
191
|
+
validateExpirationDate,
|
|
192
|
+
} from "@tonder.io/ionic-lite-sdk";
|
|
193
|
+
|
|
194
|
+
const cardNumber = "4111111111111111";
|
|
195
|
+
const cardholderName = "John Doe";
|
|
196
|
+
const cvv = "123";
|
|
197
|
+
const expirationDate = "12/25";
|
|
198
|
+
|
|
199
|
+
if (
|
|
200
|
+
validateCardNumber(cardNumber) &&
|
|
201
|
+
validateCardholderName(cardholderName) &&
|
|
202
|
+
validateCVV(cvv) &&
|
|
203
|
+
validateExpirationDate(expirationDate)
|
|
204
|
+
) {
|
|
205
|
+
// Proceed with payment
|
|
206
|
+
} else {
|
|
207
|
+
// Show error message
|
|
208
|
+
}
|
|
94
209
|
```
|
|
95
210
|
|
|
96
|
-
|
|
211
|
+
|
|
212
|
+
## API Reference
|
|
213
|
+
|
|
214
|
+
### LiteCheckout Methods
|
|
215
|
+
|
|
216
|
+
- `configureCheckout(data)`: Set initial checkout data
|
|
217
|
+
- `injectCheckout()`: Initialize the checkout
|
|
218
|
+
- `getCustomerCards()`: Retrieve saved cards
|
|
219
|
+
- `saveCustomerCard(cardData)`: Save a new card
|
|
220
|
+
- `removeCustomerCard(cardId)`: Remove a saved card
|
|
221
|
+
- `getCustomerPaymentMethods()`: Get available payment methods
|
|
222
|
+
- `payment(data)`: Process a payment
|
|
223
|
+
- `verify3dsTransaction()`: Verify a 3DS transaction
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
## Examples
|
|
227
|
+
|
|
228
|
+
Here are examples of how to implement Tonder Lite SDK:
|
|
229
|
+
|
|
230
|
+
### Angular
|
|
231
|
+
|
|
232
|
+
For Angular, we recommend using a service to manage the Tonder instance:
|
|
97
233
|
|
|
98
234
|
```typescript
|
|
235
|
+
// tonder.service.ts
|
|
236
|
+
import { Injectable } from "@angular/core";
|
|
237
|
+
import { LiteCheckout } from "@tonder.io/ionic-lite-sdk";
|
|
99
238
|
|
|
100
|
-
|
|
239
|
+
@Injectable({
|
|
240
|
+
providedIn: "root",
|
|
241
|
+
})
|
|
242
|
+
export class TonderService {
|
|
243
|
+
private liteCheckout!: LiteCheckout;
|
|
101
244
|
|
|
102
|
-
|
|
245
|
+
constructor(@Inject(Object) private sdkParameters: IInlineLiteCheckoutOptions) {
|
|
246
|
+
this.initializeInlineCheckout();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private initializeInlineCheckout(): void {
|
|
250
|
+
this.liteCheckout = new LiteCheckout({ ...this.sdkParameters });
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
configureCheckout(customerData: IConfigureCheckout): void {
|
|
254
|
+
this.liteCheckout.configureCheckout({ ...customerData });
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async injectCheckout(): Promise<void> {
|
|
258
|
+
await this.liteCheckout.injectCheckout();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
verify3dsTransaction(): Promise<ITransaction | void> {
|
|
262
|
+
return this.liteCheckout.verify3dsTransaction();
|
|
263
|
+
}
|
|
103
264
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
265
|
+
payment(
|
|
266
|
+
checkoutData: IProcessPaymentRequest,
|
|
267
|
+
): Promise<IStartCheckoutResponse> {
|
|
268
|
+
return this.inlineCheckout.payment(checkoutData);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Add more functions, for example for lite sdk: get payment methods
|
|
272
|
+
|
|
273
|
+
// getCustomerPaymentMethods(): Promise<IPaymentMethod[]> {
|
|
274
|
+
// return this.liteCheckout.getCustomerPaymentMethods();
|
|
275
|
+
// }
|
|
110
276
|
}
|
|
111
277
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
278
|
+
// checkout.component.ts
|
|
279
|
+
import { Component, OnInit, OnDestroy } from "@angular/core";
|
|
280
|
+
import { TonderService } from "./tonder.service";
|
|
281
|
+
|
|
282
|
+
@Component({
|
|
283
|
+
selector: "app-tonder-checkout",
|
|
284
|
+
template: `
|
|
285
|
+
<div id="container">
|
|
286
|
+
<form [formGroup]="paymentForm">
|
|
287
|
+
<div class="lite-container-tonder">
|
|
288
|
+
<div id="id-name" class="empty-div">
|
|
289
|
+
<label for="name">Namess: </label>
|
|
290
|
+
<input id="name" type="text" formControlName="name">
|
|
291
|
+
</div>
|
|
292
|
+
<div id="id-cardNumber" class="empty-div">
|
|
293
|
+
<label for="cardNumber">Card number: </label>
|
|
294
|
+
<input id="cardNumber" type="text" formControlName="cardNumber">
|
|
295
|
+
</div>
|
|
296
|
+
<div class="collect-row">
|
|
297
|
+
<div class="empty-div">
|
|
298
|
+
<label for="month">Month: </label>
|
|
299
|
+
<input id="month" type="text" formControlName="month">
|
|
300
|
+
</div>
|
|
301
|
+
<div class="expiration-year">
|
|
302
|
+
<label for="expirationYear">Year: </label>
|
|
303
|
+
<input id="expirationYear" type="text" formControlName="expirationYear">
|
|
304
|
+
</div>
|
|
305
|
+
<div class="empty-div">
|
|
306
|
+
<label for="cvv">CVV: </label>
|
|
307
|
+
<input id="cvv" type="text" formControlName="cvv">
|
|
308
|
+
</div>
|
|
309
|
+
</div>
|
|
310
|
+
<div id="msgError">{{ errorMessage }}</div>
|
|
311
|
+
<div id="msgNotification"></div>
|
|
312
|
+
<div class="container-pay-button">
|
|
313
|
+
<button class="lite-pay-button" (click)="onPayment($event)">Pay</button>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
</form>
|
|
318
|
+
</div>
|
|
319
|
+
`,
|
|
320
|
+
providers: [
|
|
321
|
+
{
|
|
322
|
+
provide: TonderInlineService,
|
|
323
|
+
// Initialization of the Tonder Lite SDK.
|
|
324
|
+
// Note: Replace these credentials with your own in development/production.
|
|
325
|
+
useFactory: () =>
|
|
326
|
+
new TonderInlineService({
|
|
327
|
+
apiKey: "11e3d3c3e95e0eaabbcae61ebad34ee5f93c3d27",
|
|
328
|
+
returnUrl: "http://localhost:8100/tabs/tab5",
|
|
329
|
+
mode: "stage",
|
|
330
|
+
}),
|
|
331
|
+
},
|
|
332
|
+
],
|
|
116
333
|
})
|
|
334
|
+
export class TonderCheckoutComponent implements OnInit, OnDestroy {
|
|
335
|
+
loading = false;
|
|
336
|
+
checkoutData: IProcessPaymentRequest;
|
|
337
|
+
paymentForm = new FormGroup({
|
|
338
|
+
name: new FormControl('Pedro Paramo'),
|
|
339
|
+
cardNumber: new FormControl('4242424242424242'),
|
|
340
|
+
month: new FormControl('12'),
|
|
341
|
+
expirationYear: new FormControl('28'),
|
|
342
|
+
cvv: new FormControl('123')
|
|
343
|
+
});
|
|
344
|
+
constructor(private tonderService: TonderService) {
|
|
345
|
+
this.checkoutData = {
|
|
346
|
+
customer: {
|
|
347
|
+
firstName: "Jhon",
|
|
348
|
+
lastName: "Doe",
|
|
349
|
+
email: "john.c.calhoun@examplepetstore.com",
|
|
350
|
+
phone: "+58452258525"
|
|
351
|
+
},
|
|
352
|
+
cart: {
|
|
353
|
+
total: 25,
|
|
354
|
+
items: [
|
|
355
|
+
{
|
|
356
|
+
description: "Test product description",
|
|
357
|
+
quantity: 1,
|
|
358
|
+
price_unit: 25,
|
|
359
|
+
discount: 1,
|
|
360
|
+
taxes: 12,
|
|
361
|
+
product_reference: 89456123,
|
|
362
|
+
name: "Test product",
|
|
363
|
+
amount_total: 25
|
|
364
|
+
}
|
|
365
|
+
]
|
|
366
|
+
},
|
|
367
|
+
metadata: {},
|
|
368
|
+
currency: "MXN"
|
|
369
|
+
}
|
|
370
|
+
}
|
|
117
371
|
|
|
118
|
-
|
|
372
|
+
ngOnInit() {
|
|
373
|
+
this.initCheckout();
|
|
374
|
+
}
|
|
119
375
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
376
|
+
async initCheckout() {
|
|
377
|
+
this.tonderService.configureCheckout({
|
|
378
|
+
customer: { email: "example@email.com" },
|
|
379
|
+
});
|
|
380
|
+
await this.tonderService.injectCheckout();
|
|
381
|
+
this.tonderService.verify3dsTransaction().then((response) => {
|
|
382
|
+
console.log("Verify 3ds response", response);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// Calls more functions to get payment methods, saved cards, etc.
|
|
386
|
+
}
|
|
123
387
|
|
|
388
|
+
async pay() {
|
|
389
|
+
this.loading = true;
|
|
390
|
+
try {
|
|
391
|
+
const response = await this.tonderService.payment({
|
|
392
|
+
...this.checkoutData,
|
|
393
|
+
card: { // Card details, if not using a payment method.
|
|
394
|
+
card_number: this.paymentForm.value.cardNumber || "",
|
|
395
|
+
cvv: this.paymentForm.value.cvv || "",
|
|
396
|
+
expiration_month: this.paymentForm.value.month || "",
|
|
397
|
+
expiration_year: this.paymentForm.value.expirationYear || "",
|
|
398
|
+
cardholder_name: this.paymentForm.value.name || ""
|
|
399
|
+
},
|
|
400
|
+
// card: "skyflow_id" // In case a saved card is selected.
|
|
401
|
+
// payment_method: "" // Payment method if not using the card form
|
|
402
|
+
});
|
|
403
|
+
console.log("Payment successful:", response);
|
|
404
|
+
alert("Payment successful");
|
|
405
|
+
} catch (error) {
|
|
406
|
+
console.error("Payment failed:", error);
|
|
407
|
+
alert("Payment failed");
|
|
408
|
+
} finally {
|
|
409
|
+
this.loading = false;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
124
413
|
```
|
|
125
414
|
|
|
126
|
-
|
|
415
|
+
## Deprecated Fields
|
|
127
416
|
|
|
128
|
-
|
|
417
|
+
The following functions and fields have been deprecated and should no longer be used. Consider using the recommended alternatives:
|
|
129
418
|
|
|
130
|
-
|
|
419
|
+
### `apiKeyTonder` Property
|
|
131
420
|
|
|
132
|
-
|
|
421
|
+
- **Deprecated Reason:** The `apiKeyTonder` property in the constructor and `IInlineLiteCheckoutOptions` interface is no longer required.
|
|
422
|
+
- **Alternative:** Use the `apiKey` field.
|
|
133
423
|
|
|
134
|
-
|
|
424
|
+
### `baseUrlTonder` Property
|
|
135
425
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
426
|
+
- **Deprecated Reason:** The `baseUrlTonder` property in the constructor and `IInlineLiteCheckoutOptions` interface is no longer required.
|
|
427
|
+
- **Alternative:** Use the `mode` field with `stage` | `development` | `sandbox` | `production` options.
|
|
139
428
|
|
|
140
|
-
|
|
141
|
-
customer_auth_token,
|
|
142
|
-
data
|
|
143
|
-
);
|
|
144
|
-
```
|
|
429
|
+
### `signal` Property
|
|
145
430
|
|
|
146
|
-
|
|
147
|
-
```typescript
|
|
148
|
-
{
|
|
149
|
-
skyflow_id: string;
|
|
150
|
-
user_id: number;
|
|
151
|
-
}
|
|
152
|
-
```
|
|
431
|
+
- **Deprecated Reason:** The `signal` property in the constructor and `IInlineLiteCheckoutOptions` interface is no longer required.
|
|
153
432
|
|
|
154
|
-
# Customer Cards(Get)
|
|
155
433
|
|
|
156
|
-
##
|
|
434
|
+
## Deprecated Functions
|
|
157
435
|
|
|
158
|
-
|
|
436
|
+
### `customerRegister`
|
|
159
437
|
|
|
160
|
-
|
|
438
|
+
- **Deprecated Reason:** This function is no longer necessary as registration is now automatically handled during payment processing or when using card management methods.
|
|
161
439
|
|
|
162
|
-
|
|
440
|
+
### `createOrder` and `createPayment`
|
|
163
441
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
query
|
|
167
|
-
);
|
|
168
|
-
```
|
|
442
|
+
- **Deprecated Reason:** These functions have been replaced by the `payment` function, which now automatically handles order creation and payment processing.
|
|
443
|
+
- **Alternative:** Use the `payment` function.
|
|
169
444
|
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
{
|
|
173
|
-
user_id: number,
|
|
174
|
-
cards: [
|
|
175
|
-
{
|
|
176
|
-
fields: {
|
|
177
|
-
card_number: string,
|
|
178
|
-
cardholder_name: string,
|
|
179
|
-
cvv: string,
|
|
180
|
-
expiration_month: string,
|
|
181
|
-
expiration_year: string,
|
|
182
|
-
skyflow_id: string
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
]
|
|
186
|
-
}
|
|
187
|
-
```
|
|
445
|
+
### `startCheckoutRouter` and `startCheckoutRouterFull`
|
|
188
446
|
|
|
189
|
-
|
|
447
|
+
- **Deprecated Reason:** These functions have been replaced by the `payment` function.
|
|
448
|
+
- **Alternative:** Use the `payment` function.
|
|
190
449
|
|
|
191
|
-
|
|
450
|
+
### `registerCustomerCard`
|
|
451
|
+
|
|
452
|
+
- **Deprecated Reason:** This function has been renamed to `saveCustomerCard` to better align with its purpose. The method's usage has also been updated.
|
|
453
|
+
- **Alternative:** Use the `saveCustomerCard` method and update your implementation to reflect the changes.
|
|
454
|
+
|
|
455
|
+
### `deleteCustomerCard`
|
|
456
|
+
|
|
457
|
+
- **Deprecated Reason:** This function has been renamed to `removeCustomerCard` to better align with its purpose. The method's usage has also been updated.
|
|
458
|
+
- **Alternative:** Use the `removeCustomerCard` method and update your implementation to reflect the changes.
|
|
192
459
|
|
|
193
|
-
|
|
194
|
-
customer_auth_token,
|
|
195
|
-
skyflow_id
|
|
196
|
-
);
|
|
460
|
+
### `getActiveAPMs`
|
|
197
461
|
|
|
462
|
+
- **Deprecated Reason:** This function has been renamed to `getCustomerPaymentMethods` to better align with its purpose. The method's usage has also been updated.
|
|
463
|
+
- **Alternative:** Use the `getCustomerPaymentMethods` method and update your implementation to reflect the changes.
|
|
464
|
+
|
|
465
|
+
### `getSkyflowTokens`
|
|
466
|
+
|
|
467
|
+
- **Deprecated Reason:** Card registration and checkout are now automatically handled during the payment process or through card management methods, making this method unnecessary.
|
|
468
|
+
|
|
469
|
+
### `getOpenpayDeviceSessionID`
|
|
470
|
+
|
|
471
|
+
- **Deprecated Reason:** It is no longer necessary to use this method is now automatically handled during the payment process.
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
## Notes
|
|
475
|
+
|
|
476
|
+
### General
|
|
477
|
+
|
|
478
|
+
- Replace `'your-api-key'`, `'http://your-website.com/checkout'`, `returnUrl`, and `paymentData` with your actual values.
|
|
479
|
+
- The `paymentData` should be defined according to your specific requirements.
|
|
480
|
+
- Remember to use the `configureCheckout` function after creating an instance of `LiteCheckout`. This ensures that functions such as payment processing, saving cards, deleting cards, and others work correctly.
|
|
481
|
+
|
|
482
|
+
### Script Dependencies
|
|
483
|
+
|
|
484
|
+
For all implementations, ensure you include the necessary scripts:
|
|
485
|
+
|
|
486
|
+
```html
|
|
487
|
+
<script src="https://openpay.s3.amazonaws.com/openpay.v1.min.js"></script>
|
|
488
|
+
<script src="https://openpay.s3.amazonaws.com/openpay-data.v1.min.js"></script>
|
|
198
489
|
```
|
|
199
490
|
|
|
200
491
|
## License
|