@kushki/js 1.40.4 → 1.40.5-alpha.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/lib/Kushki.d.ts +32 -0
- package/lib/Kushki.js +32 -0
- package/lib/KushkiInfo.js +1 -1
- package/lib/environments/environment.d.ts +5 -0
- package/lib/environments/environment.js +11 -0
- package/lib/service/ApplePayService.js +3 -3
- package/lib/types/apple_pay_get_token_events.d.ts +1 -0
- package/lib/types/apple_pay_get_token_options.d.ts +1 -0
- package/package.json +1 -1
package/lib/Kushki.d.ts
CHANGED
|
@@ -211,12 +211,44 @@ export declare class Kushki {
|
|
|
211
211
|
* );
|
|
212
212
|
* ```
|
|
213
213
|
*
|
|
214
|
+
* **Subscription Token:**
|
|
215
|
+
*
|
|
216
|
+
* You can make a subscription payment request by setting the `isSubscription` property to `true` in the options parameter.
|
|
217
|
+
* This will return a subscription token that can be used for recurring payments.
|
|
218
|
+
*
|
|
219
|
+
* > ⚠️ This method requires that {@link initApplePayButton} has been successfully
|
|
220
|
+
* initialized and rendered beforehand.
|
|
221
|
+
*
|
|
222
|
+
* ### Example usage:
|
|
223
|
+
* ```ts
|
|
224
|
+
* kushki.requestApplePayToken(
|
|
225
|
+
* {
|
|
226
|
+
* countryCode: "EC",
|
|
227
|
+
* currencyCode: "USD",
|
|
228
|
+
* displayName: "My Store",
|
|
229
|
+
* amount: 5000,
|
|
230
|
+
* isSubscription: true
|
|
231
|
+
* },
|
|
232
|
+
* response => {
|
|
233
|
+
* if ("token" in response) {
|
|
234
|
+
* console.log("Subscription token:", response.token);
|
|
235
|
+
* } else {
|
|
236
|
+
* console.error("Error requesting token:", response);
|
|
237
|
+
* }
|
|
238
|
+
* },
|
|
239
|
+
* () => {
|
|
240
|
+
* console.log("User cancelled Apple Pay payment flow");
|
|
241
|
+
* }
|
|
242
|
+
* );
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
214
245
|
* @param {ApplePayGetTokenOptions} options - Configuration options for the Apple Pay payment request.
|
|
215
246
|
* - **countryCode**: Merchant’s country (e.g., `"MX"`, `"CO"`, `"EC"`, etc.).
|
|
216
247
|
* - **currencyCode**: Currency for the transaction (e.g., `"USD"`, `"MXN"`, `"COP"`, etc.).
|
|
217
248
|
* - **displayName**: The merchant name displayed in the Apple Pay sheet.
|
|
218
249
|
* - **amount**: Transaction amount.
|
|
219
250
|
* - **optionalApplePayFields**: Additional Apple Pay configuration fields,
|
|
251
|
+
* - **isSubscription**: Indicates if the payment is for a subscription. If `true`, the token will be a subscription token. If `false` or not provided, the token will be a card token.
|
|
220
252
|
* following Apple’s specification:
|
|
221
253
|
* {@link https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest}
|
|
222
254
|
* These fields allow merchants to customize their checkout experience
|
package/lib/Kushki.js
CHANGED
|
@@ -271,12 +271,44 @@ class Kushki {
|
|
|
271
271
|
* );
|
|
272
272
|
* ```
|
|
273
273
|
*
|
|
274
|
+
* **Subscription Token:**
|
|
275
|
+
*
|
|
276
|
+
* You can make a subscription payment request by setting the `isSubscription` property to `true` in the options parameter.
|
|
277
|
+
* This will return a subscription token that can be used for recurring payments.
|
|
278
|
+
*
|
|
279
|
+
* > ⚠️ This method requires that {@link initApplePayButton} has been successfully
|
|
280
|
+
* initialized and rendered beforehand.
|
|
281
|
+
*
|
|
282
|
+
* ### Example usage:
|
|
283
|
+
* ```ts
|
|
284
|
+
* kushki.requestApplePayToken(
|
|
285
|
+
* {
|
|
286
|
+
* countryCode: "EC",
|
|
287
|
+
* currencyCode: "USD",
|
|
288
|
+
* displayName: "My Store",
|
|
289
|
+
* amount: 5000,
|
|
290
|
+
* isSubscription: true
|
|
291
|
+
* },
|
|
292
|
+
* response => {
|
|
293
|
+
* if ("token" in response) {
|
|
294
|
+
* console.log("Subscription token:", response.token);
|
|
295
|
+
* } else {
|
|
296
|
+
* console.error("Error requesting token:", response);
|
|
297
|
+
* }
|
|
298
|
+
* },
|
|
299
|
+
* () => {
|
|
300
|
+
* console.log("User cancelled Apple Pay payment flow");
|
|
301
|
+
* }
|
|
302
|
+
* );
|
|
303
|
+
* ```
|
|
304
|
+
*
|
|
274
305
|
* @param {ApplePayGetTokenOptions} options - Configuration options for the Apple Pay payment request.
|
|
275
306
|
* - **countryCode**: Merchant’s country (e.g., `"MX"`, `"CO"`, `"EC"`, etc.).
|
|
276
307
|
* - **currencyCode**: Currency for the transaction (e.g., `"USD"`, `"MXN"`, `"COP"`, etc.).
|
|
277
308
|
* - **displayName**: The merchant name displayed in the Apple Pay sheet.
|
|
278
309
|
* - **amount**: Transaction amount.
|
|
279
310
|
* - **optionalApplePayFields**: Additional Apple Pay configuration fields,
|
|
311
|
+
* - **isSubscription**: Indicates if the payment is for a subscription. If `true`, the token will be a subscription token. If `false` or not provided, the token will be a card token.
|
|
280
312
|
* following Apple’s specification:
|
|
281
313
|
* {@link https://developer.apple.com/documentation/applepayontheweb/applepaypaymentrequest}
|
|
282
314
|
* These fields allow merchants to customize their checkout experience
|
package/lib/KushkiInfo.js
CHANGED
|
@@ -12,7 +12,7 @@ const UtilsService_1 = require("./../lib/service/UtilsService");
|
|
|
12
12
|
*/
|
|
13
13
|
class KInfo {
|
|
14
14
|
static buildKushkiInfo(kushkiInfo) {
|
|
15
|
-
const kushki_js_version = "1.40.
|
|
15
|
+
const kushki_js_version = "1.40.5-alpha.0";
|
|
16
16
|
if (kushkiInfo) {
|
|
17
17
|
if (UtilsService_1.UtilsService.sIsEmpty(kushkiInfo.platformVersion))
|
|
18
18
|
kushkiInfo.platformVersion = kushki_js_version;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.environment = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Environment file
|
|
6
|
+
*/
|
|
7
|
+
/* tslint:disable:all */
|
|
8
|
+
// The file contents for the current environment will overwrite these during build.
|
|
9
|
+
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
|
|
10
|
+
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
|
11
|
+
exports.environment = {};
|
|
@@ -66,7 +66,7 @@ let ApplePayService = ApplePayService_1 = class ApplePayService {
|
|
|
66
66
|
} }, options.optionalApplePayFields);
|
|
67
67
|
const session = new window.ApplePaySession(this._getSupportedApplePayVersion(), session_params);
|
|
68
68
|
session.onvalidatemerchant = (event) => this._onValidateMerchant(event, mid, session, options, isTest, regional, callback);
|
|
69
|
-
session.onpaymentauthorized = (event) => this._onPaymentAuthorized(event, mid, session, isTest, regional, callback);
|
|
69
|
+
session.onpaymentauthorized = (event) => this._onPaymentAuthorized(event, mid, session, isTest, regional, options.isSubscription, callback);
|
|
70
70
|
session.oncancel = () => {
|
|
71
71
|
onCancel();
|
|
72
72
|
};
|
|
@@ -150,10 +150,10 @@ let ApplePayService = ApplePayService_1 = class ApplePayService {
|
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
_onPaymentAuthorized(event, mid, session, isTest, regional, callback) {
|
|
153
|
+
_onPaymentAuthorized(event, mid, session, isTest, regional, isSubscription = false, callback) {
|
|
154
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
155
|
try {
|
|
156
|
-
const apple_token = Object.assign(Object.assign({}, event.payment.token.paymentData), { paymentMethod: event.payment.token.paymentMethod });
|
|
156
|
+
const apple_token = Object.assign(Object.assign({}, event.payment.token.paymentData), { isSubscription, paymentMethod: event.payment.token.paymentMethod });
|
|
157
157
|
const kushki_token = yield this._gateway
|
|
158
158
|
.getApplePayToken(apple_token, mid, isTest, regional)
|
|
159
159
|
.toPromise();
|
|
@@ -6,6 +6,7 @@ export interface ApplePayGetTokenOptions {
|
|
|
6
6
|
currencyCode: "USD" | "COP" | "CLP" | "UF" | "PEN" | "MXN" | "BRL" | "CRC" | "GTQ" | "HNL" | "NIO";
|
|
7
7
|
displayName: string;
|
|
8
8
|
amount: number;
|
|
9
|
+
isSubscription?: boolean;
|
|
9
10
|
optionalApplePayFields?: {
|
|
10
11
|
[k: string]: any;
|
|
11
12
|
};
|