@paydock/client-sdk 1.11.3-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.
@@ -7399,7 +7399,7 @@
7399
7399
  var _this = this;
7400
7400
 
7401
7401
  this.iFrameEvent.on(EVENT.CHARGE_AUTH, widgetId, function (data) {
7402
- if (data.status === "MethodSkipped" /* SKIPPED */) _this.performAuthentication(data);
7402
+ if (data.status === "MethodSkipped" /* SKIPPED */ || data.status === "MethodFinished" /* FINISHED */) _this.performAuthentication(data);
7403
7403
  });
7404
7404
  this.iFrameEvent.on(EVENT.CHARGE_AUTH_SUCCESS, widgetId, function (data) {
7405
7405
  _this.processResult(data.charge_3ds_id);
@@ -7990,11 +7990,11 @@
7990
7990
  classCallCheck(this, VisaSRCStyles);
7991
7991
  };
7992
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: 30px; cursor: pointer;";
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
7994
  VisaSRCStyles.footerContainerStyles = "display: flex; flex: 1; flex-wrap: wrap; justify-content: center;";
7995
- VisaSRCStyles.footerTextStyles = "text-align: center; color: #666666; margin: 0;";
7995
+ VisaSRCStyles.footerTextStyles = "text-align: center; color: #666666; margin: 2px 0;";
7996
7996
  VisaSRCStyles.verticalLineStyle = "display: inline-block; padding: 0.5px; background-color: #E5E5E5; height: 15px;";
7997
- VisaSRCStyles.clickToPayAllCardsStyle = "height: 21px; margin-left: 8px; vertical-align: middle;";
7997
+ VisaSRCStyles.clickToPayAllCardsStyle = "height: 17px; margin-left: 8px; vertical-align: middle; padding-top: 3px;";
7998
7998
 
7999
7999
  /**
8000
8000
  * List of available event's name in the SRC checkout lifecycle
@@ -8010,13 +8010,55 @@
8010
8010
  */
8011
8011
  var EVENT$3;
8012
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";
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
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
+ };
8020
8062
 
8021
8063
  var VisaSRC = function () {
8022
8064
  function VisaSRC(button_selector, iframe_selector, service_id, public_key, meta, eventEmitter, autoResize, env, alias) {
@@ -8063,10 +8105,13 @@
8063
8105
  value: function load() {
8064
8106
  var _this2 = this;
8065
8107
 
8108
+ var _a;
8066
8109
  var container = document.createElement('div');
8067
8110
  container.setAttribute('style', VisaSRCStyles.buttonContainerStyles);
8068
8111
  var checkoutButton = document.createElement('button');
8069
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;
8070
8115
  checkoutButton.innerHTML = 'Checkout';
8071
8116
  var footerContainer = document.createElement('div');
8072
8117
  footerContainer.setAttribute('style', VisaSRCStyles.footerContainerStyles);
@@ -8077,7 +8122,7 @@
8077
8122
  footerText.innerHTML = 'WE ACCEPT';
8078
8123
  var clickToPayAllCards = document.createElement('img');
8079
8124
  clickToPayAllCards.setAttribute('style', VisaSRCStyles.clickToPayAllCardsStyle);
8080
- clickToPayAllCards.src = this.link.getBaseUrl() + '/images/visa-src/src-vmad.svg';
8125
+ clickToPayAllCards.src = this.link.getBaseUrl() + ('' + GenerateCardSchemesLogo((_a = this.meta.customizations) === null || _a === void 0 ? void 0 : _a.card_schemes, true));
8081
8126
  checkoutButton.onclick = function () {
8082
8127
  _this2.eventEmitter.emit(EVENT$3.CHECKOUT_BUTTON_CLICKED, {});
8083
8128
  _this2.iFrame.load(_this2.link.getUrl(), { title: 'Visa SRC checkout' });
@@ -8189,7 +8234,6 @@
8189
8234
  * @param {string} [customer.payment_source.address_postcode] Customer billing address postcode.
8190
8235
  * @param {string} [customer.payment_source.address_state] Customer billing address state code (if applicable for the country, example "FL" for Florida).
8191
8236
  * @param {string} [customer.payment_source.address_country] Customer billing address country code (example "US").
8192
- *
8193
8237
  */
8194
8238
  /**
8195
8239
  * Class SRC include methods for interacting with different secure remote commerce options such as Visa SRC
@@ -8198,32 +8242,58 @@
8198
8242
  * @param {string} button_selector - Selector of html element. Container for SRC checkout button.
8199
8243
  * @param {string} iframe_selector - Selector of html element. Container for SRC checkout iFrame.
8200
8244
  * @param {string} service_id - Card Scheme Service ID
8201
- * @param {string} public_key - Paydock public key
8245
+ * @param {string} public_key_or_access_token - Paydock public key or Access Token
8202
8246
  * @param {IVisaSRCMeta} meta - Data that configures the SRC checkout
8203
8247
  * @example
8204
8248
  * var SRC = new SRC('#checkoutButton', '#checkoutIframe', 'service_id', 'public_key', {});
8205
8249
  *
8206
8250
  **/
8207
8251
  var SRC = function () {
8208
- function SRC(button_selector, iframe_selector, service_id, public_key, meta) {
8252
+ function SRC(button_selector, iframe_selector, service_id, public_key_or_access_token, meta) {
8209
8253
  classCallCheck(this, SRC);
8210
8254
 
8211
8255
  this.button_selector = button_selector;
8212
8256
  this.iframe_selector = iframe_selector;
8213
8257
  this.service_id = service_id;
8214
- this.public_key = public_key;
8258
+ this.public_key_or_access_token = public_key_or_access_token;
8215
8259
  this.meta = meta;
8216
8260
  this.autoResize = false;
8217
- this.api = new ApiInternal(public_key, API_AUTH_TYPE.PUBLIC_KEY);
8261
+ this.style = {};
8262
+ this.api = new ApiInternal(public_key_or_access_token, API_AUTH_TYPE.PUBLIC_KEY);
8218
8263
  this.eventEmitter = new EventEmitter();
8219
8264
  }
8220
8265
  /**
8221
- * The final method after configuring the SRC to start the load process of SRC checkout
8222
- *
8223
- */
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
+ */
8224
8277
 
8225
8278
 
8226
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
+ }, {
8227
8297
  key: 'load',
8228
8298
  value: function load() {
8229
8299
  var _this = this;
@@ -8232,9 +8302,10 @@
8232
8302
  this.api.service().getConfig(this.service_id).then(function (_ref) {
8233
8303
  var type = _ref.type;
8234
8304
 
8305
+ _this.meta.customizations = _this.style; // assign the style on the start of the widget
8235
8306
  switch (type) {
8236
8307
  case CARD_SCHEME_SERVICE.VISA_SRC:
8237
- _this.provider = new VisaSRC(_this.button_selector, _this.iframe_selector, _this.service_id, _this.public_key, _this.meta, _this.eventEmitter, _this.autoResize, _this.env, _this.alias);
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);
8238
8309
  break;
8239
8310
  }
8240
8311
  if (_this.provider) _this.provider.load();