#Farbod

1 messages · Page 1 of 1 (latest)

finite rainBOT
mossy grove
#

Hi there!

tropic tiger
#

Hey

mossy grove
#

Can you give a concrete example of what you are trying to achieve?

tropic tiger
#

yeah let me write in details

#

this is the process:

  1. user visits my site and goes to the booking page
  2. books a tour which they can either pay in total or in installments (I'm creating subcriptionSchedules for installments, the first phase of the schedule will be paid immediately and the second phase has a number of iterations based on the number of installments the user selected)
  3. the user can see their bookings and can choose to pay the remaining installments for the tour immediately from my site.
#

I've tried updating the schedule and creating a new phase

mossy grove
#

So the user can at any time pay the remaining of the installements in one payment?

tropic tiger
#

yeah they can choose a number of installments

#

and it should be paid in one payment

#

I'm creating a new price based on the number of installments the user selected

#
const installmentPrice = await stripe.prices.create({
            unit_amount: number_of_installments * latestPhasePrice.unit_amount,
            currency: 'usd',
            recurring: {
                interval: "month",
                interval_count: 1,
                usage_type: "licensed"
            },
            product_data: {
                name: `interim installment payment for subscription: ${subscriptionID}`
            },
        });

mossy grove
#

When you create the instalment it makes sense to use a subscription schedule. But when the user ask to pay the remaining of what they own you at once, I don't think subscription schedule make sense.
Instead, compute how much the customer need to pay, create a PaymentIntent for this amount, and if it succeeds cancel the subscription.

tropic tiger
#

but how can I track that the payment intent is for that specific subscription?

mossy grove
#

You can use metadata on the PaymentIntent or/and on the Subscription object.

tropic tiger
#

hmm, few extra API calls

#

but I guess it will work

mossy grove
#

The other option could be computing the new price, update the subscription with that new price, and then delete the subscription.

tropic tiger
#

delete the subscription? I didn't quite get this one.

if I could charge the user immediately after changing the phases it would be great :))