#Gizmo-payments

1 messages · Page 1 of 1 (latest)

minor dove
#

The only way to do that would be to apply a coupon to the Invoice.

#

if it was me I would use Checkout, in subscription mode, passing the Price IDs of a one time Price and a recurring Price. That does the "charge now and also start a subscription". Checkout supports promotion codes and coupons.

But either way the only option otherwise is you change your order of things, so you only create the Stripe Invoice after you have accepted the coupon details from the customer and know the final amount, that's an option.

subtle prairie
#

Thanks, but right now my checkout page displays the Stripe payment Elements/form on the same page where it displays the price and prompts for a coupon. Wouldn't I not be able to display the Stripe payment elements/form if I didn't already created the invoice and attach it to the invoice's PaymentIntent?

minor dove
#

I don't really understand what you mean but like you can use Checkout this way, as a random example.

subtle prairie
#

Thanks, but we're using the Stripe API to integrate the payment form directly into our website

minor dove
#

any reason you can't use Checkout instead?

#

but ok, then like I said the options are mainly you have to update the Invoice. There is one other option I think

#

that option would be

  • create PaymentIntent for whatever amount you want, including any coupons. For example if it's $50 now and $100 a month, make the PI for $150
  • confirm that
  • when it's completed, start a subscription. Use a trial period set to the next billing date. That way, the first invoice is for $0 so is automatically paid(and you don't have to do anything with it on the frontend), and you've charged the customer and have started a subscription.
subtle prairie
#

Unfortunately switching to Checkout isn't an option at the moment. I've been working on this app for a long time and it took a good while to get it integrated with Stripe. Everything is working now except updating the invoice amount when a coupon is applied, so I'd rather try to solve that than delay launching by who-knows-how-long to switch to Checkout.

#

Let me grok your suggestion.

#

Before I resort to that, I'll share exactly what i'm doing for the subscription case with you and maybe there's an easier way?

#

So, basically, I create a subscription with an invoice item added to it. I use whatever the one-time payment amount is for the unit_amount of the invoice item. I then use $subscription->latest_invoice->payment_intent as the PaymentIntent i render the Stripe payment elements/form with.

Does that change anything or make anything else possible? e.g. updating the unit_amount of the invoice item or something?

minor dove
#

I mean you can't change anything after the invoice is finalized

subtle prairie
#

Does calling create on the subscription finalize the invoice?

minor dove
#

yes

#

so if you want a discount you have to pass it at that point

#

you can use add_invoice_items with a negative amount, to be clear

subtle prairie
#

Got it, but not after create is called on the subscription.

#

In that case, can invoices be deleted so that when a customer enters a coupon in this scenario I can delete their invoice, generate a new invoice with the updated/discounted amount, and render the page using the new invoice's PaymentIntent?

minor dove
#

no, finalised invoices can't be deleted

#

you really need to build this "preview" functionality on your end and the UI for accepting a discount request from the customer and like I said, only call the Stripe API when you know the finalised amount you want

#

that's essentially what Checkout is doing

subtle prairie
#

Got it, thanks. So I would basically collect all of the customer's details, display the price, and allow them to enter a coupon code to adjust the price on the page before rendering the Stripe PaymentIntent, right?

minor dove
#

yep!

subtle prairie
#

Ok, thank you. And since it seems I have to revisit this anyway, what would I need to do in order to leverage Stripe tax? I understand I can't now using PaymentIntents.

#

Also, if a customer doesn't follow through with their payment, if I can't delete the invoice, is there anything I can do to close out an unused invoice?

minor dove
#

oops, missed this

rough sierra
#

👋 taking over for my colleague. Let me know if there's any follow-up Qs I can answer!