@kushki/js 1.40.4-alpha.1 → 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/gateway/KushkiGateway.d.ts +2 -2
- package/lib/gateway/KushkiGateway.js +6 -14
- package/lib/repository/IKushkiGateway.d.ts +2 -2
- package/lib/service/ApplePayService.js +3 -3
- package/lib/service/CardService.js +14 -20
- 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 = {};
|
|
@@ -49,9 +49,9 @@ export declare class KushkiGateway implements IKushkiGateway {
|
|
|
49
49
|
requestGet<T extends object = object>(path: string, testEnv: boolean, regional: boolean, mid?: string): Observable<T>;
|
|
50
50
|
requestBrandsByMerchant(mid: string, testEnv: boolean, regional: boolean): Observable<string[]>;
|
|
51
51
|
requestBrandsLogosByMerchant(mid: string, testEnv: boolean, regional: boolean): Observable<GetBrandsLogosByMerchantResponse[]>;
|
|
52
|
-
requestToken(body: KushkiTokensRequest, mid: string, testEnv: boolean, regional: boolean
|
|
52
|
+
requestToken(body: KushkiTokensRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
53
53
|
requestDeviceToken(body: TokenChargeRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
54
|
-
requestSubscriptionToken(body: KushkiSubscriptionTokensRequest, mid: string, testEnv: boolean, regional: boolean
|
|
54
|
+
requestSubscriptionToken(body: KushkiSubscriptionTokensRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
55
55
|
requestTransferToken(body: TransferTokenRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
56
56
|
requestMerchantSettings(mid: string, testEnv: boolean, regional: boolean): Observable<MerchantSettingsResponse>;
|
|
57
57
|
requestPseBankList(mid: string, testEnv: boolean, regional: boolean): Observable<BankListResponse>;
|
|
@@ -61,28 +61,20 @@ let KushkiGateway = KushkiGateway_1 = class KushkiGateway {
|
|
|
61
61
|
requestBrandsLogosByMerchant(mid, testEnv, regional) {
|
|
62
62
|
return this.requestGet(`${PathEnum_1.PathEnum.brands_logos_by_merchant}`, testEnv, regional, mid);
|
|
63
63
|
}
|
|
64
|
-
requestToken(body, mid, testEnv, regional
|
|
65
|
-
return
|
|
64
|
+
requestToken(body, mid, testEnv, regional) {
|
|
65
|
+
return this.request(body, {
|
|
66
66
|
[this._publicHeader]: mid,
|
|
67
67
|
[this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
|
|
68
|
-
}, PathEnum_1.PathEnum.card_tokens, testEnv, regional)
|
|
69
|
-
[this._kshAuthorization]: authorization,
|
|
70
|
-
[this._publicHeader]: mid,
|
|
71
|
-
[this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
|
|
72
|
-
}, PathEnum_1.PathEnum.card_tokens, testEnv, regional))));
|
|
68
|
+
}, PathEnum_1.PathEnum.card_tokens, testEnv, regional);
|
|
73
69
|
}
|
|
74
70
|
requestDeviceToken(body, mid, testEnv, regional) {
|
|
75
71
|
return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), `${PathEnum_1.PathEnum.card_token_charge}${body.subscriptionId}/tokens`, testEnv, regional)));
|
|
76
72
|
}
|
|
77
|
-
requestSubscriptionToken(body, mid, testEnv, regional
|
|
78
|
-
return
|
|
79
|
-
[this._publicHeader]: mid,
|
|
80
|
-
[this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
|
|
81
|
-
}, PathEnum_1.PathEnum.card_subscription_tokens, testEnv, regional), this.request(body, {
|
|
82
|
-
[this._kshAuthorization]: authorization,
|
|
73
|
+
requestSubscriptionToken(body, mid, testEnv, regional) {
|
|
74
|
+
return this.request(body, {
|
|
83
75
|
[this._publicHeader]: mid,
|
|
84
76
|
[this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
|
|
85
|
-
}, PathEnum_1.PathEnum.card_subscription_tokens, testEnv, regional)
|
|
77
|
+
}, PathEnum_1.PathEnum.card_subscription_tokens, testEnv, regional);
|
|
86
78
|
}
|
|
87
79
|
requestTransferToken(body, mid, testEnv, regional) {
|
|
88
80
|
return rxjs_1.of(1).pipe(operators_1.concatMap(() => this.request(body, Object.assign(Object.assign({}, this._buildHeader(mid)), { [this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo }), PathEnum_1.PathEnum.transfer_tokens, testEnv, regional)));
|
|
@@ -45,7 +45,7 @@ export interface IKushkiGateway {
|
|
|
45
45
|
/**
|
|
46
46
|
* Send tokens request to Kushki API
|
|
47
47
|
*/
|
|
48
|
-
requestToken(body: KushkiTokensRequest, mid: string, testEnv: boolean, regional: boolean
|
|
48
|
+
requestToken(body: KushkiTokensRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
49
49
|
/**
|
|
50
50
|
* Send charge tokens request to Kushki API
|
|
51
51
|
*/
|
|
@@ -53,7 +53,7 @@ export interface IKushkiGateway {
|
|
|
53
53
|
/**
|
|
54
54
|
* Send tokens subscription request to Kushki API
|
|
55
55
|
*/
|
|
56
|
-
requestSubscriptionToken(body: KushkiSubscriptionTokensRequest, mid: string, testEnv: boolean, regional: boolean
|
|
56
|
+
requestSubscriptionToken(body: KushkiSubscriptionTokensRequest, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
57
57
|
/**
|
|
58
58
|
* Send transfer tokens request to Kushki API
|
|
59
59
|
*/
|
|
@@ -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();
|
|
@@ -93,21 +93,18 @@ let CardService = CardService_1 = class CardService {
|
|
|
93
93
|
const data_to_transform = Object.assign(Object.assign({}, request), sift_object);
|
|
94
94
|
if (jwt !== undefined)
|
|
95
95
|
data_to_transform.jwt = jwt;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
rxjs_1.of(undefined),
|
|
99
|
-
rxjs_1.of(merchant),
|
|
100
|
-
]);
|
|
96
|
+
const final_request = dot.transform(this._receipt, Object.assign(Object.assign({}, data_to_transform), { merchantName: merchant.merchant_name }));
|
|
97
|
+
return rxjs_1.of({ final_request, merchant });
|
|
101
98
|
}))
|
|
102
99
|
.subscribe({
|
|
103
100
|
error: (err) => Kushki_1.Kushki.callbackError(err, callback),
|
|
104
|
-
next: (
|
|
101
|
+
next: ({ final_request, merchant, }) => {
|
|
105
102
|
if (final_request.jwt && !merchant.sandboxEnable)
|
|
106
103
|
this._request3DSToken(() => {
|
|
107
|
-
this._requestTokenGateway(final_request, mid, isTest, regional, callback
|
|
104
|
+
this._requestTokenGateway(final_request, mid, isTest, regional, callback);
|
|
108
105
|
});
|
|
109
106
|
else
|
|
110
|
-
this._requestTokenGateway(final_request, mid, isTest, regional, callback
|
|
107
|
+
this._requestTokenGateway(final_request, mid, isTest, regional, callback);
|
|
111
108
|
},
|
|
112
109
|
});
|
|
113
110
|
}
|
|
@@ -157,21 +154,18 @@ let CardService = CardService_1 = class CardService {
|
|
|
157
154
|
const data_to_transform = this._getCreateSubscriptionDataToTransform(sift_object, subscriptionTokenRequest);
|
|
158
155
|
if (jwt !== undefined)
|
|
159
156
|
data_to_transform.jwt = jwt;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
rxjs_1.of(undefined),
|
|
163
|
-
rxjs_1.of(merchant),
|
|
164
|
-
]);
|
|
157
|
+
const body = dot.transform(this._receipt, Object.assign(Object.assign({}, data_to_transform), { merchantName: merchant.merchant_name }));
|
|
158
|
+
return rxjs_1.of({ body, merchant });
|
|
165
159
|
}))
|
|
166
160
|
.subscribe({
|
|
167
161
|
error: (err) => Kushki_1.Kushki.callbackError(err, callback),
|
|
168
|
-
next: (
|
|
162
|
+
next: ({ body, merchant, }) => {
|
|
169
163
|
if (body.jwt && !merchant.sandboxEnable)
|
|
170
164
|
this._request3DSToken(() => {
|
|
171
|
-
this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback
|
|
165
|
+
this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback);
|
|
172
166
|
});
|
|
173
167
|
else
|
|
174
|
-
this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback
|
|
168
|
+
this._requestSubscriptionTokenGateway(body, mid, isTest, regional, callback);
|
|
175
169
|
},
|
|
176
170
|
});
|
|
177
171
|
}
|
|
@@ -230,8 +224,8 @@ let CardService = CardService_1 = class CardService {
|
|
|
230
224
|
});
|
|
231
225
|
}
|
|
232
226
|
// istanbul ignore next
|
|
233
|
-
_requestTokenGateway(body, mid, testEnv, regional, callback
|
|
234
|
-
const request_token = this._gateway.requestToken(body, mid, testEnv, regional
|
|
227
|
+
_requestTokenGateway(body, mid, testEnv, regional, callback) {
|
|
228
|
+
const request_token = this._gateway.requestToken(body, mid, testEnv, regional);
|
|
235
229
|
return request_token.subscribe({
|
|
236
230
|
error: (err) => Kushki_1.Kushki.callbackError(err, callback),
|
|
237
231
|
next: (response) => {
|
|
@@ -447,9 +441,9 @@ let CardService = CardService_1 = class CardService {
|
|
|
447
441
|
_getUserId(subscriptionId, mid, testEnv, regional, userId) {
|
|
448
442
|
return rxjs_1.of(1).pipe(operators_1.switchMap(() => rxjs_1.iif(() => UtilsService_1.UtilsService.sIsEmpty(userId), this._gateway.getUserId(subscriptionId, mid, testEnv, regional), rxjs_1.of(undefined))), operators_1.catchError(() => rxjs_1.of(undefined)));
|
|
449
443
|
}
|
|
450
|
-
_requestSubscriptionTokenGateway(body, mid, testEnv, regional, callback
|
|
444
|
+
_requestSubscriptionTokenGateway(body, mid, testEnv, regional, callback) {
|
|
451
445
|
this._gateway
|
|
452
|
-
.requestSubscriptionToken(body, mid, testEnv, regional
|
|
446
|
+
.requestSubscriptionToken(body, mid, testEnv, regional)
|
|
453
447
|
.subscribe({
|
|
454
448
|
error: (err) => Kushki_1.Kushki.callbackError(err, callback),
|
|
455
449
|
next: (response) => {
|
|
@@ -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
|
};
|