#dan-subscription-trial-wallets

1 messages · Page 1 of 1 (latest)

hard forgeBOT
hybrid wharf
#

dan-subscription-trial-wallets

#

Do you have an example transaction where I can have a look at it?

mortal root
#

What info do you need? This is something we only discovered when testing in prod

hybrid wharf
#

Some request id req_123 where the payment happen or something similar? I'm still barely understanding what you describe and how you use our API.
Like if you do Subscriptions and a trial period, there's no PaymentIntent upfront

mortal root
#

I think the PaymentIntent comes into play with the Wallet Elements

hybrid wharf
#

But it shouldn't. If you have a PaymentIntent and confirm it, this really takes a payment upfront

mortal root
#

Okay; gimme just a second (a few convos going on) and I can walk through the process I've setup

#

Okay:

  1. When our custom wallet element first loads, we send the price of the subscription along w/ any extra data to a new backend call we created to create a PaymentIntent and get back a client_secret. Additionally we check if we have/can create a PaymentRequest; we pass that PaymentRequest to the PaymentRequestButtonElement
  2. Now that we have a PaymentRequest, a client_secret, and a visible wallet button, we start listening for changes on the PaymentRequest, specifically paymentmethod. When that event fires, we call stripe.confirmCardPayment with the paymentMethodId passed in from the event and our client_secret. Assuming that works, it returns a PaymentIntent.
  3. We send that paymentMethodId to our backend which completes the process (I can get the details for how we handle this; I can't describe it off the top of my head and this explaination was getting a little long 🙂 )

Generally the process outlined here https://stripe.com/docs/stripe-js/elements/payment-request-button?html-or-react=react

hybrid wharf
#

I'm sorry but I don't get any of this

#

aren't you using Billing at all here?

mortal root
#

Not to my knowledge

hybrid wharf
#

Gotcha, so there's no Subscription, no Invoice, no trial period at all right? What you do is you have your own logic to charge a payment each month or something and you handle the trial period yourself?

mortal root
#

We create the subscription with Stripe.subscriptions.create

items: [{plan: plan.gatewayPlanId}],
trial_from_plan: true,```
#

Not seeing reqIds, but this is a payment ID from a test payment yesterday pm_1M9GvUKDJMRN1di2upI22Z4m

#

(real payment, used while testing)

solar spoke
#

Hey there

#

Stepping in as koopa had to step away

#

Catching up

mortal root
#

👍

solar spoke
#

So to clarify are you creating a separate PaymentIntent or grabbing the client secret from the Subscription's latest_invoice on Subscription creation?

mortal root
#

These would all be for new subscriptions, so we're creating the PaymentIntent. We haven't really worked with PaymentIntents before, so the creation and usage of their client_secret are the only places we use them

solar spoke
#

Okay but you shouldn't be creating a PaymentIntent at all

#

These Subscriptions involve a trial, correct?

mortal root
solar spoke
#

So yeah that guide is only for one-off payments

#

Since you are using Subscriptions, the PaymentIntent (or SetupIntent in the case of a trial) is generated for you

#

So when you create the Subscription, you want to retrieve the latest_invoice.payment_intent.client_secret

#

And pass that to your frontend

#

Then use that with confirmPayment

#

Which you grab the client secret from that to use on the frontend to set up a PaymentMethod for future use with the Sub

mortal root
#

I don't think we create the subscription until all the payment processing stuff is done

#

(we could re-configure, just calling it out)

solar spoke
#

What "payment processing stuff" specifically?

#

If you do want to collect the PaymentMethod ahead of creating the Subsription then you should just be creating a SetupIntent instead of a PaymentIntent to collect the PaymetnMethod from the Payment Request Button

mortal root
#

Yes, I believe this is what we want to do, "PaymetnMethod from the Payment Request Button"

solar spoke
#

Yep okay then create a SetupIntent, not PaymentIntent, and pass the SetupIntent's client secret to the frontend

mortal root
#

Okay. I need to grab lunch and read through those docs. If I have questions later, can I ping you here?

#

(and thanks)

solar spoke
#

Yep we'll be here! I'll likely archive this thread but you can ping again in the main channel

mortal root
#

Perfect. Thanks so much!