@payment-kit-js/vanilla 0.5.6 → 0.5.8

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * PaymentKit.js v0.5.6
2
+ * PaymentKit.js v0.5.8
3
3
  * https://paymentkit.com
4
4
  *
5
5
  * @license MIT
@@ -42,7 +42,7 @@ var PaymentKit = (() => {
42
42
  });
43
43
 
44
44
  // package.json
45
- var version = "0.5.6";
45
+ var version = "0.5.8";
46
46
 
47
47
  // src/analytics/mock-adapter.ts
48
48
  var MockAnalyticsAdapter = class {
@@ -85,7 +85,7 @@ var PaymentKit = (() => {
85
85
  }
86
86
  };
87
87
 
88
- // ../../node_modules/posthog-js/dist/module.js
88
+ // node_modules/posthog-js/dist/module.js
89
89
  var t = "undefined" != typeof window ? window : void 0;
90
90
  var i = "undefined" != typeof globalThis ? globalThis : t;
91
91
  "undefined" == typeof self && (i.self = i), "undefined" == typeof File && (i.File = function() {
@@ -6053,8 +6053,8 @@ var PaymentKit = (() => {
6053
6053
  apiBaseUrl: "https://staging.paymentkit.com"
6054
6054
  },
6055
6055
  production: {
6056
- baseUrl: "https://paymentkit.com/customer",
6057
- apiBaseUrl: "https://paymentkit.com"
6056
+ baseUrl: "https://app.paymentkit.com/customer",
6057
+ apiBaseUrl: "https://app.paymentkit.com"
6058
6058
  }
6059
6059
  };
6060
6060
  function getTunnelUrls() {
@@ -6941,13 +6941,37 @@ var PaymentKit = (() => {
6941
6941
  };
6942
6942
  var mapFieldsToCustomerInfo = (fields) => {
6943
6943
  const { firstName, lastName } = splitName(fields.customer_name);
6944
+ const hasBillingAddress = fields.customer_country || fields.customer_zip_code || fields.customer_address_line1 || fields.customer_address_line2 || fields.customer_city || fields.customer_state;
6945
+ const hasShippingAddress = fields.shipping_address_line1 || fields.shipping_address_line2 || fields.shipping_city || fields.shipping_state || fields.shipping_zip_code || fields.shipping_country;
6946
+ let taxIds;
6947
+ if (fields.customer_tax_ids) {
6948
+ try {
6949
+ taxIds = JSON.parse(fields.customer_tax_ids);
6950
+ } catch {
6951
+ taxIds = void 0;
6952
+ }
6953
+ }
6944
6954
  return {
6945
6955
  email: fields.customer_email || void 0,
6946
6956
  firstName,
6947
6957
  lastName,
6948
- billingAddress: fields.customer_country || fields.customer_zip_code ? {
6958
+ businessName: fields.customer_business_name || void 0,
6959
+ taxIds: taxIds?.length ? taxIds : void 0,
6960
+ billingAddress: hasBillingAddress ? {
6949
6961
  country: fields.customer_country || void 0,
6950
- zipCode: fields.customer_zip_code || void 0
6962
+ zipCode: fields.customer_zip_code || void 0,
6963
+ line1: fields.customer_address_line1 || void 0,
6964
+ line2: fields.customer_address_line2 || void 0,
6965
+ city: fields.customer_city || void 0,
6966
+ state: fields.customer_state || void 0
6967
+ } : void 0,
6968
+ shippingAddress: hasShippingAddress ? {
6969
+ line1: fields.shipping_address_line1 || void 0,
6970
+ line2: fields.shipping_address_line2 || void 0,
6971
+ city: fields.shipping_city || void 0,
6972
+ state: fields.shipping_state || void 0,
6973
+ zipCode: fields.shipping_zip_code || void 0,
6974
+ country: fields.shipping_country || void 0
6951
6975
  } : void 0
6952
6976
  };
6953
6977
  };
@@ -7105,14 +7129,15 @@ var PaymentKit = (() => {
7105
7129
  };
7106
7130
  };
7107
7131
  var defSubmitPayment = (states) => {
7108
- const submitPayment = async (fields) => {
7132
+ const submitPayment = async (fields, options) => {
7109
7133
  if (states._sessionConfigReady) await states._sessionConfigReady;
7110
7134
  const isVgsMode = states.cardTokenizationMode === "vgs";
7111
7135
  const { timingTracker, checkoutRequestId } = states;
7112
7136
  timingTracker.trackSubmit();
7113
7137
  const requestOptions = withRequestId(checkoutRequestId);
7114
7138
  const tunnelX = await TunnelXManager.createFromPenpalConnection(states.tunnelXConnection);
7115
- const validateFormResult = await validateFormFields(fields);
7139
+ const skipCustomerValidation = options?.skipCustomerValidation === true;
7140
+ const validateFormResult = skipCustomerValidation ? { isSuccess: true } : await validateFormFields(fields);
7116
7141
  if (!isVgsMode) {
7117
7142
  const validateCardResult = await validateCardFields(states);
7118
7143
  if (!(validateCardResult.isSuccess && validateFormResult.isSuccess)) {
@@ -7278,6 +7303,9 @@ var PaymentKit = (() => {
7278
7303
  );
7279
7304
  })
7280
7305
  ]).finally(() => clearTimeout(createCardTimeoutId));
7306
+ if (!cardResult?.data?.attributes) {
7307
+ throw new Error("VGS createCard returned an invalid response");
7308
+ }
7281
7309
  const { pan_alias, cvc_alias, exp_month, exp_year } = cardResult.data.attributes;
7282
7310
  const fullYear = exp_year < 100 ? 2e3 + exp_year : exp_year;
7283
7311
  const formattedExp = `${String(exp_month).padStart(2, "0")}/${fullYear}`;