swell-js 5.6.0 → 5.7.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/dist/api.mjs +1 -1
- package/dist/payment.mjs +29 -5
- package/dist/swell.cjs +30 -6
- package/dist/swell.cjs.map +1 -1
- package/dist/swell.umd.min.js +30 -6
- package/dist/swell.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/api.mjs
CHANGED
package/dist/payment.mjs
CHANGED
|
@@ -678,6 +678,7 @@ async function createPaymentMethod(stripe, cardElement, cart) {
|
|
|
678
678
|
return error
|
|
679
679
|
? { error }
|
|
680
680
|
: {
|
|
681
|
+
gateway: 'stripe',
|
|
681
682
|
token: paymentMethod.id,
|
|
682
683
|
last4: paymentMethod.card.last4,
|
|
683
684
|
exp_month: paymentMethod.card.exp_month,
|
|
@@ -948,6 +949,10 @@ class StripeCardPayment extends Payment {
|
|
|
948
949
|
throw new Error(paymentMethod.error.message);
|
|
949
950
|
}
|
|
950
951
|
|
|
952
|
+
if (!isLiveMode(this.method.mode)) {
|
|
953
|
+
paymentMethod.test = true;
|
|
954
|
+
}
|
|
955
|
+
|
|
951
956
|
// should save payment method data when payment amount is not chargeable
|
|
952
957
|
if (!isStripeChargeableAmount(cart.capture_total, cart.currency)) {
|
|
953
958
|
await this.updateCart({
|
|
@@ -2156,12 +2161,25 @@ async function onPaymentDataChanged(intermediatePaymentData) {
|
|
|
2156
2161
|
);
|
|
2157
2162
|
}
|
|
2158
2163
|
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2164
|
+
let shippingService;
|
|
2165
|
+
|
|
2166
|
+
if (intermediatePaymentData.shippingOptionData?.id) {
|
|
2167
|
+
const defaultServiceId =
|
|
2168
|
+
intermediatePaymentData.shippingOptionData?.id;
|
|
2169
|
+
|
|
2170
|
+
shippingService = cart.shipment_rating.services.find(
|
|
2171
|
+
(service) => service.id === defaultServiceId,
|
|
2172
|
+
);
|
|
2173
|
+
}
|
|
2162
2174
|
|
|
2175
|
+
if (shippingService === undefined) {
|
|
2176
|
+
// Auto-apply first shipping service in the list
|
|
2177
|
+
shippingService = cart.shipment_rating.services[0];
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
if (cart.shipping?.service !== shippingService.id) {
|
|
2163
2181
|
cart = await this.updateCart({
|
|
2164
|
-
shipping: { service:
|
|
2182
|
+
shipping: { service: shippingService.id },
|
|
2165
2183
|
});
|
|
2166
2184
|
}
|
|
2167
2185
|
|
|
@@ -3870,7 +3888,7 @@ class QuickpayCardPayment extends Payment {
|
|
|
3870
3888
|
}
|
|
3871
3889
|
|
|
3872
3890
|
get orderId() {
|
|
3873
|
-
return Math.random().toString(36).
|
|
3891
|
+
return Math.random().toString(36).slice(2, 11);
|
|
3874
3892
|
}
|
|
3875
3893
|
|
|
3876
3894
|
async tokenize() {
|
|
@@ -3932,6 +3950,12 @@ class QuickpayCardPayment extends Payment {
|
|
|
3932
3950
|
throw new Error(card.error.message);
|
|
3933
3951
|
}
|
|
3934
3952
|
|
|
3953
|
+
card.gateway = 'quickpay';
|
|
3954
|
+
|
|
3955
|
+
if (!isLiveMode(this.method.mode)) {
|
|
3956
|
+
card.test = true;
|
|
3957
|
+
}
|
|
3958
|
+
|
|
3935
3959
|
await this.updateCart({
|
|
3936
3960
|
billing: {
|
|
3937
3961
|
method: 'card',
|
package/dist/swell.cjs
CHANGED
|
@@ -7296,6 +7296,7 @@ async function createPaymentMethod(stripe, cardElement, cart) {
|
|
|
7296
7296
|
return error
|
|
7297
7297
|
? { error }
|
|
7298
7298
|
: {
|
|
7299
|
+
gateway: 'stripe',
|
|
7299
7300
|
token: paymentMethod.id,
|
|
7300
7301
|
last4: paymentMethod.card.last4,
|
|
7301
7302
|
exp_month: paymentMethod.card.exp_month,
|
|
@@ -7566,6 +7567,10 @@ class StripeCardPayment extends Payment {
|
|
|
7566
7567
|
throw new Error(paymentMethod.error.message);
|
|
7567
7568
|
}
|
|
7568
7569
|
|
|
7570
|
+
if (!isLiveMode(this.method.mode)) {
|
|
7571
|
+
paymentMethod.test = true;
|
|
7572
|
+
}
|
|
7573
|
+
|
|
7569
7574
|
// should save payment method data when payment amount is not chargeable
|
|
7570
7575
|
if (!isStripeChargeableAmount(cart.capture_total, cart.currency)) {
|
|
7571
7576
|
await this.updateCart({
|
|
@@ -8774,12 +8779,25 @@ async function onPaymentDataChanged(intermediatePaymentData) {
|
|
|
8774
8779
|
);
|
|
8775
8780
|
}
|
|
8776
8781
|
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8782
|
+
let shippingService;
|
|
8783
|
+
|
|
8784
|
+
if (intermediatePaymentData.shippingOptionData?.id) {
|
|
8785
|
+
const defaultServiceId =
|
|
8786
|
+
intermediatePaymentData.shippingOptionData?.id;
|
|
8787
|
+
|
|
8788
|
+
shippingService = cart.shipment_rating.services.find(
|
|
8789
|
+
(service) => service.id === defaultServiceId,
|
|
8790
|
+
);
|
|
8791
|
+
}
|
|
8780
8792
|
|
|
8793
|
+
if (shippingService === undefined) {
|
|
8794
|
+
// Auto-apply first shipping service in the list
|
|
8795
|
+
shippingService = cart.shipment_rating.services[0];
|
|
8796
|
+
}
|
|
8797
|
+
|
|
8798
|
+
if (cart.shipping?.service !== shippingService.id) {
|
|
8781
8799
|
cart = await this.updateCart({
|
|
8782
|
-
shipping: { service:
|
|
8800
|
+
shipping: { service: shippingService.id },
|
|
8783
8801
|
});
|
|
8784
8802
|
}
|
|
8785
8803
|
|
|
@@ -10488,7 +10506,7 @@ class QuickpayCardPayment extends Payment {
|
|
|
10488
10506
|
}
|
|
10489
10507
|
|
|
10490
10508
|
get orderId() {
|
|
10491
|
-
return Math.random().toString(36).
|
|
10509
|
+
return Math.random().toString(36).slice(2, 11);
|
|
10492
10510
|
}
|
|
10493
10511
|
|
|
10494
10512
|
async tokenize() {
|
|
@@ -10550,6 +10568,12 @@ class QuickpayCardPayment extends Payment {
|
|
|
10550
10568
|
throw new Error(card.error.message);
|
|
10551
10569
|
}
|
|
10552
10570
|
|
|
10571
|
+
card.gateway = 'quickpay';
|
|
10572
|
+
|
|
10573
|
+
if (!isLiveMode(this.method.mode)) {
|
|
10574
|
+
card.test = true;
|
|
10575
|
+
}
|
|
10576
|
+
|
|
10553
10577
|
await this.updateCart({
|
|
10554
10578
|
billing: {
|
|
10555
10579
|
method: 'card',
|
|
@@ -12931,7 +12955,7 @@ function swell(initStore = undefined, initKey, initOptions = {}) {
|
|
|
12931
12955
|
const api = {};
|
|
12932
12956
|
|
|
12933
12957
|
Object.assign(api, {
|
|
12934
|
-
version: '5.
|
|
12958
|
+
version: '5.7.0',
|
|
12935
12959
|
options,
|
|
12936
12960
|
request,
|
|
12937
12961
|
|