@@ -15,8 +15,8 @@ import { DevOnly } from '../../common/DevOnly';
15
15
import { useCheckoutContext , usePaymentMethods } from '../../contexts' ;
16
16
import { Box , Button , Col , descriptors , Flex , Form , localizationKeys , Spinner , Text } from '../../customizables' ;
17
17
import { ChevronUpDown , InformationCircle } from '../../icons' ;
18
- import * as AddPaymentSource from '../PaymentSources/AddPaymentSource ' ;
19
- import { PaymentSourceRow } from '../PaymentSources/PaymentSourceRow ' ;
18
+ import * as AddPaymentMethod from '../PaymentMethods/AddPaymentMethod ' ;
19
+ import { PaymentMethodRow } from '../PaymentMethods/PaymentMethodRow ' ;
20
20
import { SubscriptionBadge } from '../Subscriptions/badge' ;
21
21
22
22
type PaymentMethodSource = 'existing' | 'new' ;
@@ -213,10 +213,10 @@ const CheckoutFormElements = () => {
213
213
const CheckoutFormElementsInternal = ( ) => {
214
214
const { checkout } = useCheckout ( ) ;
215
215
const { id, totals, isImmediatePlanChange, freeTrialEndsAt } = checkout ;
216
- const { data : paymentSources } = usePaymentMethods ( ) ;
216
+ const { data : paymentMethods } = usePaymentMethods ( ) ;
217
217
218
218
const [ paymentMethodSource , setPaymentMethodSource ] = useState < PaymentMethodSource > ( ( ) =>
219
- paymentSources . length > 0 || __BUILD_DISABLE_RHC__ ? 'existing' : 'new' ,
219
+ paymentMethods . length > 0 || __BUILD_DISABLE_RHC__ ? 'existing' : 'new' ,
220
220
) ;
221
221
222
222
const showPaymentMethods = isImmediatePlanChange && ( totals . totalDueNow . amount > 0 || ! ! freeTrialEndsAt ) ;
@@ -233,7 +233,7 @@ const CheckoutFormElementsInternal = () => {
233
233
>
234
234
{ __BUILD_DISABLE_RHC__ ? null : (
235
235
< >
236
- { paymentSources . length > 0 && showPaymentMethods && (
236
+ { paymentMethods . length > 0 && showPaymentMethods && (
237
237
< SegmentedControl . Root
238
238
aria-label = 'Payment method source'
239
239
value = { paymentMethodSource }
@@ -255,18 +255,18 @@ const CheckoutFormElementsInternal = () => {
255
255
) }
256
256
257
257
{ paymentMethodSource === 'existing' && (
258
- < ExistingPaymentSourceForm
259
- paymentSources = { paymentSources }
258
+ < ExistingPaymentMethodForm
259
+ paymentMethods = { paymentMethods }
260
260
totalDueNow = { totals . totalDueNow }
261
261
/>
262
262
) }
263
263
264
- { __BUILD_DISABLE_RHC__ ? null : paymentMethodSource === 'new' && < AddPaymentSourceForCheckout /> }
264
+ { __BUILD_DISABLE_RHC__ ? null : paymentMethodSource === 'new' && < AddPaymentMethodForCheckout /> }
265
265
</ Col >
266
266
) ;
267
267
} ;
268
268
269
- export const PayWithTestPaymentSource = ( ) => {
269
+ export const PayWithTestPaymentMethod = ( ) => {
270
270
const { isLoading } = useCardState ( ) ;
271
271
const { payWithTestCard } = useCheckoutMutations ( ) ;
272
272
@@ -344,32 +344,32 @@ const useSubmitLabel = () => {
344
344
return localizationKeys ( 'commerce.subscribe' ) ;
345
345
} ;
346
346
347
- const AddPaymentSourceForCheckout = withCardStateProvider ( ( ) => {
347
+ const AddPaymentMethodForCheckout = withCardStateProvider ( ( ) => {
348
348
const { addPaymentMethodAndPay } = useCheckoutMutations ( ) ;
349
349
const submitLabel = useSubmitLabel ( ) ;
350
350
const { checkout } = useCheckout ( ) ;
351
351
352
352
return (
353
- < AddPaymentSource . Root
353
+ < AddPaymentMethod . Root
354
354
onSuccess = { addPaymentMethodAndPay }
355
355
checkout = { checkout }
356
356
>
357
357
< DevOnly >
358
- < PayWithTestPaymentSource />
358
+ < PayWithTestPaymentMethod />
359
359
</ DevOnly >
360
360
361
- < AddPaymentSource . FormButton text = { submitLabel } />
362
- </ AddPaymentSource . Root >
361
+ < AddPaymentMethod . FormButton text = { submitLabel } />
362
+ </ AddPaymentMethod . Root >
363
363
) ;
364
364
} ) ;
365
365
366
- const ExistingPaymentSourceForm = withCardStateProvider (
366
+ const ExistingPaymentMethodForm = withCardStateProvider (
367
367
( {
368
368
totalDueNow,
369
- paymentSources ,
369
+ paymentMethods ,
370
370
} : {
371
371
totalDueNow : BillingMoneyAmount ;
372
- paymentSources : BillingPaymentMethodResource [ ] ;
372
+ paymentMethods : BillingPaymentMethodResource [ ] ;
373
373
} ) => {
374
374
const submitLabel = useSubmitLabel ( ) ;
375
375
const { checkout } = useCheckout ( ) ;
@@ -378,22 +378,22 @@ const ExistingPaymentSourceForm = withCardStateProvider(
378
378
const { payWithExistingPaymentMethod } = useCheckoutMutations ( ) ;
379
379
const card = useCardState ( ) ;
380
380
const [ selectedPaymentMethod , setSelectedPaymentMethod ] = useState < BillingPaymentMethodResource | undefined > (
381
- paymentMethod || paymentSources . find ( p => p . isDefault ) ,
381
+ paymentMethod || paymentMethods . find ( p => p . isDefault ) ,
382
382
) ;
383
383
384
384
const options = useMemo ( ( ) => {
385
- return paymentSources . map ( source => {
385
+ return paymentMethods . map ( method => {
386
386
const label =
387
- source . paymentType !== 'card'
388
- ? `${ capitalize ( source . paymentType ) } `
389
- : `${ capitalize ( source . cardType ) } ⋯ ${ source . last4 } ` ;
387
+ method . paymentType !== 'card'
388
+ ? `${ capitalize ( method . paymentType ) } `
389
+ : `${ capitalize ( method . cardType ) } ⋯ ${ method . last4 } ` ;
390
390
391
391
return {
392
- value : source . id ,
392
+ value : method . id ,
393
393
label,
394
394
} ;
395
395
} ) ;
396
- } , [ paymentSources ] ) ;
396
+ } , [ paymentMethods ] ) ;
397
397
398
398
const showPaymentMethods = isImmediatePlanChange && ( totalDueNow . amount > 0 || ! ! freeTrialEndsAt ) ;
399
399
@@ -412,8 +412,8 @@ const ExistingPaymentSourceForm = withCardStateProvider(
412
412
options = { options }
413
413
value = { selectedPaymentMethod ?. id || null }
414
414
onChange = { option => {
415
- const paymentSource = paymentSources . find ( source => source . id === option . value ) ;
416
- setSelectedPaymentMethod ( paymentSource ) ;
415
+ const paymentMethod = paymentMethods . find ( source => source . id === option . value ) ;
416
+ setSelectedPaymentMethod ( paymentMethod ) ;
417
417
} }
418
418
portal
419
419
>
@@ -430,7 +430,7 @@ const ExistingPaymentSourceForm = withCardStateProvider(
430
430
backgroundColor : t . colors . $colorBackground ,
431
431
} ) }
432
432
>
433
- { selectedPaymentMethod && < PaymentSourceRow paymentSource = { selectedPaymentMethod } /> }
433
+ { selectedPaymentMethod && < PaymentMethodRow paymentMethod = { selectedPaymentMethod } /> }
434
434
</ SelectButton >
435
435
< SelectOptionList
436
436
sx = { t => ( {
0 commit comments