@paydock/client-sdk 1.138.1 → 1.139.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -9
- package/bundles/index.cjs +194 -164
- package/bundles/index.cjs.d.ts +13 -2
- package/bundles/index.mjs +194 -164
- package/bundles/index.mjs.d.ts +13 -2
- package/bundles/types/checkout/v3/instructions/instruction.card_form.show.d.ts.map +1 -1
- package/bundles/types/checkout/v3/utils/checkout-customisation-styles.util.d.ts.map +1 -1
- package/bundles/types/components/iframe.d.ts +2 -0
- package/bundles/types/components/iframe.d.ts.map +1 -1
- package/bundles/types/helper/browser.d.ts +1 -0
- package/bundles/types/helper/browser.d.ts.map +1 -1
- package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts +12 -3
- package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts.map +1 -1
- package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts +6 -5
- package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts.map +1 -1
- package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/index-cba.d.ts +132 -1
- package/bundles/types/wallet-buttons/index-cba.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-buttons.d.ts +1 -1
- package/bundles/types/wallet-buttons/wallet-cba-buttons.d.ts +81 -126
- package/bundles/types/wallet-buttons/wallet-cba-buttons.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/afterpay.wallet-service.d.ts +1 -0
- package/bundles/types/wallet-buttons/wallet-services/afterpay.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts +0 -1
- package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/flypay-v2.wallet-service.d.ts +0 -1
- package/bundles/types/wallet-buttons/wallet-services/flypay-v2.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/google.wallet-service.d.ts +0 -1
- package/bundles/types/wallet-buttons/wallet-services/google.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/paypal.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts +6 -0
- package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts.map +1 -1
- package/bundles/widget.umd.js +194 -164
- package/bundles/widget.umd.js.d.ts +13 -2
- package/bundles/widget.umd.js.min.d.ts +13 -2
- package/bundles/widget.umd.min.js +1 -1
- package/docs/paypal-data-collector-examples.md +12 -7
- package/docs/paypal-data-collector.md +11 -1
- package/docs/wallet-buttons.md +1 -1
- package/package.json +1 -1
package/bundles/widget.umd.js
CHANGED
|
@@ -851,6 +851,11 @@
|
|
|
851
851
|
value: function isJavaEnabled() {
|
|
852
852
|
return navigator.javaEnabled();
|
|
853
853
|
}
|
|
854
|
+
}, {
|
|
855
|
+
key: "getAgentUser",
|
|
856
|
+
value: function getAgentUser() {
|
|
857
|
+
return navigator.userAgent;
|
|
858
|
+
}
|
|
854
859
|
}, {
|
|
855
860
|
key: "getColorDepth",
|
|
856
861
|
value: function getColorDepth() {
|
|
@@ -1193,7 +1198,7 @@
|
|
|
1193
1198
|
version: 'x-sdk-version',
|
|
1194
1199
|
type: 'x-sdk-type'
|
|
1195
1200
|
});
|
|
1196
|
-
SDK._version = 'v1.
|
|
1201
|
+
SDK._version = 'v1.139.0';
|
|
1197
1202
|
|
|
1198
1203
|
function isFunction(value) {
|
|
1199
1204
|
return typeof value === 'function';
|
|
@@ -4937,9 +4942,28 @@
|
|
|
4937
4942
|
var iframeClass = arguments.length > 2 ? arguments[2] : undefined;
|
|
4938
4943
|
if (!this.container.isExist() || this.isExist()) return;
|
|
4939
4944
|
var iFrame = document.createElement('iframe');
|
|
4940
|
-
iFrame.setAttribute('src', link);
|
|
4941
4945
|
if (options.title) iFrame.title = options.title;
|
|
4942
4946
|
if (iframeClass) iFrame.classList.add(iframeClass);
|
|
4947
|
+
// Set additional attributes before src and DOM insertion so that
|
|
4948
|
+
// Permissions-Policy (e.g. allow="payment") is in place when the
|
|
4949
|
+
// browser starts navigating the iframe.
|
|
4950
|
+
if (options.attributes) {
|
|
4951
|
+
for (var _i = 0, _Object$entries = Object.entries(options.attributes); _i < _Object$entries.length; _i++) {
|
|
4952
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
4953
|
+
key = _Object$entries$_i[0],
|
|
4954
|
+
value = _Object$entries$_i[1];
|
|
4955
|
+
iFrame.setAttribute(key, value);
|
|
4956
|
+
}
|
|
4957
|
+
}
|
|
4958
|
+
if (options.styles) {
|
|
4959
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(options.styles); _i2 < _Object$entries2.length; _i2++) {
|
|
4960
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
4961
|
+
prop = _Object$entries2$_i[0],
|
|
4962
|
+
_value = _Object$entries2$_i[1];
|
|
4963
|
+
iFrame.style[prop] = _value;
|
|
4964
|
+
}
|
|
4965
|
+
}
|
|
4966
|
+
iFrame.setAttribute('src', link);
|
|
4943
4967
|
this.container.getElement().appendChild(iFrame);
|
|
4944
4968
|
}
|
|
4945
4969
|
}, {
|
|
@@ -7781,6 +7805,33 @@
|
|
|
7781
7805
|
});
|
|
7782
7806
|
});
|
|
7783
7807
|
}
|
|
7808
|
+
/**
|
|
7809
|
+
* Handles the merchant's onClick callback event.
|
|
7810
|
+
* Supports both synchronous (boolean) and asynchronous (Promise) handlers.
|
|
7811
|
+
* @protected
|
|
7812
|
+
*/
|
|
7813
|
+
}, {
|
|
7814
|
+
key: "handleMerchantOnButtonClickEvent",
|
|
7815
|
+
value: function handleMerchantOnButtonClickEvent() {
|
|
7816
|
+
var _this2 = this;
|
|
7817
|
+
return new Promise(function (resolve, reject) {
|
|
7818
|
+
var merchantResult;
|
|
7819
|
+
_this2.eventEmitter.emit(WALLET_EVENT.BUTTON_CLICK, {
|
|
7820
|
+
attachResult: function attachResult(value) {
|
|
7821
|
+
merchantResult = value;
|
|
7822
|
+
}
|
|
7823
|
+
});
|
|
7824
|
+
if (merchantResult instanceof Promise) {
|
|
7825
|
+
merchantResult.then(resolve)["catch"](reject);
|
|
7826
|
+
} else {
|
|
7827
|
+
if (merchantResult === false) {
|
|
7828
|
+
reject();
|
|
7829
|
+
} else {
|
|
7830
|
+
resolve();
|
|
7831
|
+
}
|
|
7832
|
+
}
|
|
7833
|
+
});
|
|
7834
|
+
}
|
|
7784
7835
|
}]);
|
|
7785
7836
|
}();
|
|
7786
7837
|
|
|
@@ -7840,6 +7891,16 @@
|
|
|
7840
7891
|
key: "onAfterPayButtonClicked",
|
|
7841
7892
|
value: function onAfterPayButtonClicked() {
|
|
7842
7893
|
var _this4 = this;
|
|
7894
|
+
this.handleMerchantOnButtonClickEvent().then(function () {
|
|
7895
|
+
_this4.initializeAfterpay();
|
|
7896
|
+
})["catch"](function (err) {
|
|
7897
|
+
console.error('Error while processing merchant callback', err);
|
|
7898
|
+
});
|
|
7899
|
+
}
|
|
7900
|
+
}, {
|
|
7901
|
+
key: "initializeAfterpay",
|
|
7902
|
+
value: function initializeAfterpay() {
|
|
7903
|
+
var _this5 = this;
|
|
7843
7904
|
var _a, _b;
|
|
7844
7905
|
var afterpayJS = document.createElement('script');
|
|
7845
7906
|
var countryCode = (_a = this.meta) === null || _a === void 0 ? void 0 : _a.country;
|
|
@@ -7851,15 +7912,15 @@
|
|
|
7851
7912
|
window.AfterPay.initialize({
|
|
7852
7913
|
countryCode: countryCode
|
|
7853
7914
|
});
|
|
7854
|
-
if (
|
|
7855
|
-
|
|
7915
|
+
if (_this5.isRedirectMode) {
|
|
7916
|
+
_this5.storageDispatcher.push({
|
|
7856
7917
|
intent: StorageDataIntent.WIDGET_SESSION,
|
|
7857
7918
|
data: {
|
|
7858
|
-
token:
|
|
7919
|
+
token: _this5.token
|
|
7859
7920
|
}
|
|
7860
7921
|
}, {
|
|
7861
7922
|
onSuccess: function onSuccess() {
|
|
7862
|
-
|
|
7923
|
+
_this5.getCheckoutSession()
|
|
7863
7924
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
7864
7925
|
.then(function (response) {
|
|
7865
7926
|
window.AfterPay.redirect({
|
|
@@ -7867,7 +7928,7 @@
|
|
|
7867
7928
|
});
|
|
7868
7929
|
})["catch"](function (err) {
|
|
7869
7930
|
window.AfterPay.close();
|
|
7870
|
-
|
|
7931
|
+
_this5.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, {
|
|
7871
7932
|
err: err
|
|
7872
7933
|
});
|
|
7873
7934
|
});
|
|
@@ -7875,30 +7936,30 @@
|
|
|
7875
7936
|
onError: function onError() {
|
|
7876
7937
|
console.error('Error initializing Afterpay wallet');
|
|
7877
7938
|
window.AfterPay.close();
|
|
7878
|
-
|
|
7939
|
+
_this5.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, {});
|
|
7879
7940
|
}
|
|
7880
7941
|
});
|
|
7881
7942
|
} else {
|
|
7882
7943
|
window.AfterPay.open();
|
|
7883
|
-
|
|
7944
|
+
_this5.getCheckoutSession()
|
|
7884
7945
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
7885
7946
|
.then(function (response) {
|
|
7886
7947
|
window.AfterPay.onComplete = function (event) {
|
|
7887
7948
|
if (event.data.status === 'SUCCESS') {
|
|
7888
|
-
|
|
7949
|
+
_this5.eventEmitter.emit(WALLET_EVENT.PAYMENT_METHOD_SELECTED, {
|
|
7889
7950
|
data: {
|
|
7890
7951
|
token: response.ref_token,
|
|
7891
7952
|
merchantReference: event.data.orderToken
|
|
7892
7953
|
},
|
|
7893
7954
|
onSuccess: function onSuccess() {
|
|
7894
|
-
return
|
|
7955
|
+
return _this5.eventEmitter.emit(WALLET_EVENT.PAYMENT_SUCCESS);
|
|
7895
7956
|
},
|
|
7896
7957
|
onError: function onError() {
|
|
7897
|
-
return
|
|
7958
|
+
return _this5.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR);
|
|
7898
7959
|
}
|
|
7899
7960
|
});
|
|
7900
7961
|
} else {
|
|
7901
|
-
|
|
7962
|
+
_this5.eventEmitter.emit(WALLET_EVENT.CHECKOUT_CLOSE, {
|
|
7902
7963
|
data: event.data
|
|
7903
7964
|
});
|
|
7904
7965
|
}
|
|
@@ -7908,7 +7969,7 @@
|
|
|
7908
7969
|
});
|
|
7909
7970
|
})["catch"](function (err) {
|
|
7910
7971
|
window.AfterPay.close();
|
|
7911
|
-
|
|
7972
|
+
_this5.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, {
|
|
7912
7973
|
err: err
|
|
7913
7974
|
});
|
|
7914
7975
|
});
|
|
@@ -7919,20 +7980,20 @@
|
|
|
7919
7980
|
}, {
|
|
7920
7981
|
key: "getCheckoutSession",
|
|
7921
7982
|
value: function getCheckoutSession() {
|
|
7922
|
-
var
|
|
7983
|
+
var _this6 = this;
|
|
7923
7984
|
return new Promise(function (resolve, reject) {
|
|
7924
|
-
return
|
|
7985
|
+
return _this6.eventEmitter.emit(WALLET_EVENT.CALLBACK, {
|
|
7925
7986
|
data: {
|
|
7926
7987
|
request_type: 'CREATE_SESSION',
|
|
7927
7988
|
wallet_type: WALLET_TYPE.AFTERPAY,
|
|
7928
|
-
checkout_url: !
|
|
7989
|
+
checkout_url: !_this6.isRedirectMode ? _this6.CHECKOUT_URL : undefined
|
|
7929
7990
|
},
|
|
7930
7991
|
onSuccess: function onSuccess(res) {
|
|
7931
7992
|
resolve(res);
|
|
7932
7993
|
},
|
|
7933
7994
|
onError: function onError(message) {
|
|
7934
7995
|
console.error('Error generating order id', message);
|
|
7935
|
-
|
|
7996
|
+
_this6.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
|
|
7936
7997
|
message: message
|
|
7937
7998
|
});
|
|
7938
7999
|
reject(message);
|
|
@@ -9750,34 +9811,12 @@
|
|
|
9750
9811
|
this.flypayV2Button.innerHTML = getFlypayV2Button(this.widgetId);
|
|
9751
9812
|
return this.flypayV2Button;
|
|
9752
9813
|
}
|
|
9753
|
-
}, {
|
|
9754
|
-
key: "handleMerchantOnButtonClickEvent",
|
|
9755
|
-
value: function handleMerchantOnButtonClickEvent() {
|
|
9756
|
-
var _this3 = this;
|
|
9757
|
-
return new Promise(function (resolve, reject) {
|
|
9758
|
-
var merchantResult;
|
|
9759
|
-
_this3.eventEmitter.emit(WALLET_EVENT.BUTTON_CLICK, {
|
|
9760
|
-
attachResult: function attachResult(value) {
|
|
9761
|
-
merchantResult = value;
|
|
9762
|
-
}
|
|
9763
|
-
});
|
|
9764
|
-
if (merchantResult instanceof Promise) {
|
|
9765
|
-
merchantResult.then(resolve)["catch"](reject);
|
|
9766
|
-
} else {
|
|
9767
|
-
if (merchantResult === false) {
|
|
9768
|
-
reject();
|
|
9769
|
-
} else {
|
|
9770
|
-
resolve();
|
|
9771
|
-
}
|
|
9772
|
-
}
|
|
9773
|
-
});
|
|
9774
|
-
}
|
|
9775
9814
|
}, {
|
|
9776
9815
|
key: "getOrderId",
|
|
9777
9816
|
value: function getOrderId() {
|
|
9778
|
-
var
|
|
9817
|
+
var _this3 = this;
|
|
9779
9818
|
return new Promise(function (resolve, reject) {
|
|
9780
|
-
return
|
|
9819
|
+
return _this3.eventEmitter.emit(WALLET_EVENT.CALLBACK, {
|
|
9781
9820
|
data: {
|
|
9782
9821
|
request_type: 'CREATE_SESSION'
|
|
9783
9822
|
},
|
|
@@ -9786,7 +9825,7 @@
|
|
|
9786
9825
|
},
|
|
9787
9826
|
onError: function onError(message, code) {
|
|
9788
9827
|
console.error('Error generating order id', message);
|
|
9789
|
-
|
|
9828
|
+
_this3.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
|
|
9790
9829
|
message: message
|
|
9791
9830
|
});
|
|
9792
9831
|
reject({
|
|
@@ -9800,7 +9839,7 @@
|
|
|
9800
9839
|
}, {
|
|
9801
9840
|
key: "flypayV2Checkout",
|
|
9802
9841
|
value: function flypayV2Checkout(orderId) {
|
|
9803
|
-
var
|
|
9842
|
+
var _this4 = this;
|
|
9804
9843
|
var _a;
|
|
9805
9844
|
this.checkout = new Checkout$1(_extends(_extends({
|
|
9806
9845
|
orderId: orderId
|
|
@@ -9815,29 +9854,29 @@
|
|
|
9815
9854
|
url: ((_a = this.meta) === null || _a === void 0 ? void 0 : _a.gateway_mode) === 'live' ? 'https://checkout.colespay.com.au' : 'https://checkout.sandbox.cxbflypay.com.au',
|
|
9816
9855
|
onCheckoutClosed: function onCheckoutClosed() {
|
|
9817
9856
|
var _a;
|
|
9818
|
-
|
|
9819
|
-
(_a =
|
|
9820
|
-
|
|
9857
|
+
_this4.eventEmitter.emit(WALLET_EVENT.CHECKOUT_CLOSE);
|
|
9858
|
+
(_a = _this4.background) === null || _a === void 0 ? void 0 : _a.clear();
|
|
9859
|
+
_this4.enable();
|
|
9821
9860
|
},
|
|
9822
9861
|
onError: function onError(err) {
|
|
9823
|
-
return
|
|
9862
|
+
return _this4.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
|
|
9824
9863
|
error: err
|
|
9825
9864
|
});
|
|
9826
9865
|
},
|
|
9827
9866
|
onPaymentSuccess: function onPaymentSuccess(data) {
|
|
9828
|
-
return
|
|
9867
|
+
return _this4.eventEmitter.emit(WALLET_EVENT.PAYMENT_SUCCESS, data);
|
|
9829
9868
|
},
|
|
9830
9869
|
onPaymentError: function onPaymentError(err) {
|
|
9831
|
-
return
|
|
9870
|
+
return _this4.eventEmitter.emit(WALLET_EVENT.PAYMENT_ERROR, {
|
|
9832
9871
|
error: err
|
|
9833
9872
|
});
|
|
9834
9873
|
},
|
|
9835
9874
|
onTokensChanged: function onTokensChanged(_ref) {
|
|
9836
9875
|
var accessToken = _ref.accessToken,
|
|
9837
9876
|
refreshToken = _ref.refreshToken;
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9877
|
+
_this4.accessToken = accessToken;
|
|
9878
|
+
_this4.refreshToken = refreshToken;
|
|
9879
|
+
_this4.eventEmitter.emit(WALLET_EVENT.AUTH_TOKENS_CHANGED, {
|
|
9841
9880
|
accessToken: accessToken,
|
|
9842
9881
|
refreshToken: refreshToken
|
|
9843
9882
|
});
|
|
@@ -9852,18 +9891,18 @@
|
|
|
9852
9891
|
}, {
|
|
9853
9892
|
key: "initBackground",
|
|
9854
9893
|
value: function initBackground() {
|
|
9855
|
-
var
|
|
9894
|
+
var _this5 = this;
|
|
9856
9895
|
var bg = new WalletBackground(this.link.getNetUrl() + FLYPAY_LOGO_LINK, false, false);
|
|
9857
9896
|
bg.setBackdropTitle('');
|
|
9858
9897
|
bg.setBackdropDescription('');
|
|
9859
9898
|
bg.onTrigger(TRIGGER$2.CLOSE, function () {
|
|
9860
9899
|
var _a;
|
|
9861
|
-
|
|
9862
|
-
(_a =
|
|
9863
|
-
|
|
9900
|
+
_this5.checkout.close();
|
|
9901
|
+
(_a = _this5.background) === null || _a === void 0 ? void 0 : _a.clear();
|
|
9902
|
+
_this5.enable();
|
|
9864
9903
|
});
|
|
9865
9904
|
bg.onTrigger(TRIGGER$2.FOCUS, function () {
|
|
9866
|
-
return
|
|
9905
|
+
return _this5.checkout.open();
|
|
9867
9906
|
});
|
|
9868
9907
|
return bg;
|
|
9869
9908
|
}
|
|
@@ -10545,28 +10584,6 @@
|
|
|
10545
10584
|
});
|
|
10546
10585
|
});
|
|
10547
10586
|
}
|
|
10548
|
-
}, {
|
|
10549
|
-
key: "handleMerchantOnButtonClickEvent",
|
|
10550
|
-
value: function handleMerchantOnButtonClickEvent() {
|
|
10551
|
-
var _this6 = this;
|
|
10552
|
-
return new Promise(function (resolve, reject) {
|
|
10553
|
-
var merchantResult;
|
|
10554
|
-
_this6.eventEmitter.emit(WALLET_EVENT.BUTTON_CLICK, {
|
|
10555
|
-
attachResult: function attachResult(value) {
|
|
10556
|
-
merchantResult = value;
|
|
10557
|
-
}
|
|
10558
|
-
});
|
|
10559
|
-
if (merchantResult instanceof Promise) {
|
|
10560
|
-
merchantResult.then(resolve)["catch"](reject);
|
|
10561
|
-
} else {
|
|
10562
|
-
if (merchantResult === false) {
|
|
10563
|
-
reject();
|
|
10564
|
-
} else {
|
|
10565
|
-
resolve();
|
|
10566
|
-
}
|
|
10567
|
-
}
|
|
10568
|
-
});
|
|
10569
|
-
}
|
|
10570
10587
|
}, {
|
|
10571
10588
|
key: "formatCapabilities",
|
|
10572
10589
|
value: function formatCapabilities(capabilities) {
|
|
@@ -10822,39 +10839,17 @@
|
|
|
10822
10839
|
console.error('Error while processing merchant callback', err);
|
|
10823
10840
|
});
|
|
10824
10841
|
}
|
|
10825
|
-
}, {
|
|
10826
|
-
key: "handleMerchantOnButtonClickEvent",
|
|
10827
|
-
value: function handleMerchantOnButtonClickEvent() {
|
|
10828
|
-
var _this5 = this;
|
|
10829
|
-
return new Promise(function (resolve, reject) {
|
|
10830
|
-
var merchantResult;
|
|
10831
|
-
_this5.eventEmitter.emit(WALLET_EVENT.BUTTON_CLICK, {
|
|
10832
|
-
attachResult: function attachResult(value) {
|
|
10833
|
-
merchantResult = value;
|
|
10834
|
-
}
|
|
10835
|
-
});
|
|
10836
|
-
if (merchantResult instanceof Promise) {
|
|
10837
|
-
merchantResult.then(resolve)["catch"](reject);
|
|
10838
|
-
} else {
|
|
10839
|
-
if (merchantResult === false) {
|
|
10840
|
-
reject();
|
|
10841
|
-
} else {
|
|
10842
|
-
resolve();
|
|
10843
|
-
}
|
|
10844
|
-
}
|
|
10845
|
-
});
|
|
10846
|
-
}
|
|
10847
10842
|
}, {
|
|
10848
10843
|
key: "loadPaymentData",
|
|
10849
10844
|
value: function loadPaymentData() {
|
|
10850
10845
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
|
|
10851
|
-
var
|
|
10846
|
+
var _this5 = this;
|
|
10852
10847
|
return _regenerator().w(function (_context2) {
|
|
10853
10848
|
while (1) switch (_context2.n) {
|
|
10854
10849
|
case 0:
|
|
10855
10850
|
return _context2.a(2, this.paymentsClient.loadPaymentData(this.createPaymentDataRequest())["catch"](function (err) {
|
|
10856
|
-
|
|
10857
|
-
|
|
10851
|
+
_this5.eventEmitter.emit(WALLET_EVENT.CHECKOUT_CLOSE);
|
|
10852
|
+
_this5.processingButtonClick = false;
|
|
10858
10853
|
console.error('Error while loading payment data', err);
|
|
10859
10854
|
throw err;
|
|
10860
10855
|
}));
|
|
@@ -10865,7 +10860,7 @@
|
|
|
10865
10860
|
}, {
|
|
10866
10861
|
key: "onPaymentAuthorized",
|
|
10867
10862
|
value: function onPaymentAuthorized(paymentData) {
|
|
10868
|
-
var
|
|
10863
|
+
var _this6 = this;
|
|
10869
10864
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
10870
10865
|
var billingAddressLine1 = (_c = (_b = (_a = paymentData.paymentMethodData) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.billingAddress) === null || _c === void 0 ? void 0 : _c.address1;
|
|
10871
10866
|
var billingAddressLine2 = (_f = (_e = (_d = paymentData.paymentMethodData) === null || _d === void 0 ? void 0 : _d.info) === null || _e === void 0 ? void 0 : _e.billingAddress) === null || _f === void 0 ? void 0 : _f.address2;
|
|
@@ -10882,7 +10877,7 @@
|
|
|
10882
10877
|
var onPaymentAuthorizedResponse = new Promise(function (resolve) {
|
|
10883
10878
|
var emitPaymentEvent = function emitPaymentEvent() {
|
|
10884
10879
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
10885
|
-
|
|
10880
|
+
_this6.eventEmitter.emit(WALLET_EVENT.PAYMENT_METHOD_SELECTED, {
|
|
10886
10881
|
data: _extends({
|
|
10887
10882
|
customer: {
|
|
10888
10883
|
payment_source: _extends(_extends(_extends({
|
|
@@ -10901,11 +10896,11 @@
|
|
|
10901
10896
|
ref_token: paymentData.paymentMethodData.tokenizationData.token
|
|
10902
10897
|
})
|
|
10903
10898
|
}
|
|
10904
|
-
},
|
|
10899
|
+
}, _this6.isShippingRequired() && {
|
|
10905
10900
|
shipping: _extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends({}, shippingOptionMethod && {
|
|
10906
10901
|
method: shippingOptionMethod
|
|
10907
|
-
}),
|
|
10908
|
-
options:
|
|
10902
|
+
}), _this6.hasShippingOptions() && {
|
|
10903
|
+
options: _this6.meta.shipping_options
|
|
10909
10904
|
}), shippingAddressLine1 && {
|
|
10910
10905
|
address_line1: shippingAddressLine1
|
|
10911
10906
|
}), shippingAddressLine2 && {
|
|
@@ -10929,15 +10924,15 @@
|
|
|
10929
10924
|
})
|
|
10930
10925
|
}),
|
|
10931
10926
|
onSuccess: function onSuccess() {
|
|
10932
|
-
|
|
10933
|
-
|
|
10927
|
+
_this6.processingButtonClick = false;
|
|
10928
|
+
_this6.isProcessingAuthorization = false;
|
|
10934
10929
|
resolve({
|
|
10935
10930
|
transactionState: 'SUCCESS'
|
|
10936
10931
|
});
|
|
10937
10932
|
},
|
|
10938
10933
|
onError: function onError(error) {
|
|
10939
|
-
|
|
10940
|
-
|
|
10934
|
+
_this6.processingButtonClick = false;
|
|
10935
|
+
_this6.isProcessingAuthorization = false;
|
|
10941
10936
|
resolve({
|
|
10942
10937
|
transactionState: 'ERROR',
|
|
10943
10938
|
error: {
|
|
@@ -10949,7 +10944,7 @@
|
|
|
10949
10944
|
}
|
|
10950
10945
|
});
|
|
10951
10946
|
};
|
|
10952
|
-
if (
|
|
10947
|
+
if (_this6.isProcessingAuthorization) {
|
|
10953
10948
|
console.warn('Duplicate payment authorization detected. Ignoring.');
|
|
10954
10949
|
resolve({
|
|
10955
10950
|
transactionState: 'ERROR',
|
|
@@ -10960,7 +10955,7 @@
|
|
|
10960
10955
|
}
|
|
10961
10956
|
});
|
|
10962
10957
|
} else {
|
|
10963
|
-
|
|
10958
|
+
_this6.isProcessingAuthorization = true;
|
|
10964
10959
|
emitPaymentEvent();
|
|
10965
10960
|
}
|
|
10966
10961
|
});
|
|
@@ -10969,14 +10964,14 @@
|
|
|
10969
10964
|
}, {
|
|
10970
10965
|
key: "onPaymentDataChanged",
|
|
10971
10966
|
value: function onPaymentDataChanged(intermediatePaymentData) {
|
|
10972
|
-
var
|
|
10967
|
+
var _this7 = this;
|
|
10973
10968
|
if (!this.isShippingRequired()) {
|
|
10974
10969
|
return;
|
|
10975
10970
|
}
|
|
10976
10971
|
var parsedUpdateData = this.parseUpdateData(intermediatePaymentData);
|
|
10977
10972
|
var returnPromise = new Promise(function (res, rej) {
|
|
10978
|
-
|
|
10979
|
-
|
|
10973
|
+
_this7.latestShippingChangePromiseResolve = res;
|
|
10974
|
+
_this7.latestShippingChangePromiseReject = rej;
|
|
10980
10975
|
});
|
|
10981
10976
|
this.eventEmitter.emit(WALLET_EVENT.UPDATE, parsedUpdateData);
|
|
10982
10977
|
return returnPromise;
|
|
@@ -11223,6 +11218,11 @@
|
|
|
11223
11218
|
});
|
|
11224
11219
|
} else {
|
|
11225
11220
|
responseValue = value;
|
|
11221
|
+
if (responseValue === false) {
|
|
11222
|
+
actions.reject();
|
|
11223
|
+
} else {
|
|
11224
|
+
actions.resolve();
|
|
11225
|
+
}
|
|
11226
11226
|
}
|
|
11227
11227
|
}
|
|
11228
11228
|
});
|
|
@@ -12094,7 +12094,7 @@
|
|
|
12094
12094
|
* There are two operational modes supported, Synchronous and Asynchronous.
|
|
12095
12095
|
* When asynchronous operations need to occur on the callback handler, attaching the Promise via `attachResult` is required to have the wallet wait for a result.
|
|
12096
12096
|
* When synchronous operations occur on the callback handler, attaching a boolean result via `attachResult` is optional to control the execution flow.
|
|
12097
|
-
* Note this is supported for Paypal, GooglePay and
|
|
12097
|
+
* Note this is supported for Paypal, GooglePay, ApplePay, Afterpay and FlypayV2 wallet buttons at the moment.
|
|
12098
12098
|
*
|
|
12099
12099
|
* @example
|
|
12100
12100
|
* button.onClick((data) => {
|
|
@@ -17307,7 +17307,9 @@
|
|
|
17307
17307
|
payload: _extends(_extends({
|
|
17308
17308
|
status: 'success',
|
|
17309
17309
|
ott_token: event.payment_source,
|
|
17310
|
-
browser_details: get.getBrowserDetails()
|
|
17310
|
+
browser_details: _extends(_extends({}, get.getBrowserDetails()), {
|
|
17311
|
+
user_agent: Browser.getAgentUser()
|
|
17312
|
+
})
|
|
17311
17313
|
}, event.card_scheme && {
|
|
17312
17314
|
card_schema: event.card_scheme
|
|
17313
17315
|
}), {
|
|
@@ -17534,7 +17536,7 @@
|
|
|
17534
17536
|
parentEl.style.setProperty('--pd-text-color', customStyles.text_color);
|
|
17535
17537
|
}
|
|
17536
17538
|
if (customStyles.font_family) {
|
|
17537
|
-
parentEl.style.setProperty('--pd-font-family', customStyles.font_family);
|
|
17539
|
+
parentEl.style.setProperty('--pd-font-family', "".concat(customStyles.font_family, ", \"Inter\", sans-serif"));
|
|
17538
17540
|
}
|
|
17539
17541
|
if (customStyles.font_size) {
|
|
17540
17542
|
parentEl.style.setProperty('--pd-font-size', customStyles.font_size);
|
|
@@ -20836,47 +20838,28 @@
|
|
|
20836
20838
|
key: "collectDeviceData",
|
|
20837
20839
|
value: function collectDeviceData() {
|
|
20838
20840
|
if (!window.Promise) {
|
|
20839
|
-
|
|
20841
|
+
var errorData = {
|
|
20840
20842
|
error_code: ErrorCodes$1.PROMISE_NOT_ENABLED
|
|
20841
|
-
}
|
|
20843
|
+
};
|
|
20844
|
+
this.eventEmitter.emit(PAYPAL_DATA_COLLECTOR_EVENTS.ON_ERROR, errorData);
|
|
20845
|
+
throw errorData;
|
|
20842
20846
|
}
|
|
20843
20847
|
this.correlationId = Uuid.generate().replace(/-/g, '');
|
|
20844
|
-
return this.
|
|
20848
|
+
return this.appendPaypalDataCollectorComponent();
|
|
20845
20849
|
}
|
|
20846
20850
|
}, {
|
|
20847
|
-
key: "
|
|
20848
|
-
value: function
|
|
20851
|
+
key: "appendPaypalDataCollectorComponent",
|
|
20852
|
+
value: function appendPaypalDataCollectorComponent() {
|
|
20849
20853
|
var _this = this;
|
|
20850
|
-
var _a;
|
|
20851
|
-
var paypalScript = document.createElement("script");
|
|
20852
|
-
paypalScript.type = "application/json";
|
|
20853
|
-
paypalScript.setAttribute("fncls", "fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99");
|
|
20854
|
-
var scriptContent = _extends(_extends({
|
|
20855
|
-
f: this.correlationId,
|
|
20856
|
-
s: this.flowId ? this.flowId : Uuid.generate(),
|
|
20857
|
-
cb1: 'paydockPayPalDataCollectorServiceCallbackPostOne',
|
|
20858
|
-
cb2: 'paydockPayPalDataCollectorServiceCallbackPostTwo'
|
|
20859
|
-
}, this.isSandbox && {
|
|
20860
|
-
sandbox: this.isSandbox
|
|
20861
|
-
}), ((_a = this.config) === null || _a === void 0 ? void 0 : _a.mouse_movement) && {
|
|
20862
|
-
mm: this.config.mouse_movement
|
|
20863
|
-
});
|
|
20864
|
-
paypalScript.textContent = JSON.stringify(scriptContent, null, 4);
|
|
20865
|
-
var fraudnetScript = document.createElement("script");
|
|
20866
|
-
fraudnetScript.type = "text/javascript";
|
|
20867
|
-
fraudnetScript.src = "https://c.paypal.com/da/r/fb.js";
|
|
20868
|
-
fraudnetScript.onerror = function () {
|
|
20869
|
-
return _this.onError();
|
|
20870
|
-
};
|
|
20871
|
-
document.body.appendChild(paypalScript);
|
|
20872
|
-
document.body.appendChild(fraudnetScript);
|
|
20873
|
-
return this.setupCallbacks();
|
|
20874
|
-
}
|
|
20875
|
-
}, {
|
|
20876
|
-
key: "setupCallbacks",
|
|
20877
|
-
value: function setupCallbacks() {
|
|
20878
|
-
var _this2 = this;
|
|
20879
20854
|
return new Promise(function (resolve, reject) {
|
|
20855
|
+
var paypalScript = _this.createPaypalScript();
|
|
20856
|
+
paypalScript.onerror = function () {
|
|
20857
|
+
_this.onError(reject);
|
|
20858
|
+
};
|
|
20859
|
+
var fraudnetScript = _this.createFraudnetScript();
|
|
20860
|
+
fraudnetScript.onerror = function () {
|
|
20861
|
+
_this.onError(reject);
|
|
20862
|
+
};
|
|
20880
20863
|
var callbackOnePromise = new Promise(function (resolve) {
|
|
20881
20864
|
window.paydockPayPalDataCollectorServiceCallbackPostOne = function () {
|
|
20882
20865
|
resolve();
|
|
@@ -20887,19 +20870,53 @@
|
|
|
20887
20870
|
resolve();
|
|
20888
20871
|
};
|
|
20889
20872
|
});
|
|
20873
|
+
document.body.appendChild(paypalScript);
|
|
20874
|
+
document.body.appendChild(fraudnetScript);
|
|
20890
20875
|
Promise.all([callbackOnePromise, callbackTwoPromise]).then(function () {
|
|
20891
20876
|
resolve({
|
|
20892
|
-
correlation_id:
|
|
20877
|
+
correlation_id: _this.correlationId
|
|
20893
20878
|
});
|
|
20894
20879
|
})["catch"](reject);
|
|
20895
20880
|
});
|
|
20896
20881
|
}
|
|
20882
|
+
}, {
|
|
20883
|
+
key: "createPaypalScript",
|
|
20884
|
+
value: function createPaypalScript() {
|
|
20885
|
+
var _a;
|
|
20886
|
+
var paypalScript = document.createElement('script');
|
|
20887
|
+
paypalScript.type = 'application/json';
|
|
20888
|
+
paypalScript.setAttribute('fncls', 'fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99');
|
|
20889
|
+
var scriptContent = _extends(_extends({
|
|
20890
|
+
f: this.correlationId,
|
|
20891
|
+
s: this.flowId ? this.flowId : Uuid.generate(),
|
|
20892
|
+
cb1: 'paydockPayPalDataCollectorServiceCallbackPostOne',
|
|
20893
|
+
cb2: 'paydockPayPalDataCollectorServiceCallbackPostTwo'
|
|
20894
|
+
}, this.isSandbox && {
|
|
20895
|
+
sandbox: this.isSandbox
|
|
20896
|
+
}), ((_a = this.config) === null || _a === void 0 ? void 0 : _a.mouse_movement) && {
|
|
20897
|
+
mm: this.config.mouse_movement
|
|
20898
|
+
});
|
|
20899
|
+
paypalScript.textContent = JSON.stringify(scriptContent, null, 4);
|
|
20900
|
+
return paypalScript;
|
|
20901
|
+
}
|
|
20902
|
+
}, {
|
|
20903
|
+
key: "createFraudnetScript",
|
|
20904
|
+
value: function createFraudnetScript() {
|
|
20905
|
+
var fraudnetScript = document.createElement('script');
|
|
20906
|
+
fraudnetScript.type = 'text/javascript';
|
|
20907
|
+
fraudnetScript.src = 'https://c.paypal.com/da/r/fb.js';
|
|
20908
|
+
return fraudnetScript;
|
|
20909
|
+
}
|
|
20897
20910
|
}, {
|
|
20898
20911
|
key: "onError",
|
|
20899
|
-
value: function onError() {
|
|
20900
|
-
|
|
20912
|
+
value: function onError(rejectPromise) {
|
|
20913
|
+
var errorData = {
|
|
20901
20914
|
error_code: ErrorCodes$1.SCRIPT_ERROR
|
|
20902
|
-
}
|
|
20915
|
+
};
|
|
20916
|
+
this.eventEmitter.emit(PAYPAL_DATA_COLLECTOR_EVENTS.ON_ERROR, errorData);
|
|
20917
|
+
if (rejectPromise) {
|
|
20918
|
+
rejectPromise(errorData);
|
|
20919
|
+
}
|
|
20903
20920
|
}
|
|
20904
20921
|
}, {
|
|
20905
20922
|
key: "setEnv",
|
|
@@ -20935,11 +20952,20 @@
|
|
|
20935
20952
|
* the correlation id used among the requests asynchronously.
|
|
20936
20953
|
*
|
|
20937
20954
|
* @returns {Promise<CollectedDeviceData>} Promise when resolved, returns an object
|
|
20938
|
-
* that contains the `correlation_id` key.
|
|
20955
|
+
* that contains the `correlation_id` key. The promise may be rejected if script loading fails.
|
|
20939
20956
|
*
|
|
20940
20957
|
* @example
|
|
20941
20958
|
* const collectedDeviceData = await payPalDataCollectorWidget.collectDeviceData();
|
|
20942
20959
|
* console.log(collectedDeviceData.correlation_id)
|
|
20960
|
+
*
|
|
20961
|
+
* @example
|
|
20962
|
+
* payPalDataCollectorWidget.collectDeviceData()
|
|
20963
|
+
* .then((collectedDeviceData) => {
|
|
20964
|
+
* console.log(collectedDeviceData.correlation_id);
|
|
20965
|
+
* })
|
|
20966
|
+
* .catch((error) => {
|
|
20967
|
+
* console.error('Failed to collect device data', error);
|
|
20968
|
+
* });
|
|
20943
20969
|
*/
|
|
20944
20970
|
return _createClass(PayPalDataCollector, [{
|
|
20945
20971
|
key: "collectDeviceData",
|
|
@@ -21561,12 +21587,16 @@
|
|
|
21561
21587
|
// Initialize performance optimizations when environment is guaranteed to be final
|
|
21562
21588
|
PerformanceService.initialize(this.link.getEnv());
|
|
21563
21589
|
this.iFrame.load(this.link.getUrl(), {
|
|
21564
|
-
title: 'Click To Pay checkout'
|
|
21590
|
+
title: 'Click To Pay checkout',
|
|
21591
|
+
attributes: {
|
|
21592
|
+
allow: 'payment; accelerometer;'
|
|
21593
|
+
},
|
|
21594
|
+
styles: {
|
|
21595
|
+
width: '100%'
|
|
21596
|
+
}
|
|
21565
21597
|
});
|
|
21566
21598
|
var iframeElement = this.iFrame.getElement();
|
|
21567
|
-
this.iFrame.setStyle('width', '100%');
|
|
21568
21599
|
if (iframeElement) {
|
|
21569
|
-
iframeElement.setAttribute('allow', 'payment; accelerometer;');
|
|
21570
21600
|
iframeElement.onload = function () {
|
|
21571
21601
|
_this2.isIframeLoaded = true;
|
|
21572
21602
|
_this2.eventEmitter.emit(EVENT$1.IFRAME_LOADED, {});
|