@funnelfox/payments-sdk 0.2.0-beta.1 → 0.2.0-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.
package/dist/index.cjs CHANGED
@@ -151,6 +151,7 @@ var StripeEmbeddedPageUi = class {
151
151
 
152
152
  // src/providers/stripe/ui/form.ts
153
153
  var CHECKOUT_FORM_BETA = "custom_checkout_payment_form_1";
154
+ var EXPRESS_CHECKOUT_SOURCE = "checkout-form-ece";
154
155
  var StripeFormUi = class {
155
156
  constructor(options = {}) {
156
157
  this.options = options;
@@ -206,17 +207,30 @@ var StripeFormUi = class {
206
207
  }
207
208
  return result.actions;
208
209
  }
210
+ async isFormValid(actions) {
211
+ try {
212
+ const validation = await actions.validateElements();
213
+ return validation.type !== "error";
214
+ } catch {
215
+ return true;
216
+ }
217
+ }
209
218
  async confirm(actions, event, host) {
210
- const express = event.source === "checkout-form-ece";
219
+ const express = event.source === EXPRESS_CHECKOUT_SOURCE;
211
220
  const paymentMethodType = express ? void 0 : event.paymentMethodType ?? void 0;
212
- host.confirmed({ paymentMethodType, express });
213
221
  try {
222
+ const attempted = express || await this.isFormValid(actions);
223
+ if (attempted) {
224
+ host.confirmed({ paymentMethodType, express });
225
+ }
214
226
  const result = await actions.confirm({ formConfirmEvent: event, redirect: "if_required" });
215
227
  if (result.type === "error") {
216
- host.paymentFailed(result.error, {
217
- declineCode: result.error.code === "paymentFailed" ? result.error.paymentFailed.declineCode : null,
218
- message: result.error.message
219
- });
228
+ if (result.error.code === "paymentFailed") {
229
+ host.paymentFailed(result.error, {
230
+ declineCode: result.error.paymentFailed.declineCode,
231
+ message: result.error.message
232
+ });
233
+ }
220
234
  return;
221
235
  }
222
236
  host.succeeded(fromSession(result.session));
package/dist/index.js CHANGED
@@ -123,6 +123,7 @@ var StripeEmbeddedPageUi = class {
123
123
 
124
124
  // src/providers/stripe/ui/form.ts
125
125
  var CHECKOUT_FORM_BETA = "custom_checkout_payment_form_1";
126
+ var EXPRESS_CHECKOUT_SOURCE = "checkout-form-ece";
126
127
  var StripeFormUi = class {
127
128
  constructor(options = {}) {
128
129
  this.options = options;
@@ -178,17 +179,30 @@ var StripeFormUi = class {
178
179
  }
179
180
  return result.actions;
180
181
  }
182
+ async isFormValid(actions) {
183
+ try {
184
+ const validation = await actions.validateElements();
185
+ return validation.type !== "error";
186
+ } catch {
187
+ return true;
188
+ }
189
+ }
181
190
  async confirm(actions, event, host) {
182
- const express = event.source === "checkout-form-ece";
191
+ const express = event.source === EXPRESS_CHECKOUT_SOURCE;
183
192
  const paymentMethodType = express ? void 0 : event.paymentMethodType ?? void 0;
184
- host.confirmed({ paymentMethodType, express });
185
193
  try {
194
+ const attempted = express || await this.isFormValid(actions);
195
+ if (attempted) {
196
+ host.confirmed({ paymentMethodType, express });
197
+ }
186
198
  const result = await actions.confirm({ formConfirmEvent: event, redirect: "if_required" });
187
199
  if (result.type === "error") {
188
- host.paymentFailed(result.error, {
189
- declineCode: result.error.code === "paymentFailed" ? result.error.paymentFailed.declineCode : null,
190
- message: result.error.message
191
- });
200
+ if (result.error.code === "paymentFailed") {
201
+ host.paymentFailed(result.error, {
202
+ declineCode: result.error.paymentFailed.declineCode,
203
+ message: result.error.message
204
+ });
205
+ }
192
206
  return;
193
207
  }
194
208
  host.succeeded(fromSession(result.session));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelfox/payments-sdk",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "dev": "tsup --watch"
22
22
  },
23
23
  "dependencies": {
24
- "@stripe/stripe-js": "^9.1.0"
24
+ "@stripe/stripe-js": "^9.14.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsup": "^8.4.0",