@pelcro/react-pelcro-js 3.26.0-beta.21 → 3.26.0-beta.23
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/dist/index.cjs.js +41 -17
- package/dist/index.esm.js +41 -17
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -9517,6 +9517,43 @@ const calcAndFormatItemsTotal = (items, currency) => {
|
|
|
9517
9517
|
}
|
|
9518
9518
|
return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
|
|
9519
9519
|
};
|
|
9520
|
+
const getOrderInfo = order => {
|
|
9521
|
+
if (!order) {
|
|
9522
|
+
return {
|
|
9523
|
+
price: null,
|
|
9524
|
+
currency: null,
|
|
9525
|
+
label: null
|
|
9526
|
+
};
|
|
9527
|
+
}
|
|
9528
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
9529
|
+
if (isQuickPurchase) {
|
|
9530
|
+
return {
|
|
9531
|
+
price: order.price * order.quantity,
|
|
9532
|
+
currency: order.currency,
|
|
9533
|
+
label: order.name
|
|
9534
|
+
};
|
|
9535
|
+
}
|
|
9536
|
+
if (order.length === 0) {
|
|
9537
|
+
return {
|
|
9538
|
+
price: null,
|
|
9539
|
+
currency: null,
|
|
9540
|
+
label: null
|
|
9541
|
+
};
|
|
9542
|
+
}
|
|
9543
|
+
if (order.length === 1) {
|
|
9544
|
+
return {
|
|
9545
|
+
price: order[0].price * order[0].quantity,
|
|
9546
|
+
currency: order[0].currency,
|
|
9547
|
+
label: order[0].name
|
|
9548
|
+
};
|
|
9549
|
+
}
|
|
9550
|
+
const price = order.reduce((total, item) => total + item.price * item.quantity, 0);
|
|
9551
|
+
return {
|
|
9552
|
+
price,
|
|
9553
|
+
currency: order[0].currency,
|
|
9554
|
+
label: price === 0 ? "Free Items" : "Order"
|
|
9555
|
+
};
|
|
9556
|
+
};
|
|
9520
9557
|
|
|
9521
9558
|
/**
|
|
9522
9559
|
* returns true if the URL contains a supported view trigger URL
|
|
@@ -21257,7 +21294,7 @@ const ApplePayButton = _ref => {
|
|
|
21257
21294
|
if (pelcroApplyPayButton) {
|
|
21258
21295
|
pelcroApplyPayButton.style.display = "block";
|
|
21259
21296
|
}
|
|
21260
|
-
console.log("canMakePayments", canMakePayments);
|
|
21297
|
+
console.log("ApplePay canMakePayments: ", canMakePayments);
|
|
21261
21298
|
}
|
|
21262
21299
|
});
|
|
21263
21300
|
} else {
|
|
@@ -21299,7 +21336,7 @@ const ApplePayButton = _ref => {
|
|
|
21299
21336
|
amount: updatedPrice / 100
|
|
21300
21337
|
}
|
|
21301
21338
|
};
|
|
21302
|
-
|
|
21339
|
+
|
|
21303
21340
|
// Create ApplePaySession
|
|
21304
21341
|
// @todo - Clarify supported version parameter
|
|
21305
21342
|
// @odo - Apple Pay demo uses version 6 (https://applepaydemo.apple.com/)
|
|
@@ -21312,7 +21349,6 @@ const ApplePayButton = _ref => {
|
|
|
21312
21349
|
const {
|
|
21313
21350
|
validationURL
|
|
21314
21351
|
} = event;
|
|
21315
|
-
console.log("then merchantSession step", event);
|
|
21316
21352
|
// Call your own server to request a new merchant session.
|
|
21317
21353
|
window.Pelcro.payment.startSession({
|
|
21318
21354
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
@@ -21321,7 +21357,6 @@ const ApplePayButton = _ref => {
|
|
|
21321
21357
|
}, (err, res) => {
|
|
21322
21358
|
if (err) {
|
|
21323
21359
|
// Handle any errors during merchant validation
|
|
21324
|
-
console.error("Merchant validation SDK error: ", err);
|
|
21325
21360
|
session.abort();
|
|
21326
21361
|
return dispatch({
|
|
21327
21362
|
type: SHOW_ALERT,
|
|
@@ -21332,13 +21367,11 @@ const ApplePayButton = _ref => {
|
|
|
21332
21367
|
});
|
|
21333
21368
|
}
|
|
21334
21369
|
// Complete merchant validation with the merchant session object
|
|
21335
|
-
console.log("Merchant validation SDK response: ", res);
|
|
21336
21370
|
const merchantSession = res;
|
|
21337
21371
|
session.completeMerchantValidation(merchantSession);
|
|
21338
21372
|
});
|
|
21339
21373
|
};
|
|
21340
21374
|
session.onpaymentmethodselected = event => {
|
|
21341
|
-
console.log("payment method selected step", event);
|
|
21342
21375
|
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
21343
21376
|
// No updates or errors are needed, pass an empty object.
|
|
21344
21377
|
const newTotal = {
|
|
@@ -21356,7 +21389,6 @@ const ApplePayButton = _ref => {
|
|
|
21356
21389
|
|
|
21357
21390
|
// TODO: Check if onshippingmethodselected it should be implemented
|
|
21358
21391
|
// session.onshippingmethodselected = (event) => {
|
|
21359
|
-
// console.log("on shipping method selected step", event);
|
|
21360
21392
|
// // Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
21361
21393
|
// // No updates or errors are needed, pass an empty object.
|
|
21362
21394
|
// const newTotal = {
|
|
@@ -21378,14 +21410,12 @@ const ApplePayButton = _ref => {
|
|
|
21378
21410
|
|
|
21379
21411
|
// TODO: Check if onshippingcontactselected it should be implemented
|
|
21380
21412
|
// session.onshippingcontactselected = (event) => {
|
|
21381
|
-
// console.log("on shipping contact selected step", event);
|
|
21382
21413
|
// // Define ApplePayShippingContactUpdate based on the selected shipping contact.
|
|
21383
21414
|
// const update = {};
|
|
21384
21415
|
// session.completeShippingContactSelection(update);
|
|
21385
21416
|
// };
|
|
21386
21417
|
|
|
21387
21418
|
session.onpaymentauthorized = event => {
|
|
21388
|
-
console.log("on payment authorized step", event);
|
|
21389
21419
|
// Define ApplePayPaymentAuthorizationResult
|
|
21390
21420
|
const result = {
|
|
21391
21421
|
status: ApplePaySession.STATUS_SUCCESS // eslint-disable-line no-undef
|
|
@@ -21414,7 +21444,6 @@ const ApplePayButton = _ref => {
|
|
|
21414
21444
|
transactionId: transactionId
|
|
21415
21445
|
}
|
|
21416
21446
|
};
|
|
21417
|
-
console.log(applePayToken);
|
|
21418
21447
|
const orderId = `pelcro-${new Date().getTime()}`;
|
|
21419
21448
|
const eProtectRequest = {
|
|
21420
21449
|
paypageId: payPageId,
|
|
@@ -21430,7 +21459,6 @@ const ApplePayButton = _ref => {
|
|
|
21430
21459
|
const {
|
|
21431
21460
|
expDate
|
|
21432
21461
|
} = vantivResponse;
|
|
21433
|
-
console.log("Response:", vantivResponse);
|
|
21434
21462
|
const expMonth = expDate.substring(0, 2);
|
|
21435
21463
|
const expYear = expDate.substring(2);
|
|
21436
21464
|
const vantivPaymentRequest = {
|
|
@@ -21469,7 +21497,6 @@ const ApplePayButton = _ref => {
|
|
|
21469
21497
|
|
|
21470
21498
|
// TODO: Check if oncouponcodechanged it should be implemented
|
|
21471
21499
|
// session.oncouponcodechanged = (event) => {
|
|
21472
|
-
// console.log("on coupon code changed step", event);
|
|
21473
21500
|
// // Define ApplePayCouponCodeUpdate
|
|
21474
21501
|
// const newTotal = calculateNewTotal(event.couponCode);
|
|
21475
21502
|
// const newLineItems = calculateNewLineItems(event.couponCode);
|
|
@@ -21488,7 +21515,6 @@ const ApplePayButton = _ref => {
|
|
|
21488
21515
|
|
|
21489
21516
|
session.oncancel = event => {
|
|
21490
21517
|
// Payment cancelled by WebKit
|
|
21491
|
-
console.log("on cancel step", event);
|
|
21492
21518
|
dispatch({
|
|
21493
21519
|
type: LOADING,
|
|
21494
21520
|
payload: false
|
|
@@ -21558,11 +21584,9 @@ function PaymentMethodView(_ref) {
|
|
|
21558
21584
|
className: "plc-w-full plc-p-2 plc-mb-4 plc-font-semibold plc-text-center plc-text-gray-900 plc-bg-gray-100 plc-border plc-border-gray-200"
|
|
21559
21585
|
}, /*#__PURE__*/React__default['default'].createElement("p", {
|
|
21560
21586
|
className: "plc-text-gray-600"
|
|
21561
|
-
},
|
|
21562
|
-
className: "plc-tracking-wider plc-uppercase"
|
|
21563
|
-
}, order === null || order === void 0 ? void 0 : order.name) : /*#__PURE__*/React__default['default'].createElement("span", {
|
|
21587
|
+
}, /*#__PURE__*/React__default['default'].createElement("span", {
|
|
21564
21588
|
className: "plc-tracking-wider plc-uppercase"
|
|
21565
|
-
},
|
|
21589
|
+
}, getOrderInfo(order).label), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
|
|
21566
21590
|
className: "plc-text-xl plc-font-semibold plc-text-primary-600"
|
|
21567
21591
|
}, (_calcAndFormatItemsTo = calcAndFormatItemsTotal(order, (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency)) !== null && _calcAndFormatItemsTo !== void 0 ? _calcAndFormatItemsTo : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage())))), cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
21568
21592
|
className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
|
package/dist/index.esm.js
CHANGED
|
@@ -9487,6 +9487,43 @@ const calcAndFormatItemsTotal = (items, currency) => {
|
|
|
9487
9487
|
}
|
|
9488
9488
|
return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
|
|
9489
9489
|
};
|
|
9490
|
+
const getOrderInfo = order => {
|
|
9491
|
+
if (!order) {
|
|
9492
|
+
return {
|
|
9493
|
+
price: null,
|
|
9494
|
+
currency: null,
|
|
9495
|
+
label: null
|
|
9496
|
+
};
|
|
9497
|
+
}
|
|
9498
|
+
const isQuickPurchase = !Array.isArray(order);
|
|
9499
|
+
if (isQuickPurchase) {
|
|
9500
|
+
return {
|
|
9501
|
+
price: order.price * order.quantity,
|
|
9502
|
+
currency: order.currency,
|
|
9503
|
+
label: order.name
|
|
9504
|
+
};
|
|
9505
|
+
}
|
|
9506
|
+
if (order.length === 0) {
|
|
9507
|
+
return {
|
|
9508
|
+
price: null,
|
|
9509
|
+
currency: null,
|
|
9510
|
+
label: null
|
|
9511
|
+
};
|
|
9512
|
+
}
|
|
9513
|
+
if (order.length === 1) {
|
|
9514
|
+
return {
|
|
9515
|
+
price: order[0].price * order[0].quantity,
|
|
9516
|
+
currency: order[0].currency,
|
|
9517
|
+
label: order[0].name
|
|
9518
|
+
};
|
|
9519
|
+
}
|
|
9520
|
+
const price = order.reduce((total, item) => total + item.price * item.quantity, 0);
|
|
9521
|
+
return {
|
|
9522
|
+
price,
|
|
9523
|
+
currency: order[0].currency,
|
|
9524
|
+
label: price === 0 ? "Free Items" : "Order"
|
|
9525
|
+
};
|
|
9526
|
+
};
|
|
9490
9527
|
|
|
9491
9528
|
/**
|
|
9492
9529
|
* returns true if the URL contains a supported view trigger URL
|
|
@@ -21227,7 +21264,7 @@ const ApplePayButton = _ref => {
|
|
|
21227
21264
|
if (pelcroApplyPayButton) {
|
|
21228
21265
|
pelcroApplyPayButton.style.display = "block";
|
|
21229
21266
|
}
|
|
21230
|
-
console.log("canMakePayments", canMakePayments);
|
|
21267
|
+
console.log("ApplePay canMakePayments: ", canMakePayments);
|
|
21231
21268
|
}
|
|
21232
21269
|
});
|
|
21233
21270
|
} else {
|
|
@@ -21269,7 +21306,7 @@ const ApplePayButton = _ref => {
|
|
|
21269
21306
|
amount: updatedPrice / 100
|
|
21270
21307
|
}
|
|
21271
21308
|
};
|
|
21272
|
-
|
|
21309
|
+
|
|
21273
21310
|
// Create ApplePaySession
|
|
21274
21311
|
// @todo - Clarify supported version parameter
|
|
21275
21312
|
// @odo - Apple Pay demo uses version 6 (https://applepaydemo.apple.com/)
|
|
@@ -21282,7 +21319,6 @@ const ApplePayButton = _ref => {
|
|
|
21282
21319
|
const {
|
|
21283
21320
|
validationURL
|
|
21284
21321
|
} = event;
|
|
21285
|
-
console.log("then merchantSession step", event);
|
|
21286
21322
|
// Call your own server to request a new merchant session.
|
|
21287
21323
|
window.Pelcro.payment.startSession({
|
|
21288
21324
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
@@ -21291,7 +21327,6 @@ const ApplePayButton = _ref => {
|
|
|
21291
21327
|
}, (err, res) => {
|
|
21292
21328
|
if (err) {
|
|
21293
21329
|
// Handle any errors during merchant validation
|
|
21294
|
-
console.error("Merchant validation SDK error: ", err);
|
|
21295
21330
|
session.abort();
|
|
21296
21331
|
return dispatch({
|
|
21297
21332
|
type: SHOW_ALERT,
|
|
@@ -21302,13 +21337,11 @@ const ApplePayButton = _ref => {
|
|
|
21302
21337
|
});
|
|
21303
21338
|
}
|
|
21304
21339
|
// Complete merchant validation with the merchant session object
|
|
21305
|
-
console.log("Merchant validation SDK response: ", res);
|
|
21306
21340
|
const merchantSession = res;
|
|
21307
21341
|
session.completeMerchantValidation(merchantSession);
|
|
21308
21342
|
});
|
|
21309
21343
|
};
|
|
21310
21344
|
session.onpaymentmethodselected = event => {
|
|
21311
|
-
console.log("payment method selected step", event);
|
|
21312
21345
|
// Define ApplePayPaymentMethodUpdate based on the selected payment method.
|
|
21313
21346
|
// No updates or errors are needed, pass an empty object.
|
|
21314
21347
|
const newTotal = {
|
|
@@ -21326,7 +21359,6 @@ const ApplePayButton = _ref => {
|
|
|
21326
21359
|
|
|
21327
21360
|
// TODO: Check if onshippingmethodselected it should be implemented
|
|
21328
21361
|
// session.onshippingmethodselected = (event) => {
|
|
21329
|
-
// console.log("on shipping method selected step", event);
|
|
21330
21362
|
// // Define ApplePayShippingMethodUpdate based on the selected shipping method.
|
|
21331
21363
|
// // No updates or errors are needed, pass an empty object.
|
|
21332
21364
|
// const newTotal = {
|
|
@@ -21348,14 +21380,12 @@ const ApplePayButton = _ref => {
|
|
|
21348
21380
|
|
|
21349
21381
|
// TODO: Check if onshippingcontactselected it should be implemented
|
|
21350
21382
|
// session.onshippingcontactselected = (event) => {
|
|
21351
|
-
// console.log("on shipping contact selected step", event);
|
|
21352
21383
|
// // Define ApplePayShippingContactUpdate based on the selected shipping contact.
|
|
21353
21384
|
// const update = {};
|
|
21354
21385
|
// session.completeShippingContactSelection(update);
|
|
21355
21386
|
// };
|
|
21356
21387
|
|
|
21357
21388
|
session.onpaymentauthorized = event => {
|
|
21358
|
-
console.log("on payment authorized step", event);
|
|
21359
21389
|
// Define ApplePayPaymentAuthorizationResult
|
|
21360
21390
|
const result = {
|
|
21361
21391
|
status: ApplePaySession.STATUS_SUCCESS // eslint-disable-line no-undef
|
|
@@ -21384,7 +21414,6 @@ const ApplePayButton = _ref => {
|
|
|
21384
21414
|
transactionId: transactionId
|
|
21385
21415
|
}
|
|
21386
21416
|
};
|
|
21387
|
-
console.log(applePayToken);
|
|
21388
21417
|
const orderId = `pelcro-${new Date().getTime()}`;
|
|
21389
21418
|
const eProtectRequest = {
|
|
21390
21419
|
paypageId: payPageId,
|
|
@@ -21400,7 +21429,6 @@ const ApplePayButton = _ref => {
|
|
|
21400
21429
|
const {
|
|
21401
21430
|
expDate
|
|
21402
21431
|
} = vantivResponse;
|
|
21403
|
-
console.log("Response:", vantivResponse);
|
|
21404
21432
|
const expMonth = expDate.substring(0, 2);
|
|
21405
21433
|
const expYear = expDate.substring(2);
|
|
21406
21434
|
const vantivPaymentRequest = {
|
|
@@ -21439,7 +21467,6 @@ const ApplePayButton = _ref => {
|
|
|
21439
21467
|
|
|
21440
21468
|
// TODO: Check if oncouponcodechanged it should be implemented
|
|
21441
21469
|
// session.oncouponcodechanged = (event) => {
|
|
21442
|
-
// console.log("on coupon code changed step", event);
|
|
21443
21470
|
// // Define ApplePayCouponCodeUpdate
|
|
21444
21471
|
// const newTotal = calculateNewTotal(event.couponCode);
|
|
21445
21472
|
// const newLineItems = calculateNewLineItems(event.couponCode);
|
|
@@ -21458,7 +21485,6 @@ const ApplePayButton = _ref => {
|
|
|
21458
21485
|
|
|
21459
21486
|
session.oncancel = event => {
|
|
21460
21487
|
// Payment cancelled by WebKit
|
|
21461
|
-
console.log("on cancel step", event);
|
|
21462
21488
|
dispatch({
|
|
21463
21489
|
type: LOADING,
|
|
21464
21490
|
payload: false
|
|
@@ -21528,11 +21554,9 @@ function PaymentMethodView(_ref) {
|
|
|
21528
21554
|
className: "plc-w-full plc-p-2 plc-mb-4 plc-font-semibold plc-text-center plc-text-gray-900 plc-bg-gray-100 plc-border plc-border-gray-200"
|
|
21529
21555
|
}, /*#__PURE__*/React__default.createElement("p", {
|
|
21530
21556
|
className: "plc-text-gray-600"
|
|
21531
|
-
},
|
|
21532
|
-
className: "plc-tracking-wider plc-uppercase"
|
|
21533
|
-
}, order === null || order === void 0 ? void 0 : order.name) : /*#__PURE__*/React__default.createElement("span", {
|
|
21557
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
21534
21558
|
className: "plc-tracking-wider plc-uppercase"
|
|
21535
|
-
},
|
|
21559
|
+
}, getOrderInfo(order).label), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
|
|
21536
21560
|
className: "plc-text-xl plc-font-semibold plc-text-primary-600"
|
|
21537
21561
|
}, (_calcAndFormatItemsTo = calcAndFormatItemsTotal(order, (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency)) !== null && _calcAndFormatItemsTo !== void 0 ? _calcAndFormatItemsTo : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage())))), cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default.createElement("div", {
|
|
21538
21562
|
className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
|