@fat-zebra/sdk 1.5.8-beta.1 → 1.5.8-beta.2
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.
|
@@ -132,12 +132,39 @@ export class ApplePay {
|
|
|
132
132
|
this.applePaySession.onpaymentauthorized = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
133
133
|
try {
|
|
134
134
|
const result = yield payNow.authorizePayment(Object.assign(Object.assign({}, payNowPaymentAttributes), { merchant: this.username, token: event.payment.token, domain_name: this.domain_name }), `${this.fzPayNowDomain}${purchaseTokenPath}?react_sdk=${this.react_sdk}`);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
if (result.ok) {
|
|
136
|
+
this.applePaySession.completePayment(window.ApplePaySession.STATUS_SUCCESS);
|
|
137
|
+
const payload = {
|
|
138
|
+
message: 'Payment successful.',
|
|
139
|
+
data: result,
|
|
140
|
+
};
|
|
141
|
+
emit(FatZebra.PublicEvent.PAYMENT_SUCCESS, payload);
|
|
142
|
+
const message = {
|
|
143
|
+
channel,
|
|
144
|
+
subject: 'Payment successful.',
|
|
145
|
+
data: {
|
|
146
|
+
payload
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
this.postMessageClient.send(message);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this.applePaySession.completePayment(window.ApplePaySession.STATUS_FAILURE);
|
|
153
|
+
const payload = {
|
|
154
|
+
data: 'Payment failed.',
|
|
155
|
+
errors: result.purchase.errors
|
|
156
|
+
};
|
|
157
|
+
console.log('its successful apple pay', result);
|
|
158
|
+
emit(FatZebra.PublicEvent.PAYMENT_ERROR, payload);
|
|
159
|
+
const message = {
|
|
160
|
+
channel,
|
|
161
|
+
subject: 'Payment unsuccessful.',
|
|
162
|
+
data: {
|
|
163
|
+
payload
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
this.postMessageClient.send(message);
|
|
167
|
+
}
|
|
141
168
|
}
|
|
142
169
|
catch (e) {
|
|
143
170
|
this.applePaySession.completePayment(window.ApplePaySession.STATUS_FAILURE);
|
|
@@ -36,7 +36,7 @@ export const authorizePayment = (payload, url) => __awaiter(void 0, void 0, void
|
|
|
36
36
|
const request = new XMLHttpRequest();
|
|
37
37
|
request.onload = () => {
|
|
38
38
|
if (request.status >= 200 && request.status < 300) {
|
|
39
|
-
return resolve(
|
|
39
|
+
return resolve(JSON.parse(request.responseText));
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
42
|
return reject(new Error());
|
package/dist/staging/fatzebra.js
CHANGED
|
@@ -16023,9 +16023,10 @@ var ApplePay = /** @class */ (function () {
|
|
|
16023
16023
|
}
|
|
16024
16024
|
ApplePay.prototype.load = function (config) {
|
|
16025
16025
|
var _this = this;
|
|
16026
|
-
var _a, _b;
|
|
16026
|
+
var _a, _b, _c;
|
|
16027
16027
|
this.domain_name = (_b = (_a = config === null || config === void 0 ? void 0 : config.options) === null || _a === void 0 ? void 0 : _a.domain_name) !== null && _b !== void 0 ? _b : window.location.hostname;
|
|
16028
16028
|
this.iframe = document.createElement('iframe');
|
|
16029
|
+
this.react_sdk = (_c = config.options.react_sdk) !== null && _c !== void 0 ? _c : false;
|
|
16029
16030
|
document.getElementById(config.containerId).appendChild(this.iframe);
|
|
16030
16031
|
var applePayUrl = this.getPayNowUrl(config.options);
|
|
16031
16032
|
this.iframe.setAttribute("src", applePayUrl);
|
|
@@ -16076,8 +16077,9 @@ var ApplePay = /** @class */ (function () {
|
|
|
16076
16077
|
if (options === null || options === void 0 ? void 0 : options.apple_button_locale) {
|
|
16077
16078
|
query.append('apple_button_locale', options.apple_button_locale.toString());
|
|
16078
16079
|
}
|
|
16079
|
-
|
|
16080
|
-
|
|
16080
|
+
if (options === null || options === void 0 ? void 0 : options.react_sdk) {
|
|
16081
|
+
query.append('react_sdk', 'true');
|
|
16082
|
+
}
|
|
16081
16083
|
query.append('domain_name', this.domain_name);
|
|
16082
16084
|
return "".concat(base, "?").concat(query.toString());
|
|
16083
16085
|
};
|
|
@@ -16166,20 +16168,47 @@ var ApplePay = /** @class */ (function () {
|
|
|
16166
16168
|
});
|
|
16167
16169
|
}); };
|
|
16168
16170
|
this.applePaySession.onpaymentauthorized = function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
16169
|
-
var result, payload, e_2, payload;
|
|
16171
|
+
var result, payload, message, payload, message, e_2, payload;
|
|
16170
16172
|
return __generator(this, function (_a) {
|
|
16171
16173
|
switch (_a.label) {
|
|
16172
16174
|
case 0:
|
|
16173
16175
|
_a.trys.push([0, 2, , 3]);
|
|
16174
|
-
return [4 /*yield*/, payNow.authorizePayment(__assign(__assign({}, payNowPaymentAttributes), { merchant: this.username, token: event.payment.token, domain_name: this.domain_name }), "".concat(this.fzPayNowDomain).concat(purchaseTokenPath))];
|
|
16176
|
+
return [4 /*yield*/, payNow.authorizePayment(__assign(__assign({}, payNowPaymentAttributes), { merchant: this.username, token: event.payment.token, domain_name: this.domain_name }), "".concat(this.fzPayNowDomain).concat(purchaseTokenPath, "?react_sdk=").concat(this.react_sdk))];
|
|
16175
16177
|
case 1:
|
|
16176
16178
|
result = _a.sent();
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
|
|
16179
|
+
if (result.ok) {
|
|
16180
|
+
this.applePaySession.completePayment(window.ApplePaySession.STATUS_SUCCESS);
|
|
16181
|
+
payload = {
|
|
16182
|
+
message: 'Payment successful.',
|
|
16183
|
+
data: result,
|
|
16184
|
+
};
|
|
16185
|
+
(0, event_manager_1.emit)(FatZebra.PublicEvent.PAYMENT_SUCCESS, payload);
|
|
16186
|
+
message = {
|
|
16187
|
+
channel: channel,
|
|
16188
|
+
subject: 'Payment successful.',
|
|
16189
|
+
data: {
|
|
16190
|
+
payload: payload
|
|
16191
|
+
}
|
|
16192
|
+
};
|
|
16193
|
+
this.postMessageClient.send(message);
|
|
16194
|
+
}
|
|
16195
|
+
else {
|
|
16196
|
+
this.applePaySession.completePayment(window.ApplePaySession.STATUS_FAILURE);
|
|
16197
|
+
payload = {
|
|
16198
|
+
data: 'Payment failed.',
|
|
16199
|
+
errors: result.purchase.errors
|
|
16200
|
+
};
|
|
16201
|
+
console.log('its successful apple pay', result);
|
|
16202
|
+
(0, event_manager_1.emit)(FatZebra.PublicEvent.PAYMENT_ERROR, payload);
|
|
16203
|
+
message = {
|
|
16204
|
+
channel: channel,
|
|
16205
|
+
subject: 'Payment unsuccessful.',
|
|
16206
|
+
data: {
|
|
16207
|
+
payload: payload
|
|
16208
|
+
}
|
|
16209
|
+
};
|
|
16210
|
+
this.postMessageClient.send(message);
|
|
16211
|
+
}
|
|
16183
16212
|
return [3 /*break*/, 3];
|
|
16184
16213
|
case 2:
|
|
16185
16214
|
e_2 = _a.sent();
|
|
@@ -16390,7 +16419,7 @@ var authorizePayment = function (payload, url) { return __awaiter(void 0, void 0
|
|
|
16390
16419
|
var request = new XMLHttpRequest();
|
|
16391
16420
|
request.onload = function () {
|
|
16392
16421
|
if (request.status >= 200 && request.status < 300) {
|
|
16393
|
-
return resolve(
|
|
16422
|
+
return resolve(JSON.parse(request.responseText));
|
|
16394
16423
|
}
|
|
16395
16424
|
else {
|
|
16396
16425
|
return reject(new Error());
|
|
@@ -19279,7 +19308,7 @@ exports.version = '1.5.5';
|
|
|
19279
19308
|
/******/
|
|
19280
19309
|
/******/ /* webpack/runtime/getFullHash */
|
|
19281
19310
|
/******/ (() => {
|
|
19282
|
-
/******/ __webpack_require__.h = () => ("
|
|
19311
|
+
/******/ __webpack_require__.h = () => ("f5678cb79c3bbd979132")
|
|
19283
19312
|
/******/ })();
|
|
19284
19313
|
/******/
|
|
19285
19314
|
/******/ /* webpack/runtime/global */
|