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