@funnelsgrove/payments 0.1.26 → 0.1.27

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.
@@ -30,7 +30,6 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
30
30
  normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelVersionId),
31
31
  normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelSdkPublishableKey),
32
32
  ].join('|');
33
- const analyticsMetadataSignature = JSON.stringify(analyticsMetadata !== null && analyticsMetadata !== void 0 ? analyticsMetadata : {});
34
33
  const configured = enabled &&
35
34
  (isStripeConfigured(checkoutMode) ||
36
35
  Boolean(normalizeRuntimeConfigValue(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelSdkPublishableKey)));
@@ -38,7 +37,6 @@ export function useStripeSubscriptionCheckoutSession({ checkoutMode, analyticsMe
38
37
  'stripe',
39
38
  checkoutMode,
40
39
  runtimeConfigSignature,
41
- analyticsMetadataSignature,
42
40
  (couponId === null || couponId === void 0 ? void 0 : couponId.trim()) || '',
43
41
  returnUrl.trim(),
44
42
  ].join('|');
@@ -65,6 +65,28 @@ type CreatePaymentIntentResponse = {
65
65
  environment?: 'test' | 'live';
66
66
  };
67
67
  export declare function createStripePaymentIntent(input: CreatePaymentIntentInput): Promise<CreatePaymentIntentResponse>;
68
+ type ChargeOneClickPaymentInput = {
69
+ planId: string;
70
+ amountCents: number;
71
+ analyticsMetadata?: Record<string, unknown> | null;
72
+ checkoutSessionId?: string | null;
73
+ currency?: string | null;
74
+ idempotencyKey?: string | null;
75
+ stripe_customer_id?: string | null;
76
+ user_id?: string | null;
77
+ environment?: RuntimeMode;
78
+ runtimeConfig?: StripeRuntimeConfigOverrides;
79
+ };
80
+ type ChargeOneClickPaymentResponse = {
81
+ paymentIntentId: string;
82
+ status: string;
83
+ amountCents?: number;
84
+ clientSecret?: string;
85
+ currency?: string;
86
+ environment?: 'test' | 'live';
87
+ stripePublishableKey?: string;
88
+ };
89
+ export declare function chargeStripeOneClickPayment(input: ChargeOneClickPaymentInput): Promise<ChargeOneClickPaymentResponse>;
68
90
  type CreateSubscriptionCheckoutInput = {
69
91
  plan: CheckoutSessionPlanInput;
70
92
  couponId?: string | null;
@@ -598,6 +598,35 @@ export async function createStripePaymentIntent(input) {
598
598
  }
599
599
  return (await response.json());
600
600
  }
601
+ export async function chargeStripeOneClickPayment(input) {
602
+ var _a, _b, _c, _d, _e;
603
+ const runtimeConfig = resolveStripeRuntimeConfig(input.runtimeConfig);
604
+ const response = await fetch(buildStripeRuntimeApiUrl('/sdk/public/payments/one-click', runtimeConfig), {
605
+ method: 'POST',
606
+ headers: buildStripeRuntimeHeaders(runtimeConfig, {
607
+ 'Content-Type': 'application/json',
608
+ }),
609
+ body: JSON.stringify({
610
+ publishableKey: runtimeConfig.funnelSdkPublishableKey || undefined,
611
+ funnelId: runtimeConfig.funnelId || undefined,
612
+ funnelVersionId: runtimeConfig.funnelVersionId || undefined,
613
+ planId: input.planId,
614
+ amountCents: input.amountCents,
615
+ currency: ((_a = input.currency) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
616
+ analyticsMetadata: normalizeAnalyticsMetadata(input.analyticsMetadata),
617
+ user_id: ((_b = input.user_id) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
618
+ stripe_customer_id: ((_c = input.stripe_customer_id) === null || _c === void 0 ? void 0 : _c.trim()) || undefined,
619
+ checkoutSessionId: ((_d = input.checkoutSessionId) === null || _d === void 0 ? void 0 : _d.trim()) || undefined,
620
+ idempotencyKey: ((_e = input.idempotencyKey) === null || _e === void 0 ? void 0 : _e.trim()) || undefined,
621
+ environment: input.environment || undefined,
622
+ }),
623
+ });
624
+ if (!response.ok) {
625
+ const errorMessage = await parseErrorMessage(response, 'Unable to charge one-click payment');
626
+ throw new Error(errorMessage);
627
+ }
628
+ return (await response.json());
629
+ }
601
630
  export async function createStripeSubscriptionCheckout(input) {
602
631
  var _a, _b, _c, _d, _e;
603
632
  const recurring = resolveCheckoutPlanRecurringConfig(input.plan);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",