#sraka-paymentelement-subscription

1 messages · Page 1 of 1 (latest)

lavish bronzeBOT
unique trellis
#

These are the only API calls we make (first 2 from backend, 3rd one is from Stripe Elements)

#

And this is the latest_invoice.payment_intent that is generated on the POST /v1/subscriptions (subscription creation)

river patrol
#

Hello! Sorry the Discord server is really busy and there isn't much I can do from just pictures. Can you explain how you create the Subscription and how you initialize Stripe.js/PaymentElement exactly (without pictures)

unique trellis
#

Explain as in text or with code?

#

We first create a Stripe customer and then a subscription using

stripe_subscription_data = %{
            customer: stripe_customer_id,
            items: [%{ price: product.stripe_price_id }], # Basic Box price id
            payment_behavior: "default_incomplete",
            payment_settings: %{ save_default_payment_method: "on_subscription" },
            expand: ["latest_invoice.payment_intent"]
          } ||| stripe_discount_payload,```
#

Then we return the client_secret from the expanded latest_invoice.payment_intent and use confirmPayment on Stripe Elements

river patrol
#

How do you initialize Elements client-side exactly

#

sraka-paymentelement-subscription

unique trellis
#
    <Elements stripe={stripePromise} options={{
      mode: 'payment',
      amount: 1800,
      currency: 'eur',
      setup_future_usage: 'off_session',
      setupFutureUsage: 'off_session',
    }}>
      <Checkout />
    </Elements>
#

oh

#

Does mode: 'subscription' make a difference?

#

Just saw it in the docs

#

Whoa, it worked!

#

Thanks for rubber-duckying 😄

#

I do have another question

#

Are those not supported for subscriptions?

river patrol
#

Sorry the server is super busy, but yes that's wht I was getting at. You're using what we call the "defer intent flow" which is newer and usually mapped to developers using automatic payment methods.
Today though this feature (autoPMs) doesn't work for Subscriptions/Invoices just yet, so they have a separate list of enabled payment methods and it makes the overall integration a bit more confusing

#

Honestly in your case you're doing it wrong I think: you already have a Subscription and it has a latest_invoice Invoice that has a PaymentIntent. Really you should be passing that PaymentIntent's client_secret to PaymentElement in this case on initialization

unique trellis
#

But how does the user enter their details then...

#

Isn't the point of this deferral that I don't need a PaymentIntent just to initialise the Elements

#

We have a one step checkout...user enters their email and address and whatnot in the top and then payment info in the bottom and then there's a single "Pay" button

#

Any ideas why Apple Pay is not showing as an available payment method in the Invoice settings list even though we have it in the main payment method settings?

river patrol
#

this is the canonical doc for "I collect payment method upfront and then I confirm the underlying PaymentIntent of my Subscription"
but you do have to be clear about the mode in that case

unique trellis
#

Yes, in that page they specify the mode: subscription and amount, not the clientSecret when init-ing the Elements

river patrol
unique trellis
river patrol
#

Yeah that's normal, it works as a card so it will just work

unique trellis
#

Mkay

#

And then another thing - is PayPal still in beta?

#

I'm not seeing it under available payment methods and we'd really like to integrate with it

river patrol
unique trellis
#

It says
Recurring payments
Requires approval

#

Not unsupported. Does this mean approval from Stripe or PayPal?

river patrol
#

recurring payments require approval from Stripe and are still in beta

unique trellis
#

Okay. Who do we contact?

#

Can you enable them?

river patrol
#

No I can't, and there's a long waiting list, you wouldn't get access now so you should just plan without it. But you'd ask our support team: https://support.stripe.com/contact

unique trellis
#

Okay, thanks

lavish bronzeBOT
unique trellis
#

Hm, it's pretty critical as our entire product offering is subscription based...

river patrol
#

sure but it wouldn't be different from a month ago when Paypal was not public. We want to support it, but it comes with restrictions and it's a small beta right now that's all