wpswings / subscriptions-for-woocommerce

Subscriptions for WooCommerce enables you to provide customers an option for subscribing your products and services to your WooCommerce store. Sell subscriptions for physical and downloadable products. You can avail WooCommerce recurring revenue with a complete subscription plan management. Collect repeated payments by your subscriptions orders.
https://wordpress.org/plugins/subscriptions-for-woocommerce/
GNU General Public License v3.0
6 stars 7 forks source link

Stripe Webhook/Frontend Checkout Fails with Stripe Gateway Plugin for WooCommerce's New Checkout Experience When Total Amount is $0 Due to Free Trial Period #255

Open ydwnj opened 1 month ago

ydwnj commented 1 month ago

Please view my original post in woocommerce/woocommerce-gateway-stripe for more context. It's a : https://github.com/woocommerce/woocommerce-gateway-stripe/issues/3350

Subscriptions for WooCommerce needs an update for free trials to be recognized as payment needed so that Stripe will process the webhook successfully and store the credit card record for auto payment after the trial period.

Original Post: Describe the bug When using the Stripe Gateway plugin for WooCommerce with the Subscriptions for WooCommerce plugin, an issue occurs during checkout if the total amount due is $0 (due to a free trial period). Instead of proceeding to the order confirmation page, the frontend displays a Cannot read properties of undefined (reading 'match') error above the card payment block. This issue does not occur when the total amount due is greater than $0 or when the plugin is set to legacy checkout mode. This issue persists on both live and test mode.

To Reproduce Steps to reproduce the behavior:

  1. Add a subscription product to the cart that includes a free trial period, resulting in a $0 total at checkout.
  2. Go to the checkout page on my WooCommerce site.
  3. Enter payment details using the Stripe payment gateway.
  4. Submit the order.
  5. Observe that the frontend does not redirect to the order confirmation page and instead shows a Cannot read properties of undefined (reading 'match') error above the card payment detail block.
  6. The order is successfully submitted, customer and admin receive the order confirmation email. Subscription is successfully created in the backend. Payment/Order does not show up in Stripe's webhook logs. No errors in console.

Behavior in Legacy Stripe Mode:

  1. Submit the order.
  2. Customer is redirected to Order Confirmation Page and receives a confirmation email. Admin receives "order received" email. Subscription is created in the backend.
  3. Webhook connection successful between WooCommerce and Stripe. A "POST /v1/payment_methods" log is created with customer and order details. Customer is not added in Customer table and order does not show up in Transactions table within Stripe.

Expected behavior After submitting payment details, even if the total amount due is $0, the user is redirected to the order confirmation page upon successful payment processing. Customer's preferred payment method detail is saved in their account and in Stripe. Order triggers confirmation emails for customer and admin. Stripe webhook succeeds.

Screenshots Screenshot 2024-08-10 025451

Environment (please complete the following information):

Additional context I haven't tested if the subscription triggers after the free trial is over. I just set up a product with 1 day free trial, and process a payment every day to see how it triggers and captures the customer data table to charge the card they input. There is no card saved on file on the WooCommerce side for the customer. Will update here when it triggers.