@paydock/client-sdk 1.11.2-beta → 1.11.4

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 (48) hide show
  1. package/README.md +999 -474
  2. package/bundles/widget.umd.js +501 -1
  3. package/bundles/widget.umd.min.js +1 -1
  4. package/lib/api/api-internal.d.ts +2 -0
  5. package/lib/api/api-internal.js +4 -0
  6. package/lib/api/api-internal.js.map +1 -1
  7. package/lib/api/api-service-internal.d.ts +17 -0
  8. package/lib/api/api-service-internal.js +18 -0
  9. package/lib/api/api-service-internal.js.map +1 -0
  10. package/lib/canvas-3ds/services/gpayments-service.js +1 -1
  11. package/lib/canvas-3ds/services/gpayments-service.js.map +1 -1
  12. package/lib/components/iframe-event.d.ts +3 -0
  13. package/lib/components/iframe-event.js +2 -0
  14. package/lib/components/iframe-event.js.map +1 -1
  15. package/lib/components/link.d.ts +4 -2
  16. package/lib/components/link.js +4 -0
  17. package/lib/components/link.js.map +1 -1
  18. package/lib/components/param.d.ts +6 -0
  19. package/lib/components/param.js.map +1 -1
  20. package/lib/index.d.ts +1 -0
  21. package/lib/index.js +1 -0
  22. package/lib/index.js.map +1 -1
  23. package/lib/secure-remote-commerce/index.d.ts +1 -0
  24. package/lib/secure-remote-commerce/index.js +2 -0
  25. package/lib/secure-remote-commerce/index.js.map +1 -0
  26. package/lib/secure-remote-commerce/interfaces.d.ts +71 -0
  27. package/lib/secure-remote-commerce/interfaces.js +28 -0
  28. package/lib/secure-remote-commerce/interfaces.js.map +1 -0
  29. package/lib/secure-remote-commerce/providers/src-provider.d.ts +10 -0
  30. package/lib/secure-remote-commerce/providers/src-provider.js +1 -0
  31. package/lib/secure-remote-commerce/providers/src-provider.js.map +1 -0
  32. package/lib/secure-remote-commerce/providers/visa-src/helper.d.ts +7 -0
  33. package/lib/secure-remote-commerce/providers/visa-src/helper.js +36 -0
  34. package/lib/secure-remote-commerce/providers/visa-src/helper.js.map +1 -0
  35. package/lib/secure-remote-commerce/providers/visa-src/index.d.ts +1 -0
  36. package/lib/secure-remote-commerce/providers/visa-src/index.js +2 -0
  37. package/lib/secure-remote-commerce/providers/visa-src/index.js.map +1 -0
  38. package/lib/secure-remote-commerce/providers/visa-src/visa-src.d.ts +27 -0
  39. package/lib/secure-remote-commerce/providers/visa-src/visa-src.js +106 -0
  40. package/lib/secure-remote-commerce/providers/visa-src/visa-src.js.map +1 -0
  41. package/lib/secure-remote-commerce/providers/visa-src/visa-src.styles.d.ts +8 -0
  42. package/lib/secure-remote-commerce/providers/visa-src/visa-src.styles.js +10 -0
  43. package/lib/secure-remote-commerce/providers/visa-src/visa-src.styles.js.map +1 -0
  44. package/lib/secure-remote-commerce/secure-remote-commerce.d.ts +162 -0
  45. package/lib/secure-remote-commerce/secure-remote-commerce.js +237 -0
  46. package/lib/secure-remote-commerce/secure-remote-commerce.js.map +1 -0
  47. package/package.json +1 -1
  48. package/slate.md +261 -3
@@ -343,6 +343,7 @@
343
343
  var SECURE_3D = '/3ds/webhook';
344
344
  var FLYPAY_LINK = '/wallet/flypay';
345
345
  var FLYPAY_LOGO_LINK = '/images/logo.png';
346
+ var VISA_SRC = '/secure-remote-commerce/visa';
346
347
  var Link = function () {
347
348
  function Link(linkResource) {
348
349
  classCallCheck(this, Link);
@@ -398,6 +399,11 @@
398
399
  value: function getEnv() {
399
400
  return this.env.getEnv();
400
401
  }
402
+ }, {
403
+ key: "getBaseUrl",
404
+ value: function getBaseUrl() {
405
+ return this.env.getConf().url;
406
+ }
401
407
  }]);
402
408
  return Link;
403
409
  }();
@@ -1585,7 +1591,9 @@
1585
1591
  VALIDATION_ERROR: 'validationError',
1586
1592
  SYSTEM_ERROR: 'systemError',
1587
1593
  CHECKOUT_SUCCESS: 'checkoutSuccess',
1594
+ CHECKOUT_READY: 'checkoutReady',
1588
1595
  CHECKOUT_ERROR: 'checkoutError',
1596
+ CHECKOUT_COMPLETED: 'checkoutCompleted',
1589
1597
  VALIDATION: 'validation',
1590
1598
  SELECT: 'select',
1591
1599
  UNSELECT: 'unselect',
@@ -6401,6 +6409,28 @@
6401
6409
  return ApiChargeInternal;
6402
6410
  }();
6403
6411
 
6412
+ var GET_CONFIG = '/v1/services/:service_id/config';
6413
+ var ApiServiceInternal = function () {
6414
+ function ApiServiceInternal(api) {
6415
+ classCallCheck(this, ApiServiceInternal);
6416
+
6417
+ this.api = api;
6418
+ }
6419
+
6420
+ createClass(ApiServiceInternal, [{
6421
+ key: 'getConfig',
6422
+ value: function getConfig(service_id) {
6423
+ var url = GET_CONFIG.replace(':service_id', service_id);
6424
+ return this.api.getClientPromise('GET', url).send(undefined);
6425
+ }
6426
+ }]);
6427
+ return ApiServiceInternal;
6428
+ }();
6429
+ var CARD_SCHEME_SERVICE;
6430
+ (function (CARD_SCHEME_SERVICE) {
6431
+ CARD_SCHEME_SERVICE["VISA_SRC"] = "VisaSRC";
6432
+ })(CARD_SCHEME_SERVICE || (CARD_SCHEME_SERVICE = {}));
6433
+
6404
6434
  var ApiInternal = function (_ApiBase) {
6405
6435
  inherits(ApiInternal, _ApiBase);
6406
6436
 
@@ -6414,6 +6444,11 @@
6414
6444
  value: function charge() {
6415
6445
  return new ApiChargeInternal(this);
6416
6446
  }
6447
+ }, {
6448
+ key: 'service',
6449
+ value: function service() {
6450
+ return new ApiServiceInternal(this);
6451
+ }
6417
6452
  }]);
6418
6453
  return ApiInternal;
6419
6454
  }(ApiBase);
@@ -7364,7 +7399,7 @@
7364
7399
  var _this = this;
7365
7400
 
7366
7401
  this.iFrameEvent.on(EVENT.CHARGE_AUTH, widgetId, function (data) {
7367
- if (data.status === "MethodSkipped" /* SKIPPED */) _this.performAuthentication(data);
7402
+ if (data.status === "MethodSkipped" /* SKIPPED */ || data.status === "MethodFinished" /* FINISHED */) _this.performAuthentication(data);
7368
7403
  });
7369
7404
  this.iFrameEvent.on(EVENT.CHARGE_AUTH_SUCCESS, widgetId, function (data) {
7370
7405
  _this.processResult(data.charge_3ds_id);
@@ -7951,6 +7986,470 @@
7951
7986
  return VaultDisplayWidget;
7952
7987
  }();
7953
7988
 
7989
+ var VisaSRCStyles = function VisaSRCStyles() {
7990
+ classCallCheck(this, VisaSRCStyles);
7991
+ };
7992
+ VisaSRCStyles.buttonContainerStyles = "display: flex; flex-direction: column; justify-content: center; align-items: center;";
7993
+ VisaSRCStyles.buttonStyles = "color: #ffff; background-color: #ffbe24; border: none; width: 100%; min-height: 40px; font-size: 16px; font-weight: bold; line-height: 19px; letter-spacing: 0.7px; text-transform: uppercase; border-radius: 4px; margin-bottom: 15px; cursor: pointer;";
7994
+ VisaSRCStyles.footerContainerStyles = "display: flex; flex: 1; flex-wrap: wrap; justify-content: center;";
7995
+ VisaSRCStyles.footerTextStyles = "text-align: center; color: #666666; margin: 2px 0;";
7996
+ VisaSRCStyles.verticalLineStyle = "display: inline-block; padding: 0.5px; background-color: #E5E5E5; height: 15px;";
7997
+ VisaSRCStyles.clickToPayAllCardsStyle = "height: 17px; margin-left: 8px; vertical-align: middle; padding-top: 3px;";
7998
+
7999
+ /**
8000
+ * List of available event's name in the SRC checkout lifecycle
8001
+ * @enum EVENT
8002
+ *
8003
+ * @type {object}
8004
+ * @param {string} CHECKOUT_BUTTON_LOADED=checkoutButtonLoaded
8005
+ * @param {string} CHECKOUT_BUTTON_CLICKED=checkoutButtonClicked
8006
+ * @param {string} IFRAME_LOADED=iframeLoaded
8007
+ * @param {string} CHECKOUT_READY=checkoutReady
8008
+ * @param {string} CHECKOUT_COMPLETED=checkoutCompleted
8009
+ * @param {string} CHECKOUT_ERROR=checkoutError
8010
+ */
8011
+ var EVENT$3;
8012
+ (function (EVENT) {
8013
+ EVENT["CHECKOUT_BUTTON_LOADED"] = "checkoutButtonLoaded";
8014
+ EVENT["CHECKOUT_BUTTON_CLICKED"] = "checkoutButtonClicked";
8015
+ EVENT["IFRAME_LOADED"] = "iframeLoaded";
8016
+ EVENT["CHECKOUT_READY"] = "checkoutReady";
8017
+ EVENT["CHECKOUT_COMPLETED"] = "checkoutCompleted";
8018
+ EVENT["CHECKOUT_ERROR"] = "checkoutError";
8019
+ })(EVENT$3 || (EVENT$3 = {}));
8020
+ var STYLE$2 = {
8021
+ BUTTON_TEXT_COLOR: 'button_text_color',
8022
+ PRIMARY_COLOR: 'primary_color',
8023
+ FONT_FAMILY: 'font_family',
8024
+ CARD_SCHEMES: 'card_schemes'
8025
+ };
8026
+
8027
+ var CARD_SCHEME = {
8028
+ VISA: 'visa',
8029
+ MASTERCARD: 'mastercard',
8030
+ AMEX: 'amex',
8031
+ DISCOVER: 'discover'
8032
+ };
8033
+ var CHEVRON_VMAD_IMG_PATH = '/images/visa-src/Chevron_Large_VMAD.png';
8034
+ var CHEVRON_VMA_IMG_PATH = '/images/visa-src/Chevron_Large_VMA.png';
8035
+ var CHEVRON_VM_IMG_PATH = '/images/visa-src/Chevron_Large_VM.png';
8036
+ var CHEVRON_M_IMG_PATH = '/images/visa-src/Chevron_Large_M.png';
8037
+ var CHEVRON_D_IMG_PATH = '/images/visa-src/Chevron_Large_D.png';
8038
+ var CHEVRON_V_IMG_PATH = '/images/visa-src/Chevron_Large_V.png';
8039
+ var VMAD_IMG_PATH = '/images/visa-src/vmad.svg';
8040
+ var VMA_IMG_PATH = '/images/visa-src/logos/Networks_Large_VMA.png';
8041
+ var VM_IMG_PATH = '/images/visa-src/logos/Networks_Large_VM.png';
8042
+ var M_IMG_PATH = '/images/visa-src/logos/master-logo.png';
8043
+ var D_IMG_PATH = '/images/visa-src/logos/Networks_Large_D.png';
8044
+ var V_IMG_PATH = '/images/visa-src/logos/visa-logo.png';
8045
+ var GenerateCardSchemesLogo = function GenerateCardSchemesLogo(card_scheme) {
8046
+ var chevron = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
8047
+
8048
+ if (!card_scheme || !Array.isArray(card_scheme)) return chevron ? CHEVRON_VMAD_IMG_PATH : VMAD_IMG_PATH;
8049
+ var card_scheme_sort = card_scheme.sort();
8050
+ if (includeArray([CARD_SCHEME.AMEX, CARD_SCHEME.MASTERCARD, CARD_SCHEME.VISA], card_scheme_sort)) return chevron ? CHEVRON_VMA_IMG_PATH : VMA_IMG_PATH;
8051
+ if (includeArray([CARD_SCHEME.MASTERCARD, CARD_SCHEME.VISA], card_scheme_sort)) return chevron ? CHEVRON_VM_IMG_PATH : VM_IMG_PATH;
8052
+ if (includeArray([CARD_SCHEME.MASTERCARD], card_scheme_sort)) return chevron ? CHEVRON_M_IMG_PATH : M_IMG_PATH;
8053
+ if (includeArray([CARD_SCHEME.DISCOVER], card_scheme_sort)) return chevron ? CHEVRON_D_IMG_PATH : D_IMG_PATH;
8054
+ if (includeArray([CARD_SCHEME.VISA], card_scheme_sort)) return chevron ? CHEVRON_V_IMG_PATH : V_IMG_PATH;
8055
+ return chevron ? CHEVRON_V_IMG_PATH : VMAD_IMG_PATH;
8056
+ };
8057
+ var includeArray = function includeArray(condition, card_scheme) {
8058
+ return condition.every(function (card, index) {
8059
+ return card === card_scheme[index];
8060
+ });
8061
+ };
8062
+
8063
+ var VisaSRC = function () {
8064
+ function VisaSRC(button_selector, iframe_selector, service_id, public_key, meta, eventEmitter, autoResize, env, alias) {
8065
+ classCallCheck(this, VisaSRC);
8066
+
8067
+ this.meta = meta;
8068
+ this.eventEmitter = eventEmitter;
8069
+ this.autoResize = autoResize;
8070
+ this.link = new Link(VISA_SRC);
8071
+ this.link.setParams(_extends({ service_id: service_id, public_key: public_key }, meta && { meta: JSON.stringify(meta) }));
8072
+ if (env) this.link.setEnv(env, alias);
8073
+ this.iFrameContainer = new Container(iframe_selector);
8074
+ this.iFrame = new IFrame(this.iFrameContainer);
8075
+ this.buttonContainer = new Container(button_selector);
8076
+ this.iFrameEvent = new IFrameEvent(window);
8077
+ this.setupIFrameEvents();
8078
+ }
8079
+
8080
+ createClass(VisaSRC, [{
8081
+ key: 'setupIFrameEvents',
8082
+ value: function setupIFrameEvents() {
8083
+ var _this = this;
8084
+
8085
+ var widgetId = this.link.getParams().widget_id;
8086
+ this.iFrameEvent.on(EVENT$3.CHECKOUT_READY, widgetId, function (_ref) {
8087
+ var data = _ref.data;
8088
+
8089
+ _this.eventEmitter.emit(EVENT$3.CHECKOUT_READY, data);
8090
+ });
8091
+ this.iFrameEvent.on(EVENT$3.CHECKOUT_COMPLETED, widgetId, function (_ref2) {
8092
+ var data = _ref2.data;
8093
+
8094
+ _this.eventEmitter.emit(EVENT$3.CHECKOUT_COMPLETED, data);
8095
+ });
8096
+ this.iFrameEvent.on(EVENT$3.CHECKOUT_ERROR, widgetId, function (_ref3) {
8097
+ var data = _ref3.data;
8098
+
8099
+ _this.eventEmitter.emit(EVENT$3.CHECKOUT_ERROR, data);
8100
+ });
8101
+ if (this.autoResize) this.useAutoResize(true);
8102
+ }
8103
+ }, {
8104
+ key: 'load',
8105
+ value: function load() {
8106
+ var _this2 = this;
8107
+
8108
+ var _a;
8109
+ var container = document.createElement('div');
8110
+ container.setAttribute('style', VisaSRCStyles.buttonContainerStyles);
8111
+ var checkoutButton = document.createElement('button');
8112
+ checkoutButton.setAttribute('style', VisaSRCStyles.buttonStyles);
8113
+ if (this.meta.customizations.primary_color) checkoutButton.style.backgroundColor = this.meta.customizations.primary_color;
8114
+ if (this.meta.customizations.button_text_color) checkoutButton.style.color = this.meta.customizations.button_text_color;
8115
+ checkoutButton.innerHTML = 'Checkout';
8116
+ var footerContainer = document.createElement('div');
8117
+ footerContainer.setAttribute('style', VisaSRCStyles.footerContainerStyles);
8118
+ var verticalLine = document.createElement('div');
8119
+ verticalLine.setAttribute('style', VisaSRCStyles.verticalLineStyle);
8120
+ var footerText = document.createElement('p');
8121
+ footerText.setAttribute('style', VisaSRCStyles.footerTextStyles);
8122
+ footerText.innerHTML = 'WE ACCEPT';
8123
+ var clickToPayAllCards = document.createElement('img');
8124
+ clickToPayAllCards.setAttribute('style', VisaSRCStyles.clickToPayAllCardsStyle);
8125
+ clickToPayAllCards.src = this.link.getBaseUrl() + ('' + GenerateCardSchemesLogo((_a = this.meta.customizations) === null || _a === void 0 ? void 0 : _a.card_schemes, true));
8126
+ checkoutButton.onclick = function () {
8127
+ _this2.eventEmitter.emit(EVENT$3.CHECKOUT_BUTTON_CLICKED, {});
8128
+ _this2.iFrame.load(_this2.link.getUrl(), { title: 'Visa SRC checkout' });
8129
+ _this2.iFrame.getElement().onload = function () {
8130
+ return _this2.eventEmitter.emit(EVENT$3.IFRAME_LOADED, {});
8131
+ };
8132
+ };
8133
+ container.appendChild(checkoutButton);
8134
+ container.appendChild(footerContainer);
8135
+ footerContainer.appendChild(footerText);
8136
+ footerContainer.appendChild(clickToPayAllCards);
8137
+ this.buttonContainer.getElement().appendChild(container);
8138
+ this.eventEmitter.emit(EVENT$3.CHECKOUT_BUTTON_LOADED, {});
8139
+ }
8140
+ }, {
8141
+ key: 'getEnv',
8142
+ value: function getEnv() {
8143
+ return this.link.getEnv();
8144
+ }
8145
+ }, {
8146
+ key: 'hideButton',
8147
+ value: function hideButton(_saveSize) {
8148
+ if (this.buttonContainer.getElement()) this.buttonContainer.getElement().style['display'] = 'none';
8149
+ }
8150
+ }, {
8151
+ key: 'showButton',
8152
+ value: function showButton() {
8153
+ if (this.buttonContainer.getElement()) this.buttonContainer.getElement().style['display'] = 'block';
8154
+ }
8155
+ }, {
8156
+ key: 'hideCheckout',
8157
+ value: function hideCheckout(saveSize) {
8158
+ if (this.iFrame) this.iFrame.hide();
8159
+ }
8160
+ }, {
8161
+ key: 'showCheckout',
8162
+ value: function showCheckout() {
8163
+ if (this.iFrame) this.iFrame.show();
8164
+ }
8165
+ }, {
8166
+ key: 'reload',
8167
+ value: function reload() {
8168
+ this.iFrame.remove();
8169
+ this.load();
8170
+ }
8171
+ }, {
8172
+ key: 'useAutoResize',
8173
+ value: function useAutoResize(force) {
8174
+ var _this3 = this;
8175
+
8176
+ if (this.autoResize && !force) return;
8177
+ this.autoResize = true;
8178
+ this.iFrameEvent.on('resize', this.link.getParams().widget_id, function (_ref4) {
8179
+ var data = _ref4.data;
8180
+
8181
+ if (_this3.iFrame.getElement()) {
8182
+ _this3.iFrame.getElement().scrolling = 'no';
8183
+ if (data.height) _this3.iFrame.setStyle('height', data.height + 'px');
8184
+ }
8185
+ });
8186
+ }
8187
+ }]);
8188
+ return VisaSRC;
8189
+ }();
8190
+
8191
+ /**
8192
+ * Interface of data used for the Visa Checkout.
8193
+ * @interface IVisaSRCMeta
8194
+ *
8195
+ * @type {object}
8196
+ * @param {string} [srci_transaction_id] Used to identify the SRC Id.
8197
+ * @param {object} [dpa_data] Object where the DPA creation data is stored.
8198
+ * @param {string} [dpa_data.dpa_presentation_name] Name in which the DPA is presented in.
8199
+ * @param {string} [dpa_data.dpa_uri] Used for indicating the DPA URI.
8200
+ * @param {object} [dpa_transaction_options] Object that stores options for creating a trasaction with DPA.
8201
+ * @param {string} [dpa_transaction_options.dpa_locale] DPA’s preferred locale, example en_US.
8202
+ * @param {Array} [dpa_transaction_options.dpa_accepted_billing_countries] Used to indicate list of accepted billing countries for DPA.
8203
+ * @param {Array} [dpa_transaction_options.dpa_accepted_shipping_countries] Used to indicate list of accepted shipping countries for DPA.
8204
+ * @param {string} [dpa_transaction_options.dpa_billing_preference] Used for listing the enumeration for billing preferences for DPA. Options are 'ALL', 'POSTAL_COUNTRY' and 'NONE'.
8205
+ * @param {string} [dpa_transaction_options.dpa_shipping_preference] Used for listing the enumeration for shipping preferences for DPA. Options are 'ALL', 'POSTAL_COUNTRY' and 'NONE'.
8206
+ * @param {boolean} [dpa_transaction_options.consumer_name_requested] Used to check if the name of the consumer is needed.
8207
+ * @param {boolean} [dpa_transaction_options.consumer_email_address_requested] Used to check if the email of the consumer is needed.
8208
+ * @param {boolean} [dpa_transaction_options.consumer_phone_number_requested] Used to check if the phone number of the consumer is needed.
8209
+ * @param {object} [dpa_transaction_options.payment_options] Object used to check the payment options that are included.
8210
+ * @param {number} [dpa_transaction_options.payment_options.dpa_dynamic_data_ttl_minutes] The minimum requested validity period for the transaction credentials.
8211
+ * @param {string} [dpa_transaction_options.payment_options.dynamic_data_type] Used for listing the enumeration for dynamic data types. Options are 'TAVV' and 'DTVV'.
8212
+ * @param {boolean} [dpa_transaction_options.payment_options.dpa_pan_requested] Used to check if PAN number was requested.
8213
+ * @param {string} [dpa_transaction_options.review_action] Used for listing the enumeration of review actions. Options are 'pay' and 'continue'.
8214
+ * @param {string} [dpa_transaction_options.checkout_description] Used for indicating the description of the checkout.
8215
+ * @param {string} [dpa_transaction_options.transaction_type] Used for listing the enumeration of the type of the transaction. 'PURCHASE', 'BILL_PAYMENT' and 'MONEY_TRANSFER'
8216
+ * @param {string} [dpa_transaction_options.order_type] Used for listing the enumeration of the type of the order. Options are 'REAUTHORIZATION', 'RECURRING' and 'INSTALLMENT'.
8217
+ * @param {object} [dpa_transaction_options.transaction_amount] Object used to describe the details of the transaction.
8218
+ * @param {number} [dpa_transaction_options.transaction_amount.transaction_amount] Used to indicate the amount of the transaction.
8219
+ * @param {string} [dpa_transaction_options.transaction_amount.transaction_currency_code] Used to indicate the currency code of the transaction. 3 letter ISO code format.
8220
+ * @param {string} [dpa_transaction_options.merchant_order_id] Used to indicate the merchants order Id.
8221
+ * @param {string} [dpa_transaction_options.merchant_category_code] Used to indicate the merchants category code.
8222
+ * @param {string} [dpa_transaction_options.merchant_country_code] Used to indicate the merchants country code. 2 letter ISO code format.
8223
+ * @param {object} [customer] Object where the customer data is stored to prefill in the checkout.
8224
+ * @param {string} [customer.email] Customer email.
8225
+ * @param {string} [customer.first_name] Customer first name.
8226
+ * @param {string} [customer.last_name] Customer last name.
8227
+ * @param {object} [customer.phone] Object where the customer phone is stored.
8228
+ * @param {string} [customer.phone.country_code] Customer phone country code (example "1" for US).
8229
+ * @param {string} [customer.phone.phone] Customer phone number.
8230
+ * @param {object} [customer.payment_source] Object where the customer billing address data is stored.
8231
+ * @param {string} [customer.payment_source.address_line1] Customer billing address line 1.
8232
+ * @param {string} [customer.payment_source.address_line2] Customer billing address line 2.
8233
+ * @param {string} [customer.payment_source.address_city] Customer billing address city.
8234
+ * @param {string} [customer.payment_source.address_postcode] Customer billing address postcode.
8235
+ * @param {string} [customer.payment_source.address_state] Customer billing address state code (if applicable for the country, example "FL" for Florida).
8236
+ * @param {string} [customer.payment_source.address_country] Customer billing address country code (example "US").
8237
+ */
8238
+ /**
8239
+ * Class SRC include methods for interacting with different secure remote commerce options such as Visa SRC
8240
+ * @constructor
8241
+ *
8242
+ * @param {string} button_selector - Selector of html element. Container for SRC checkout button.
8243
+ * @param {string} iframe_selector - Selector of html element. Container for SRC checkout iFrame.
8244
+ * @param {string} service_id - Card Scheme Service ID
8245
+ * @param {string} public_key_or_access_token - Paydock public key or Access Token
8246
+ * @param {IVisaSRCMeta} meta - Data that configures the SRC checkout
8247
+ * @example
8248
+ * var SRC = new SRC('#checkoutButton', '#checkoutIframe', 'service_id', 'public_key', {});
8249
+ *
8250
+ **/
8251
+ var SRC = function () {
8252
+ function SRC(button_selector, iframe_selector, service_id, public_key_or_access_token, meta) {
8253
+ classCallCheck(this, SRC);
8254
+
8255
+ this.button_selector = button_selector;
8256
+ this.iframe_selector = iframe_selector;
8257
+ this.service_id = service_id;
8258
+ this.public_key_or_access_token = public_key_or_access_token;
8259
+ this.meta = meta;
8260
+ this.autoResize = false;
8261
+ this.style = {};
8262
+ this.api = new ApiInternal(public_key_or_access_token, API_AUTH_TYPE.PUBLIC_KEY);
8263
+ this.eventEmitter = new EventEmitter();
8264
+ }
8265
+ /**
8266
+ * Object contain styles for widget - call before `.load()`.
8267
+ *
8268
+ * @example
8269
+ * widget.setStyles({
8270
+ * button_text_color: '#32a852',
8271
+ * primary_color: '#32a852',
8272
+ * font_family: 'sans-serif',
8273
+ * card_schemes: ['visa']
8274
+ * });
8275
+ * @param {IStyles} fields - name of styles which can be shown in widget [STYLE]{@link STYLE}
8276
+ */
8277
+
8278
+
8279
+ createClass(SRC, [{
8280
+ key: 'setStyles',
8281
+ value: function setStyles(styles) {
8282
+ for (var index in styles) {
8283
+ if (styles.hasOwnProperty(index)) this.setStyle(index, styles[index]);
8284
+ }
8285
+ }
8286
+ }, {
8287
+ key: 'setStyle',
8288
+ value: function setStyle(param, value) {
8289
+ if (ObjectHelper.values(STYLE$2).indexOf(param) !== -1) this.style[param] = value;else console.warn('Widget::setStyle[s: unsupported style param ' + param);
8290
+ }
8291
+ /**
8292
+ * The final method after configuring the SRC to start the load process of SRC checkout
8293
+ *
8294
+ */
8295
+
8296
+ }, {
8297
+ key: 'load',
8298
+ value: function load() {
8299
+ var _this = this;
8300
+
8301
+ if (this.provider) return;
8302
+ this.api.service().getConfig(this.service_id).then(function (_ref) {
8303
+ var type = _ref.type;
8304
+
8305
+ _this.meta.customizations = _this.style; // assign the style on the start of the widget
8306
+ switch (type) {
8307
+ case CARD_SCHEME_SERVICE.VISA_SRC:
8308
+ _this.provider = new VisaSRC(_this.button_selector, _this.iframe_selector, _this.service_id, _this.public_key_or_access_token, _this.meta, _this.eventEmitter, _this.autoResize, _this.env, _this.alias);
8309
+ break;
8310
+ }
8311
+ if (_this.provider) _this.provider.load();
8312
+ });
8313
+ }
8314
+ /**
8315
+ * Current method can change environment. By default environment = sandbox.
8316
+ * Also we can change domain alias for this environment. By default domain_alias = paydock.com
8317
+ *
8318
+ * @example
8319
+ * SRC.setEnv('production');
8320
+ * @param {string} env - sandbox, production
8321
+ * @param {string} [alias] - Own domain alias
8322
+ */
8323
+
8324
+ }, {
8325
+ key: 'setEnv',
8326
+ value: function setEnv(env, alias) {
8327
+ if (this.provider) return;
8328
+ this.env = env;
8329
+ this.alias = alias;
8330
+ this.api.setEnv(env, alias);
8331
+ }
8332
+ /**
8333
+ * Method to read the current environment
8334
+ *
8335
+ * @example
8336
+ * SRC.getEnv();
8337
+ */
8338
+
8339
+ }, {
8340
+ key: 'getEnv',
8341
+ value: function getEnv() {
8342
+ if (this.provider) return this.provider.getEnv();else return this.env;
8343
+ }
8344
+ /**
8345
+ * Listen to events of SRC
8346
+ *
8347
+ * @example
8348
+ *
8349
+ * SRC.on('checkoutCompleted', function (token) {
8350
+ * console.log(token);
8351
+ * });
8352
+ * // or
8353
+ * SRC.on('checkoutCompleted').then(function (token) {
8354
+ * console.log(token);
8355
+ * });
8356
+ * @param {string} eventName - Available event names [EVENT]{@link EVENT}
8357
+ * @param {listener} [cb]
8358
+ * @return {Promise<any> | void}
8359
+ */
8360
+
8361
+ }, {
8362
+ key: 'on',
8363
+ value: function on(eventName, cb) {
8364
+ var _this2 = this;
8365
+
8366
+ if (typeof cb === "function") return this.eventEmitter.subscribe(eventName, cb);
8367
+ return new Promise(function (resolve) {
8368
+ return _this2.eventEmitter.subscribe(eventName, function (res) {
8369
+ return resolve(res);
8370
+ });
8371
+ });
8372
+ }
8373
+ /**
8374
+ * Using this method you can hide button
8375
+ * @param {boolean} [saveSize=false] - using this param you can save iframe's size (if applicable)
8376
+ *
8377
+ * @example
8378
+ * SRC.hideButton();
8379
+ */
8380
+
8381
+ }, {
8382
+ key: 'hideButton',
8383
+ value: function hideButton(saveSize) {
8384
+ if (this.provider && typeof this.provider.hideButton === 'function') this.provider.hideButton(saveSize);
8385
+ }
8386
+ /**
8387
+ * Using this method you can show the SRC button after using hideButton method
8388
+ *
8389
+ * @example
8390
+ * SRC.showButton();
8391
+ */
8392
+
8393
+ }, {
8394
+ key: 'showButton',
8395
+ value: function showButton() {
8396
+ if (this.provider && typeof this.provider.showButton === 'function') this.provider.showButton();
8397
+ }
8398
+ /**
8399
+ * Using this method you can hide checkout after load and button click
8400
+ * @param {boolean} [saveSize=false] - using this param you can save iframe's size (if applicable)
8401
+ *
8402
+ * @example
8403
+ * SRC.hideCheckout();
8404
+ */
8405
+
8406
+ }, {
8407
+ key: 'hideCheckout',
8408
+ value: function hideCheckout(saveSize) {
8409
+ if (this.provider && typeof this.provider.hideCheckout === 'function') this.provider.hideCheckout(saveSize);
8410
+ }
8411
+ /**
8412
+ * Using this method you can show checkout after using hideCheckout method
8413
+ *
8414
+ * @example
8415
+ * SRC.showCheckout()
8416
+ */
8417
+
8418
+ }, {
8419
+ key: 'showCheckout',
8420
+ value: function showCheckout() {
8421
+ if (this.provider && typeof this.provider.showCheckout === 'function') this.provider.showCheckout();
8422
+ }
8423
+ /**
8424
+ * Using this method you can reload the whole checkout
8425
+ *
8426
+ * @example
8427
+ * SRC.reload()
8428
+ */
8429
+
8430
+ }, {
8431
+ key: 'reload',
8432
+ value: function reload() {
8433
+ if (this.provider) this.provider.reload();
8434
+ }
8435
+ /**
8436
+ * Use this method for resize checkout iFrame according to content height, if applicable
8437
+ *
8438
+ * @example
8439
+ * SRC.useAutoResize();
8440
+ *
8441
+ */
8442
+
8443
+ }, {
8444
+ key: 'useAutoResize',
8445
+ value: function useAutoResize() {
8446
+ this.autoResize = true;
8447
+ if (this.provider && typeof this.provider.useAutoResize === 'function') this.provider.useAutoResize();
8448
+ }
8449
+ }]);
8450
+ return SRC;
8451
+ }();
8452
+
7954
8453
  exports.AfterpayCheckoutButton = AfterpayCheckoutButton;
7955
8454
  exports.Api = Api;
7956
8455
  exports.CHECKOUT_BUTTON_EVENT = CHECKOUT_BUTTON_EVENT;
@@ -7971,6 +8470,7 @@
7971
8470
  exports.PaymentSourceBuilder = Builder$1;
7972
8471
  exports.PaymentSourceWidget = PaymentSourceWidget;
7973
8472
  exports.PaypalCheckoutButton = PaypalCheckoutButton;
8473
+ exports.SRC = SRC;
7974
8474
  exports.STYLABLE_ELEMENT = STYLABLE_ELEMENT;
7975
8475
  exports.STYLABLE_ELEMENT_STATE = STYLABLE_ELEMENT_STATE;
7976
8476
  exports.STYLE = STYLE;