Stripe Checkout: setup_future_usage required

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
2 years 11 months ago #144090 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Stripe Checkout: setup_future_usage required
Looks good to me !

Tuan
The following user(s) said Thank You: hide10

Please Log in or Create an account to join the conversation.

  • hide10
  • Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 11 months ago #144114 by hide10
Hello Tuan,

Sorry for bothering you again.

I noticed that the modification I made is also applied to one time payment, and now I understand it is not good because checkout page ask customer for permission for future usage which is not necessary.

Is it possible to configure setup_future_usage respectively as below?

For one time payment:
setup_future_usage = on_session

For recurring payment:
setup_future_usage = off_session


Thank you again for your help.

Please Log in or Create an account to join the conversation.

More
2 years 11 months ago #144118 by Paul Adams
Replied by Paul Adams on topic Stripe Checkout: setup_future_usage required
Hi Tuan,

I understand you're not sure why this is needed but if Stripe is sending out emails saying that this is important. Maybe it's best to make the change. To be honest, I don't understand the ins and outs of how payments are taken or any related code for that matter. That's why I use your service. I guess we will find out soon if it is important or not. However, I run a rather large business and most of the company's revenue comes from this plugin. So, it's a bit concerning what will happen. Maybe the code isn't needed, but maybe it is. I don't think Stripe would send out emails if it wasn't.

Regards,

Paul

Please Log in or Create an account to join the conversation.

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
2 years 11 months ago #144119 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Stripe Checkout: setup_future_usage required
Hi Paul

The reason is that It is unclear to me why the change is needed and so far, it seems only two of you asked for this change. I wonder why Stripe does not send email to other customers? As a large payment gateway and widely used by customers, I don't think they would make big change and only give us a short timeframe like this to implement

So if you want to be sure, please contact them and ask them to see why the change is needed. And if Yes, for one time payment, what should be value to use for setup_future_usage and what would be value for recurring subscription

I offer to make change and email you privately. But when everything is not clear, I could not implement the change into core package to avoid effecting other customers

Tuan

Please Log in or Create an account to join the conversation.

  • hide10
  • Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 11 months ago - 2 years 11 months ago #144121 by hide10
Hi Tuan,

I was assuming that every Stripe Checkout user had received the alert email.
But as you pointed out, possibly it was not sent to everyone.

With that in mind, I have reviewed the email I received once again.
Then one thing came up to my mind about why I received the email.

I'm using Membership Pro for both of one-time and recurring payment.
One of the recurring plan has a Trial period. (Monthly subscription with one-month trial price)

We were experiencing issues every time when trial period ended. (I've reported you about this in Ticket #105800.)
When trial period ended, we expect it to be renewed automatically with a normal price.
However, it was never renewed automatically. Renewal payment fails every time after trial period ended.
Therefore, in order to process the payment, I needed to login to the Stripe dashboard, and find the failed customer.
Then, set the customer's payment method as default, and click on the 'Retry' button to make payment completed.

I guess that when customer make payment for Trial price, it is treated as one-time payment, instead of subscription.
So the payment method will not be saved for future usage.
Probably that's why 2nd payment fails after trial ended.
So, maybe from now on, I cannot use 'Retry' button for failed payment, because it is assumed by Stripe that customer did not agree for future charges. 

I don't know if Paul is experiencing the same or not.
So this is just my guess...

Below is a quote from the email (auto translated from non-English email):

We would like to remind you again of a planned change to Stripe Checkout that may affect your embedding. 
After May 21, 2021, in order to save a payment method for future use, you must include the setup_future_usage argument when creating a Stripe Checkout session. Stripe uses this argument to dynamically optimize the payment flow and ensure compliance with local laws and network rules.    
Your account XXXXXXX was previously billed for a payment method stored using a Stripe Checkout session that did not include the setup_future_usage argument. We strongly recommend that you review your embeds and make any necessary changes prior to the above due date to avoid any issues.    


Tuan, is it possible to treat Trial payment as a part of subscription so that it would be renewed automatically even after Trial period ended?
Or to include 'setup_future_usage = off_session' parameter for Trial payment?

Thanks,
Rika
Last edit: 2 years 11 months ago by hide10. Reason: added the last sentence

Please Log in or Create an account to join the conversation.

More
2 years 11 months ago #144131 by Paul Adams
Replied by Paul Adams on topic Stripe Checkout: setup_future_usage required
Hi Tuan,

I contacted Stipe support and they said the changes were needed. They said:

We are changing the behavior of a property (`setup_future_usage`) on Checkout Sessions which instructs Checkout specifically to save a payment method upon completion of a Checkout Session. Historically, we always save the payment method even if the user does not include `setup_future_usage` but are turning off this behavior and requiring `payment_intent_data.setup_future_usage` in order to save a payment method which can be charged again in the future. Your developer can follow the below API on this

stripe.com/docs/api/checkout/sessions/cr...a-setup_future_usage

I asked is this change really needed. They said:

Yes. So you can save the customer payment method

I pressed them on the values and they said:

The link directly provide you the payment_intent_data.setup_future_usage`, you can setup as on session or off session. all explanation in the link

I really hope that helps and that the plugin can be changed even if it is just for me. Beyond that, I just don't know. I tried to get as much information as I could for you. I opened a ticket with the same information if you think that this needs to be dealt with on a more personal level. Thank you.

Please Log in or Create an account to join the conversation.

  • hide10
  • Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 11 months ago #144178 by hide10
Hello Tuan,

Any thoughts on this issue?

Please Log in or Create an account to join the conversation.

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
2 years 11 months ago #144183 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Stripe Checkout: setup_future_usage required
Hi Paul

Base on what I see, I think it is only needed with recurring subscription which has trial payment amount (for example, when you setup trial duration or when someone uses coupon code for the subscription)

You can open the file components/com_osmembership/plugins/os_stripe.php, find the method processTrialPayment, change the code to:
Code:
$session = \Stripe\Checkout\Session::create([ 'payment_method_types' => $this->params->get('payment_method_types', ['card']), 'line_items' => [[ 'name' => $data['item_name'], 'amount' => $amount, 'currency' => $data['currency'], 'quantity' => 1, ]], 'payment_intent_data' => [ 'setup_future_usage' => 'off_session', ], 'success_url' => $returnUrl, 'cancel_url' => $cancelUrl, 'client_reference_id' => $this->params->get('order_prefix', 'MP') . $row->id, 'customer_email' => $row->email, ]);

I think we should set setup_future_usage to off_session because the payment method will be used for future payment (next recurring payment)

Tuan

Please Log in or Create an account to join the conversation.

  • hide10
  • Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 3 months ago #148629 by hide10
Hi Tuan,

I'm going to update Stripe Checkout plugin to the latest version (2.25.0).
But I noticed that setup_future_usage related codes are not included in the latest file.

We use trial duration for some of the recurring subscription plans.
So I think I need to customize the os_stripe.php file on my own every time the plugin is updated.

Do you have plan to include this code in the distribution file in the future?


Thanks,
Rikao

Please Log in or Create an account to join the conversation.

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
2 years 3 months ago #148630 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Stripe Checkout: setup_future_usage required
Hello Rikao

For now, I think you can manual patch the change. Or if the current payment plugin still works well for you, you do not need to update (unless you want to switch your site to use PHP 8)

Tuan

Please Log in or Create an account to join the conversation.