John Davidson

PHP Stripe API: one time purchase plus subscription with 3D secure

0 comments
Message:


Hello and nice day to everyone!


We are currently building stripe integration (PHP), but are facing problems regarding the valid approach.


The case is, that our e-commerce has business model, where you are buying some physical good (usually one item per purchase) and the you pick type of support plan for that item (subscription with trial).


Practically, it shall go like:


you pay one-time purchase


you subscribe to support plan with certain trial (30 days)


after 30 days you got charged


So in the same time you pay for the product and sign for subscription with trial period.


It shall be 3D secure protected, so our customers wont be bothered with authentication when trial ends.


Sadly, we didnt figured it out yet :(


What kind of approach shall we use? Thanks for any answer and your time



My Answer:
One possible approach to achieve this is to use Stripe's Payment Intents API along with Subscription API.

Here's a high-level overview of the steps you can take:

1. Create a Payment Intent for the one-time purchase when the customer adds the item to their cart. Make sure to set the `setup_future_usage` parameter to `off_session` to indicate that this payment method can be used for future off-session payments.

2. Once the customer completes the one-time purchase, create a subscription for the support plan with a trial period using the Subscription API. You can set the `trial_end` parameter to 30 days from the current date.

3. After 30 days, Stripe will automatically charge the customer for the subscription using the payment method saved during the one-time purchase. Since the payment method was used in an off-session context, it should be 3D Secure protected.

4. Handle any necessary webhook events to update your system and notify the customer about the successful subscription charge.

This approach allows you to combine a one-time purchase with a subscription and ensure that the payment method is 3D Secure protected when the trial period ends.

I hope this helps! Let me know if you have any further questions.

Rate this post

4 of 5 based on 2917 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us