@funnelsgrove/payments 0.11.9 → 0.11.11
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/providers/solidgate/components/SolidgateCheckoutDialog.js +12 -2
- package/dist/providers/solidgate/services/solidgate.service.d.ts +4 -0
- package/dist/providers/solidgate/services/solidgate.service.js +43 -17
- package/dist/providers/stripe/components/ApplePaySubscriptionCheckoutSlot.js +6 -2
- package/dist/providers/stripe/components/GooglePaySubscriptionCheckoutSlot.js +6 -2
- package/package.json +1 -1
|
@@ -211,14 +211,18 @@ export function SolidgateCheckoutDialog({ open, request, customerEmail, checkout
|
|
|
211
211
|
setCommittedEmail(normalizedCustomerEmail);
|
|
212
212
|
setEmailError(null);
|
|
213
213
|
}, [customerEmail, normalizedCustomerEmail]);
|
|
214
|
-
const { discountKeyOrProviderId, failUrl, funnelPlanKey, funnelEndUserId, funnelId, idempotencyKey, offerSetId, returnUrl, runtimeConfig, successUrl, } = request;
|
|
215
|
-
const { apiBaseUrl, funnelId: runtimeFunnelId, funnelSdkPublishableKey, funnelVersionId, } = runtimeConfig || {};
|
|
214
|
+
const { discountKeyOrProviderId, failUrl, funnelPlanKey, paymentProfileId, providerPlanId, checkoutType, environment, funnelEndUserId, funnelId, idempotencyKey, offerSetId, returnUrl, runtimeConfig, successUrl, } = request;
|
|
215
|
+
const { apiBaseUrl, funnelId: runtimeFunnelId, funnelSdkPublishableKey, funnelVersionId, paymentsApiVersion, } = runtimeConfig || {};
|
|
216
216
|
const hasRuntimeConfig = runtimeConfig !== undefined;
|
|
217
217
|
const normalizedRequest = useMemo(() => ({
|
|
218
218
|
funnelId: (funnelId === null || funnelId === void 0 ? void 0 : funnelId.trim()) || null,
|
|
219
219
|
funnelEndUserId: funnelEndUserId.trim(),
|
|
220
220
|
offerSetId: offerSetId.trim(),
|
|
221
221
|
funnelPlanKey: funnelPlanKey.trim(),
|
|
222
|
+
paymentProfileId: (paymentProfileId === null || paymentProfileId === void 0 ? void 0 : paymentProfileId.trim()) || null,
|
|
223
|
+
providerPlanId: (providerPlanId === null || providerPlanId === void 0 ? void 0 : providerPlanId.trim()) || null,
|
|
224
|
+
checkoutType: checkoutType || null,
|
|
225
|
+
environment: environment || null,
|
|
222
226
|
idempotencyKey: idempotencyKey.trim(),
|
|
223
227
|
discountKeyOrProviderId: (discountKeyOrProviderId === null || discountKeyOrProviderId === void 0 ? void 0 : discountKeyOrProviderId.trim()) || null,
|
|
224
228
|
returnUrl: returnUrl.trim(),
|
|
@@ -229,16 +233,22 @@ export function SolidgateCheckoutDialog({ open, request, customerEmail, checkout
|
|
|
229
233
|
funnelId: (runtimeFunnelId === null || runtimeFunnelId === void 0 ? void 0 : runtimeFunnelId.trim()) || null,
|
|
230
234
|
funnelVersionId: (funnelVersionId === null || funnelVersionId === void 0 ? void 0 : funnelVersionId.trim()) || null,
|
|
231
235
|
funnelSdkPublishableKey: (funnelSdkPublishableKey === null || funnelSdkPublishableKey === void 0 ? void 0 : funnelSdkPublishableKey.trim()) || null,
|
|
236
|
+
paymentsApiVersion: paymentsApiVersion || null,
|
|
232
237
|
} : undefined,
|
|
233
238
|
}), [
|
|
234
239
|
apiBaseUrl,
|
|
235
240
|
discountKeyOrProviderId,
|
|
236
241
|
failUrl,
|
|
237
242
|
funnelPlanKey,
|
|
243
|
+
paymentProfileId,
|
|
244
|
+
providerPlanId,
|
|
245
|
+
checkoutType,
|
|
246
|
+
environment,
|
|
238
247
|
funnelEndUserId,
|
|
239
248
|
funnelId,
|
|
240
249
|
funnelSdkPublishableKey,
|
|
241
250
|
funnelVersionId,
|
|
251
|
+
paymentsApiVersion,
|
|
242
252
|
idempotencyKey,
|
|
243
253
|
offerSetId,
|
|
244
254
|
returnUrl,
|
|
@@ -26,6 +26,10 @@ export type PrepareSolidgateCheckoutInput = {
|
|
|
26
26
|
funnelEndUserId: string;
|
|
27
27
|
offerSetId: string;
|
|
28
28
|
funnelPlanKey: string;
|
|
29
|
+
paymentProfileId?: string | null;
|
|
30
|
+
providerPlanId?: string | null;
|
|
31
|
+
checkoutType?: 'subscription' | 'one_time' | null;
|
|
32
|
+
environment?: 'test' | 'live' | null;
|
|
29
33
|
idempotencyKey: string;
|
|
30
34
|
discountKeyOrProviderId?: string | null;
|
|
31
35
|
returnUrl: string;
|
|
@@ -32,6 +32,18 @@ const postJson = async (path, body, runtimeConfig, signal) => {
|
|
|
32
32
|
}
|
|
33
33
|
return response.json();
|
|
34
34
|
};
|
|
35
|
+
const getJson = async (path, runtimeConfig, signal) => {
|
|
36
|
+
const publishableKey = resolvePublishableKey(runtimeConfig);
|
|
37
|
+
const response = await fetch(resolveApiUrl(path, runtimeConfig), {
|
|
38
|
+
method: 'GET',
|
|
39
|
+
headers: Object.assign({}, (publishableKey ? { 'x-sdk-publishable-key': publishableKey } : {})),
|
|
40
|
+
signal,
|
|
41
|
+
});
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
throw new Error('Solidgate checkout is temporarily unavailable');
|
|
44
|
+
}
|
|
45
|
+
return response.json();
|
|
46
|
+
};
|
|
35
47
|
const isRecord = (value) => (Boolean(value) && typeof value === 'object' && !Array.isArray(value));
|
|
36
48
|
const parsePreparation = (value) => {
|
|
37
49
|
if (!isRecord(value) || !isRecord(value.display) || !isRecord(value.initialization)) {
|
|
@@ -98,26 +110,40 @@ const parseStatus = (value) => {
|
|
|
98
110
|
};
|
|
99
111
|
};
|
|
100
112
|
export const prepareSolidgateCheckout = async (input) => {
|
|
101
|
-
var _a;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
var _a, _b, _c, _d;
|
|
114
|
+
const useV2 = ((_a = input.runtimeConfig) === null || _a === void 0 ? void 0 : _a.paymentsApiVersion) === 'v2';
|
|
115
|
+
const paymentProfileId = ((_b = input.paymentProfileId) === null || _b === void 0 ? void 0 : _b.trim()) || null;
|
|
116
|
+
const providerPlanId = ((_c = input.providerPlanId) === null || _c === void 0 ? void 0 : _c.trim()) || null;
|
|
117
|
+
const checkoutType = input.checkoutType || null;
|
|
118
|
+
const environment = input.environment || null;
|
|
119
|
+
if (useV2 && (!paymentProfileId || !providerPlanId || !checkoutType || !environment)) {
|
|
120
|
+
throw new Error('Solidgate V2 checkout selection is incomplete');
|
|
121
|
+
}
|
|
122
|
+
return parsePreparation(await postJson(useV2
|
|
123
|
+
? '/sdk/public/v2/payments/checkout-sessions'
|
|
124
|
+
: '/sdk/public/payments/solidgate/checkout', Object.assign(Object.assign({}, (useV2 ? {
|
|
125
|
+
checkoutType,
|
|
126
|
+
uiMode: 'custom',
|
|
127
|
+
environment,
|
|
128
|
+
paymentProfileId,
|
|
129
|
+
provider: 'solidgate',
|
|
130
|
+
providerPlanId,
|
|
131
|
+
planKey: requiredString(input.funnelPlanKey, 'funnelPlanKey'),
|
|
132
|
+
} : {})), { funnelId: resolveFunnelId(input.funnelId, input.runtimeConfig), funnelEndUserId: requiredString(input.funnelEndUserId, 'funnelEndUserId'), offerSetId: requiredString(input.offerSetId, 'offerSetId'), funnelPlanKey: requiredString(input.funnelPlanKey, 'funnelPlanKey'), idempotencyKey: requiredString(input.idempotencyKey, 'idempotencyKey'), discountKeyOrProviderId: ((_d = input.discountKeyOrProviderId) === null || _d === void 0 ? void 0 : _d.trim()) || null, returnUrl: requiredString(input.returnUrl, 'returnUrl'), successUrl: requiredString(input.successUrl, 'successUrl'), failUrl: requiredString(input.failUrl, 'failUrl') }), input.runtimeConfig, input.signal));
|
|
113
133
|
};
|
|
114
134
|
export const retrieveSolidgateCheckoutStatus = async (input) => {
|
|
135
|
+
var _a;
|
|
115
136
|
const attemptId = requiredString(input.attemptId, 'attemptId');
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
137
|
+
const useV2 = ((_a = input.runtimeConfig) === null || _a === void 0 ? void 0 : _a.paymentsApiVersion) === 'v2';
|
|
138
|
+
const funnelId = resolveFunnelId(input.funnelId, input.runtimeConfig);
|
|
139
|
+
const funnelEndUserId = requiredString(input.funnelEndUserId, 'funnelEndUserId');
|
|
140
|
+
const result = parseStatus(await (useV2
|
|
141
|
+
? getJson(`/sdk/public/v2/payments/checkout-sessions/${encodeURIComponent(attemptId)}?provider=solidgate&funnelId=${encodeURIComponent(funnelId)}&funnelEndUserId=${encodeURIComponent(funnelEndUserId)}`, input.runtimeConfig, input.signal)
|
|
142
|
+
: postJson('/sdk/public/payments/solidgate/checkout/status', {
|
|
143
|
+
funnelId: resolveFunnelId(input.funnelId, input.runtimeConfig),
|
|
144
|
+
funnelEndUserId,
|
|
145
|
+
attemptId,
|
|
146
|
+
}, input.runtimeConfig, input.signal)));
|
|
121
147
|
if (result.attemptId !== attemptId) {
|
|
122
148
|
throw new Error('Solidgate checkout status returned the wrong attempt');
|
|
123
149
|
}
|
|
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { useMemo } from 'react';
|
|
14
15
|
import { ApplePaySubscribeButton } from './ApplePaySubscribeButton.js';
|
|
15
16
|
import { WalletSubscriptionCheckoutLoadingPlaceholder, WalletSubscriptionCheckoutSlot, } from './WalletSubscriptionCheckoutSlot.js';
|
|
16
17
|
const applePayExpressCheckoutOptions = {
|
|
@@ -42,7 +43,10 @@ const applePayExpressCheckoutOptions = {
|
|
|
42
43
|
* primitive; its checkout session must never be shared across placements.
|
|
43
44
|
*/
|
|
44
45
|
export function ApplePaySubscriptionCheckoutSlot(_a) {
|
|
45
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
46
46
|
var { options, placeholderLabel = 'Subscribe with Apple Pay' } = _a, slotProps = __rest(_a, ["options", "placeholderLabel"]);
|
|
47
|
-
|
|
47
|
+
const expressCheckoutOptions = useMemo(() => {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
49
|
+
return (Object.assign(Object.assign(Object.assign({}, applePayExpressCheckoutOptions), (options !== null && options !== void 0 ? options : {})), { buttonTheme: Object.assign(Object.assign({}, ((_a = applePayExpressCheckoutOptions.buttonTheme) !== null && _a !== void 0 ? _a : {})), ((_b = options === null || options === void 0 ? void 0 : options.buttonTheme) !== null && _b !== void 0 ? _b : {})), buttonType: Object.assign(Object.assign({}, ((_c = applePayExpressCheckoutOptions.buttonType) !== null && _c !== void 0 ? _c : {})), ((_d = options === null || options === void 0 ? void 0 : options.buttonType) !== null && _d !== void 0 ? _d : {})), layout: Object.assign(Object.assign({}, ((_e = applePayExpressCheckoutOptions.layout) !== null && _e !== void 0 ? _e : {})), ((_f = options === null || options === void 0 ? void 0 : options.layout) !== null && _f !== void 0 ? _f : {})), paymentMethods: Object.assign(Object.assign({}, ((_g = applePayExpressCheckoutOptions.paymentMethods) !== null && _g !== void 0 ? _g : {})), ((_h = options === null || options === void 0 ? void 0 : options.paymentMethods) !== null && _h !== void 0 ? _h : {})), paymentMethodOrder: (_j = options === null || options === void 0 ? void 0 : options.paymentMethodOrder) !== null && _j !== void 0 ? _j : applePayExpressCheckoutOptions.paymentMethodOrder }));
|
|
50
|
+
}, [options]);
|
|
51
|
+
return (_jsx(WalletSubscriptionCheckoutSlot, Object.assign({}, slotProps, { availabilityPaymentMethod: 'applePay', options: expressCheckoutOptions, placeholderLabel: placeholderLabel, renderPreparingPlaceholder: (placeholderProps) => (_jsx(WalletSubscriptionCheckoutLoadingPlaceholder, Object.assign({}, placeholderProps, { label: 'Loading Apple Pay' }))), renderPlaceholder: (placeholderProps) => (_jsx(ApplePaySubscribeButton, Object.assign({}, placeholderProps))) })));
|
|
48
52
|
}
|
|
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { useMemo } from 'react';
|
|
14
15
|
import { GooglePaySubscribeButton } from './GooglePaySubscribeButton.js';
|
|
15
16
|
import { WalletSubscriptionCheckoutLoadingPlaceholder, WalletSubscriptionCheckoutSlot, } from './WalletSubscriptionCheckoutSlot.js';
|
|
16
17
|
const googlePayExpressCheckoutOptions = {
|
|
@@ -42,7 +43,10 @@ const googlePayExpressCheckoutOptions = {
|
|
|
42
43
|
* primitive; its checkout session must never be shared across placements.
|
|
43
44
|
*/
|
|
44
45
|
export function GooglePaySubscriptionCheckoutSlot(_a) {
|
|
45
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
46
46
|
var { options, placeholderLabel = 'Subscribe with Google Pay' } = _a, slotProps = __rest(_a, ["options", "placeholderLabel"]);
|
|
47
|
-
|
|
47
|
+
const expressCheckoutOptions = useMemo(() => {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
49
|
+
return (Object.assign(Object.assign(Object.assign({}, googlePayExpressCheckoutOptions), (options !== null && options !== void 0 ? options : {})), { buttonTheme: Object.assign(Object.assign({}, ((_a = googlePayExpressCheckoutOptions.buttonTheme) !== null && _a !== void 0 ? _a : {})), ((_b = options === null || options === void 0 ? void 0 : options.buttonTheme) !== null && _b !== void 0 ? _b : {})), buttonType: Object.assign(Object.assign({}, ((_c = googlePayExpressCheckoutOptions.buttonType) !== null && _c !== void 0 ? _c : {})), ((_d = options === null || options === void 0 ? void 0 : options.buttonType) !== null && _d !== void 0 ? _d : {})), layout: Object.assign(Object.assign({}, ((_e = googlePayExpressCheckoutOptions.layout) !== null && _e !== void 0 ? _e : {})), ((_f = options === null || options === void 0 ? void 0 : options.layout) !== null && _f !== void 0 ? _f : {})), paymentMethods: Object.assign(Object.assign({}, ((_g = googlePayExpressCheckoutOptions.paymentMethods) !== null && _g !== void 0 ? _g : {})), ((_h = options === null || options === void 0 ? void 0 : options.paymentMethods) !== null && _h !== void 0 ? _h : {})), paymentMethodOrder: (_j = options === null || options === void 0 ? void 0 : options.paymentMethodOrder) !== null && _j !== void 0 ? _j : googlePayExpressCheckoutOptions.paymentMethodOrder }));
|
|
50
|
+
}, [options]);
|
|
51
|
+
return (_jsx(WalletSubscriptionCheckoutSlot, Object.assign({}, slotProps, { availabilityPaymentMethod: 'googlePay', options: expressCheckoutOptions, placeholderLabel: placeholderLabel, renderPreparingPlaceholder: (placeholderProps) => (_jsx(WalletSubscriptionCheckoutLoadingPlaceholder, Object.assign({}, placeholderProps, { label: 'Loading Google Pay' }))), renderPlaceholder: (placeholderProps) => (_jsx(GooglePaySubscribeButton, Object.assign({}, placeholderProps))) })));
|
|
48
52
|
}
|