#wullig

1 messages · Page 1 of 1 (latest)

vapid frigateBOT
topaz lichen
#

Hi
Could you please summarize your latest follow up question ?

loud void
#

Hi, on react-native I'm trying to have a payment sheet that collect the payment method, and then a subscription with a trial is started.

#

I have my payment sheet now and once the payment is inputed, I have this callback clinet side

        paymentMethod,
        shouldSavePaymentMethod,
        intentCreationCallback
    ) ```

So if I understood correctly, now I should call my server and pass the payment method, create a new customer (or fetch an existing one), create a subscription by passing the paymment method, is that it?
topaz lichen
#

Yes

loud void
#

This is my snippet, one thing about the payment method, I should attach it to the customer, right?

            'email' => $email,
            'limit' => 1,
        ])->data;
    

        $customer = $customersList[0] ?? null;

        if (!$customer) {
            $customer = $stripe->customers->create([
                'email' => $email,
            ]);
        }

        $payment_method = $request->input('payment_method');

        $price_id = '1234';
        $subscription = $stripe->subscriptions->create([
            'customer' => $customer->id,
            'items' => [['price' => $price_id]],
            'default_payment_method' => $payment_method->id,
            'trial_period_days' => 3,
        ]);```
#

Or if I leave it like this is fine as well?

topaz lichen
#

How are you collecting the PaymentMethod using SetupIntent ?

loud void
#

Mmh not sure, this is my clinet code to call the payment sheet

            merchantDisplayName: "Example, Inc.",
            intentConfiguration: {
                mode: {
                    amount: 200,
                    currencyCode: "USD",
                },
                confirmHandler: confirmHandler,
            },
            returnURL: "com.myapp.com://stripe-redirect",
        });```
#

And this collects the payment info

topaz lichen
#

I encourage you to use SetupIntent in that case in order to keep the PaymenMethod attached to the customer.

loud void
#

The problem with that is that it's starts the trial immediately. I want to have the payment info first, and then start the subscription with trial

winter field
#

Hi! I'm taking over this thread.

#

In this case start with a SetupIntent, and once it's succeeded create the Susbcription

loud void
#

Which guide do you reccomend to follow?

winter field
#

Speficially for React Native?