@kushki/js 1.40.2-alpha.1 → 1.40.2-alpha.2
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/README.md +1 -1
- package/lib/KushkiInfo.js +1 -1
- package/lib/gateway/KushkiGateway.d.ts +3 -2
- package/lib/gateway/KushkiGateway.js +13 -3
- package/lib/repository/IKushkiGateway.d.ts +2 -2
- package/lib/service/ApplePayService.js +1 -1
- package/lib/service/CardService.js +20 -16
- package/lib/types/apple_pay_get_token_events.d.ts +12 -4
- package/lib/types/jwt_response.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
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.2-alpha.
|
|
15
|
+
const kushki_js_version = "1.40.2-alpha.2";
|
|
16
16
|
if (kushkiInfo) {
|
|
17
17
|
if (UtilsService_1.UtilsService.sIsEmpty(kushkiInfo.platformVersion))
|
|
18
18
|
kushkiInfo.platformVersion = kushki_js_version;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "reflect-metadata";
|
|
3
3
|
import { IKushkiGateway } from "./../../lib/repository/IKushkiGateway";
|
|
4
4
|
import { Observable } from "rxjs";
|
|
5
|
-
import {
|
|
5
|
+
import { ApplePayPaymentData } from "./../../lib/types/apple_pay_get_token_events";
|
|
6
6
|
import { ApplePayStartSessionRequest } from "./../../lib/types/apple_pay_start_session_request";
|
|
7
7
|
import { BankListResponse } from "./../../lib/types/bank_list_response";
|
|
8
8
|
import { BinInfoResponse } from "./../../lib/types/bin_info_response";
|
|
@@ -73,7 +73,8 @@ export declare class KushkiGateway implements IKushkiGateway {
|
|
|
73
73
|
getUserId(subscriptionId: string, mid: string, testEnv: boolean, regional: boolean): Observable<GetUserId>;
|
|
74
74
|
validateAppleDomain(domain: string, mid: string, testEnv: boolean, regional: boolean): Observable<Validate3DsResponse>;
|
|
75
75
|
startApplePaySession(body: ApplePayStartSessionRequest, mid: string, testEnv: boolean, regional: boolean): Observable<object>;
|
|
76
|
-
getApplePayToken(body:
|
|
76
|
+
getApplePayToken(body: ApplePayPaymentData, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
77
|
+
private _buildCybersourceJwtPath;
|
|
77
78
|
private _assignChannel;
|
|
78
79
|
private _buildHeader;
|
|
79
80
|
}
|
|
@@ -136,9 +136,10 @@ let KushkiGateway = KushkiGateway_1 = class KushkiGateway {
|
|
|
136
136
|
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => this.requestGet(PathEnum_1.PathEnum.bank_list_payouts_transfer, testEnv, regional, mid)), operators_1.map((response) => response));
|
|
137
137
|
}
|
|
138
138
|
cybersourceJwt(mid, testEnv, regional, subscriptionId) {
|
|
139
|
-
return rxjs_1.of(1).pipe(operators_1.concatMap(() =>
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
return rxjs_1.of(1).pipe(operators_1.concatMap(() => {
|
|
140
|
+
const path = this._buildCybersourceJwtPath(subscriptionId);
|
|
141
|
+
return this.requestGet(path, testEnv, regional, mid);
|
|
142
|
+
}), operators_1.map((response) => response));
|
|
142
143
|
}
|
|
143
144
|
getUserId(subscriptionId, mid, testEnv, regional) {
|
|
144
145
|
return rxjs_1.of(1).pipe(operators_1.map(() => `${PathEnum_1.PathEnum.get_user_id}${subscriptionId}/user`), operators_1.concatMap((path) => this.request({}, {
|
|
@@ -160,6 +161,15 @@ let KushkiGateway = KushkiGateway_1 = class KushkiGateway {
|
|
|
160
161
|
[this._kushkiInfoHeader]: KushkiInfo_1.KInfo.sKushkiInfo,
|
|
161
162
|
}, `${PathEnum_1.PathEnum.get_apple_pay_token}?switch=${this._multiRegionEcommSwitch}`, testEnv, regional)));
|
|
162
163
|
}
|
|
164
|
+
_buildCybersourceJwtPath(subscriptionId) {
|
|
165
|
+
let path = PathEnum_1.PathEnum.cybersource_jwt;
|
|
166
|
+
const params = [];
|
|
167
|
+
params.push(`securityAuthConfiguration=true`);
|
|
168
|
+
if (subscriptionId)
|
|
169
|
+
params.push(`subscriptionId=${subscriptionId}`);
|
|
170
|
+
path += `?${params.join("&")}`;
|
|
171
|
+
return path;
|
|
172
|
+
}
|
|
163
173
|
_assignChannel(regional, path) {
|
|
164
174
|
if (!regional) {
|
|
165
175
|
this._uatUrl = `${EnvironmentEnum_1.EnvironmentEnum.uat}${path}`;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Interface for Kushki Gateway.
|
|
4
4
|
*/
|
|
5
5
|
import { Observable } from "rxjs";
|
|
6
|
-
import {
|
|
6
|
+
import { ApplePayPaymentData } from "./../../lib/types/apple_pay_get_token_events";
|
|
7
7
|
import { ApplePayStartSessionRequest } from "./../../lib/types/apple_pay_start_session_request";
|
|
8
8
|
import { BankListResponse } from "./../../lib/types/bank_list_response";
|
|
9
9
|
import { BinInfoResponse } from "./../../lib/types/bin_info_response";
|
|
@@ -166,5 +166,5 @@ export interface IKushkiGateway {
|
|
|
166
166
|
* @param testEnv - is test environment
|
|
167
167
|
* @param regional - Define if endpoint used regional URL
|
|
168
168
|
*/
|
|
169
|
-
getApplePayToken(body:
|
|
169
|
+
getApplePayToken(body: ApplePayPaymentData, mid: string, testEnv: boolean, regional: boolean): Observable<TokenResponse>;
|
|
170
170
|
}
|
|
@@ -153,7 +153,7 @@ let ApplePayService = ApplePayService_1 = class ApplePayService {
|
|
|
153
153
|
_onPaymentAuthorized(event, mid, session, isTest, regional, callback) {
|
|
154
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
155
|
try {
|
|
156
|
-
const apple_token = event.payment.token.paymentData;
|
|
156
|
+
const apple_token = Object.assign(Object.assign({}, event.payment.token.paymentData), { paymentMethod: event.payment.token.paymentMethod });
|
|
157
157
|
const kushki_token = yield this._gateway
|
|
158
158
|
.getApplePayToken(apple_token, mid, isTest, regional)
|
|
159
159
|
.toPromise();
|
|
@@ -311,7 +311,7 @@ let CardService = CardService_1 = class CardService {
|
|
|
311
311
|
_is3DSSecureEnabled(merchantSettings) {
|
|
312
312
|
return merchantSettings[this._3Dsecure] === true;
|
|
313
313
|
}
|
|
314
|
-
_loadCardinalScript(isTest, onLoad, onLoadError) {
|
|
314
|
+
_loadCardinalScript(isTest, onLoad, onLoadError, cybersourceResponse) {
|
|
315
315
|
const last_script = document.getElementById("cardinal_sc_id");
|
|
316
316
|
if (last_script)
|
|
317
317
|
last_script.remove();
|
|
@@ -321,20 +321,24 @@ let CardService = CardService_1 = class CardService {
|
|
|
321
321
|
script.src = isTest
|
|
322
322
|
? "https://songbirdstag.cardinalcommerce.com/cardinalcruise/v1/songbird.js"
|
|
323
323
|
: "https://songbird.cardinalcommerce.com/cardinalcruise/v1/songbird.js";
|
|
324
|
+
if (cybersourceResponse.songbirdUrl !== undefined &&
|
|
325
|
+
cybersourceResponse.songbirdIntegrityHashValue !== undefined) {
|
|
326
|
+
script.src = cybersourceResponse.songbirdUrl;
|
|
327
|
+
script.integrity = cybersourceResponse.songbirdIntegrityHashValue;
|
|
328
|
+
script.crossOrigin = "anonymous";
|
|
329
|
+
}
|
|
324
330
|
head.appendChild(script);
|
|
325
331
|
script.onload = onLoad;
|
|
326
332
|
script.onerror = onLoadError;
|
|
327
333
|
}
|
|
328
334
|
_initCybersource(cardNumber, mid, isTest, regional) {
|
|
329
|
-
return new rxjs_1.Observable(observer => {
|
|
335
|
+
return rxjs_1.of(1).pipe(operators_1.mergeMap(() => this._gateway.cybersourceJwt(mid, isTest, regional)), operators_1.mergeMap((jwtResponse) => new rxjs_1.Observable(observer => {
|
|
330
336
|
this._loadCardinalScript(isTest, () => {
|
|
331
|
-
|
|
337
|
+
this._initializeCardinal(jwtResponse.jwt, cardNumber);
|
|
338
|
+
observer.next(jwtResponse.jwt);
|
|
332
339
|
observer.complete();
|
|
333
|
-
}, () => observer.error(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E018)));
|
|
334
|
-
})
|
|
335
|
-
this._initializeCardinal(jwtResponse.jwt, cardNumber);
|
|
336
|
-
return jwtResponse.jwt;
|
|
337
|
-
}));
|
|
340
|
+
}, () => observer.error(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E018)), jwtResponse);
|
|
341
|
+
})));
|
|
338
342
|
}
|
|
339
343
|
_initializeCardinal(jwt, cardNumber) {
|
|
340
344
|
window.Cardinal.setup("init", {
|
|
@@ -349,16 +353,16 @@ let CardService = CardService_1 = class CardService {
|
|
|
349
353
|
});
|
|
350
354
|
}
|
|
351
355
|
_initCybersourceSubscription(subscriptionId, mid, isTest, regional) {
|
|
352
|
-
return
|
|
356
|
+
return this._gateway
|
|
357
|
+
.cybersourceJwt(mid, isTest, regional, subscriptionId)
|
|
358
|
+
.pipe(operators_1.mergeMap((jwtResponse) => new rxjs_1.Observable(observer => {
|
|
353
359
|
this._loadCardinalScript(isTest, () => {
|
|
354
|
-
|
|
360
|
+
const bin = buffer_1.Buffer.from(jwtResponse.identifier, "base64").toString("ascii");
|
|
361
|
+
this._initializeCardinal(jwtResponse.jwt, bin);
|
|
362
|
+
observer.next(jwtResponse.jwt);
|
|
355
363
|
observer.complete();
|
|
356
|
-
}, () => observer.error(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E018)));
|
|
357
|
-
})
|
|
358
|
-
const bin = buffer_1.Buffer.from(jwtResponse.identifier, "base64").toString("ascii");
|
|
359
|
-
this._initializeCardinal(jwtResponse.jwt, bin);
|
|
360
|
-
return jwtResponse.jwt;
|
|
361
|
-
}));
|
|
364
|
+
}, () => observer.error(new KushkiError_1.KushkiError(ErrorEnum_1.ERRORS.E018)), jwtResponse);
|
|
365
|
+
})));
|
|
362
366
|
}
|
|
363
367
|
// istanbul ignore next
|
|
364
368
|
_completeCardinal(secureServiceId, mid, isTest, regional, callback) {
|
|
@@ -5,9 +5,7 @@ export interface ApplePaymentEvent {
|
|
|
5
5
|
payment: {
|
|
6
6
|
billingContact?: ApplePayPaymentContact;
|
|
7
7
|
shippingContact?: ApplePayPaymentContact;
|
|
8
|
-
token:
|
|
9
|
-
paymentData: ApplePayGetTokenRequest;
|
|
10
|
-
};
|
|
8
|
+
token: ApplePayPaymentToken;
|
|
11
9
|
};
|
|
12
10
|
validationURL: string;
|
|
13
11
|
appleTokenResponse?: AppleTokenResponse;
|
|
@@ -28,7 +26,11 @@ export interface ApplePayPaymentContact {
|
|
|
28
26
|
countryCode: string;
|
|
29
27
|
addressLines: string[];
|
|
30
28
|
}
|
|
31
|
-
export interface
|
|
29
|
+
export interface ApplePayPaymentToken {
|
|
30
|
+
paymentData: ApplePayPaymentData;
|
|
31
|
+
paymentMethod: ApplePayPaymentMethod;
|
|
32
|
+
}
|
|
33
|
+
export interface ApplePayPaymentData {
|
|
32
34
|
data: string;
|
|
33
35
|
header: {
|
|
34
36
|
ephemeralPublicKey: string;
|
|
@@ -38,6 +40,12 @@ export interface ApplePayGetTokenRequest {
|
|
|
38
40
|
};
|
|
39
41
|
signature: string;
|
|
40
42
|
version: string;
|
|
43
|
+
paymentMethod?: ApplePayPaymentMethod;
|
|
44
|
+
}
|
|
45
|
+
export interface ApplePayPaymentMethod {
|
|
46
|
+
network: string;
|
|
47
|
+
displayName: string;
|
|
48
|
+
type: string;
|
|
41
49
|
}
|
|
42
50
|
export interface AppleTokenResponse {
|
|
43
51
|
token: string;
|