@@ -15,8 +15,8 @@ import { DevOnly } from '../../common/DevOnly';
1515import { useCheckoutContext , usePaymentMethods } from '../../contexts' ;
1616import { Box , Button , Col , descriptors , Flex , Form , localizationKeys , Spinner , Text } from '../../customizables' ;
1717import { 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 ' ;
2020import { SubscriptionBadge } from '../Subscriptions/badge' ;
2121
2222type PaymentMethodSource = 'existing' | 'new' ;
@@ -213,10 +213,10 @@ const CheckoutFormElements = () => {
213213const CheckoutFormElementsInternal = ( ) => {
214214 const { checkout } = useCheckout ( ) ;
215215 const { id, totals, isImmediatePlanChange, freeTrialEndsAt } = checkout ;
216- const { data : paymentSources } = usePaymentMethods ( ) ;
216+ const { data : paymentMethods } = usePaymentMethods ( ) ;
217217
218218 const [ paymentMethodSource , setPaymentMethodSource ] = useState < PaymentMethodSource > ( ( ) =>
219- paymentSources . length > 0 || __BUILD_DISABLE_RHC__ ? 'existing' : 'new' ,
219+ paymentMethods . length > 0 || __BUILD_DISABLE_RHC__ ? 'existing' : 'new' ,
220220 ) ;
221221
222222 const showPaymentMethods = isImmediatePlanChange && ( totals . totalDueNow . amount > 0 || ! ! freeTrialEndsAt ) ;
@@ -233,7 +233,7 @@ const CheckoutFormElementsInternal = () => {
233233 >
234234 { __BUILD_DISABLE_RHC__ ? null : (
235235 < >
236- { paymentSources . length > 0 && showPaymentMethods && (
236+ { paymentMethods . length > 0 && showPaymentMethods && (
237237 < SegmentedControl . Root
238238 aria-label = 'Payment method source'
239239 value = { paymentMethodSource }
@@ -255,18 +255,18 @@ const CheckoutFormElementsInternal = () => {
255255 ) }
256256
257257 { paymentMethodSource === 'existing' && (
258- < ExistingPaymentSourceForm
259- paymentSources = { paymentSources }
258+ < ExistingPaymentMethodForm
259+ paymentMethods = { paymentMethods }
260260 totalDueNow = { totals . totalDueNow }
261261 />
262262 ) }
263263
264- { __BUILD_DISABLE_RHC__ ? null : paymentMethodSource === 'new' && < AddPaymentSourceForCheckout /> }
264+ { __BUILD_DISABLE_RHC__ ? null : paymentMethodSource === 'new' && < AddPaymentMethodForCheckout /> }
265265 </ Col >
266266 ) ;
267267} ;
268268
269- export const PayWithTestPaymentSource = ( ) => {
269+ export const PayWithTestPaymentMethod = ( ) => {
270270 const { isLoading } = useCardState ( ) ;
271271 const { payWithTestCard } = useCheckoutMutations ( ) ;
272272
@@ -344,32 +344,32 @@ const useSubmitLabel = () => {
344344 return localizationKeys ( 'commerce.subscribe' ) ;
345345} ;
346346
347- const AddPaymentSourceForCheckout = withCardStateProvider ( ( ) => {
347+ const AddPaymentMethodForCheckout = withCardStateProvider ( ( ) => {
348348 const { addPaymentMethodAndPay } = useCheckoutMutations ( ) ;
349349 const submitLabel = useSubmitLabel ( ) ;
350350 const { checkout } = useCheckout ( ) ;
351351
352352 return (
353- < AddPaymentSource . Root
353+ < AddPaymentMethod . Root
354354 onSuccess = { addPaymentMethodAndPay }
355355 checkout = { checkout }
356356 >
357357 < DevOnly >
358- < PayWithTestPaymentSource />
358+ < PayWithTestPaymentMethod />
359359 </ DevOnly >
360360
361- < AddPaymentSource . FormButton text = { submitLabel } />
362- </ AddPaymentSource . Root >
361+ < AddPaymentMethod . FormButton text = { submitLabel } />
362+ </ AddPaymentMethod . Root >
363363 ) ;
364364} ) ;
365365
366- const ExistingPaymentSourceForm = withCardStateProvider (
366+ const ExistingPaymentMethodForm = withCardStateProvider (
367367 ( {
368368 totalDueNow,
369- paymentSources ,
369+ paymentMethods ,
370370 } : {
371371 totalDueNow : BillingMoneyAmount ;
372- paymentSources : BillingPaymentMethodResource [ ] ;
372+ paymentMethods : BillingPaymentMethodResource [ ] ;
373373 } ) => {
374374 const submitLabel = useSubmitLabel ( ) ;
375375 const { checkout } = useCheckout ( ) ;
@@ -378,22 +378,22 @@ const ExistingPaymentSourceForm = withCardStateProvider(
378378 const { payWithExistingPaymentMethod } = useCheckoutMutations ( ) ;
379379 const card = useCardState ( ) ;
380380 const [ selectedPaymentMethod , setSelectedPaymentMethod ] = useState < BillingPaymentMethodResource | undefined > (
381- paymentMethod || paymentSources . find ( p => p . isDefault ) ,
381+ paymentMethod || paymentMethods . find ( p => p . isDefault ) ,
382382 ) ;
383383
384384 const options = useMemo ( ( ) => {
385- return paymentSources . map ( source => {
385+ return paymentMethods . map ( method => {
386386 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 } ` ;
390390
391391 return {
392- value : source . id ,
392+ value : method . id ,
393393 label,
394394 } ;
395395 } ) ;
396- } , [ paymentSources ] ) ;
396+ } , [ paymentMethods ] ) ;
397397
398398 const showPaymentMethods = isImmediatePlanChange && ( totalDueNow . amount > 0 || ! ! freeTrialEndsAt ) ;
399399
@@ -412,8 +412,8 @@ const ExistingPaymentSourceForm = withCardStateProvider(
412412 options = { options }
413413 value = { selectedPaymentMethod ?. id || null }
414414 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 ) ;
417417 } }
418418 portal
419419 >
@@ -430,7 +430,7 @@ const ExistingPaymentSourceForm = withCardStateProvider(
430430 backgroundColor : t . colors . $colorBackground ,
431431 } ) }
432432 >
433- { selectedPaymentMethod && < PaymentSourceRow paymentSource = { selectedPaymentMethod } /> }
433+ { selectedPaymentMethod && < PaymentMethodRow paymentMethod = { selectedPaymentMethod } /> }
434434 </ SelectButton >
435435 < SelectOptionList
436436 sx = { t => ( {
0 commit comments