@paydock/client-sdk 1.115.0 → 1.116.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 +531 -40
- package/bundles/index.cjs +515 -87
- package/bundles/index.cjs.d.ts +214 -1
- package/bundles/index.mjs +514 -88
- 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/checkout/layout-widgets/payment-methods.d.ts +0 -1
- package/bundles/types/checkout/layout-widgets/payment-methods.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/secure-remote-commerce/index.d.ts +0 -1
- package/bundles/types/secure-remote-commerce/index.d.ts.map +1 -1
- package/bundles/types/secure-remote-commerce/interfaces.d.ts +1 -5
- package/bundles/types/secure-remote-commerce/interfaces.d.ts.map +1 -1
- package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts.map +1 -1
- 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 +515 -87
- 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/click-to-pay-examples.md +0 -36
- package/docs/click-to-pay.md +0 -3
- 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/slate.md +0 -36
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.2';
|
|
897
897
|
|
|
898
898
|
/******************************************************************************
|
|
899
899
|
Copyright (c) Microsoft Corporation.
|
|
@@ -9109,8 +9109,6 @@
|
|
|
9109
9109
|
* @param {string} CHECKOUT_POPUP_CLOSE=checkoutPopupClose Event sent when Click To Pay checkout flow is closed, regardless of embedded or windowed mode.
|
|
9110
9110
|
* @param {string} CHECKOUT_COMPLETED=checkoutCompleted Event sent on successful checkout by customer. Check [data](#EventDataCheckoutCompletedData) for more information.
|
|
9111
9111
|
* @param {string} CHECKOUT_ERROR=checkoutError Event sent on error checkout by customer. Check [data](#EventData) for more information.
|
|
9112
|
-
* @param {string} RECOGNITION_TOKEN_REQUESTED=recognitionTokenRequested Event sent when a recognition token was found on the mastercard SDK response.
|
|
9113
|
-
* @param {string} RECOGNITION_TOKEN_DROPPED=recognitionTokenDropped Event sent when a recognition token needs to be dropped for user be no longer remembered.
|
|
9114
9112
|
*/
|
|
9115
9113
|
var EVENT$3;
|
|
9116
9114
|
(function (EVENT) {
|
|
@@ -9120,8 +9118,6 @@
|
|
|
9120
9118
|
EVENT["CHECKOUT_ERROR"] = "checkoutError";
|
|
9121
9119
|
EVENT["CHECKOUT_POPUP_OPEN"] = "checkoutPopupOpen";
|
|
9122
9120
|
EVENT["CHECKOUT_POPUP_CLOSE"] = "checkoutPopupClose";
|
|
9123
|
-
EVENT["RECOGNITION_TOKEN_REQUESTED"] = "recognitionTokenRequested";
|
|
9124
|
-
EVENT["RECOGNITION_TOKEN_DROPPED"] = "recognitionTokenDropped";
|
|
9125
9121
|
})(EVENT$3 || (EVENT$3 = {}));
|
|
9126
9122
|
/**
|
|
9127
9123
|
* List of available event data types
|
|
@@ -9198,13 +9194,6 @@
|
|
|
9198
9194
|
var data = _ref5.data;
|
|
9199
9195
|
_this.eventEmitter.emit(EVENT$3.CHECKOUT_ERROR, data);
|
|
9200
9196
|
});
|
|
9201
|
-
this.iFrameEvent.on(EVENT$3.RECOGNITION_TOKEN_REQUESTED, widgetId, function (_ref6) {
|
|
9202
|
-
var data = _ref6.data;
|
|
9203
|
-
_this.eventEmitter.emit(EVENT$3.RECOGNITION_TOKEN_REQUESTED, data);
|
|
9204
|
-
});
|
|
9205
|
-
this.iFrameEvent.on(EVENT$3.RECOGNITION_TOKEN_DROPPED, widgetId, function () {
|
|
9206
|
-
_this.eventEmitter.emit(EVENT$3.RECOGNITION_TOKEN_DROPPED);
|
|
9207
|
-
});
|
|
9208
9197
|
if (this.autoResize) this.useAutoResize(true);
|
|
9209
9198
|
}
|
|
9210
9199
|
}, {
|
|
@@ -9252,8 +9241,8 @@
|
|
|
9252
9241
|
this.autoResize = true;
|
|
9253
9242
|
var params = this.link.getParams();
|
|
9254
9243
|
if (!(params === null || params === void 0 ? void 0 : params.widget_id)) return;
|
|
9255
|
-
this.iFrameEvent.on('resize', params.widget_id, function (
|
|
9256
|
-
var data =
|
|
9244
|
+
this.iFrameEvent.on('resize', params.widget_id, function (_ref6) {
|
|
9245
|
+
var data = _ref6.data;
|
|
9257
9246
|
var _a, _b;
|
|
9258
9247
|
var iframeElement = _this3.iFrame.getElement();
|
|
9259
9248
|
if (iframeElement) {
|
|
@@ -14703,7 +14692,7 @@
|
|
|
14703
14692
|
_iterator.s();
|
|
14704
14693
|
case 4:
|
|
14705
14694
|
if ((_step = _iterator.n()).done) {
|
|
14706
|
-
_context.next =
|
|
14695
|
+
_context.next = 11;
|
|
14707
14696
|
break;
|
|
14708
14697
|
}
|
|
14709
14698
|
method = _step.value;
|
|
@@ -14711,46 +14700,30 @@
|
|
|
14711
14700
|
_context.next = 8;
|
|
14712
14701
|
break;
|
|
14713
14702
|
}
|
|
14714
|
-
return _context.abrupt("continue",
|
|
14703
|
+
return _context.abrupt("continue", 9);
|
|
14715
14704
|
case 8:
|
|
14716
|
-
_context.t0 = method === PAYMENTS_METHODS.GOOGLE_PAY;
|
|
14717
|
-
if (!_context.t0) {
|
|
14718
|
-
_context.next = 13;
|
|
14719
|
-
break;
|
|
14720
|
-
}
|
|
14721
|
-
_context.next = 12;
|
|
14722
|
-
return this.isGooglePaySupported();
|
|
14723
|
-
case 12:
|
|
14724
|
-
_context.t0 = !_context.sent;
|
|
14725
|
-
case 13:
|
|
14726
|
-
if (!_context.t0) {
|
|
14727
|
-
_context.next = 15;
|
|
14728
|
-
break;
|
|
14729
|
-
}
|
|
14730
|
-
return _context.abrupt("continue", 16);
|
|
14731
|
-
case 15:
|
|
14732
14705
|
paymentMethodsAllowed.push(PAYMENT_METHOD[method]);
|
|
14733
|
-
case
|
|
14706
|
+
case 9:
|
|
14734
14707
|
_context.next = 4;
|
|
14735
14708
|
break;
|
|
14736
|
-
case
|
|
14737
|
-
_context.next =
|
|
14709
|
+
case 11:
|
|
14710
|
+
_context.next = 16;
|
|
14738
14711
|
break;
|
|
14739
|
-
case
|
|
14740
|
-
_context.prev =
|
|
14741
|
-
_context.
|
|
14742
|
-
_iterator.e(_context.
|
|
14743
|
-
case
|
|
14744
|
-
_context.prev =
|
|
14712
|
+
case 13:
|
|
14713
|
+
_context.prev = 13;
|
|
14714
|
+
_context.t0 = _context["catch"](2);
|
|
14715
|
+
_iterator.e(_context.t0);
|
|
14716
|
+
case 16:
|
|
14717
|
+
_context.prev = 16;
|
|
14745
14718
|
_iterator.f();
|
|
14746
|
-
return _context.finish(
|
|
14747
|
-
case
|
|
14719
|
+
return _context.finish(16);
|
|
14720
|
+
case 19:
|
|
14748
14721
|
resolve(paymentMethodsAllowed.join(' '));
|
|
14749
|
-
case
|
|
14722
|
+
case 20:
|
|
14750
14723
|
case "end":
|
|
14751
14724
|
return _context.stop();
|
|
14752
14725
|
}
|
|
14753
|
-
}, _callee, this, [[2,
|
|
14726
|
+
}, _callee, this, [[2, 13, 16, 19]]);
|
|
14754
14727
|
}));
|
|
14755
14728
|
});
|
|
14756
14729
|
initState.then(function (content) {
|
|
@@ -14816,45 +14789,6 @@
|
|
|
14816
14789
|
value: function isApplePaySupported() {
|
|
14817
14790
|
return window.ApplePaySession && ApplePaySession.canMakePayments();
|
|
14818
14791
|
}
|
|
14819
|
-
}, {
|
|
14820
|
-
key: "isGooglePaySupported",
|
|
14821
|
-
value: function isGooglePaySupported() {
|
|
14822
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
14823
|
-
var paymentRequest;
|
|
14824
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
14825
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
14826
|
-
case 0:
|
|
14827
|
-
_context2.prev = 0;
|
|
14828
|
-
if (window.PaymentRequest) {
|
|
14829
|
-
_context2.next = 3;
|
|
14830
|
-
break;
|
|
14831
|
-
}
|
|
14832
|
-
return _context2.abrupt("return", false);
|
|
14833
|
-
case 3:
|
|
14834
|
-
paymentRequest = new PaymentRequest([{
|
|
14835
|
-
supportedMethods: 'https://google.com/pay'
|
|
14836
|
-
}], {
|
|
14837
|
-
total: {
|
|
14838
|
-
label: 'Test',
|
|
14839
|
-
amount: {
|
|
14840
|
-
currency: 'USD',
|
|
14841
|
-
value: '0.00'
|
|
14842
|
-
}
|
|
14843
|
-
}
|
|
14844
|
-
});
|
|
14845
|
-
return _context2.abrupt("return", paymentRequest.canMakePayment());
|
|
14846
|
-
case 7:
|
|
14847
|
-
_context2.prev = 7;
|
|
14848
|
-
_context2.t0 = _context2["catch"](0);
|
|
14849
|
-
console.error('Error google pay check support:');
|
|
14850
|
-
return _context2.abrupt("return", false);
|
|
14851
|
-
case 11:
|
|
14852
|
-
case "end":
|
|
14853
|
-
return _context2.stop();
|
|
14854
|
-
}
|
|
14855
|
-
}, _callee2, null, [[0, 7]]);
|
|
14856
|
-
}));
|
|
14857
|
-
}
|
|
14858
14792
|
}, {
|
|
14859
14793
|
key: "setStylesToStandaloneWidget",
|
|
14860
14794
|
value: function setStylesToStandaloneWidget() {
|
|
@@ -14989,8 +14923,8 @@
|
|
|
14989
14923
|
}, {
|
|
14990
14924
|
key: "destroy",
|
|
14991
14925
|
value: function destroy() {
|
|
14992
|
-
clearTimeout(this.timeoutId);
|
|
14993
14926
|
// TODO: Adjust when implementing the failure payment flow
|
|
14927
|
+
// clearTimeout(this.timeoutId);
|
|
14994
14928
|
// document.querySelector(this.formSelector).innerHTML = '';
|
|
14995
14929
|
}
|
|
14996
14930
|
}]);
|
|
@@ -16050,7 +15984,8 @@
|
|
|
16050
15984
|
address_city: billingContact === null || billingContact === void 0 ? void 0 : billingContact.locality,
|
|
16051
15985
|
address_postcode: billingContact === null || billingContact === void 0 ? void 0 : billingContact.postalCode,
|
|
16052
15986
|
address_state: billingContact === null || billingContact === void 0 ? void 0 : billingContact.administrativeArea,
|
|
16053
|
-
ref_token: token.paymentData ? JSON.stringify(token.paymentData) : ''
|
|
15987
|
+
ref_token: token.paymentData ? JSON.stringify(token.paymentData) : '',
|
|
15988
|
+
wallet_express: true
|
|
16054
15989
|
}
|
|
16055
15990
|
}
|
|
16056
15991
|
}).then(function () {
|
|
@@ -16333,7 +16268,8 @@
|
|
|
16333
16268
|
payment_method_id: data.orderID,
|
|
16334
16269
|
customer: {
|
|
16335
16270
|
payment_source: {
|
|
16336
|
-
external_payer_id: data.payerID
|
|
16271
|
+
external_payer_id: data.payerID,
|
|
16272
|
+
wallet_express: true
|
|
16337
16273
|
}
|
|
16338
16274
|
}
|
|
16339
16275
|
})["finally"](function () {
|
|
@@ -16353,6 +16289,496 @@
|
|
|
16353
16289
|
}]);
|
|
16354
16290
|
}(BaseWalletButton);
|
|
16355
16291
|
|
|
16292
|
+
var PAYPAL_DATA_COLLECTOR_EVENTS;
|
|
16293
|
+
(function (PAYPAL_DATA_COLLECTOR_EVENTS) {
|
|
16294
|
+
PAYPAL_DATA_COLLECTOR_EVENTS["ON_ERROR"] = "ON_ERROR";
|
|
16295
|
+
})(PAYPAL_DATA_COLLECTOR_EVENTS || (PAYPAL_DATA_COLLECTOR_EVENTS = {}));
|
|
16296
|
+
var ErrorCodes$1;
|
|
16297
|
+
(function (ErrorCodes) {
|
|
16298
|
+
ErrorCodes["PROMISE_NOT_ENABLED"] = "promise_not_enabled";
|
|
16299
|
+
ErrorCodes["SCRIPT_ERROR"] = "script_error";
|
|
16300
|
+
})(ErrorCodes$1 || (ErrorCodes$1 = {}));
|
|
16301
|
+
|
|
16302
|
+
var PayPalDataCollectorService = /*#__PURE__*/function () {
|
|
16303
|
+
function PayPalDataCollectorService(eventEmitter, flowId, config) {
|
|
16304
|
+
_classCallCheck(this, PayPalDataCollectorService);
|
|
16305
|
+
this.eventEmitter = eventEmitter;
|
|
16306
|
+
this.flowId = flowId;
|
|
16307
|
+
this.config = config;
|
|
16308
|
+
}
|
|
16309
|
+
return _createClass(PayPalDataCollectorService, [{
|
|
16310
|
+
key: "collectDeviceData",
|
|
16311
|
+
value: function collectDeviceData() {
|
|
16312
|
+
if (!window.Promise) {
|
|
16313
|
+
this.eventEmitter.emit(PAYPAL_DATA_COLLECTOR_EVENTS.ON_ERROR, {
|
|
16314
|
+
error_code: ErrorCodes$1.PROMISE_NOT_ENABLED
|
|
16315
|
+
});
|
|
16316
|
+
}
|
|
16317
|
+
this.correlationId = Uuid.generate();
|
|
16318
|
+
return this.appendPaypalSavePaymentSourceComponent();
|
|
16319
|
+
}
|
|
16320
|
+
}, {
|
|
16321
|
+
key: "appendPaypalSavePaymentSourceComponent",
|
|
16322
|
+
value: function appendPaypalSavePaymentSourceComponent() {
|
|
16323
|
+
var _this = this;
|
|
16324
|
+
var paypalScript = document.createElement("script");
|
|
16325
|
+
paypalScript.type = "application/json";
|
|
16326
|
+
paypalScript.setAttribute("fncls", "fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99");
|
|
16327
|
+
var scriptContent = _extends(_extends({
|
|
16328
|
+
f: this.correlationId,
|
|
16329
|
+
s: this.flowId ? this.flowId : Uuid.generate(),
|
|
16330
|
+
cb1: 'paydockPayPalDataCollectorServiceCallbackPostOne',
|
|
16331
|
+
cb2: 'paydockPayPalDataCollectorServiceCallbackPostTwo'
|
|
16332
|
+
}, this.isSandbox && {
|
|
16333
|
+
sandbox: this.isSandbox
|
|
16334
|
+
}), this.config.mouse_movement && {
|
|
16335
|
+
mm: this.config.mouse_movement
|
|
16336
|
+
});
|
|
16337
|
+
paypalScript.textContent = JSON.stringify(scriptContent, null, 4);
|
|
16338
|
+
var fraudnetScript = document.createElement("script");
|
|
16339
|
+
fraudnetScript.type = "text/javascript";
|
|
16340
|
+
fraudnetScript.src = "https://c.paypal.com/da/r/fb.js";
|
|
16341
|
+
fraudnetScript.onerror = function () {
|
|
16342
|
+
return _this.onError();
|
|
16343
|
+
};
|
|
16344
|
+
document.body.appendChild(paypalScript);
|
|
16345
|
+
document.body.appendChild(fraudnetScript);
|
|
16346
|
+
return this.setupCallbacks();
|
|
16347
|
+
}
|
|
16348
|
+
}, {
|
|
16349
|
+
key: "setupCallbacks",
|
|
16350
|
+
value: function setupCallbacks() {
|
|
16351
|
+
var _this2 = this;
|
|
16352
|
+
return new Promise(function (resolve, reject) {
|
|
16353
|
+
var callbackOnePromise = new Promise(function (resolve) {
|
|
16354
|
+
window.paydockPayPalDataCollectorServiceCallbackPostOne = function () {
|
|
16355
|
+
resolve();
|
|
16356
|
+
};
|
|
16357
|
+
});
|
|
16358
|
+
var callbackTwoPromise = new Promise(function (resolve) {
|
|
16359
|
+
window.paydockPayPalDataCollectorServiceCallbackPostTwo = function () {
|
|
16360
|
+
resolve();
|
|
16361
|
+
};
|
|
16362
|
+
});
|
|
16363
|
+
Promise.all([callbackOnePromise, callbackTwoPromise]).then(function () {
|
|
16364
|
+
resolve({
|
|
16365
|
+
correlation_id: _this2.correlationId
|
|
16366
|
+
});
|
|
16367
|
+
})["catch"](reject);
|
|
16368
|
+
});
|
|
16369
|
+
}
|
|
16370
|
+
}, {
|
|
16371
|
+
key: "onError",
|
|
16372
|
+
value: function onError() {
|
|
16373
|
+
this.eventEmitter.emit(PAYPAL_DATA_COLLECTOR_EVENTS.ON_ERROR, {
|
|
16374
|
+
error_code: ErrorCodes$1.SCRIPT_ERROR
|
|
16375
|
+
});
|
|
16376
|
+
}
|
|
16377
|
+
}, {
|
|
16378
|
+
key: "setEnv",
|
|
16379
|
+
value: function setEnv(env) {
|
|
16380
|
+
this.isSandbox = env !== 'live';
|
|
16381
|
+
}
|
|
16382
|
+
}], [{
|
|
16383
|
+
key: "fromConfig",
|
|
16384
|
+
value: function fromConfig(eventEmitter, flowId, config) {
|
|
16385
|
+
return new PayPalDataCollectorService(eventEmitter, flowId, config);
|
|
16386
|
+
}
|
|
16387
|
+
}]);
|
|
16388
|
+
}();
|
|
16389
|
+
|
|
16390
|
+
/**
|
|
16391
|
+
* PayPal Data Collector Widget constructor
|
|
16392
|
+
*
|
|
16393
|
+
* @param {string} flowId - This string identifies the source website of the FraudNet request.
|
|
16394
|
+
* @param {PayPalDataCollectorConfig} config - Extra configuration for the widget.
|
|
16395
|
+
*
|
|
16396
|
+
* @example
|
|
16397
|
+
* var payPalDataCollector = new PayPalDataCollector('FLOW_ID', {});
|
|
16398
|
+
*/
|
|
16399
|
+
var PayPalDataCollector = /*#__PURE__*/function () {
|
|
16400
|
+
/** @constructs */ // constructs added for correct parse classes jsdoc2md
|
|
16401
|
+
function PayPalDataCollector(flowId, config) {
|
|
16402
|
+
_classCallCheck(this, PayPalDataCollector);
|
|
16403
|
+
this.eventEmitter = new EventEmitter();
|
|
16404
|
+
this.service = PayPalDataCollectorService.fromConfig(this.eventEmitter, flowId, config);
|
|
16405
|
+
}
|
|
16406
|
+
/**
|
|
16407
|
+
* After configuring the PayPalDataCollector Widget, starts the process and returns
|
|
16408
|
+
* the correlation id used among the requests.
|
|
16409
|
+
*
|
|
16410
|
+
* @returns {Promise<CollectedDeviceData>} Promise when resolved, returnsa an object
|
|
16411
|
+
* that contains the `correlation_id` key.
|
|
16412
|
+
*
|
|
16413
|
+
* @example
|
|
16414
|
+
* const collectedDeviceData = await payPalDataCollectorWidget.collectDeviceData();
|
|
16415
|
+
* console.log(collectedDeviceData.correlation_id)
|
|
16416
|
+
*/
|
|
16417
|
+
return _createClass(PayPalDataCollector, [{
|
|
16418
|
+
key: "collectDeviceData",
|
|
16419
|
+
value: function collectDeviceData() {
|
|
16420
|
+
try {
|
|
16421
|
+
return this.service.collectDeviceData();
|
|
16422
|
+
} catch (err) {
|
|
16423
|
+
this.eventEmitter.emit(PAYPAL_DATA_COLLECTOR_EVENTS.ON_ERROR, null);
|
|
16424
|
+
throw err;
|
|
16425
|
+
}
|
|
16426
|
+
}
|
|
16427
|
+
/**
|
|
16428
|
+
* Callback for onError method.
|
|
16429
|
+
*
|
|
16430
|
+
* @callback OnErrorCallback
|
|
16431
|
+
* @param {IOnErrorEventData|null} data
|
|
16432
|
+
*/
|
|
16433
|
+
/**
|
|
16434
|
+
* If the process fails, the function passed as parameter will be called.
|
|
16435
|
+
* Important: Do not perform thread blocking operations in callback such as window.alert() calls.
|
|
16436
|
+
*
|
|
16437
|
+
* @example
|
|
16438
|
+
* PayPalDataCollector.onError((eventData) => console.log('Some error occur'));
|
|
16439
|
+
*
|
|
16440
|
+
* @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
|
|
16441
|
+
*/
|
|
16442
|
+
}, {
|
|
16443
|
+
key: "onError",
|
|
16444
|
+
value: function onError(callback) {
|
|
16445
|
+
return this.eventEmitter.subscribe(PAYPAL_DATA_COLLECTOR_EVENTS.ON_ERROR, callback);
|
|
16446
|
+
}
|
|
16447
|
+
/**
|
|
16448
|
+
* Current method can change environment. By default environment = test.
|
|
16449
|
+
* This method does not affect Paydock's API calls or environments, is only for PayPal Data Collector
|
|
16450
|
+
* script, in order to know if the script is injected on a live server or is a testing
|
|
16451
|
+
* environment. The available values are `test` and `live`. This should match with the used
|
|
16452
|
+
* `gateway.mode` in Paydock to process the transaction.
|
|
16453
|
+
*
|
|
16454
|
+
* @example
|
|
16455
|
+
* PayPalDataCollector.setEnv('live');
|
|
16456
|
+
* @param {string} env - test, live
|
|
16457
|
+
*/
|
|
16458
|
+
}, {
|
|
16459
|
+
key: "setEnv",
|
|
16460
|
+
value: function setEnv(env) {
|
|
16461
|
+
this.service.setEnv(env);
|
|
16462
|
+
}
|
|
16463
|
+
}]);
|
|
16464
|
+
}();
|
|
16465
|
+
|
|
16466
|
+
var PAYPAL_SAVE_PAYMENT_EVENTS = {
|
|
16467
|
+
ON_SUCCESS: 'ON_SUCCESS',
|
|
16468
|
+
ON_ERROR: 'ON_ERROR',
|
|
16469
|
+
ON_CANCEL: 'ON_CANCEL'
|
|
16470
|
+
};
|
|
16471
|
+
var ErrorCodes;
|
|
16472
|
+
(function (ErrorCodes) {
|
|
16473
|
+
ErrorCodes["UNAVAILABLE"] = "unavailable";
|
|
16474
|
+
ErrorCodes["ON_PAYPAL_VAULT_SETUP_TOKEN_ERROR"] = "onPaypalVaultSetupTokenError";
|
|
16475
|
+
ErrorCodes["ON_GET_ID_TOKEN_ERROR"] = "onGetIdTokenError";
|
|
16476
|
+
ErrorCodes["ON_GET_WALLET_CONFIG_ERROR"] = "onGetWalletConfigError";
|
|
16477
|
+
ErrorCodes["ON_GET_SETUP_TOKEN_ERROR"] = "onGetSetupTokenError";
|
|
16478
|
+
ErrorCodes["ON_ONE_TIME_TOKEN_ERROR"] = "onOneTimeTokenError";
|
|
16479
|
+
})(ErrorCodes || (ErrorCodes = {}));
|
|
16480
|
+
var EVENTS;
|
|
16481
|
+
(function (EVENTS) {
|
|
16482
|
+
EVENTS["ON_SUCCESS"] = "ON_SUCCESS";
|
|
16483
|
+
EVENTS["ON_ERROR"] = "ON_ERROR";
|
|
16484
|
+
EVENTS["ON_CANCEL"] = "ON_CANCEL";
|
|
16485
|
+
})(EVENTS || (EVENTS = {}));
|
|
16486
|
+
|
|
16487
|
+
var PAYPAL_OAUTH_TOKEN_ROUTE = '/v1/payment_sources/oauth-tokens';
|
|
16488
|
+
var PAYPAL_SETUP_TOKEN_ROUTE = '/v1/payment_sources/setup-tokens';
|
|
16489
|
+
var PAYPAL_OTT_ROUTE = '/v1/payment_sources/setup-tokens/:setup_token/tokens';
|
|
16490
|
+
var PayPalSavePaymentSourceService = /*#__PURE__*/function () {
|
|
16491
|
+
function PayPalSavePaymentSourceService(publicKey, gatewayId, eventEmitter, config) {
|
|
16492
|
+
_classCallCheck(this, PayPalSavePaymentSourceService);
|
|
16493
|
+
this.publicKey = publicKey;
|
|
16494
|
+
this.gatewayId = gatewayId;
|
|
16495
|
+
this.eventEmitter = eventEmitter;
|
|
16496
|
+
this.config = config;
|
|
16497
|
+
this.api = new ApiInternal(publicKey, this.getApiAuthType(publicKey));
|
|
16498
|
+
}
|
|
16499
|
+
return _createClass(PayPalSavePaymentSourceService, [{
|
|
16500
|
+
key: "getApiAuthType",
|
|
16501
|
+
value: function getApiAuthType(publicKeyOrAccessToken) {
|
|
16502
|
+
if (AccessToken.validateJWT(publicKeyOrAccessToken)) {
|
|
16503
|
+
return API_AUTH_TYPE.TOKEN;
|
|
16504
|
+
}
|
|
16505
|
+
return API_AUTH_TYPE.PUBLIC_KEY;
|
|
16506
|
+
}
|
|
16507
|
+
}, {
|
|
16508
|
+
key: "setEnv",
|
|
16509
|
+
value: function setEnv(env, alias) {
|
|
16510
|
+
this.api.setEnv(env, alias);
|
|
16511
|
+
}
|
|
16512
|
+
}, {
|
|
16513
|
+
key: "load",
|
|
16514
|
+
value: function load(container) {
|
|
16515
|
+
var _this = this;
|
|
16516
|
+
if (!window.Promise) {
|
|
16517
|
+
this.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, {
|
|
16518
|
+
error_code: ErrorCodes.UNAVAILABLE
|
|
16519
|
+
});
|
|
16520
|
+
}
|
|
16521
|
+
Promise.all([this.getWalletConfig(), this.getIdToken()]).then(function () {
|
|
16522
|
+
return _this.renderPaypalSavePaymentSourceComponent(container);
|
|
16523
|
+
})["catch"](function (error) {
|
|
16524
|
+
throw error;
|
|
16525
|
+
});
|
|
16526
|
+
}
|
|
16527
|
+
}, {
|
|
16528
|
+
key: "renderPaypalSavePaymentSourceComponent",
|
|
16529
|
+
value: function renderPaypalSavePaymentSourceComponent(container) {
|
|
16530
|
+
var _this2 = this;
|
|
16531
|
+
var _a;
|
|
16532
|
+
var buttonId = ((_a = container.getElement()) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
16533
|
+
var paypalScript = document.createElement('script');
|
|
16534
|
+
paypalScript.src = "https://www.paypal.com/sdk/js?client-id=".concat(this.getClientAuthFromWalletConfig());
|
|
16535
|
+
paypalScript.setAttribute('data-user-id-token', this.idToken);
|
|
16536
|
+
paypalScript.async = true;
|
|
16537
|
+
paypalScript.onload = function () {
|
|
16538
|
+
if (window.paypal) {
|
|
16539
|
+
_this2.paypal = window.paypal;
|
|
16540
|
+
var button = _this2.paypal.Buttons(_extends(_extends({
|
|
16541
|
+
createVaultSetupToken: function createVaultSetupToken() {
|
|
16542
|
+
return _this2.getSetupToken(_this2.accessToken);
|
|
16543
|
+
},
|
|
16544
|
+
onApprove: function onApprove(_ref) {
|
|
16545
|
+
var vaultSetupToken = _ref.vaultSetupToken;
|
|
16546
|
+
_this2.onObtainedVaultSetupToken(vaultSetupToken);
|
|
16547
|
+
},
|
|
16548
|
+
onError: function onError(error) {
|
|
16549
|
+
_this2.onErrorVaultSetupToken(error);
|
|
16550
|
+
},
|
|
16551
|
+
onCancel: function onCancel() {
|
|
16552
|
+
_this2.onCancelVaultSetupToken();
|
|
16553
|
+
}
|
|
16554
|
+
}, _this2.config.style && {
|
|
16555
|
+
style: _this2.config.style
|
|
16556
|
+
}), _this2.config.message && {
|
|
16557
|
+
message: _this2.config.message
|
|
16558
|
+
}));
|
|
16559
|
+
if (button.isEligible()) {
|
|
16560
|
+
button.render("#".concat(buttonId));
|
|
16561
|
+
} else {
|
|
16562
|
+
_this2.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, {
|
|
16563
|
+
error_code: ErrorCodes.UNAVAILABLE
|
|
16564
|
+
});
|
|
16565
|
+
}
|
|
16566
|
+
} else {
|
|
16567
|
+
_this2.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, {
|
|
16568
|
+
error_code: ErrorCodes.UNAVAILABLE
|
|
16569
|
+
});
|
|
16570
|
+
}
|
|
16571
|
+
};
|
|
16572
|
+
document.head.appendChild(paypalScript);
|
|
16573
|
+
}
|
|
16574
|
+
}, {
|
|
16575
|
+
key: "getClientAuthFromWalletConfig",
|
|
16576
|
+
value: function getClientAuthFromWalletConfig() {
|
|
16577
|
+
var _a;
|
|
16578
|
+
return ((_a = this.walletConfig) === null || _a === void 0 ? void 0 : _a.credentials).client_auth;
|
|
16579
|
+
}
|
|
16580
|
+
}, {
|
|
16581
|
+
key: "getSetupToken",
|
|
16582
|
+
value: function getSetupToken(accessToken) {
|
|
16583
|
+
var _this3 = this;
|
|
16584
|
+
return this.api.getClientPromise('POST', PAYPAL_SETUP_TOKEN_ROUTE).send({
|
|
16585
|
+
gateway_id: this.gatewayId,
|
|
16586
|
+
token: accessToken
|
|
16587
|
+
}).then(function (responseSetupToken) {
|
|
16588
|
+
return responseSetupToken.setup_token;
|
|
16589
|
+
})["catch"](function (error) {
|
|
16590
|
+
_this3.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, _extends({
|
|
16591
|
+
error_code: ErrorCodes.ON_GET_SETUP_TOKEN_ERROR
|
|
16592
|
+
}, _this3.extractErrorDetails(error)));
|
|
16593
|
+
return Promise.reject(error);
|
|
16594
|
+
});
|
|
16595
|
+
}
|
|
16596
|
+
}, {
|
|
16597
|
+
key: "onObtainedVaultSetupToken",
|
|
16598
|
+
value: function onObtainedVaultSetupToken(vaultSetupToken) {
|
|
16599
|
+
var _this4 = this;
|
|
16600
|
+
return this.api.getClientPromise('POST', PAYPAL_OTT_ROUTE.replace(':setup_token', vaultSetupToken)).send({
|
|
16601
|
+
gateway_id: this.gatewayId
|
|
16602
|
+
}).then(function (responseSetupToken) {
|
|
16603
|
+
_this4.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_SUCCESS, {
|
|
16604
|
+
token: responseSetupToken.token,
|
|
16605
|
+
email: responseSetupToken.email
|
|
16606
|
+
});
|
|
16607
|
+
})["catch"](function () {
|
|
16608
|
+
_this4.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, {
|
|
16609
|
+
error_code: ErrorCodes.ON_ONE_TIME_TOKEN_ERROR
|
|
16610
|
+
});
|
|
16611
|
+
});
|
|
16612
|
+
}
|
|
16613
|
+
}, {
|
|
16614
|
+
key: "onErrorVaultSetupToken",
|
|
16615
|
+
value: function onErrorVaultSetupToken(error) {
|
|
16616
|
+
this.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, _extends({
|
|
16617
|
+
error_code: ErrorCodes.ON_PAYPAL_VAULT_SETUP_TOKEN_ERROR
|
|
16618
|
+
}, this.extractErrorDetails(error)));
|
|
16619
|
+
}
|
|
16620
|
+
}, {
|
|
16621
|
+
key: "onCancelVaultSetupToken",
|
|
16622
|
+
value: function onCancelVaultSetupToken() {
|
|
16623
|
+
this.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_CANCEL);
|
|
16624
|
+
}
|
|
16625
|
+
}, {
|
|
16626
|
+
key: "getIdToken",
|
|
16627
|
+
value: function getIdToken() {
|
|
16628
|
+
var _this5 = this;
|
|
16629
|
+
return this.api.getClientPromise('POST', PAYPAL_OAUTH_TOKEN_ROUTE).send({
|
|
16630
|
+
gateway_id: this.gatewayId
|
|
16631
|
+
}).then(function (data) {
|
|
16632
|
+
_this5.idToken = data.id_token;
|
|
16633
|
+
_this5.accessToken = data.access_token;
|
|
16634
|
+
})["catch"](function (error) {
|
|
16635
|
+
_this5.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, _extends({
|
|
16636
|
+
error_code: ErrorCodes.ON_GET_ID_TOKEN_ERROR
|
|
16637
|
+
}, _this5.extractErrorDetails(error)));
|
|
16638
|
+
});
|
|
16639
|
+
}
|
|
16640
|
+
}, {
|
|
16641
|
+
key: "getWalletConfig",
|
|
16642
|
+
value: function getWalletConfig() {
|
|
16643
|
+
var _this6 = this;
|
|
16644
|
+
return this.api.gateway().getWalletConfig(this.gatewayId).then(function (walletConfigResponse) {
|
|
16645
|
+
_this6.walletConfig = walletConfigResponse;
|
|
16646
|
+
})["catch"](function (error) {
|
|
16647
|
+
_this6.eventEmitter.emit(PAYPAL_SAVE_PAYMENT_EVENTS.ON_ERROR, _extends({
|
|
16648
|
+
error_code: ErrorCodes.ON_GET_WALLET_CONFIG_ERROR
|
|
16649
|
+
}, _this6.extractErrorDetails(error)));
|
|
16650
|
+
});
|
|
16651
|
+
}
|
|
16652
|
+
}, {
|
|
16653
|
+
key: "extractErrorDetails",
|
|
16654
|
+
value: function extractErrorDetails(error) {
|
|
16655
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16656
|
+
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];
|
|
16657
|
+
var message = error === null || error === void 0 ? void 0 : error.message;
|
|
16658
|
+
return _extends(_extends({}, details && {
|
|
16659
|
+
details: details
|
|
16660
|
+
}), message && {
|
|
16661
|
+
message: message
|
|
16662
|
+
});
|
|
16663
|
+
}
|
|
16664
|
+
}], [{
|
|
16665
|
+
key: "fromConfig",
|
|
16666
|
+
value: function fromConfig(publicKey, gatewayId, eventEmitter, config) {
|
|
16667
|
+
return new PayPalSavePaymentSourceService(publicKey, gatewayId, eventEmitter, config);
|
|
16668
|
+
}
|
|
16669
|
+
}]);
|
|
16670
|
+
}();
|
|
16671
|
+
|
|
16672
|
+
/**
|
|
16673
|
+
* PayPal Save Payment Source Widget constructor
|
|
16674
|
+
*
|
|
16675
|
+
* @param {string} selector - Selector of html element. Container for PayPal Save Payment Source Widget.
|
|
16676
|
+
* @param {string} publicKey - PayDock users public key.
|
|
16677
|
+
* @param {string} gatewayId - PayDock's PayPal gatewayId.
|
|
16678
|
+
* @param {PayPalSavePaymentSourceWidgetConfig} config - Extra configuration for the widget, like styles.
|
|
16679
|
+
*
|
|
16680
|
+
* @example
|
|
16681
|
+
* var payPalSavePaymentSourceWidget = new PayPalSavePaymentSourceWidget('#paypalButton', 'public_key', 'gateway_id');
|
|
16682
|
+
*/
|
|
16683
|
+
var PayPalSavePaymentSourceWidget = /*#__PURE__*/function () {
|
|
16684
|
+
/** @constructs */ // constructs added for correct parse classes jsdoc2md
|
|
16685
|
+
function PayPalSavePaymentSourceWidget(selector, publicKey, gatewayId, config) {
|
|
16686
|
+
_classCallCheck(this, PayPalSavePaymentSourceWidget);
|
|
16687
|
+
this.eventEmitter = new EventEmitter();
|
|
16688
|
+
this.container = new Container(selector);
|
|
16689
|
+
this.service = PayPalSavePaymentSourceService.fromConfig(publicKey, gatewayId, this.eventEmitter, config);
|
|
16690
|
+
}
|
|
16691
|
+
/**
|
|
16692
|
+
* The final method after configuring the PayPalSavePaymentSource Widget to
|
|
16693
|
+
* start the load process.
|
|
16694
|
+
*/
|
|
16695
|
+
return _createClass(PayPalSavePaymentSourceWidget, [{
|
|
16696
|
+
key: "load",
|
|
16697
|
+
value: function load() {
|
|
16698
|
+
try {
|
|
16699
|
+
this.service.load(this.container);
|
|
16700
|
+
} catch (err) {
|
|
16701
|
+
this.eventEmitter.emit(EVENTS.ON_ERROR, null);
|
|
16702
|
+
throw err;
|
|
16703
|
+
}
|
|
16704
|
+
}
|
|
16705
|
+
/**
|
|
16706
|
+
* Current method can change environment. By default environment = sandbox.
|
|
16707
|
+
* Also we can change domain alias for this environment. By default domain_alias = paydock.com
|
|
16708
|
+
*
|
|
16709
|
+
* @example
|
|
16710
|
+
* payPalSavePaymentSourceWidget.setEnv('production');
|
|
16711
|
+
* @param {string} env - sandbox, production
|
|
16712
|
+
* @param {string} [alias] - Own domain alias
|
|
16713
|
+
*/
|
|
16714
|
+
}, {
|
|
16715
|
+
key: "setEnv",
|
|
16716
|
+
value: function setEnv(env, alias) {
|
|
16717
|
+
this.service.setEnv(env, alias);
|
|
16718
|
+
}
|
|
16719
|
+
/**
|
|
16720
|
+
* Callback for onSuccess method.
|
|
16721
|
+
*
|
|
16722
|
+
* @callback OnSuccessCallback
|
|
16723
|
+
* @param {IOnSuccessEventData} data
|
|
16724
|
+
*/
|
|
16725
|
+
/**
|
|
16726
|
+
* If the setup token was successfully approved and a OTT was generated, the function passed as parameter will be called.
|
|
16727
|
+
* Important: Do not perform thread blocking operations in callback such as window.alert() calls.
|
|
16728
|
+
*
|
|
16729
|
+
* @example
|
|
16730
|
+
* payPalSavePaymentSourceWidget.onSuccess((eventData) => console.log('One time token and email obtained successfully'));
|
|
16731
|
+
*
|
|
16732
|
+
* @param {OnSuccessCallback} [callback] - Function to be called when the result is successful.
|
|
16733
|
+
*/
|
|
16734
|
+
}, {
|
|
16735
|
+
key: "onSuccess",
|
|
16736
|
+
value: function onSuccess(callback) {
|
|
16737
|
+
return this.eventEmitter.subscribe(EVENTS.ON_SUCCESS, callback);
|
|
16738
|
+
}
|
|
16739
|
+
/**
|
|
16740
|
+
* Callback for onError method.
|
|
16741
|
+
*
|
|
16742
|
+
* @callback OnErrorCallback
|
|
16743
|
+
* @param {IOnErrorEventData} data
|
|
16744
|
+
*/
|
|
16745
|
+
/**
|
|
16746
|
+
* If in the process for obtaining the setup token fails, the function passed as parameter will be called.
|
|
16747
|
+
* Important: Do not perform thread blocking operations in callback such as window.alert() calls.
|
|
16748
|
+
*
|
|
16749
|
+
* @example
|
|
16750
|
+
* payPalSavePaymentSourceWidget.onError((eventData) => console.log('Some error occurred'));
|
|
16751
|
+
*
|
|
16752
|
+
* @param {OnErrorCallback} [callback] - Function to be called when there is an error in the flow.
|
|
16753
|
+
*/
|
|
16754
|
+
}, {
|
|
16755
|
+
key: "onError",
|
|
16756
|
+
value: function onError(callback) {
|
|
16757
|
+
return this.eventEmitter.subscribe(EVENTS.ON_ERROR, callback);
|
|
16758
|
+
}
|
|
16759
|
+
/**
|
|
16760
|
+
* Callback for onCancel method.
|
|
16761
|
+
*
|
|
16762
|
+
* @callback OnCancelCallback
|
|
16763
|
+
* @param {IOnCancelEventData} data
|
|
16764
|
+
*/
|
|
16765
|
+
/**
|
|
16766
|
+
* If in the process for obtaining the setup token was cancelled, the function passed as parameter will be called.
|
|
16767
|
+
* Important: Do not perform thread blocking operations in callback such as window.alert() calls.
|
|
16768
|
+
*
|
|
16769
|
+
* @example
|
|
16770
|
+
* payPalSavePaymentSourceWidget.onCancel(() => console.log('Operation cancelled'));
|
|
16771
|
+
*
|
|
16772
|
+
* @param {OnCancelCallback} [callback] - Function to be called when the operation is cancelled.
|
|
16773
|
+
*/
|
|
16774
|
+
}, {
|
|
16775
|
+
key: "onCancel",
|
|
16776
|
+
value: function onCancel(callback) {
|
|
16777
|
+
return this.eventEmitter.subscribe(EVENTS.ON_CANCEL, callback);
|
|
16778
|
+
}
|
|
16779
|
+
}]);
|
|
16780
|
+
}();
|
|
16781
|
+
|
|
16356
16782
|
class Timer {
|
|
16357
16783
|
constructor(opts, ms) {
|
|
16358
16784
|
if (!opts.onEnd) throw new Error('onEnd handler is required');
|
|
@@ -34479,6 +34905,8 @@
|
|
|
34479
34905
|
exports.MultiWidget = MultiWidget;
|
|
34480
34906
|
exports.PAYMENT_TYPE = PAYMENT_TYPE;
|
|
34481
34907
|
exports.PURPOSE = PURPOSE;
|
|
34908
|
+
exports.PayPalDataCollector = PayPalDataCollector;
|
|
34909
|
+
exports.PayPalSavePaymentSourceWidget = PayPalSavePaymentSourceWidget;
|
|
34482
34910
|
exports.PaymentSourceBuilder = Builder;
|
|
34483
34911
|
exports.PaymentSourceWidget = PaymentSourceWidget;
|
|
34484
34912
|
exports.PaypalCheckoutButton = PaypalCheckoutButton;
|