#carllewisc

1 messages ยท Page 1 of 1 (latest)

strange plazaBOT
sullen rivet
#

Hi ๐Ÿ‘‹

You need to set up the user's payment method for off-session charges. Do you have an example of the setup intent you are using?

minor hedge
#

sure. i will share code than i using

API (Screenshot)

Client (React native SDK)

export function ConfirmPaymentFuture() {
  const user = useSelector(state => state.user.user);

  const {initPaymentSheet, presentPaymentSheet} = useStripe();
  const [loading, setLoading] = useState(false);

  const fetchClientSecret = async () => {
    const response = await raixerApi.setupPaymentSheet(user.stripeCustomerId);

    if (!response.ok) {
      return null;
    }

    const {setupIntent, ephemeralKey, customer} = await response.data;

    return {
      setupIntent,
      ephemeralKey,
      customer,
    };
  };

  const initializePaymentSheet = async () => {
    const {setupIntent, ephemeralKey, customer} = await fetchClientSecret();

    const {error} = await initPaymentSheet({
      merchantDisplayName: 'Example, Inc.',
      customerId: customer,
      customerEphemeralKeySecret: ephemeralKey,
      setupIntentClientSecret: setupIntent,
    });
    if (!error) {
      setLoading(true);
    }
  };

  const openPaymentSheet = async () => {
    const {error} = await presentPaymentSheet();

    if (error) {
      AlertService.error(`Error code: ${error.code}`, error.message);
    } else {
      AlertService.success(
        'Success',
        'Your payment method is successfully set up for future payments!',
      );
    }
  };

  useEffect(() => {
    initializePaymentSheet();
  }, []);

  return (
    <View>
      <Button
        variant="primary"
        disabled={!loading}
        title="Set up"
        onPress={openPaymentSheet}
      />
    </View>
  );
}
sullen rivet
#

The ID would be better

minor hedge
#

should i change something?

sullen rivet
#

You should provide a setup intent ID. It'll start with seti_

minor hedge
#

OK. i understand

seti_1N6yyHBDYIj360H0Up9Pdz2f

#

you can see default payment method (with setup intent) but when i create a subscription status is incomplete.

if user have a default payment method (with setup intent) subscription status should be active, right?

#

you can see usage (off session)

sullen rivet
#

Okay I can see that. And it's set as the Customers default in invoice_settings.default_payment_method

#

Can you share the ID of one of the subscriptions?

minor hedge
#

sure, sub_1N6xkoBDYIj360H09zHePRJ8

strange plazaBOT
hazy frigate
#

๐Ÿ‘‹ Hopping in here since snufkin has to head out

#

give me a minute to catch up

minor hedge
#

Ok.

hazy frigate
#

It looks like you're testing with the 4000000000003220 test card, right?

#

That test card requires 3DS on ALL transactions, even if it has been setup w/ a setup intent

minor hedge
#

That is right, but i have done testing with different cards and always i have same result

hazy frigate
#

Even the 4242 card?

minor hedge
#

yes, like that its

hazy frigate
#

Can you share an example of subscription that was incomplete with the 4242 card?

minor hedge
#

I have deleted the customer with which I was using the card (4242)

#

i going to delete all data and then try it again

hazy frigate
#

You don't have to delete all data if you don't want to - but yeah, try again with the 4242 card

minor hedge
#

OK. I'll tell you in a few minutes if everything was ok

hazy frigate
#

@minor hedge Did you still need help?

strange plazaBOT
minor hedge
#

I think that with the comments that they have told me, it helps me to continue advancing on my side.

thank you so much

#

However, I am going to comment on a scenario that happened to me a few minutes ago.

when creating the first subscription the status was incomplete then it was active

Then I leave more detailed if the scenario repeats itself