#jesuisilya

1 messages · Page 1 of 1 (latest)

azure smeltBOT
severe spire
#

hi! what's the exact code you're using?

Overall I'm not sure the RN library supports calling that function with a pm_xxx ID directly, but can have a look

abstract scaffold
#
  const createPaymentMethod = async () => {
    const { error, paymentMethod } = await createGooglePayPaymentMethod({
      amount: 0,
      currencyCode: 'GBP',
    });
    if (error) {
      Log.error('Error when creating Google Pay method', error.code, error.message);
    } else if (paymentMethod) {
      Log.debug('Payment Method created successfuly', JSON.stringify(paymentMethod));
      setNewPaymentMethod(paymentMethod);
      await ConfirmSetupIntent();
      }
  };

  const ConfirmSetupIntent = async () => {
    Log.debug('ConfirmSetupIntent', clientSecret, newPaymentMethod);
    const { setupIntent, error } = await confirmSetupIntent(clientSecret, {
      paymentMethodType: 'Card',
      newPaymentMethod,
    });
    if (error) {
      Log.error('Error when confirming setup intent', error);
    } else if (setupIntent) {
      const payload = {
        ...setupIntent,
        ...newPaymentMethod,
      };
      props.addStripeAccountAction(payload);
      Log.debug('Done adding Google Pay method');
      if (fromRoute) {
        navigation.navigate('BookingSummary', {
          newPaymentMethod,
        });
      }
    }
  };
severe spire
#

yeah I think you need to call a specific overload of confirmSetupIntent that take an ID. Let me look.

abstract scaffold
#

Thank you, I've only found others mention this error when using a custom UI component to collect PM, which doesn't really apply to me

severe spire
#

I think it's something like this

const {error} = await confirmSetupIntent(clientSecret, {
          paymentMethodType: 'Card',
          paymentMethodData: {
            paymentMethodId: "pm_xxx", // probably newPaymentMethod.id in your case
          },
        });
abstract scaffold
#

Thank you very much! I'll try this out and let you know if any issues arise

#

Hope you have a good day