#theuchi-price-change

1 messages · Page 1 of 1 (latest)

runic dagger
#

@high mirage not really, you have to either use a coupon or combine multiple Prices

high mirage
#

Hmmm ok, how about a different approach. I set a "first-time" price on my product in my cart item. Is there a way that, I can create a payment intent to pay for the sub AND the first time payment separately?

#

There is a plugin in Wordpress that does implement the "First time payment" feature, but I just don't know how it is implemented

runic dagger
#

yes and no, there are many different ways to do this

#

The best option is to create a Subscription Schedule really that has 2 phases, one phase for Price A for $10 and then the next phase for Price B for $5

#

Alternatively you could subscribe to Price B for $5 and have a separate Price C that is a one-time $5 set up fee added to the first invoice via add_invoice_items

#

You could also do a $5 Price B with a month trial and have a $10 Price D and add this one via add_invoice_items. There are like 8 to 10 ways of building this and it really depends how you want the flow to behave

high mirage
#

So, this is the workflow I would like to have:

  • Admin creates a product on the webapp
  • The webapp creates a product on Stripe via API
  • Said product is a subscription product that has an "Entry Fee"(one time fee)
  • On the webapp, the admin creates a user
  • The user created gets assigned a product of our choosing.
  • The created user gets login details sent to them
  • The created user now goes through a payment form in which they will enter their payment information
  • They will be billed the monthly fee + "Entry Fee"
  • Later on, it will just be normal monthly fee
#

I am able to do everything, but the "Entry Fee"

hot scaffold
#

Hi @high mirage I'm taking over this thread

#

You can use subscription schedule to automate this process like what koopajah suggests. If this is just one time, you can also consider to listen to the invoice.created event and add the one-time product to the first invoice before finalizing it.

high mirage
#

Hmm so what you are saying is, the moment the subscription is paid, to listen to the webhook of when it is paid, and then make another charge during the webhook event? If so, how would I do that?

hot scaffold
#

No, this shall happen before the payment.

When an invoice for a subscription is created, it's status is draft and you will receive a invoice.created webhook event. You can still edit the invoice by adding the one-time product to it.

You can learn about the invoice lifecycle here https://stripe.com/docs/invoicing/overview#invoice-statuses

Learn more about the basics of Stripe Invoicing.

high mirage
#

Hmmm

#

So what you are saying is, on the payment intent for the subscription, I can add a product to it?

#

If that is the case, could you show me a sample?

#

Sorry if I am asking for too much

hot scaffold
#

You don't edit the PaymentIntent, you edit the invoice.

high mirage
#

Hmmm I see. I was under the impression that, when I want to charge for a subscription, I had to make one be "incomplete", and then that will get me a client_secret that has payment intent

#

So that is why I am a bit confused on how to add the one-time payment

hot scaffold
#

Let me walk you through the steps

  1. Listen to the invoice.created event
  2. In the handler for invoice.created
    a. Call create invoice item API (https://stripe.com/docs/api/invoiceitems/create?lang=curl#create_invoiceitem) to add an item to the invoice, make sure you pass in the invoice id so that this invoice item can be added to the intended invoice
    b. Call this API (https://stripe.com/docs/api/invoices/finalize?lang=curl#finalize_invoice) to finalize invoice
high mirage
#

Perfect, thanks. I assume I will need to add metadata to the invoice(in this case when the subscription invoice is created) so that I can pass that quantity, right? For that "First time" payment, I don't need to create a stripe product, right?

hot scaffold
#

Why do you want to pass quantity to the metadata? you can specify the quantity when creating the invoice item (https://stripe.com/docs/api/invoiceitems/create?lang=php#create_invoiceitem-quantity)

Yes you can use price_data to generate a new inline price (https://stripe.com/docs/api/invoiceitems/create?lang=php#create_invoiceitem-price_data)

high mirage
#

Ah, perfect, that works

#

I will experiment with those, thanks!