@funnelsgrove/runtime 0.11.1 → 0.11.3
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/README.md +51 -0
- package/dist/components/ManageSubscriptionScreen.js +7 -2
- package/dist/runtime/funnel-attribution.js +34 -1
- package/dist/services/api.service.d.ts +28 -104
- package/dist/services/api.service.js +24 -519
- package/dist/services/funnel-sdk/checkout/chargeOneClickPayment.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/chargeOneClickPayment.js +17 -0
- package/dist/services/funnel-sdk/checkout/createHostedCheckoutSession.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/createHostedCheckoutSession.js +9 -0
- package/dist/services/funnel-sdk/checkout/createOneTimeCheckout.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/createOneTimeCheckout.js +18 -0
- package/dist/services/funnel-sdk/checkout/createOneTimePaymentIntent.d.ts +3 -0
- package/dist/services/funnel-sdk/checkout/createOneTimePaymentIntent.js +10 -0
- package/dist/services/funnel-sdk/checkout/createSubscriptionCheckout.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/createSubscriptionCheckout.js +19 -0
- package/dist/services/funnel-sdk/checkout/requests.d.ts +126 -0
- package/dist/services/funnel-sdk/checkout/requests.js +111 -0
- package/dist/services/funnel-sdk/checkout/types.d.ts +183 -0
- package/dist/services/funnel-sdk/checkout/types.js +1 -0
- package/dist/services/funnel-sdk/checkout/updateSubscriptionCheckoutPlan.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/updateSubscriptionCheckoutPlan.js +18 -0
- package/dist/services/funnel-sdk/checkout/verifySubscriptionCheckout.d.ts +2 -0
- package/dist/services/funnel-sdk/checkout/verifySubscriptionCheckout.js +18 -0
- package/dist/services/funnel-sdk/shared/http.d.ts +20 -0
- package/dist/services/funnel-sdk/shared/http.js +65 -0
- package/dist/services/funnel-sdk/shared/runtimeConfig.d.ts +17 -0
- package/dist/services/funnel-sdk/shared/runtimeConfig.js +42 -0
- package/dist/services/funnel-sdk/shared/types.d.ts +9 -0
- package/dist/services/funnel-sdk/shared/types.js +1 -0
- package/dist/services/funnel-sdk/subscriptions/listSubscriptions.d.ts +3 -0
- package/dist/services/funnel-sdk/subscriptions/listSubscriptions.js +17 -0
- package/dist/services/funnel-sdk/subscriptions/types.d.ts +24 -0
- package/dist/services/funnel-sdk/subscriptions/types.js +1 -0
- package/dist/services/funnel-sdk/subscriptions/updateSubscription.d.ts +2 -0
- package/dist/services/funnel-sdk/subscriptions/updateSubscription.js +33 -0
- package/dist/services/funnel-sdk/subscriptions/validator.d.ts +2 -0
- package/dist/services/funnel-sdk/subscriptions/validator.js +15 -0
- package/dist/services/funnel-sdk/uploads/preparePhotoUpload.d.ts +4 -0
- package/dist/services/funnel-sdk/uploads/preparePhotoUpload.js +19 -0
- package/dist/services/funnel-sdk/uploads/types.d.ts +32 -0
- package/dist/services/funnel-sdk/uploads/types.js +1 -0
- package/dist/services/funnel-sdk/uploads/uploadPhoto.d.ts +7 -0
- package/dist/services/funnel-sdk/uploads/uploadPhoto.js +18 -0
- package/dist/services/funnel-sdk/uploads/uploadPhotoFile.d.ts +2 -0
- package/dist/services/funnel-sdk/uploads/uploadPhotoFile.js +26 -0
- package/dist/services/funnel-sdk/users/bootstrapUser.d.ts +3 -0
- package/dist/services/funnel-sdk/users/bootstrapUser.js +15 -0
- package/dist/services/funnel-sdk/users/captureEmail.d.ts +2 -0
- package/dist/services/funnel-sdk/users/captureEmail.js +15 -0
- package/dist/services/funnel-sdk/users/claimUserSubscription.d.ts +3 -0
- package/dist/services/funnel-sdk/users/claimUserSubscription.js +7 -0
- package/dist/services/funnel-sdk/users/getCurrentUser.d.ts +3 -0
- package/dist/services/funnel-sdk/users/getCurrentUser.js +13 -0
- package/dist/services/funnel-sdk/users/getUserSubscriptionStatus.d.ts +3 -0
- package/dist/services/funnel-sdk/users/getUserSubscriptionStatus.js +14 -0
- package/dist/services/funnel-sdk/users/types.d.ts +57 -0
- package/dist/services/funnel-sdk/users/types.js +1 -0
- package/dist/services/funnel-sdk/users/updateFunnelUser.d.ts +3 -0
- package/dist/services/funnel-sdk/users/updateFunnelUser.js +18 -0
- package/dist/services/funnel-sdk.service.d.ts +26 -319
- package/dist/services/funnel-sdk.service.js +38 -456
- package/dist/services/session/bootstrap/bootstrapSession.d.ts +8 -0
- package/dist/services/session/bootstrap/bootstrapSession.js +23 -0
- package/dist/services/session/bootstrap/currentUser.d.ts +1 -0
- package/dist/services/session/bootstrap/currentUser.js +37 -0
- package/dist/services/session/bootstrap/idempotency.d.ts +9 -0
- package/dist/services/session/bootstrap/idempotency.js +97 -0
- package/dist/services/session/bootstrap/requests.d.ts +23 -0
- package/dist/services/session/bootstrap/requests.js +25 -0
- package/dist/services/session/bootstrap/responses.d.ts +3 -0
- package/dist/services/session/bootstrap/responses.js +10 -0
- package/dist/services/session/bootstrap/types.d.ts +11 -0
- package/dist/services/session/bootstrap/types.js +1 -0
- package/dist/services/session/emailCapture/captureEmail.d.ts +8 -0
- package/dist/services/session/emailCapture/captureEmail.js +13 -0
- package/dist/services/session/emailCapture/requests.d.ts +12 -0
- package/dist/services/session/emailCapture/requests.js +6 -0
- package/dist/services/session/emailCapture/responses.d.ts +3 -0
- package/dist/services/session/emailCapture/responses.js +14 -0
- package/dist/services/session/emailCapture/types.d.ts +8 -0
- package/dist/services/session/emailCapture/types.js +1 -0
- package/dist/services/session/emailCapture/validator.d.ts +16 -0
- package/dist/services/session/emailCapture/validator.js +37 -0
- package/dist/services/session/identity.d.ts +6 -0
- package/dist/services/session/identity.js +48 -0
- package/dist/services/session/ping/pingUserContext.d.ts +2 -0
- package/dist/services/session/ping/pingUserContext.js +10 -0
- package/dist/services/session/ping/transport.d.ts +2 -0
- package/dist/services/session/ping/transport.js +41 -0
- package/dist/services/session/shared/values.d.ts +6 -0
- package/dist/services/session/shared/values.js +25 -0
- package/dist/services/session/subscriptions/getManageSubscriptions.d.ts +3 -0
- package/dist/services/session/subscriptions/getManageSubscriptions.js +8 -0
- package/dist/services/session/subscriptions/identity.d.ts +3 -0
- package/dist/services/session/subscriptions/identity.js +8 -0
- package/dist/services/session/subscriptions/types.d.ts +35 -0
- package/dist/services/session/subscriptions/types.js +1 -0
- package/dist/services/session/subscriptions/updateSubscription.d.ts +10 -0
- package/dist/services/session/subscriptions/updateSubscription.js +7 -0
- package/dist/services/session/subscriptions/validator.d.ts +6 -0
- package/dist/services/session/subscriptions/validator.js +13 -0
- package/dist/services/session/uploads/localPhoto.d.ts +2 -0
- package/dist/services/session/uploads/localPhoto.js +10 -0
- package/dist/services/session/uploads/requests.d.ts +10 -0
- package/dist/services/session/uploads/requests.js +7 -0
- package/dist/services/session/uploads/types.d.ts +7 -0
- package/dist/services/session/uploads/types.js +1 -0
- package/dist/services/session/uploads/uploadTempPhoto.d.ts +6 -0
- package/dist/services/session/uploads/uploadTempPhoto.js +13 -0
- package/dist/services/session/uploads/validator.d.ts +3 -0
- package/dist/services/session/uploads/validator.js +12 -0
- package/dist/services/session/users/mappers.d.ts +13 -0
- package/dist/services/session/users/mappers.js +33 -0
- package/dist/services/session/users/requests.d.ts +15 -0
- package/dist/services/session/users/requests.js +8 -0
- package/dist/services/session/users/syncUrlUserAttributes.d.ts +10 -0
- package/dist/services/session/users/syncUrlUserAttributes.js +21 -0
- package/dist/services/session/users/types.d.ts +20 -0
- package/dist/services/session/users/types.js +1 -0
- package/dist/services/session/users/updateUser.d.ts +6 -0
- package/dist/services/session/users/updateUser.js +18 -0
- package/package.json +1 -1
- /package/dist/services/{funnel-sdk-payments.functions.d.ts → funnel-sdk/checkout/selection.d.ts} +0 -0
- /package/dist/services/{funnel-sdk-payments.functions.js → funnel-sdk/checkout/selection.js} +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { FunnelSdkCreateHostedCheckoutSessionInput, FunnelSdkCreateSubscriptionCheckoutInput, FunnelSdkCreateOneTimeCheckoutInput, FunnelSdkUpdateSubscriptionCheckoutPlanInput, FunnelSdkVerifySubscriptionCheckoutInput, FunnelSdkCreateOneTimePaymentIntentInput, FunnelSdkChargeOneClickPaymentInput } from './types.js';
|
|
2
|
+
export declare const toV1HostedCheckoutRequest: (input: FunnelSdkCreateHostedCheckoutSessionInput) => {
|
|
3
|
+
offerSetId: string | null | undefined;
|
|
4
|
+
offerSetKey: string | null | undefined;
|
|
5
|
+
planId: string;
|
|
6
|
+
providerPlanId: string | null | undefined;
|
|
7
|
+
title: string | null | undefined;
|
|
8
|
+
description: string | null | undefined;
|
|
9
|
+
amountCents: number;
|
|
10
|
+
billingInterval: string | null | undefined;
|
|
11
|
+
billingIntervalCount: number | null | undefined;
|
|
12
|
+
couponId: string | null | undefined;
|
|
13
|
+
analyticsMetadata: Record<string, unknown> | null | undefined;
|
|
14
|
+
successUrl: string;
|
|
15
|
+
cancelUrl: string;
|
|
16
|
+
customerEmail: string | null | undefined;
|
|
17
|
+
user_id: string | null | undefined;
|
|
18
|
+
environment: import("../shared/types.js").FunnelSdkRuntimeMode | undefined;
|
|
19
|
+
};
|
|
20
|
+
export declare const toV1SubscriptionCheckoutRequest: (input: FunnelSdkCreateSubscriptionCheckoutInput) => {
|
|
21
|
+
offerSetId: string | null | undefined;
|
|
22
|
+
offerSetKey: string | null | undefined;
|
|
23
|
+
planId: string;
|
|
24
|
+
providerPlanId: string | null | undefined;
|
|
25
|
+
title: string | null | undefined;
|
|
26
|
+
description: string | null | undefined;
|
|
27
|
+
amountCents: number;
|
|
28
|
+
billingInterval: string | null | undefined;
|
|
29
|
+
billingIntervalCount: number | null | undefined;
|
|
30
|
+
followUpProviderPlanId: string | null | undefined;
|
|
31
|
+
followUpPlanTitle: string | null | undefined;
|
|
32
|
+
followUpBillingInterval: string | null | undefined;
|
|
33
|
+
followUpBillingIntervalCount: number | null | undefined;
|
|
34
|
+
introIterations: number | null | undefined;
|
|
35
|
+
couponId: string | null | undefined;
|
|
36
|
+
analyticsMetadata: Record<string, unknown> | null | undefined;
|
|
37
|
+
customerEmail: string | null | undefined;
|
|
38
|
+
returnUrl: string;
|
|
39
|
+
user_id: string | null | undefined;
|
|
40
|
+
anonymousUserId: string | null | undefined;
|
|
41
|
+
idempotencyKey: string | null | undefined;
|
|
42
|
+
environment: import("../shared/types.js").FunnelSdkRuntimeMode | undefined;
|
|
43
|
+
};
|
|
44
|
+
export declare const toV1OneTimeCheckoutRequest: (input: FunnelSdkCreateOneTimeCheckoutInput) => {
|
|
45
|
+
offerSetId: string | null | undefined;
|
|
46
|
+
offerSetKey: string | null | undefined;
|
|
47
|
+
planId: string;
|
|
48
|
+
providerPlanId: string | null | undefined;
|
|
49
|
+
title: string | null | undefined;
|
|
50
|
+
description: string | null | undefined;
|
|
51
|
+
amountCents: number;
|
|
52
|
+
couponId: string | null | undefined;
|
|
53
|
+
analyticsMetadata: Record<string, unknown> | null | undefined;
|
|
54
|
+
customerEmail: string | null | undefined;
|
|
55
|
+
returnUrl: string;
|
|
56
|
+
user_id: string | null | undefined;
|
|
57
|
+
environment: import("../shared/types.js").FunnelSdkRuntimeMode | undefined;
|
|
58
|
+
};
|
|
59
|
+
export declare const toV2SubscriptionPlanUpdateRequest: (input: FunnelSdkUpdateSubscriptionCheckoutPlanInput) => {
|
|
60
|
+
couponId: string | null | undefined;
|
|
61
|
+
analyticsMetadata: Record<string, unknown> | null | undefined;
|
|
62
|
+
environment: import("../shared/types.js").FunnelSdkRuntimeMode | undefined;
|
|
63
|
+
offerSetId: string | undefined;
|
|
64
|
+
paymentProfileId: string | undefined;
|
|
65
|
+
provider: "stripe" | null | undefined;
|
|
66
|
+
providerPlanId: string | undefined;
|
|
67
|
+
planKey: string | undefined;
|
|
68
|
+
runtimeConfigRevisionId: string | undefined;
|
|
69
|
+
};
|
|
70
|
+
export declare const toV1SubscriptionPlanUpdateRequest: (input: FunnelSdkUpdateSubscriptionCheckoutPlanInput) => {
|
|
71
|
+
checkoutSessionId: string;
|
|
72
|
+
offerSetId: string | null | undefined;
|
|
73
|
+
offerSetKey: string | null | undefined;
|
|
74
|
+
planId: string;
|
|
75
|
+
providerPlanId: string | null | undefined;
|
|
76
|
+
title: string | null | undefined;
|
|
77
|
+
description: string | null | undefined;
|
|
78
|
+
amountCents: number;
|
|
79
|
+
billingInterval: string | null | undefined;
|
|
80
|
+
billingIntervalCount: number | null | undefined;
|
|
81
|
+
couponId: string | null | undefined;
|
|
82
|
+
analyticsMetadata: Record<string, unknown> | null | undefined;
|
|
83
|
+
customerEmail: string | null | undefined;
|
|
84
|
+
user_id: string | null | undefined;
|
|
85
|
+
environment: import("../shared/types.js").FunnelSdkRuntimeMode | undefined;
|
|
86
|
+
};
|
|
87
|
+
export declare const toV1SubscriptionCheckoutStatusRequest: (input: FunnelSdkVerifySubscriptionCheckoutInput) => {
|
|
88
|
+
checkoutSessionId: string;
|
|
89
|
+
environment: import("../shared/types.js").FunnelSdkRuntimeMode | undefined;
|
|
90
|
+
};
|
|
91
|
+
export declare const toV1PaymentIntentRequest: (input: FunnelSdkCreateOneTimePaymentIntentInput) => {
|
|
92
|
+
offerSetId: string | null | undefined;
|
|
93
|
+
offerSetKey: string | null | undefined;
|
|
94
|
+
planId: string;
|
|
95
|
+
amountCents: number;
|
|
96
|
+
couponId: string | null | undefined;
|
|
97
|
+
analyticsMetadata: Record<string, unknown> | null | undefined;
|
|
98
|
+
user_id: string | null | undefined;
|
|
99
|
+
environment: import("../shared/types.js").FunnelSdkRuntimeMode | undefined;
|
|
100
|
+
};
|
|
101
|
+
export declare const toV1OneClickPaymentRequest: (input: FunnelSdkChargeOneClickPaymentInput) => {
|
|
102
|
+
planId: string;
|
|
103
|
+
providerPlanId: string | null | undefined;
|
|
104
|
+
amountCents: number;
|
|
105
|
+
currency: string | null | undefined;
|
|
106
|
+
description: string | null | undefined;
|
|
107
|
+
analyticsMetadata: Record<string, unknown> | null | undefined;
|
|
108
|
+
user_id: string | null | undefined;
|
|
109
|
+
stripe_customer_id: string | null | undefined;
|
|
110
|
+
checkoutSessionId: string | null | undefined;
|
|
111
|
+
idempotencyKey: string | null | undefined;
|
|
112
|
+
environment: import("../shared/types.js").FunnelSdkRuntimeMode | undefined;
|
|
113
|
+
};
|
|
114
|
+
export declare const toV2OneClickPaymentRequest: (input: FunnelSdkChargeOneClickPaymentInput) => {
|
|
115
|
+
checkoutSessionId: string;
|
|
116
|
+
userId: string;
|
|
117
|
+
idempotencyKey: string;
|
|
118
|
+
analyticsMetadata: Record<string, unknown> | null | undefined;
|
|
119
|
+
environment: import("../shared/types.js").FunnelSdkRuntimeMode | undefined;
|
|
120
|
+
offerSetId: string | undefined;
|
|
121
|
+
paymentProfileId: string | undefined;
|
|
122
|
+
provider: "stripe" | null | undefined;
|
|
123
|
+
providerPlanId: string | undefined;
|
|
124
|
+
planKey: string | undefined;
|
|
125
|
+
runtimeConfigRevisionId: string | undefined;
|
|
126
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { toV2CheckoutSelection } from './selection.js';
|
|
2
|
+
export const toV1HostedCheckoutRequest = (input) => ({
|
|
3
|
+
offerSetId: input.offerSetId,
|
|
4
|
+
offerSetKey: input.offerSetKey,
|
|
5
|
+
planId: input.planId,
|
|
6
|
+
providerPlanId: input.providerPlanId,
|
|
7
|
+
title: input.title,
|
|
8
|
+
description: input.description,
|
|
9
|
+
amountCents: input.amountCents,
|
|
10
|
+
billingInterval: input.billingInterval,
|
|
11
|
+
billingIntervalCount: input.billingIntervalCount,
|
|
12
|
+
couponId: input.couponId,
|
|
13
|
+
analyticsMetadata: input.analyticsMetadata,
|
|
14
|
+
successUrl: input.successUrl,
|
|
15
|
+
cancelUrl: input.cancelUrl,
|
|
16
|
+
customerEmail: input.customerEmail,
|
|
17
|
+
user_id: input.userId,
|
|
18
|
+
environment: input.environment,
|
|
19
|
+
});
|
|
20
|
+
export const toV1SubscriptionCheckoutRequest = (input) => ({
|
|
21
|
+
offerSetId: input.offerSetId,
|
|
22
|
+
offerSetKey: input.offerSetKey,
|
|
23
|
+
planId: input.planId,
|
|
24
|
+
providerPlanId: input.providerPlanId,
|
|
25
|
+
title: input.title,
|
|
26
|
+
description: input.description,
|
|
27
|
+
amountCents: input.amountCents,
|
|
28
|
+
billingInterval: input.billingInterval,
|
|
29
|
+
billingIntervalCount: input.billingIntervalCount,
|
|
30
|
+
followUpProviderPlanId: input.followUpProviderPlanId,
|
|
31
|
+
followUpPlanTitle: input.followUpPlanTitle,
|
|
32
|
+
followUpBillingInterval: input.followUpBillingInterval,
|
|
33
|
+
followUpBillingIntervalCount: input.followUpBillingIntervalCount,
|
|
34
|
+
introIterations: input.introIterations,
|
|
35
|
+
couponId: input.couponId,
|
|
36
|
+
analyticsMetadata: input.analyticsMetadata,
|
|
37
|
+
customerEmail: input.customerEmail,
|
|
38
|
+
returnUrl: input.returnUrl,
|
|
39
|
+
user_id: input.userId,
|
|
40
|
+
anonymousUserId: input.anonymousUserId,
|
|
41
|
+
idempotencyKey: input.idempotencyKey,
|
|
42
|
+
environment: input.environment,
|
|
43
|
+
});
|
|
44
|
+
export const toV1OneTimeCheckoutRequest = (input) => ({
|
|
45
|
+
offerSetId: input.offerSetId,
|
|
46
|
+
offerSetKey: input.offerSetKey,
|
|
47
|
+
planId: input.planId,
|
|
48
|
+
providerPlanId: input.providerPlanId,
|
|
49
|
+
title: input.title,
|
|
50
|
+
description: input.description,
|
|
51
|
+
amountCents: input.amountCents,
|
|
52
|
+
couponId: input.couponId,
|
|
53
|
+
analyticsMetadata: input.analyticsMetadata,
|
|
54
|
+
customerEmail: input.customerEmail,
|
|
55
|
+
returnUrl: input.returnUrl,
|
|
56
|
+
user_id: input.userId,
|
|
57
|
+
environment: input.environment,
|
|
58
|
+
});
|
|
59
|
+
export const toV2SubscriptionPlanUpdateRequest = (input) => (Object.assign(Object.assign({}, toV2CheckoutSelection(input)), { couponId: input.couponId, analyticsMetadata: input.analyticsMetadata, environment: input.environment }));
|
|
60
|
+
export const toV1SubscriptionPlanUpdateRequest = (input) => ({
|
|
61
|
+
checkoutSessionId: input.checkoutSessionId,
|
|
62
|
+
offerSetId: input.offerSetId,
|
|
63
|
+
offerSetKey: input.offerSetKey,
|
|
64
|
+
planId: input.planId,
|
|
65
|
+
providerPlanId: input.providerPlanId,
|
|
66
|
+
title: input.title,
|
|
67
|
+
description: input.description,
|
|
68
|
+
amountCents: input.amountCents,
|
|
69
|
+
billingInterval: input.billingInterval,
|
|
70
|
+
billingIntervalCount: input.billingIntervalCount,
|
|
71
|
+
couponId: input.couponId,
|
|
72
|
+
analyticsMetadata: input.analyticsMetadata,
|
|
73
|
+
customerEmail: input.customerEmail,
|
|
74
|
+
user_id: input.userId,
|
|
75
|
+
environment: input.environment,
|
|
76
|
+
});
|
|
77
|
+
export const toV1SubscriptionCheckoutStatusRequest = (input) => ({
|
|
78
|
+
checkoutSessionId: input.checkoutSessionId,
|
|
79
|
+
environment: input.environment,
|
|
80
|
+
});
|
|
81
|
+
export const toV1PaymentIntentRequest = (input) => ({
|
|
82
|
+
offerSetId: input.offerSetId,
|
|
83
|
+
offerSetKey: input.offerSetKey,
|
|
84
|
+
planId: input.planId,
|
|
85
|
+
amountCents: input.amountCents,
|
|
86
|
+
couponId: input.couponId,
|
|
87
|
+
analyticsMetadata: input.analyticsMetadata,
|
|
88
|
+
user_id: input.userId,
|
|
89
|
+
environment: input.environment,
|
|
90
|
+
});
|
|
91
|
+
export const toV1OneClickPaymentRequest = (input) => ({
|
|
92
|
+
planId: input.planId,
|
|
93
|
+
providerPlanId: input.providerPlanId,
|
|
94
|
+
amountCents: input.amountCents,
|
|
95
|
+
currency: input.currency,
|
|
96
|
+
description: input.description,
|
|
97
|
+
analyticsMetadata: input.analyticsMetadata,
|
|
98
|
+
user_id: input.userId,
|
|
99
|
+
stripe_customer_id: input.stripeCustomerId,
|
|
100
|
+
checkoutSessionId: input.checkoutSessionId,
|
|
101
|
+
idempotencyKey: input.idempotencyKey,
|
|
102
|
+
environment: input.environment,
|
|
103
|
+
});
|
|
104
|
+
export const toV2OneClickPaymentRequest = (input) => {
|
|
105
|
+
var _a, _b, _c;
|
|
106
|
+
const selection = toV2CheckoutSelection(input);
|
|
107
|
+
if (!((_a = input.checkoutSessionId) === null || _a === void 0 ? void 0 : _a.trim()) || !((_b = input.userId) === null || _b === void 0 ? void 0 : _b.trim()) || !((_c = input.idempotencyKey) === null || _c === void 0 ? void 0 : _c.trim())) {
|
|
108
|
+
throw new Error('V2 one-click requires checkoutSessionId, userId and idempotencyKey');
|
|
109
|
+
}
|
|
110
|
+
return Object.assign(Object.assign({}, selection), { checkoutSessionId: input.checkoutSessionId, userId: input.userId, idempotencyKey: input.idempotencyKey, analyticsMetadata: input.analyticsMetadata, environment: input.environment });
|
|
111
|
+
};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { FunnelSdkRuntimeMode, FunnelSdkRuntimeConfigOverrides } from '../shared/types.js';
|
|
2
|
+
export type FunnelSdkCreateHostedCheckoutSessionInput = {
|
|
3
|
+
planId: string;
|
|
4
|
+
offerSetId?: string | null;
|
|
5
|
+
offerSetKey?: string | null;
|
|
6
|
+
amountCents: number;
|
|
7
|
+
successUrl: string;
|
|
8
|
+
cancelUrl: string;
|
|
9
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
10
|
+
billingInterval?: string | null;
|
|
11
|
+
billingIntervalCount?: number | null;
|
|
12
|
+
couponId?: string | null;
|
|
13
|
+
customerEmail?: string | null;
|
|
14
|
+
description?: string | null;
|
|
15
|
+
environment?: FunnelSdkRuntimeMode;
|
|
16
|
+
providerPlanId?: string | null;
|
|
17
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
18
|
+
title?: string | null;
|
|
19
|
+
userId?: string | null;
|
|
20
|
+
};
|
|
21
|
+
export type FunnelSdkCreateHostedCheckoutSessionResponse = {
|
|
22
|
+
sessionId?: string;
|
|
23
|
+
url: string;
|
|
24
|
+
environment?: FunnelSdkRuntimeMode;
|
|
25
|
+
};
|
|
26
|
+
export type FunnelSdkCreateSubscriptionCheckoutInput = {
|
|
27
|
+
planId: string;
|
|
28
|
+
planKey?: string | null;
|
|
29
|
+
offerSetId?: string | null;
|
|
30
|
+
offerSetKey?: string | null;
|
|
31
|
+
amountCents: number;
|
|
32
|
+
returnUrl: string;
|
|
33
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
34
|
+
billingInterval?: string | null;
|
|
35
|
+
billingIntervalCount?: number | null;
|
|
36
|
+
followUpProviderPlanId?: string | null;
|
|
37
|
+
followUpPlanTitle?: string | null;
|
|
38
|
+
followUpBillingInterval?: string | null;
|
|
39
|
+
followUpBillingIntervalCount?: number | null;
|
|
40
|
+
introIterations?: number | null;
|
|
41
|
+
couponId?: string | null;
|
|
42
|
+
customerEmail?: string | null;
|
|
43
|
+
description?: string | null;
|
|
44
|
+
environment?: FunnelSdkRuntimeMode;
|
|
45
|
+
providerPlanId?: string | null;
|
|
46
|
+
provider?: 'stripe' | null;
|
|
47
|
+
paymentProfileId?: string | null;
|
|
48
|
+
runtimeConfigRevisionId?: string | null;
|
|
49
|
+
anonymousUserId?: string | null;
|
|
50
|
+
idempotencyKey?: string | null;
|
|
51
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
52
|
+
title?: string | null;
|
|
53
|
+
userId?: string | null;
|
|
54
|
+
};
|
|
55
|
+
export type FunnelSdkCreateSubscriptionCheckoutResponse = {
|
|
56
|
+
clientSecret: string;
|
|
57
|
+
checkoutSessionId?: string;
|
|
58
|
+
subscriptionId?: string;
|
|
59
|
+
stripePublishableKey?: string;
|
|
60
|
+
environment?: FunnelSdkRuntimeMode;
|
|
61
|
+
};
|
|
62
|
+
export type FunnelSdkCreateOneTimeCheckoutInput = {
|
|
63
|
+
planId: string;
|
|
64
|
+
planKey?: string | null;
|
|
65
|
+
paymentProfileId?: string | null;
|
|
66
|
+
provider?: 'stripe' | null;
|
|
67
|
+
runtimeConfigRevisionId?: string | null;
|
|
68
|
+
anonymousUserId?: string | null;
|
|
69
|
+
idempotencyKey?: string | null;
|
|
70
|
+
offerSetId?: string | null;
|
|
71
|
+
offerSetKey?: string | null;
|
|
72
|
+
amountCents: number;
|
|
73
|
+
returnUrl: string;
|
|
74
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
75
|
+
couponId?: string | null;
|
|
76
|
+
customerEmail?: string | null;
|
|
77
|
+
description?: string | null;
|
|
78
|
+
environment?: FunnelSdkRuntimeMode;
|
|
79
|
+
providerPlanId?: string | null;
|
|
80
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
81
|
+
title?: string | null;
|
|
82
|
+
userId?: string | null;
|
|
83
|
+
};
|
|
84
|
+
export type FunnelSdkCreateOneTimeCheckoutResponse = {
|
|
85
|
+
clientSecret: string;
|
|
86
|
+
checkoutSessionId?: string;
|
|
87
|
+
stripePublishableKey?: string;
|
|
88
|
+
environment?: FunnelSdkRuntimeMode;
|
|
89
|
+
};
|
|
90
|
+
export type FunnelSdkUpdateSubscriptionCheckoutPlanInput = {
|
|
91
|
+
checkoutSessionId: string;
|
|
92
|
+
planId: string;
|
|
93
|
+
planKey?: string | null;
|
|
94
|
+
offerSetId?: string | null;
|
|
95
|
+
offerSetKey?: string | null;
|
|
96
|
+
amountCents: number;
|
|
97
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
98
|
+
billingInterval?: string | null;
|
|
99
|
+
billingIntervalCount?: number | null;
|
|
100
|
+
followUpProviderPlanId?: string | null;
|
|
101
|
+
followUpPlanTitle?: string | null;
|
|
102
|
+
followUpBillingInterval?: string | null;
|
|
103
|
+
followUpBillingIntervalCount?: number | null;
|
|
104
|
+
introIterations?: number | null;
|
|
105
|
+
couponId?: string | null;
|
|
106
|
+
customerEmail?: string | null;
|
|
107
|
+
description?: string | null;
|
|
108
|
+
environment?: FunnelSdkRuntimeMode;
|
|
109
|
+
providerPlanId?: string | null;
|
|
110
|
+
provider?: 'stripe' | null;
|
|
111
|
+
paymentProfileId?: string | null;
|
|
112
|
+
runtimeConfigRevisionId?: string | null;
|
|
113
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
114
|
+
title?: string | null;
|
|
115
|
+
userId?: string | null;
|
|
116
|
+
};
|
|
117
|
+
export type FunnelSdkUpdateSubscriptionCheckoutPlanResponse = {
|
|
118
|
+
checkoutSessionId: string;
|
|
119
|
+
environment?: FunnelSdkRuntimeMode;
|
|
120
|
+
};
|
|
121
|
+
export type FunnelSdkVerifySubscriptionCheckoutInput = {
|
|
122
|
+
checkoutSessionId: string;
|
|
123
|
+
environment?: FunnelSdkRuntimeMode;
|
|
124
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
125
|
+
};
|
|
126
|
+
export type FunnelSdkVerifySubscriptionCheckoutResponse = {
|
|
127
|
+
checkoutSessionId: string;
|
|
128
|
+
paid: boolean;
|
|
129
|
+
paymentStatus?: string | null;
|
|
130
|
+
status?: string | null;
|
|
131
|
+
environment?: FunnelSdkRuntimeMode;
|
|
132
|
+
analyticsMetadata?: Record<string, unknown>;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* @deprecated Use FunnelSdkCreateOneTimeCheckoutInput for one-time paywall checkout.
|
|
136
|
+
*/
|
|
137
|
+
export type FunnelSdkCreateOneTimePaymentIntentInput = {
|
|
138
|
+
planId: string;
|
|
139
|
+
offerSetId?: string | null;
|
|
140
|
+
offerSetKey?: string | null;
|
|
141
|
+
amountCents: number;
|
|
142
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
143
|
+
couponId?: string | null;
|
|
144
|
+
environment?: FunnelSdkRuntimeMode;
|
|
145
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
146
|
+
userId?: string | null;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated Use FunnelSdkCreateOneTimeCheckoutResponse for one-time paywall checkout.
|
|
150
|
+
*/
|
|
151
|
+
export type FunnelSdkCreateOneTimePaymentIntentResponse = {
|
|
152
|
+
clientSecret: string;
|
|
153
|
+
stripePublishableKey?: string;
|
|
154
|
+
environment?: FunnelSdkRuntimeMode;
|
|
155
|
+
};
|
|
156
|
+
export type FunnelSdkChargeOneClickPaymentInput = {
|
|
157
|
+
planId: string;
|
|
158
|
+
planKey?: string | null;
|
|
159
|
+
offerSetId?: string | null;
|
|
160
|
+
paymentProfileId?: string | null;
|
|
161
|
+
provider?: 'stripe' | null;
|
|
162
|
+
runtimeConfigRevisionId?: string | null;
|
|
163
|
+
providerPlanId?: string | null;
|
|
164
|
+
amountCents: number;
|
|
165
|
+
analyticsMetadata?: Record<string, unknown> | null;
|
|
166
|
+
checkoutSessionId?: string | null;
|
|
167
|
+
currency?: string | null;
|
|
168
|
+
description?: string | null;
|
|
169
|
+
environment?: FunnelSdkRuntimeMode;
|
|
170
|
+
idempotencyKey?: string | null;
|
|
171
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
172
|
+
stripeCustomerId?: string | null;
|
|
173
|
+
userId?: string | null;
|
|
174
|
+
};
|
|
175
|
+
export type FunnelSdkChargeOneClickPaymentResponse = {
|
|
176
|
+
paymentIntentId: string;
|
|
177
|
+
status: string;
|
|
178
|
+
amountCents?: number;
|
|
179
|
+
clientSecret?: string;
|
|
180
|
+
currency?: string;
|
|
181
|
+
environment?: FunnelSdkRuntimeMode;
|
|
182
|
+
stripePublishableKey?: string;
|
|
183
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { FunnelSdkUpdateSubscriptionCheckoutPlanInput, FunnelSdkUpdateSubscriptionCheckoutPlanResponse } from './types.js';
|
|
2
|
+
export declare const updateSubscriptionCheckoutPlan: (input: FunnelSdkUpdateSubscriptionCheckoutPlanInput) => Promise<FunnelSdkUpdateSubscriptionCheckoutPlanResponse>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { toV2SubscriptionPlanUpdateRequest, toV1SubscriptionPlanUpdateRequest } from './requests.js';
|
|
2
|
+
import { postJson, patchJson } from '../shared/http.js';
|
|
3
|
+
import { resolveRuntimeConfig } from '../shared/runtimeConfig.js';
|
|
4
|
+
export const updateSubscriptionCheckoutPlan = async (input) => {
|
|
5
|
+
const { paymentsApiVersion } = resolveRuntimeConfig(input.runtimeConfig);
|
|
6
|
+
if (paymentsApiVersion === 'v2') {
|
|
7
|
+
return patchJson(`/sdk/public/v2/payments/checkout-sessions/${encodeURIComponent(input.checkoutSessionId)}`, {
|
|
8
|
+
runtimeConfig: input.runtimeConfig,
|
|
9
|
+
body: toV2SubscriptionPlanUpdateRequest(input),
|
|
10
|
+
errorMessage: 'Unable to update subscription checkout',
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return postJson('/sdk/public/payments/subscriptions/update-plan', {
|
|
14
|
+
runtimeConfig: input.runtimeConfig,
|
|
15
|
+
body: toV1SubscriptionPlanUpdateRequest(input),
|
|
16
|
+
errorMessage: 'Unable to update subscription checkout',
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { FunnelSdkVerifySubscriptionCheckoutInput, FunnelSdkVerifySubscriptionCheckoutResponse } from './types.js';
|
|
2
|
+
export declare const verifySubscriptionCheckout: (input: FunnelSdkVerifySubscriptionCheckoutInput) => Promise<FunnelSdkVerifySubscriptionCheckoutResponse>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { toV1SubscriptionCheckoutStatusRequest } from './requests.js';
|
|
2
|
+
import { postJson, getJson } from '../shared/http.js';
|
|
3
|
+
import { resolveRuntimeConfig } from '../shared/runtimeConfig.js';
|
|
4
|
+
export const verifySubscriptionCheckout = async (input) => {
|
|
5
|
+
const { funnelId, paymentsApiVersion } = resolveRuntimeConfig(input.runtimeConfig);
|
|
6
|
+
if (paymentsApiVersion === 'v2') {
|
|
7
|
+
return getJson(`/sdk/public/v2/payments/checkout-sessions/${encodeURIComponent(input.checkoutSessionId)}`, {
|
|
8
|
+
runtimeConfig: input.runtimeConfig,
|
|
9
|
+
searchParams: { funnelId },
|
|
10
|
+
errorMessage: 'Unable to verify subscription checkout',
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return postJson('/sdk/public/payments/subscriptions/checkout-session-status', {
|
|
14
|
+
runtimeConfig: input.runtimeConfig,
|
|
15
|
+
body: toV1SubscriptionCheckoutStatusRequest(input),
|
|
16
|
+
errorMessage: 'Unable to verify subscription checkout',
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FunnelSdkRuntimeConfigOverrides } from './types.js';
|
|
2
|
+
type JsonWriteInput = {
|
|
3
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
4
|
+
body?: Record<string, unknown>;
|
|
5
|
+
errorMessage: string;
|
|
6
|
+
includeRuntimeFields?: boolean;
|
|
7
|
+
includePublishableKey?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const getJson: <ResponsePayload>(path: string, input: {
|
|
10
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
11
|
+
searchParams?: Record<string, string | null | undefined>;
|
|
12
|
+
errorMessage: string;
|
|
13
|
+
}) => Promise<ResponsePayload>;
|
|
14
|
+
export declare const postJson: <ResponsePayload>(path: string, input: JsonWriteInput) => Promise<ResponsePayload>;
|
|
15
|
+
export declare const patchJson: <ResponsePayload>(path: string, input: {
|
|
16
|
+
runtimeConfig?: FunnelSdkRuntimeConfigOverrides;
|
|
17
|
+
body?: Record<string, unknown>;
|
|
18
|
+
errorMessage: string;
|
|
19
|
+
}) => Promise<ResponsePayload>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { asTrimmedStringOrNull, removeEmptyFields, buildApiUrl, buildHeaders, withRuntimeFields, } from './runtimeConfig.js';
|
|
2
|
+
const parseErrorMessage = async (response, fallbackMessage) => {
|
|
3
|
+
try {
|
|
4
|
+
const payload = (await response.json());
|
|
5
|
+
const apiError = asTrimmedStringOrNull(payload.error);
|
|
6
|
+
if (apiError) {
|
|
7
|
+
return apiError;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
catch (_a) {
|
|
11
|
+
// ignore JSON parsing errors
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const text = await response.text();
|
|
15
|
+
if (text.trim()) {
|
|
16
|
+
return text;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (_b) {
|
|
20
|
+
// ignore text parsing errors
|
|
21
|
+
}
|
|
22
|
+
return fallbackMessage;
|
|
23
|
+
};
|
|
24
|
+
const readJsonResponse = async (response, fallbackMessage) => {
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error(await parseErrorMessage(response, fallbackMessage));
|
|
27
|
+
}
|
|
28
|
+
return (await response.json());
|
|
29
|
+
};
|
|
30
|
+
export const getJson = async (path, input) => {
|
|
31
|
+
var _a;
|
|
32
|
+
const url = new URL(buildApiUrl(path, input.runtimeConfig));
|
|
33
|
+
for (const [key, value] of Object.entries((_a = input.searchParams) !== null && _a !== void 0 ? _a : {})) {
|
|
34
|
+
const normalizedValue = asTrimmedStringOrNull(value);
|
|
35
|
+
if (normalizedValue) {
|
|
36
|
+
url.searchParams.set(key, normalizedValue);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const response = await fetch(url.toString(), {
|
|
40
|
+
method: 'GET',
|
|
41
|
+
headers: buildHeaders(input.runtimeConfig),
|
|
42
|
+
});
|
|
43
|
+
return readJsonResponse(response, input.errorMessage);
|
|
44
|
+
};
|
|
45
|
+
const writeJson = async (method, path, input) => {
|
|
46
|
+
var _a;
|
|
47
|
+
const response = await fetch(buildApiUrl(path, input.runtimeConfig), {
|
|
48
|
+
method,
|
|
49
|
+
headers: buildHeaders(input.runtimeConfig, {
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
}),
|
|
52
|
+
body: JSON.stringify(input.includeRuntimeFields === false
|
|
53
|
+
? removeEmptyFields((_a = input.body) !== null && _a !== void 0 ? _a : {})
|
|
54
|
+
: withRuntimeFields(input.runtimeConfig, input.body, {
|
|
55
|
+
includePublishableKey: input.includePublishableKey,
|
|
56
|
+
})),
|
|
57
|
+
});
|
|
58
|
+
return readJsonResponse(response, input.errorMessage);
|
|
59
|
+
};
|
|
60
|
+
export const postJson = (path, input) => {
|
|
61
|
+
return writeJson('POST', path, input);
|
|
62
|
+
};
|
|
63
|
+
export const patchJson = async (path, input) => {
|
|
64
|
+
return writeJson('PATCH', path, input);
|
|
65
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FunnelSdkRuntimeConfigOverrides } from './types.js';
|
|
2
|
+
export declare const asTrimmedStringOrNull: (value: unknown) => string | null;
|
|
3
|
+
export declare const removeEmptyFields: (input: Record<string, unknown>) => Record<string, unknown>;
|
|
4
|
+
type ResolvedFunnelSdkRuntimeConfig = {
|
|
5
|
+
apiBaseUrl: string | null;
|
|
6
|
+
funnelId: string | null;
|
|
7
|
+
funnelVersionId: string | null;
|
|
8
|
+
funnelSdkPublishableKey: string | null;
|
|
9
|
+
paymentsApiVersion: 'v1' | 'v2';
|
|
10
|
+
};
|
|
11
|
+
export declare const resolveRuntimeConfig: (runtimeConfig?: FunnelSdkRuntimeConfigOverrides) => ResolvedFunnelSdkRuntimeConfig;
|
|
12
|
+
export declare const buildApiUrl: (path: string, runtimeConfig?: FunnelSdkRuntimeConfigOverrides) => string;
|
|
13
|
+
export declare const buildHeaders: (runtimeConfig?: FunnelSdkRuntimeConfigOverrides, headers?: Record<string, string>) => Record<string, string>;
|
|
14
|
+
export declare const withRuntimeFields: (runtimeConfig?: FunnelSdkRuntimeConfigOverrides, body?: Record<string, unknown>, options?: {
|
|
15
|
+
includePublishableKey?: boolean;
|
|
16
|
+
}) => Record<string, unknown>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { buildMainApiUrl, FUNNEL_ID, FUNNEL_VERSION_ID, FUNNEL_SDK_PUBLISHABLE_KEY, } from '../../runtime-api.config.js';
|
|
2
|
+
import { resolvePreviewPaymentPublishableKey } from '../../public-env.js';
|
|
3
|
+
const trimTrailingSlash = (value) => value.replace(/\/+$/, '');
|
|
4
|
+
const toNormalizedPath = (path) => (path.startsWith('/') ? path : `/${path}`);
|
|
5
|
+
export const asTrimmedStringOrNull = (value) => {
|
|
6
|
+
if (typeof value !== 'string') {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const trimmed = value.trim();
|
|
10
|
+
return trimmed || null;
|
|
11
|
+
};
|
|
12
|
+
export const removeEmptyFields = (input) => {
|
|
13
|
+
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined && value !== null && value !== ''));
|
|
14
|
+
};
|
|
15
|
+
export const resolveRuntimeConfig = (runtimeConfig) => {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
return ({
|
|
18
|
+
apiBaseUrl: asTrimmedStringOrNull(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.apiBaseUrl),
|
|
19
|
+
funnelId: (_a = asTrimmedStringOrNull(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelId)) !== null && _a !== void 0 ? _a : asTrimmedStringOrNull(FUNNEL_ID),
|
|
20
|
+
funnelVersionId: (_b = asTrimmedStringOrNull(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelVersionId)) !== null && _b !== void 0 ? _b : asTrimmedStringOrNull(FUNNEL_VERSION_ID),
|
|
21
|
+
funnelSdkPublishableKey: resolvePreviewPaymentPublishableKey((_c = asTrimmedStringOrNull(runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.funnelSdkPublishableKey)) !== null && _c !== void 0 ? _c : asTrimmedStringOrNull(FUNNEL_SDK_PUBLISHABLE_KEY)) || null,
|
|
22
|
+
paymentsApiVersion: (runtimeConfig === null || runtimeConfig === void 0 ? void 0 : runtimeConfig.paymentsApiVersion) === 'v2' ? 'v2' : 'v1',
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export const buildApiUrl = (path, runtimeConfig) => {
|
|
26
|
+
const { apiBaseUrl } = resolveRuntimeConfig(runtimeConfig);
|
|
27
|
+
if (!apiBaseUrl) {
|
|
28
|
+
return buildMainApiUrl(path);
|
|
29
|
+
}
|
|
30
|
+
return `${trimTrailingSlash(apiBaseUrl)}${toNormalizedPath(path)}`;
|
|
31
|
+
};
|
|
32
|
+
export const buildHeaders = (runtimeConfig, headers) => {
|
|
33
|
+
const { funnelSdkPublishableKey } = resolveRuntimeConfig(runtimeConfig);
|
|
34
|
+
if (!funnelSdkPublishableKey) {
|
|
35
|
+
return Object.assign({}, (headers !== null && headers !== void 0 ? headers : {}));
|
|
36
|
+
}
|
|
37
|
+
return Object.assign({ 'x-sdk-publishable-key': funnelSdkPublishableKey }, (headers !== null && headers !== void 0 ? headers : {}));
|
|
38
|
+
};
|
|
39
|
+
export const withRuntimeFields = (runtimeConfig, body, options) => {
|
|
40
|
+
const { funnelId, funnelVersionId, funnelSdkPublishableKey } = resolveRuntimeConfig(runtimeConfig);
|
|
41
|
+
return removeEmptyFields(Object.assign({ publishableKey: (options === null || options === void 0 ? void 0 : options.includePublishableKey) === false ? undefined : funnelSdkPublishableKey || undefined, funnelId: funnelId || undefined, funnelVersionId: funnelVersionId || undefined }, (body !== null && body !== void 0 ? body : {})));
|
|
42
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type FunnelSdkRuntimeMode = 'test' | 'live';
|
|
2
|
+
export type FunnelSdkRuntimeConfigOverrides = {
|
|
3
|
+
apiBaseUrl?: string | null;
|
|
4
|
+
funnelId?: string | null;
|
|
5
|
+
funnelVersionId?: string | null;
|
|
6
|
+
funnelSdkPublishableKey?: string | null;
|
|
7
|
+
paymentsApiVersion?: 'v1' | 'v2' | null;
|
|
8
|
+
};
|
|
9
|
+
export type FunnelSdkJsonObject = Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FunnelSdkListSubscriptionsInput } from './types.js';
|
|
2
|
+
import type { FunnelSdkJsonObject } from '../shared/types.js';
|
|
3
|
+
export declare const listSubscriptions: <ResponsePayload = FunnelSdkJsonObject>(input?: FunnelSdkListSubscriptionsInput) => Promise<ResponsePayload>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getJson } from '../shared/http.js';
|
|
2
|
+
import { resolveRuntimeConfig } from '../shared/runtimeConfig.js';
|
|
3
|
+
export const listSubscriptions = async (input = {}) => {
|
|
4
|
+
var _a;
|
|
5
|
+
const { funnelId, paymentsApiVersion } = resolveRuntimeConfig(input.runtimeConfig);
|
|
6
|
+
return getJson(paymentsApiVersion === 'v2'
|
|
7
|
+
? '/sdk/public/v2/subscriptions'
|
|
8
|
+
: '/sdk/public/subscriptions', {
|
|
9
|
+
runtimeConfig: input.runtimeConfig,
|
|
10
|
+
searchParams: {
|
|
11
|
+
user_id: input.userId,
|
|
12
|
+
stripe_customer_id: input.stripeCustomerId,
|
|
13
|
+
funnelId: (_a = input.funnelId) !== null && _a !== void 0 ? _a : funnelId,
|
|
14
|
+
},
|
|
15
|
+
errorMessage: 'Failed to load subscriptions',
|
|
16
|
+
});
|
|
17
|
+
};
|