@paydock/client-sdk 1.115.0 → 1.116.0-beta
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 +531 -1
- package/bundles/index.cjs +500 -6
- package/bundles/index.cjs.d.ts +214 -1
- package/bundles/index.mjs +499 -7
- package/bundles/index.mjs.d.ts +214 -1
- package/bundles/types/api/api-charge-internal.d.ts +1 -0
- package/bundles/types/api/api-charge-internal.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.generic.show_message.d.ts.map +1 -1
- package/bundles/types/index-cba.d.ts +2 -0
- package/bundles/types/index-cba.d.ts.map +1 -1
- package/bundles/types/index.d.ts +2 -0
- package/bundles/types/index.d.ts.map +1 -1
- package/bundles/types/paypal-data-collector/index.d.ts +23 -0
- package/bundles/types/paypal-data-collector/index.d.ts.map +1 -0
- package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts +58 -0
- package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts.map +1 -0
- package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts +21 -0
- package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts.map +1 -0
- package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts +17 -0
- package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts.map +1 -0
- package/bundles/types/paypal-save-payment-source/index.d.ts +61 -0
- package/bundles/types/paypal-save-payment-source/index.d.ts.map +1 -0
- package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts +85 -0
- package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts.map +1 -0
- package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts +84 -0
- package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts.map +1 -0
- package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts +36 -0
- package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts +1 -0
- package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
- package/bundles/widget.umd.js +500 -6
- package/bundles/widget.umd.js.d.ts +214 -1
- package/bundles/widget.umd.js.min.d.ts +214 -1
- package/bundles/widget.umd.min.js +7 -7
- package/docs/paypal-data-collector-examples.md +58 -0
- package/docs/paypal-data-collector.md +149 -0
- package/docs/paypal-save-payment-source-examples.md +63 -0
- package/docs/paypal-save-payment-source.md +256 -0
- package/docs/wallet-buttons-express-examples.md +1 -1
- package/package.json +1 -1
package/bundles/widget.umd.js
CHANGED
|
@@ -893,7 +893,7 @@
|
|
|
893
893
|
version: 'x-sdk-version',
|
|
894
894
|
type: 'x-sdk-type'
|
|
895
895
|
});
|
|
896
|
-
SDK._version = 'v1.
|
|
896
|
+
SDK._version = 'v1.116.0-beta';
|
|
897
897
|
|
|
898
898
|
/******************************************************************************
|
|
899
899
|
Copyright (c) Microsoft Corporation.
|
|
@@ -3960,8 +3960,8 @@
|
|
|
3960
3960
|
var params = {
|
|
3961
3961
|
enabled: 'true',
|
|
3962
3962
|
accountId: '974691',
|
|
3963
|
-
agentId: '
|
|
3964
|
-
applicationId: '
|
|
3963
|
+
agentId: '1386157150',
|
|
3964
|
+
applicationId: '1386157150',
|
|
3965
3965
|
licenseKey: '4848a32285',
|
|
3966
3966
|
trustKey: '974691'
|
|
3967
3967
|
};
|
|
@@ -14989,8 +14989,8 @@
|
|
|
14989
14989
|
}, {
|
|
14990
14990
|
key: "destroy",
|
|
14991
14991
|
value: function destroy() {
|
|
14992
|
-
clearTimeout(this.timeoutId);
|
|
14993
14992
|
// TODO: Adjust when implementing the failure payment flow
|
|
14993
|
+
// clearTimeout(this.timeoutId);
|
|
14994
14994
|
// document.querySelector(this.formSelector).innerHTML = '';
|
|
14995
14995
|
}
|
|
14996
14996
|
}]);
|
|
@@ -16050,7 +16050,8 @@
|
|
|
16050
16050
|
address_city: billingContact === null || billingContact === void 0 ? void 0 : billingContact.locality,
|
|
16051
16051
|
address_postcode: billingContact === null || billingContact === void 0 ? void 0 : billingContact.postalCode,
|
|
16052
16052
|
address_state: billingContact === null || billingContact === void 0 ? void 0 : billingContact.administrativeArea,
|
|
16053
|
-
ref_token: token.paymentData ? JSON.stringify(token.paymentData) : ''
|
|
16053
|
+
ref_token: token.paymentData ? JSON.stringify(token.paymentData) : '',
|
|
16054
|
+
wallet_express: true
|
|
16054
16055
|
}
|
|
16055
16056
|
}
|
|
16056
16057
|
}).then(function () {
|
|
@@ -16333,7 +16334,8 @@
|
|
|
16333
16334
|
payment_method_id: data.orderID,
|
|
16334
16335
|
customer: {
|
|
16335
16336
|
payment_source: {
|
|
16336
|
-
external_payer_id: data.payerID
|
|
16337
|
+
external_payer_id: data.payerID,
|
|
16338
|
+
wallet_express: true
|
|
16337
16339
|
}
|
|
16338
16340
|
}
|
|
16339
16341
|
})["finally"](function () {
|
|
@@ -16353,6 +16355,496 @@
|
|
|
16353
16355
|
}]);
|
|
16354
16356
|
}(BaseWalletButton);
|
|
16355
16357
|
|
|
16358
|
+
var PAYPAL_DATA_COLLECTOR_EVENTS;
|
|
16359
|
+
(function (PAYPAL_DATA_COLLECTOR_EVENTS) {
|
|
16360
|
+
PAYPAL_DATA_COLLECTOR_EVENTS["ON_ERROR"] = "ON_ERROR";
|
|
16361
|
+
})(PAYPAL_DATA_COLLECTOR_EVENTS || (PAYPAL_DATA_COLLECTOR_EVENTS = {}));
|
|
16362
|
+
var ErrorCodes$1;
|
|
16363
|
+
(function (ErrorCodes) {
|
|
16364
|
+
ErrorCodes["PROMISE_NOT_ENABLED"] = "promise_not_enabled";
|
|
16365
|
+
ErrorCodes["SCRIPT_ERROR"] = "script_error";
|
|
16366
|
+
})(ErrorCodes$1 || (ErrorCodes$1 = {}));
|
|
16367
|
+
|
|
16368
|
+
var PayPalDataCollectorService = /*#__PURE__*/function () {
|
|
16369
|
+
function PayPalDataCollectorService(eventEmitter, flowId, config) {
|
|
16370
|
+
_classCallCheck(this, PayPalDataCollectorService);
|
|
16371
|
+
this.eventEmitter = eventEmitter;
|
|
16372
|
+
this.flowId = flowId;
|
|
16373
|
+
this.config = config;
|
|
16374
|
+
}
|
|
16375
|
+
return _createClass(PayPalDataCollectorService, [{
|
|
16376
|
+
key: "collectDeviceData",
|
|
16377
|
+
value: function collectDeviceData() {
|
|
16378
|
+
if (!window.Promise) {
|
|
16379
|
+
this.eventEmitter.emit(PAYPAL_DATA_COLLECTOR_EVENTS.ON_ERROR, {
|
|
16380
|
+
error_code: ErrorCodes$1.PROMISE_NOT_ENABLED
|
|
16381
|
+
});
|
|
16382
|
+
}
|
|
16383
|
+
this.correlationId = Uuid.generate();
|
|
16384
|
+
return this.appendPaypalSavePaymentSourceComponent();
|
|
16385
|
+
}
|
|
16386
|
+
}, {
|
|
16387
|
+
key: "appendPaypalSavePaymentSourceComponent",
|
|
16388
|
+
value: function appendPaypalSavePaymentSourceComponent() {
|
|
16389
|
+
var _this = this;
|
|
16390
|
+
var paypalScript = document.createElement("script");
|
|
16391
|
+
paypalScript.type = "application/json";
|
|
16392
|
+
paypalScript.setAttribute("fncls", "fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99");
|
|
16393
|
+
var scriptContent = _extends(_extends({
|
|
16394
|
+
f: this.correlationId,
|
|
16395
|
+
s: this.flowId ? this.flowId : Uuid.generate(),
|
|
16396
|
+
cb1: 'paydockPayPalDataCollectorServiceCallbackPostOne',
|
|
16397
|
+
cb2: 'paydockPayPalDataCollectorServiceCallbackPostTwo'
|
|
16398
|
+
}, this.isSandbox && {
|
|
16399
|
+
sandbox: this.isSandbox
|
|
16400
|
+
}), this.config.mouse_movement && {
|
|
16401
|
+
mm: this.config.mouse_movement
|
|
16402
|
+
});
|
|
16403
|
+
paypalScript.textContent = JSON.stringify(scriptContent, null, 4);
|
|
16404
|
+
var fraudnetScript = document.createElement("script");
|
|
16405
|
+
fraudnetScript.type = "text/javascript";
|
|
16406
|
+
fraudnetScript.src = "https://c.paypal.com/da/r/fb.js";
|
|
16407
|
+
fraudnetScript.onerror = function () {
|
|
16408
|
+
return _this.onError();
|
|
16409
|
+
};
|
|
16410
|
+
document.body.appendChild(paypalScript);
|
|
16411
|
+
document.body.appendChild(fraudnetScript);
|
|
16412
|
+
return this.setupCallbacks();
|
|
16413
|
+
}
|
|
16414
|
+
}, {
|
|
16415
|
+
key: "setupCallbacks",
|
|
16416
|
+
value: function setupCallbacks() {
|
|
16417
|
+
var _this2 = this;
|
|
16418
|
+
return new Promise(function (resolve, reject) {
|
|
16419
|
+
var callbackOnePromise = new Promise(function (resolve) {
|
|
16420
|
+
window.paydockPayPalDataCollectorServiceCallbackPostOne = function () {
|
|
16421
|
+
resolve();
|
|
16422
|
+
};
|
|
16423
|
+
});
|
|
16424
|
+
var callbackTwoPromise = new Promise(function (resolve) {
|
|
16425
|
+
window.paydockPayPalDataCollectorServiceCallbackPostTwo = function () {
|
|
16426
|
+
resolve();
|
|
16427
|
+
};
|
|
16428
|
+
});
|
|
16429
|
+
Promise.all([callbackOnePromise, callbackTwoPromise]).then(function () {
|
|
16430
|
+
resolve({
|
|
16431
|
+
correlation_id: _this2.correlationId
|
|
16432
|
+
});
|
|
16433
|
+
})["catch"](reject);
|
|
16434
|
+
});
|
|
16435
|
+
}
|
|
16436
|
+
}, {
|
|
16437
|
+
key: "onError",
|
|
16438
|
+
value: function onError() {
|
|
16439
|
+
this.eventEmitter.emit(PAYPAL_DATA_COLLECTOR_EVENTS.ON_ERROR, {
|
|
16440
|
+
error_code: ErrorCodes$1.SCRIPT_ERROR
|
|
16441
|
+
});
|
|
16442
|
+
}
|
|
16443
|
+
}, {
|
|
16444
|
+
key: "setEnv",
|
|
16445
|
+
value: function setEnv(env) {
|
|
16446
|
+
this.isSandbox = env !== 'live';
|
|
16447
|
+
}
|
|
16448
|
+
}], [{
|
|
16449
|
+
key: "fromConfig",
|
|
16450
|
+
value: function fromConfig(eventEmitter, flowId, config) {
|
|
16451
|
+
return new PayPalDataCollectorService(eventEmitter, flowId, config);
|
|
16452
|
+
}
|
|
16453
|
+
}]);
|
|
16454
|
+
}();
|
|
16455
|
+
|
|
16456
|
+
/**
|
|
16457
|
+
* PayPal Data Collector Widget constructor
|
|
16458
|
+
*
|
|
16459
|
+
* @param {string} flowId - This string identifies the source website of the FraudNet request.
|
|
16460
|
+
* @param {PayPalDataCollectorConfig} config - Extra configuration for the widget.
|
|
16461
|
+
*
|
|
16462
|
+
* @example
|
|
16463
|
+
* var payPalDataCollector = new PayPalDataCollector('FLOW_ID', {});
|
|
16464
|
+
*/
|
|
16465
|
+
var PayPalDataCollector = /*#__PURE__*/function () {
|
|
16466
|
+
/** @constructs */ // constructs added for correct parse classes jsdoc2md
|
|
16467
|
+
function PayPalDataCollector(flowId, config) {
|
|
16468
|
+
_classCallCheck(this, PayPalDataCollector);
|
|
16469
|
+
this.eventEmitter = new EventEmitter();
|
|
16470
|
+
this.service = PayPalDataCollectorService.fromConfig(this.eventEmitter, flowId, config);
|
|
16471
|
+
}
|
|
16472
|
+
/**
|
|
16473
|
+
* After configuring the PayPalDataCollector Widget, starts the process and returns
|
|
16474
|
+
* the correlation id used among the requests.
|
|
16475
|
+
*
|
|
16476
|
+
* @returns {Promise<CollectedDeviceData>} Promise when resolved, returnsa an object
|
|
16477
|
+
* that contains the `correlation_id` key.
|
|
16478
|
+
*
|
|
16479
|
+
* @example
|
|
16480
|
+
* const collectedDeviceData = await payPalDataCollectorWidget.collectDeviceData();
|
|
16481
|
+
* console.log(collectedDeviceData.correlation_id)
|
|
16482
|
+
*/
|
|
16483
|
+
return _createClass(PayPalDataCollector, [{
|
|
16484
|
+
key: "collectDeviceData",
|
|
16485
|
+
value: function collectDeviceData() {
|
|
16486
|
+
try {
|
|
16487
|
+
return this.service.collectDeviceData();
|
|
16488
|
+
} catch (err) {
|
|
16489
|
+
this.eventEmitter.emit(PAYPAL_DATA_COLLECTOR_EVENTS.ON_ERROR, null);
|
|
16490
|
+
throw err;
|
|
16491
|
+
}
|
|
16492
|
+
}
|
|
16493
|
+
/**
|
|
16494
|
+
* Callback for onError method.
|
|
16495
|
+
*
|
|
16496
|
+
* @callback OnErrorCallback
|
|
16497
|
+
* @param {IOnErrorEventData|null} data
|
|
16498
|
+
*/
|
|
16499
|
+
/**
|
|
16500
|
+
* If the process fails, the function passed as parameter will be called.
|
|
16501
|
+
* Important: Do not perform thread blocking operations in callback such as window.alert() calls.
|
|
16502
|
+
*
|
|
16503
|
+
* @example
|
|
16504
|
+
* PayPalDataCollector.onError((eventData) => console.log('Some error occur'));
|
|
16505
|
+
*
|
|
16506
|
+
* @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
|
|
16507
|
+
*/
|
|
16508
|
+
}, {
|
|
16509
|
+
key: "onError",
|
|
16510
|
+
value: function onError(callback) {
|
|
16511
|
+
return this.eventEmitter.subscribe(PAYPAL_DATA_COLLECTOR_EVENTS.ON_ERROR, callback);
|
|
16512
|
+
}
|
|
16513
|
+
/**
|
|
16514
|
+
* Current method can change environment. By default environment = test.
|
|
16515
|
+
* This method does not affect Paydock's API calls or environments, is only for PayPal Data Collector
|
|
16516
|
+
* script, in order to know if the script is injected on a live server or is a testing
|
|
16517
|
+
* environment. The available values are `test` and `live`. This should match with the used
|
|
16518
|
+
* `gateway.mode` in Paydock to process the transaction.
|
|
16519
|
+
*
|
|
16520
|
+
* @example
|
|
16521
|
+
* PayPalDataCollector.setEnv('live');
|
|
16522
|
+
* @param {string} env - test, live
|
|
16523
|
+
*/
|
|
16524
|
+
}, {
|
|
16525
|
+
key: "setEnv",
|
|
16526
|
+
value: function setEnv(env) {
|
|
16527
|
+
this.service.setEnv(env);
|
|
16528
|
+
}
|
|
16529
|
+
}]);
|
|
16530
|
+
}();
|
|
16531
|
+
|
|
16532
|
+
var PAYPAL_SAVE_PAYMENT_EVENTS = {
|
|
16533
|
+
ON_SUCCESS: 'ON_SUCCESS',
|
|
16534
|
+
ON_ERROR: 'ON_ERROR',
|
|
16535
|
+
ON_CANCEL: 'ON_CANCEL'
|
|
16536
|
+
};
|
|
16537
|
+
var ErrorCodes;
|
|
16538
|
+
(function (ErrorCodes) {
|
|
16539
|
+
ErrorCodes["UNAVAILABLE"] = "unavailable";
|
|
16540
|
+
ErrorCodes["ON_PAYPAL_VAULT_SETUP_TOKEN_ERROR"] = "onPaypalVaultSetupTokenError";
|
|
16541
|
+
ErrorCodes["ON_GET_ID_TOKEN_ERROR"] = "onGetIdTokenError";
|
|
16542
|
+
ErrorCodes["ON_GET_WALLET_CONFIG_ERROR"] = "onGetWalletConfigError";
|
|
16543
|
+
ErrorCodes["ON_GET_SETUP_TOKEN_ERROR"] = "onGetSetupTokenError";
|
|
16544
|
+
ErrorCodes["ON_ONE_TIME_TOKEN_ERROR"] = "onOneTimeTokenError";
|
|
16545
|
+
})(ErrorCodes || (ErrorCodes = {}));
|
|
16546
|
+
var EVENTS;
|
|
16547
|
+
(function (EVENTS) {
|
|
16548
|
+
EVENTS["ON_SUCCESS"] = "ON_SUCCESS";
|
|
16549
|
+
EVENTS["ON_ERROR"] = "ON_ERROR";
|
|
16550
|
+
EVENTS["ON_CANCEL"] = "ON_CANCEL";
|
|
16551
|
+
})(EVENTS || (EVENTS = {}));
|
|
16552
|
+
|
|
16553
|
+
var PAYPAL_OAUTH_TOKEN_ROUTE = '/v1/payment_sources/oauth-tokens';
|
|
16554
|
+
var PAYPAL_SETUP_TOKEN_ROUTE = '/v1/payment_sources/setup-tokens';
|
|
16555
|
+
var PAYPAL_OTT_ROUTE = '/v1/payment_sources/setup-tokens/:setup_token/tokens';
|
|
16556
|
+
var PayPalSavePaymentSourceService = /*#__PURE__*/function () {
|
|
16557
|
+
function PayPalSavePaymentSourceService(publicKey, gatewayId, eventEmitter, config) {
|
|
16558
|
+
_classCallCheck(this, PayPalSavePaymentSourceService);
|
|
16559
|
+
this.publicKey = publicKey;
|
|
16560
|
+
this.gatewayId = gatewayId;
|
|
16561
|
+
this.eventEmitter = eventEmitter;
|
|
16562
|
+
this.config = config;
|
|
16563
|
+
this.api = new ApiInternal(publicKey, this.getApiAuthType(publicKey));
|
|
16564
|
+
}
|
|
16565
|
+
return _createClass(PayPalSavePaymentSourceService, [{
|
|
16566
|
+
key: "getApiAuthType",
|
|
16567
|
+
value: function getApiAuthType(publicKeyOrAccessToken) {
|
|
16568
|
+
if (AccessToken.validateJWT(publicKeyOrAccessToken)) {
|
|
16569
|
+
return API_AUTH_TYPE.TOKEN;
|
|
16570
|
+
}
|
|
16571
|
+
return API_AUTH_TYPE.PUBLIC_KEY;
|
|
16572
|
+
}
|
|
16573
|
+
}, {
|
|
16574
|
+
key: "setEnv",
|
|
16575
|
+
value: function setEnv(env, alias) {
|
|
16576
|
+
this.api.setEnv(env, alias);
|
|
16577
|
+
}
|
|
16578
|
+
}, {
|
|
16579
|
+
key: "load",
|
|
16580
|
+
value: function load(container) {
|
|
16581
|
+
var _this = this;
|
|
16582
|
+
if (!window.Promise) {
|
|
16583
|
+
this.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, {
|
|
16584
|
+
error_code: ErrorCodes.UNAVAILABLE
|
|
16585
|
+
});
|
|
16586
|
+
}
|
|
16587
|
+
Promise.all([this.getWalletConfig(), this.getIdToken()]).then(function () {
|
|
16588
|
+
return _this.renderPaypalSavePaymentSourceComponent(container);
|
|
16589
|
+
})["catch"](function (error) {
|
|
16590
|
+
throw error;
|
|
16591
|
+
});
|
|
16592
|
+
}
|
|
16593
|
+
}, {
|
|
16594
|
+
key: "renderPaypalSavePaymentSourceComponent",
|
|
16595
|
+
value: function renderPaypalSavePaymentSourceComponent(container) {
|
|
16596
|
+
var _this2 = this;
|
|
16597
|
+
var _a;
|
|
16598
|
+
var buttonId = ((_a = container.getElement()) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
16599
|
+
var paypalScript = document.createElement('script');
|
|
16600
|
+
paypalScript.src = "https://www.paypal.com/sdk/js?client-id=".concat(this.getClientAuthFromWalletConfig());
|
|
16601
|
+
paypalScript.setAttribute('data-user-id-token', this.idToken);
|
|
16602
|
+
paypalScript.async = true;
|
|
16603
|
+
paypalScript.onload = function () {
|
|
16604
|
+
if (window.paypal) {
|
|
16605
|
+
_this2.paypal = window.paypal;
|
|
16606
|
+
var button = _this2.paypal.Buttons(_extends(_extends({
|
|
16607
|
+
createVaultSetupToken: function createVaultSetupToken() {
|
|
16608
|
+
return _this2.getSetupToken(_this2.accessToken);
|
|
16609
|
+
},
|
|
16610
|
+
onApprove: function onApprove(_ref) {
|
|
16611
|
+
var vaultSetupToken = _ref.vaultSetupToken;
|
|
16612
|
+
_this2.onObtainedVaultSetupToken(vaultSetupToken);
|
|
16613
|
+
},
|
|
16614
|
+
onError: function onError(error) {
|
|
16615
|
+
_this2.onErrorVaultSetupToken(error);
|
|
16616
|
+
},
|
|
16617
|
+
onCancel: function onCancel() {
|
|
16618
|
+
_this2.onCancelVaultSetupToken();
|
|
16619
|
+
}
|
|
16620
|
+
}, _this2.config.style && {
|
|
16621
|
+
style: _this2.config.style
|
|
16622
|
+
}), _this2.config.message && {
|
|
16623
|
+
message: _this2.config.message
|
|
16624
|
+
}));
|
|
16625
|
+
if (button.isEligible()) {
|
|
16626
|
+
button.render("#".concat(buttonId));
|
|
16627
|
+
} else {
|
|
16628
|
+
_this2.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, {
|
|
16629
|
+
error_code: ErrorCodes.UNAVAILABLE
|
|
16630
|
+
});
|
|
16631
|
+
}
|
|
16632
|
+
} else {
|
|
16633
|
+
_this2.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, {
|
|
16634
|
+
error_code: ErrorCodes.UNAVAILABLE
|
|
16635
|
+
});
|
|
16636
|
+
}
|
|
16637
|
+
};
|
|
16638
|
+
document.head.appendChild(paypalScript);
|
|
16639
|
+
}
|
|
16640
|
+
}, {
|
|
16641
|
+
key: "getClientAuthFromWalletConfig",
|
|
16642
|
+
value: function getClientAuthFromWalletConfig() {
|
|
16643
|
+
var _a;
|
|
16644
|
+
return ((_a = this.walletConfig) === null || _a === void 0 ? void 0 : _a.credentials).client_auth;
|
|
16645
|
+
}
|
|
16646
|
+
}, {
|
|
16647
|
+
key: "getSetupToken",
|
|
16648
|
+
value: function getSetupToken(accessToken) {
|
|
16649
|
+
var _this3 = this;
|
|
16650
|
+
return this.api.getClientPromise('POST', PAYPAL_SETUP_TOKEN_ROUTE).send({
|
|
16651
|
+
gateway_id: this.gatewayId,
|
|
16652
|
+
token: accessToken
|
|
16653
|
+
}).then(function (responseSetupToken) {
|
|
16654
|
+
return responseSetupToken.setup_token;
|
|
16655
|
+
})["catch"](function (error) {
|
|
16656
|
+
_this3.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, _extends({
|
|
16657
|
+
error_code: ErrorCodes.ON_GET_SETUP_TOKEN_ERROR
|
|
16658
|
+
}, _this3.extractErrorDetails(error)));
|
|
16659
|
+
return Promise.reject(error);
|
|
16660
|
+
});
|
|
16661
|
+
}
|
|
16662
|
+
}, {
|
|
16663
|
+
key: "onObtainedVaultSetupToken",
|
|
16664
|
+
value: function onObtainedVaultSetupToken(vaultSetupToken) {
|
|
16665
|
+
var _this4 = this;
|
|
16666
|
+
return this.api.getClientPromise('POST', PAYPAL_OTT_ROUTE.replace(':setup_token', vaultSetupToken)).send({
|
|
16667
|
+
gateway_id: this.gatewayId
|
|
16668
|
+
}).then(function (responseSetupToken) {
|
|
16669
|
+
_this4.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_SUCCESS, {
|
|
16670
|
+
token: responseSetupToken.token,
|
|
16671
|
+
email: responseSetupToken.email
|
|
16672
|
+
});
|
|
16673
|
+
})["catch"](function () {
|
|
16674
|
+
_this4.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, {
|
|
16675
|
+
error_code: ErrorCodes.ON_ONE_TIME_TOKEN_ERROR
|
|
16676
|
+
});
|
|
16677
|
+
});
|
|
16678
|
+
}
|
|
16679
|
+
}, {
|
|
16680
|
+
key: "onErrorVaultSetupToken",
|
|
16681
|
+
value: function onErrorVaultSetupToken(error) {
|
|
16682
|
+
this.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, _extends({
|
|
16683
|
+
error_code: ErrorCodes.ON_PAYPAL_VAULT_SETUP_TOKEN_ERROR
|
|
16684
|
+
}, this.extractErrorDetails(error)));
|
|
16685
|
+
}
|
|
16686
|
+
}, {
|
|
16687
|
+
key: "onCancelVaultSetupToken",
|
|
16688
|
+
value: function onCancelVaultSetupToken() {
|
|
16689
|
+
this.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_CANCEL);
|
|
16690
|
+
}
|
|
16691
|
+
}, {
|
|
16692
|
+
key: "getIdToken",
|
|
16693
|
+
value: function getIdToken() {
|
|
16694
|
+
var _this5 = this;
|
|
16695
|
+
return this.api.getClientPromise('POST', PAYPAL_OAUTH_TOKEN_ROUTE).send({
|
|
16696
|
+
gateway_id: this.gatewayId
|
|
16697
|
+
}).then(function (data) {
|
|
16698
|
+
_this5.idToken = data.id_token;
|
|
16699
|
+
_this5.accessToken = data.access_token;
|
|
16700
|
+
})["catch"](function (error) {
|
|
16701
|
+
_this5.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, _extends({
|
|
16702
|
+
error_code: ErrorCodes.ON_GET_ID_TOKEN_ERROR
|
|
16703
|
+
}, _this5.extractErrorDetails(error)));
|
|
16704
|
+
});
|
|
16705
|
+
}
|
|
16706
|
+
}, {
|
|
16707
|
+
key: "getWalletConfig",
|
|
16708
|
+
value: function getWalletConfig() {
|
|
16709
|
+
var _this6 = this;
|
|
16710
|
+
return this.api.gateway().getWalletConfig(this.gatewayId).then(function (walletConfigResponse) {
|
|
16711
|
+
_this6.walletConfig = walletConfigResponse;
|
|
16712
|
+
})["catch"](function (error) {
|
|
16713
|
+
_this6.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, _extends({
|
|
16714
|
+
error_code: ErrorCodes.ON_GET_WALLET_CONFIG_ERROR
|
|
16715
|
+
}, _this6.extractErrorDetails(error)));
|
|
16716
|
+
});
|
|
16717
|
+
}
|
|
16718
|
+
}, {
|
|
16719
|
+
key: "extractErrorDetails",
|
|
16720
|
+
value: function extractErrorDetails(error) {
|
|
16721
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16722
|
+
var details = (_d = (_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.details) === null || _a === void 0 ? void 0 : _a.messages) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.gateway_specific_description) !== null && _d !== void 0 ? _d : (_f = (_e = error === null || error === void 0 ? void 0 : error.details) === null || _e === void 0 ? void 0 : _e.messages) === null || _f === void 0 ? void 0 : _f[0];
|
|
16723
|
+
var message = error === null || error === void 0 ? void 0 : error.message;
|
|
16724
|
+
return _extends(_extends({}, details && {
|
|
16725
|
+
details: details
|
|
16726
|
+
}), message && {
|
|
16727
|
+
message: message
|
|
16728
|
+
});
|
|
16729
|
+
}
|
|
16730
|
+
}], [{
|
|
16731
|
+
key: "fromConfig",
|
|
16732
|
+
value: function fromConfig(publicKey, gatewayId, eventEmitter, config) {
|
|
16733
|
+
return new PayPalSavePaymentSourceService(publicKey, gatewayId, eventEmitter, config);
|
|
16734
|
+
}
|
|
16735
|
+
}]);
|
|
16736
|
+
}();
|
|
16737
|
+
|
|
16738
|
+
/**
|
|
16739
|
+
* PayPal Save Payment Source Widget constructor
|
|
16740
|
+
*
|
|
16741
|
+
* @param {string} selector - Selector of html element. Container for PayPal Save Payment Source Widget.
|
|
16742
|
+
* @param {string} publicKey - PayDock users public key.
|
|
16743
|
+
* @param {string} gatewayId - PayDock's PayPal gatewayId.
|
|
16744
|
+
* @param {PayPalSavePaymentSourceWidgetConfig} config - Extra configuration for the widget, like styles.
|
|
16745
|
+
*
|
|
16746
|
+
* @example
|
|
16747
|
+
* var payPalSavePaymentSourceWidget = new PayPalSavePaymentSourceWidget('#paypalButton', 'public_key', 'gateway_id');
|
|
16748
|
+
*/
|
|
16749
|
+
var PayPalSavePaymentSourceWidget = /*#__PURE__*/function () {
|
|
16750
|
+
/** @constructs */ // constructs added for correct parse classes jsdoc2md
|
|
16751
|
+
function PayPalSavePaymentSourceWidget(selector, publicKey, gatewayId, config) {
|
|
16752
|
+
_classCallCheck(this, PayPalSavePaymentSourceWidget);
|
|
16753
|
+
this.eventEmitter = new EventEmitter();
|
|
16754
|
+
this.container = new Container(selector);
|
|
16755
|
+
this.service = PayPalSavePaymentSourceService.fromConfig(publicKey, gatewayId, this.eventEmitter, config);
|
|
16756
|
+
}
|
|
16757
|
+
/**
|
|
16758
|
+
* The final method after configuring the PayPalSavePaymentSource Widget to
|
|
16759
|
+
* start the load process.
|
|
16760
|
+
*/
|
|
16761
|
+
return _createClass(PayPalSavePaymentSourceWidget, [{
|
|
16762
|
+
key: "load",
|
|
16763
|
+
value: function load() {
|
|
16764
|
+
try {
|
|
16765
|
+
this.service.load(this.container);
|
|
16766
|
+
} catch (err) {
|
|
16767
|
+
this.eventEmitter.emit(EVENTS.ON_ERROR, null);
|
|
16768
|
+
throw err;
|
|
16769
|
+
}
|
|
16770
|
+
}
|
|
16771
|
+
/**
|
|
16772
|
+
* Current method can change environment. By default environment = sandbox.
|
|
16773
|
+
* Also we can change domain alias for this environment. By default domain_alias = paydock.com
|
|
16774
|
+
*
|
|
16775
|
+
* @example
|
|
16776
|
+
* payPalSavePaymentSourceWidget.setEnv('production');
|
|
16777
|
+
* @param {string} env - sandbox, production
|
|
16778
|
+
* @param {string} [alias] - Own domain alias
|
|
16779
|
+
*/
|
|
16780
|
+
}, {
|
|
16781
|
+
key: "setEnv",
|
|
16782
|
+
value: function setEnv(env, alias) {
|
|
16783
|
+
this.service.setEnv(env, alias);
|
|
16784
|
+
}
|
|
16785
|
+
/**
|
|
16786
|
+
* Callback for onSuccess method.
|
|
16787
|
+
*
|
|
16788
|
+
* @callback OnSuccessCallback
|
|
16789
|
+
* @param {IOnSuccessEventData} data
|
|
16790
|
+
*/
|
|
16791
|
+
/**
|
|
16792
|
+
* If the setup token was successfully approved and a OTT was generated, the function passed as parameter will be called.
|
|
16793
|
+
* Important: Do not perform thread blocking operations in callback such as window.alert() calls.
|
|
16794
|
+
*
|
|
16795
|
+
* @example
|
|
16796
|
+
* payPalSavePaymentSourceWidget.onSuccess((eventData) => console.log('One time token and email obtained successfully'));
|
|
16797
|
+
*
|
|
16798
|
+
* @param {OnSuccessCallback} [callback] - Function to be called when the result is successful.
|
|
16799
|
+
*/
|
|
16800
|
+
}, {
|
|
16801
|
+
key: "onSuccess",
|
|
16802
|
+
value: function onSuccess(callback) {
|
|
16803
|
+
return this.eventEmitter.subscribe(EVENTS.ON_SUCCESS, callback);
|
|
16804
|
+
}
|
|
16805
|
+
/**
|
|
16806
|
+
* Callback for onError method.
|
|
16807
|
+
*
|
|
16808
|
+
* @callback OnErrorCallback
|
|
16809
|
+
* @param {IOnErrorEventData} data
|
|
16810
|
+
*/
|
|
16811
|
+
/**
|
|
16812
|
+
* If in the process for obtaining the setup token fails, the function passed as parameter will be called.
|
|
16813
|
+
* Important: Do not perform thread blocking operations in callback such as window.alert() calls.
|
|
16814
|
+
*
|
|
16815
|
+
* @example
|
|
16816
|
+
* payPalSavePaymentSourceWidget.onError((eventData) => console.log('Some error occurred'));
|
|
16817
|
+
*
|
|
16818
|
+
* @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
|
|
16819
|
+
*/
|
|
16820
|
+
}, {
|
|
16821
|
+
key: "onError",
|
|
16822
|
+
value: function onError(callback) {
|
|
16823
|
+
return this.eventEmitter.subscribe(EVENTS.ON_ERROR, callback);
|
|
16824
|
+
}
|
|
16825
|
+
/**
|
|
16826
|
+
* Callback for onCancel method.
|
|
16827
|
+
*
|
|
16828
|
+
* @callback OnCancelCallback
|
|
16829
|
+
* @param {IOnCancelEventData} data
|
|
16830
|
+
*/
|
|
16831
|
+
/**
|
|
16832
|
+
* If in the process for obtaining the setup token was cancelled, the function passed as parameter will be called.
|
|
16833
|
+
* Important: Do not perform thread blocking operations in callback such as window.alert() calls.
|
|
16834
|
+
*
|
|
16835
|
+
* @example
|
|
16836
|
+
* payPalSavePaymentSourceWidget.onCancel(() => console.log('Operation cancelled'));
|
|
16837
|
+
*
|
|
16838
|
+
* @param {OnCancelCallback} [callback] - Function to be called when the operation is cancelled.
|
|
16839
|
+
*/
|
|
16840
|
+
}, {
|
|
16841
|
+
key: "onCancel",
|
|
16842
|
+
value: function onCancel(callback) {
|
|
16843
|
+
return this.eventEmitter.subscribe(EVENTS.ON_CANCEL, callback);
|
|
16844
|
+
}
|
|
16845
|
+
}]);
|
|
16846
|
+
}();
|
|
16847
|
+
|
|
16356
16848
|
class Timer {
|
|
16357
16849
|
constructor(opts, ms) {
|
|
16358
16850
|
if (!opts.onEnd) throw new Error('onEnd handler is required');
|
|
@@ -34479,6 +34971,8 @@
|
|
|
34479
34971
|
exports.MultiWidget = MultiWidget;
|
|
34480
34972
|
exports.PAYMENT_TYPE = PAYMENT_TYPE;
|
|
34481
34973
|
exports.PURPOSE = PURPOSE;
|
|
34974
|
+
exports.PayPalDataCollector = PayPalDataCollector;
|
|
34975
|
+
exports.PayPalSavePaymentSourceWidget = PayPalSavePaymentSourceWidget;
|
|
34482
34976
|
exports.PaymentSourceBuilder = Builder;
|
|
34483
34977
|
exports.PaymentSourceWidget = PaymentSourceWidget;
|
|
34484
34978
|
exports.PaypalCheckoutButton = PaypalCheckoutButton;
|