woocommerce / woocommerce-gateway-stripe

The official Stripe Payment Gateway for WooCommerce
https://wordpress.org/plugins/woocommerce-gateway-stripe/
232 stars 204 forks source link

$0/month Subscriptions unable to process on Stripe 7.3 #2607

Closed kaushikasomaiya closed 10 months ago

kaushikasomaiya commented 1 year ago

1) 6243181-zen

User has the following setup:

1) Variable Subs with switching enabled

2) Switch settings: https://d.pr/i/5t5nd5 Full Size: https://d.pr/i/5t5nd5

Issue: When we have an active Subscription with $0/month cost (Virtual), upgrading to a paid subscription doesn't work with Stripe: (only occurs when prorating)

https://d.pr/i/q2kqvL Full Size: https://d.pr/i/q2kqvL

parameter_invalid_integer - payment_method_options[card][mandate_options][amount] This value must be greater than or equal to 1.

Able to replicate on my test site.

{
  "capture_method": "automatic",
  "description": "Woo Site Generator - Order 15",
  "payment_method_options": {
    "card": {
      "mandate_options": {
        "start_date": "1682753385",
        "amount_type": "fixed",
        "interval": "month",
        "interval_count": "1",
        "reference": "15",
        "supported_types": {
          "0": "india"
        },
        "amount": "0"
      }
    }
  },
  "metadata": {
    "payment_type": "recurring",
    "order_id": "15",
    "site_url": "http://localhost:8888/woogenerator/sites/wp-8559227",
    "customer_email": "xx@woocommerce.com",
    "save_payment_method": "true",
    "customer_name": "Test test"
  },
  "setup_future_usage": "off_session",
  "customer": ["cus_xx"](https://dashboard.stripe.com/test/customers/xx),
  "currency": "usd",
  "payment_method": "pm_xx",
  "amount": "2400",
  "payment_method_types": {
    "0": "card"
  }
}

2) 6253081-zen

Merchant's prepaid subscriptions ($0/month with a signup fee) aren't being processed.

Sorry, we are unable to process your payment at this time. Please retry later.

kaushikasomaiya commented 1 year ago

Affected tickets:

6228375-zen 6214004-zen 6211018-zen 6243181-zen 6253081-zen 6229538-zen

Slack: p1682307961991049-slack-C7U3Y3VMY

kaushikasomaiya commented 1 year ago

With UPI Enabled, the following error pops up:

As per Indian regulations, export transactions require a description. More info here: https://stripe.com/docs/india-exports

designboxuk commented 1 year ago

We're getting the same issue for £0/mo subscriptions with a Sign up fee of xx (we're in the UK).

Where in the past in the mandate_options object, the "amount" key had the correct charge as the value, now the key for amount in the mandate_options object shows as "0" and the correct price shows outside of that object afterwards.

This is why Stripe is throwing the invalid integer code as it can't process a £0 transaction.

What we've also noticed is that this issue only happens with Parent Subscription orders (i.e. when someone first signs up for a subscription). Our recurring charges aren't affected and non-subscription items can be processed just fine too.

It's clear something has changed as none of this was happening before.

mohsinoffline commented 1 year ago

Getting the exact same issue on our site with WooCommerce 7.6.0 and WooCommerce Stripe 7.3.0, I had to downgrade Stripe extension to 7.2.0 to fix the issue. I upgraded WooCommerce Stripe 7.4.0 hoping the issue was resolved, but had to go back to 7.2.0 again.

ChrissiePollock commented 1 year ago

Another ticket: #6271643-zen

nirkons commented 1 year ago

Also happening to me, will downgrade to 7.2.0 as suggested here until solved

solstudioim commented 1 year ago

Reported here as well 6274199-zd-woothemes

dflomin commented 1 year ago

I added the below code to wp-content/plugins/woocommerce-gateway-stripe/includes/compat/trait-wc-stripe-subscriptions.php at line 598 to resolve this issue

        if ($sub_amount === 0)
            return $request;
wyter commented 1 year ago

6271770-zen as well

imodouglas commented 1 year ago

6289100-zen

shevene commented 1 year ago

6288116-zen

rbgly commented 1 year ago

6298103-zen

solstudioim commented 1 year ago

Reported just now here 6313561-zd-woothemes

Brianmitchtay commented 1 year ago

6308172-zen

ricardo commented 1 year ago

I was able to replicate this with a slightly more straightforward setup:

  1. Create a simple subscription with price $0 and add a sign-up fee.
  2. No WC subscriptions switching setup required.

Error log in Stripe dashboard:

parameter_invalid_integer - payment_method_options[card][mandate_options][amount]
This value must be greater than or equal to 1.

The error is logged in Stripe with UPE enabled, but the checkout doesn't fail. At the same time, the checkout fails with UPE disabled.

Error is reproducible both in 7.3.0 and 7.4.0.

Mxchael commented 1 year ago

6300305-zen

Brianmitchtay commented 1 year ago

Marking this is high priority due to the number of affected merchants and how $0 "Free" subscriptions are a relatively common use case.

It seems this issue stems from the mandate functionality added for Indian merchants in 7.3 and how "0" is not a valid mandate amount. For many users this "free tier" subscription is integral to their business model.

Brianmitchtay commented 1 year ago

Same issue in 6315769-zen and 6299029-zen as reported in #2623 which is a duplicate of this issue.

Closing #2623 in favor of this issue (2607)

shevene commented 1 year ago

6234421-zen

jdalen commented 1 year ago

I added the below code to wp-content/plugins/woocommerce-gateway-stripe/includes/compat/trait-wc-stripe-subscriptions.php at line 598 to resolve this issue

      if ($sub_amount === 0)
          return $request;

Has the above solution worked for others?

Has anyone applied the latest Stripe security patch update and still had this issue with $0 subs?

rossviviano commented 1 year ago

6354786-zen

senff commented 1 year ago

6381004-zen

namiokuzono commented 1 year ago

Customer reported the same issue in the case 6393456-zen:

The following is what the user shared with us:

In case of switch the Stripe plugin is using the initial subscription price for the mandate instead of the new subscription price In our case, the initial subscription price is zero You have a sub $0 You switch to a sub $10 The plugin will create an intent of $10 with a mandate of $0 Instead of an intent of $10 with a mandate of $10

To reproduce:

Create a sub at $10 Switch to a sub at $20 The intent will have an amount of $20 but the mandate will be $10

The user implemented the fix and shared it with us:

I just created a fix using the wc_stripe_generate_create_intent_request filter I override the mandate amount $request['payment_method_options']['card']['mandate_options']['amount'] A cleaner way for the WooCommerce team would be welcome ;)

kaushikasomaiya commented 1 year ago

6383640-zen

ryanr14 commented 1 year ago

6407908-zen

danvy commented 1 year ago

I'm facing the same issue. I had to use the wc_stripe_generate_create_intent_request filter to overwrite $request['payment_method_options']['card']['mandate_options']['amount']. An official fix would be welcome.

dreamtooloud commented 1 year ago

6364764-zen

wyter commented 1 year ago

6414081-zen

rossviviano commented 1 year ago

6414868-zen

kgeorgee commented 1 year ago

6466659-zen

Babylon1999 commented 1 year ago

zd-6462028

jtobiesen commented 1 year ago

6479201-zen

wiesenhauss commented 1 year ago

6496437-zen

shevene commented 1 year ago

6361583-zen

shevene commented 1 year ago

6497008-zen

thuautp commented 1 year ago

6499288-zen

rossviviano commented 1 year ago

6518383-zen

wyter commented 1 year ago

6542196-zen

nicdwilson commented 1 year ago

6530210-zen

Critically, in this ticket, the value of the renewal was NOT zero but the value of the mandate is:

2023-07-12T10:16:51+00:00 DEBUG 
====Stripe Version: 7.4.1====
====Start Log====
payment_intents request: Array
(
    [amount] => 49900
    [currency] => eur
    [description] => [REDACTED]
    [metadata] => Array
        (
            [customer_name] => [REDACTED]
            [customer_email] => [REDACTED]
            [order_id] => [REDACTED]
            [site_url] => [REDACTED]
            [payment_type] => recurring
            [save_payment_method] => true
        )

    [capture_method] => automatic
    [payment_method_types] => Array
        (
            [0] => card
        )

    [payment_method] => [REDACTED]
    [setup_future_usage] => off_session
    [customer] => [REDACTED]
    [payment_method_options] => Array
        (
            [card] => Array
                (
                    [mandate_options] => Array
                        (
                            [amount_type] => fixed
                            [interval] => year
                            [interval_count] => 1
                            [amount] => 0
                            [reference] => 126419
                            [start_date] => 1689156990
                            [supported_types] => Array
                                (
                                    [0] => india
                                )

                        )

                )

        )

)

====End Log====

2023-07-12T10:16:52+00:00 DEBUG 
====Stripe Version: 7.4.1====
====Start Log====
Error: stdClass Object
(
    [error] => stdClass Object
        (
            [code] => parameter_invalid_integer
            [doc_url] => https://stripe.com/docs/error-codes/parameter-invalid-integer
            [message] => This value must be greater than or equal to 1.
            [param] => payment_method_options[card][mandate_options][amount]
            [request_log_url] => https://dashboard.stripe.com/[REDACTED]
            [type] => invalid_request_error
        )

)

====End Log====

This means that only the initial setup needs to be for zero for this bug to take effect.

wyter commented 1 year ago

6524770-zen

shevene commented 1 year ago

6556867-zen

lynnjat7 commented 1 year ago

6521080-zen

Mayisha commented 1 year ago

There are 2 PRs for the fix. The ticket was mistakenly closed on the first PR merge. Reopening the issue until the second PR is merged as well.

kgeorgee commented 1 year ago

6612997-zen

lynnjat7 commented 1 year ago

6641918-zen

ChrissiePollock commented 1 year ago

6659215-zen

kgeorgee commented 10 months ago

7224517-zen