Search code examples
ruby-on-railsdelayed-jobstripe-payments

Rails & Stripe: Is it possible to let user pay an amount monthly until they completed the amount?


For example the user needs to pay $2000, and I want to let them pay the $2000 in 5 months, and then complete the payment not charge them anymore.

This is the closes I have came close to, please let me know if this is wrong:

1- Create Subscription plans for the amounts of payment.

2- Creating a delayed job to cancel the subscription after the 5 month.

Will this be risky to do so ?

Thanks,


Solution

  • Yes, that's exactly how you'd want to handle it. To be more detailed...

    First, you'll need to have a web hooks endpoint:

    https://stripe.com/docs/webhooks

    Next, you'll want to subscribe the customer to a plan like normal. We'll notify your site, via the web hooks, of when payments are made on a recurring subscription. Specifically, you'll want to watch for invoice.payment_succeeded events:

    https://stripe.com/docs/api#event_types

    Once a specific customer has hit the right number of payments (which you'll track on your end), you'd then issue a cancel subscription request:

    https://stripe.com/docs/api#cancel_subscription

    Hope that helps! Larry

    PS I work on Support at Stripe.