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