Skip to content

Commit

Permalink
Pass stripe/configuration directly to assignNewCardProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Dec 16, 2020
1 parent 5b45c33 commit 6040262
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function ChangePaymentMethodList( {
const currentlyAssignedPaymentMethodId = 'existingCard-' + currentPaymentMethod.stored_details_id; // TODO: make this work for paypal.

const translate = useTranslate();
const { isStripeLoading } = useStripe();
const { isStripeLoading, stripe, stripeConfiguration } = useStripe();
const paymentMethods = useAssignablePaymentMethods();

const showErrorMessage = useCallback( ( error ) => {
Expand Down Expand Up @@ -218,7 +218,10 @@ function ChangePaymentMethodList( {
paymentProcessors={ {
'existing-card': ( data ) => assignExistingCardProcessor( purchase, data ),
card: ( data ) =>
assignNewCardProcessor( { purchase, translate, siteSlug, apiParams }, data ),
assignNewCardProcessor(
{ purchase, translate, siteSlug, apiParams, stripe, stripeConfiguration },
data
),
} }
isLoading={ isStripeLoading }
initiallySelectedPaymentMethodId={ currentlyAssignedPaymentMethodId }
Expand Down Expand Up @@ -252,8 +255,8 @@ async function assignExistingCardProcessor( purchase, { storedDetailsId } ) {
}

async function assignNewCardProcessor(
{ purchase, translate, siteSlug, apiParams },
{ stripe, stripeConfiguration, name, countryCode, postalCode }
{ purchase, translate, siteSlug, apiParams, stripe, stripeConfiguration },
{ name, countryCode, postalCode }
) {
const createStripeSetupIntentAsync = async ( paymentDetails ) => {
const { country, 'postal-code': zip } = paymentDetails;
Expand Down

0 comments on commit 6040262

Please sign in to comment.