#damonzucconi
1 messages · Page 1 of 1 (latest)
Hello! Yes, Payment Intents are low-level payment objects that do not have any concept of line items, discounts, and so on. This short video might help: https://docs.stripe.com/payments/tour#payment-objects
ok so follow up question
to use the payment input you need to use payment intents? is the payment input not the preferred way to collect payment details?
like i need a client secret to use this... the only way to get one is with a payment intent
so if i use this then i can't use coupons?
does that track?
i mean ig uess the answer here is: apply the coupon, get the amount from the invoice, then create the intent using that amount?
or update it, in my case
You can use the Payment Element with the client secret from a Payment Intent created by an Invoice.
But if you're using using Payment Intents by themselves then you need to handle things like discounts and coupons on your end, in your own code.
ok talk me thru this: i have some ui where you select a plan, it has an amount associated with it, at that point i want to display the payment input but also display a coupon input. i need the client secret to initialize the payment element. if a user adds a coupon code: what should i do
this doesnt feel like a particularly exotic ui, right?
The answer depends on a lot of things, but generally speaking you would handle the coupon code UI, your server would calculate the changes, update the associated Payment Intent if you already created it, then you would run code on the frontend to update the Payment Element so it updates based on the changes made to the Payment Intent.
i do not understand though because coupon codes arent supported by payment intents... like how is it that this product has become so complicated?
how is this better from a developer standpoint
im just venting forget this ticket
ill figure it out
ok wait new question! when i create a subscription with a coupon code, the stripe api automatically generates a payment intent for it with the correct amount
an 'incomplete subscription' that is
if i then update the subscription's coupon code, the associated payment intent does NOT get updated
is my understanding of this correct?
I don't think so? Hard to say without seeing an example though.
Backing up a bit, if you want to use high-level features like discounts and coupons, why are you trying to use low-level Payment Intents only?
im not, i simply want to use the payment element
which requires a client secret
which requires a payment intent
here's how im creating a subscription:
Stripe::Subscription.create({
coupon: coupon_code,
customer: payer.external_id,
items: [{ price: price_id }],
payment_behavior: 'default_incomplete',
payment_settings: {/
payment_method_types: ['card'],
save_default_payment_method: 'on_subscription'
},
expand: ['latest_invoice.payment_intent']
})
right so latest_invoice.payment_intent gives me the client secret
i use that to initialize the payment element
so at the point: i cannot update the coupon code
how is it not a bug that the payment intent doesn't update when the subscription is updated? is it the case that a whole new invoice gets created if the amount changes?
Okay, hang on. First off, the Payment Element doesn't require a client secret. It does under some flows, but not all. Have a look here: https://docs.stripe.com/payments/accept-a-payment-deferred
I think that approach would suit your use case a lot better.
which approach are yout alking about
like an error message occurs if you even try to initialize it without a client-secret if it's not in setup mode
Please read through the docs I linked.
See also the associated Stripe.js reference for initializing Elements without a client secret: https://docs.stripe.com/js/elements_object/create_without_intent
ok two take aways i have; ive read these docs multiple times
i need to either collect payment details upfront before checkout
or calculate the amount myself in the payment mode
which no
and there's still a bug in the api afaict
where the payment intent doesnt update
unless ive just misunderstood everything here
If you're seeing errors about a client secret being required then you don't understand the docs I linked you to above. I recommend you follow that guide top to bottom to get an idea of how that flow works, and how you can use Payment Element without a client secret. You can then adapat the approach to your specific needs.
i mean i do understand it and it's making assumptions about the ui; i do not want to use setup or payment mode here
i will simply encode the assumptions you all make about the ui i guess
I want to help, but I'm not sure I follow. What assumptions are you referring to?