Skip to content

Commit 526637f

Browse files
committed
fix invalid fapi param for confirm
1 parent a5b9b8b commit 526637f

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

‎packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,18 @@ const useCheckoutMutations = () => {
161161
card.setIdle();
162162
};
163163

164-
const payWithExistingPaymentSource = (e: React.FormEvent<HTMLFormElement>) => {
164+
const payWithExistingPaymentMethod = (e: React.FormEvent<HTMLFormElement>) => {
165165
e.preventDefault();
166166

167167
const data = new FormData(e.currentTarget);
168-
const paymentMethodId = data.get(HIDDEN_INPUT_NAME) as string;
168+
const paymentSourceId = data.get(HIDDEN_INPUT_NAME) as string;
169169

170170
return confirmCheckout({
171-
paymentMethodId,
171+
paymentSourceId,
172172
});
173173
};
174174

175-
const addPaymentSourceAndPay = (ctx: { gateway: 'stripe'; paymentToken: string }) => confirmCheckout(ctx);
175+
const addPaymentMethodAndPay = (ctx: { gateway: 'stripe'; paymentToken: string }) => confirmCheckout(ctx);
176176

177177
const payWithTestCard = () =>
178178
confirmCheckout({
@@ -181,8 +181,8 @@ const useCheckoutMutations = () => {
181181
});
182182

183183
return {
184-
payWithExistingPaymentSource,
185-
addPaymentSourceAndPay,
184+
payWithExistingPaymentMethod,
185+
addPaymentMethodAndPay,
186186
payWithTestCard,
187187
};
188188
};
@@ -345,13 +345,13 @@ const useSubmitLabel = () => {
345345
};
346346

347347
const AddPaymentSourceForCheckout = withCardStateProvider(() => {
348-
const { addPaymentSourceAndPay } = useCheckoutMutations();
348+
const { addPaymentMethodAndPay } = useCheckoutMutations();
349349
const submitLabel = useSubmitLabel();
350350
const { checkout } = useCheckout();
351351

352352
return (
353353
<AddPaymentSource.Root
354-
onSuccess={addPaymentSourceAndPay}
354+
onSuccess={addPaymentMethodAndPay}
355355
checkout={checkout}
356356
>
357357
<DevOnly>
@@ -375,9 +375,9 @@ const ExistingPaymentSourceForm = withCardStateProvider(
375375
const { checkout } = useCheckout();
376376
const { paymentMethod, isImmediatePlanChange, freeTrialEndsAt } = checkout;
377377

378-
const { payWithExistingPaymentSource } = useCheckoutMutations();
378+
const { payWithExistingPaymentMethod } = useCheckoutMutations();
379379
const card = useCardState();
380-
const [selectedPaymentSource, setSelectedPaymentSource] = useState<BillingPaymentMethodResource | undefined>(
380+
const [selectedPaymentMethod, setSelectedPaymentMethod] = useState<BillingPaymentMethodResource | undefined>(
381381
paymentMethod || paymentSources.find(p => p.isDefault),
382382
);
383383

@@ -399,7 +399,7 @@ const ExistingPaymentSourceForm = withCardStateProvider(
399399

400400
return (
401401
<Form
402-
onSubmit={payWithExistingPaymentSource}
402+
onSubmit={payWithExistingPaymentMethod}
403403
sx={t => ({
404404
display: 'flex',
405405
flexDirection: 'column',
@@ -408,20 +408,20 @@ const ExistingPaymentSourceForm = withCardStateProvider(
408408
>
409409
{showPaymentMethods ? (
410410
<Select
411-
elementId='paymentSource'
411+
elementId='paymentMethod'
412412
options={options}
413-
value={selectedPaymentSource?.id || null}
413+
value={selectedPaymentMethod?.id || null}
414414
onChange={option => {
415415
const paymentSource = paymentSources.find(source => source.id === option.value);
416-
setSelectedPaymentSource(paymentSource);
416+
setSelectedPaymentMethod(paymentSource);
417417
}}
418418
portal
419419
>
420420
{/*Store value inside an input in order to be accessible as form data*/}
421421
<input
422422
name={HIDDEN_INPUT_NAME}
423423
type='hidden'
424-
value={selectedPaymentSource?.id}
424+
value={selectedPaymentMethod?.id}
425425
/>
426426
<SelectButton
427427
icon={ChevronUpDown}
@@ -430,7 +430,7 @@ const ExistingPaymentSourceForm = withCardStateProvider(
430430
backgroundColor: t.colors.$colorBackground,
431431
})}
432432
>
433-
{selectedPaymentSource && <PaymentSourceRow paymentSource={selectedPaymentSource} />}
433+
{selectedPaymentMethod && <PaymentSourceRow paymentSource={selectedPaymentMethod} />}
434434
</SelectButton>
435435
<SelectOptionList
436436
sx={t => ({
@@ -443,7 +443,7 @@ const ExistingPaymentSourceForm = withCardStateProvider(
443443
<input
444444
name={HIDDEN_INPUT_NAME}
445445
type='hidden'
446-
value={selectedPaymentSource?.id}
446+
value={selectedPaymentMethod?.id}
447447
/>
448448
)}
449449
<Card.Alert>{card.error}</Card.Alert>

‎packages/types/src/billing.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,10 +695,10 @@ export type CreateCheckoutParams = WithOptionalOrgType<{
695695
}>;
696696

697697
/**
698-
* The `confirm()` method accepts the following parameters. **Only one of `paymentMethodId`, `paymentToken`, or `useTestCard` should be provided.**
698+
* The `confirm()` method accepts the following parameters. **Only one of `paymentSourceId`, `paymentToken`, or `useTestCard` should be provided.**
699699
*
700700
* @unionReturnHeadings
701-
* ["paymentMethodId", "paymentToken", "useTestCard"]
701+
* ["paymentSourceId", "paymentToken", "useTestCard"]
702702
*
703703
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
704704
*/
@@ -707,7 +707,7 @@ export type ConfirmCheckoutParams =
707707
/**
708708
* The ID of a saved payment source to use for this checkout.
709709
*/
710-
paymentMethodId?: string;
710+
paymentSourceId?: string;
711711
}
712712
| {
713713
/**

0 commit comments

Comments
 (0)