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.
@@ -12741,6 +12741,7 @@
12741
12741
  return error
12742
12742
  ? { error }
12743
12743
  : {
12744
+ gateway: 'stripe',
12744
12745
  token: paymentMethod.id,
12745
12746
  last4: paymentMethod.card.last4,
12746
12747
  exp_month: paymentMethod.card.exp_month,
@@ -13011,6 +13012,10 @@
13011
13012
  throw new Error(paymentMethod.error.message);
13012
13013
  }
13013
13014
 
13015
+ if (!isLiveMode(this.method.mode)) {
13016
+ paymentMethod.test = true;
13017
+ }
13018
+
13014
13019
  // should save payment method data when payment amount is not chargeable
13015
13020
  if (!isStripeChargeableAmount(cart.capture_total, cart.currency)) {
13016
13021
  await this.updateCart({
@@ -14219,12 +14224,25 @@
14219
14224
  );
14220
14225
  }
14221
14226
 
14222
- // Auto-apply shipping if only one service is available
14223
- if (cart.shipment_rating.services.length === 1) {
14224
- const [singleService] = cart.shipment_rating.services;
14227
+ let shippingService;
14228
+
14229
+ if (intermediatePaymentData.shippingOptionData?.id) {
14230
+ const defaultServiceId =
14231
+ intermediatePaymentData.shippingOptionData?.id;
14232
+
14233
+ shippingService = cart.shipment_rating.services.find(
14234
+ (service) => service.id === defaultServiceId,
14235
+ );
14236
+ }
14225
14237
 
14238
+ if (shippingService === undefined) {
14239
+ // Auto-apply first shipping service in the list
14240
+ shippingService = cart.shipment_rating.services[0];
14241
+ }
14242
+
14243
+ if (cart.shipping?.service !== shippingService.id) {
14226
14244
  cart = await this.updateCart({
14227
- shipping: { service: singleService.id },
14245
+ shipping: { service: shippingService.id },
14228
14246
  });
14229
14247
  }
14230
14248
 
@@ -15933,7 +15951,7 @@
15933
15951
  }
15934
15952
 
15935
15953
  get orderId() {
15936
- return Math.random().toString(36).substr(2, 9);
15954
+ return Math.random().toString(36).slice(2, 11);
15937
15955
  }
15938
15956
 
15939
15957
  async tokenize() {
@@ -15995,6 +16013,12 @@
15995
16013
  throw new Error(card.error.message);
15996
16014
  }
15997
16015
 
16016
+ card.gateway = 'quickpay';
16017
+
16018
+ if (!isLiveMode(this.method.mode)) {
16019
+ card.test = true;
16020
+ }
16021
+
15998
16022
  await this.updateCart({
15999
16023
  billing: {
16000
16024
  method: 'card',
@@ -18376,7 +18400,7 @@
18376
18400
  const api = {};
18377
18401
 
18378
18402
  Object.assign(api, {
18379
- version: '5.6.0',
18403
+ version: '5.7.0',
18380
18404
  options,
18381
18405
  request,
18382
18406