Skip to content

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Aug 4, 2025

Fixes STRIPE-240

Changes proposed in this Pull Request:

Our current implementation of the Express Checkout Element does not support free trials for subscriptions. I am adding support for that here.

We are basically checking for free trials on the backend, providing this informantion to the frontend, and changing two payment element parameters based on that:

  • mode: setting it to subscription (docs)
  • paymentMethodCreation: setting it to manual (docs)

Testing instructions

  • Checkout and build this branch on your test environment (add/allow-ece-purchases-for-free-trials)
  • Connect your Stripe account
  • Enable some express payment methods
  • Install the subscriptions extension
  • Create a subscription product with a free trial period
  • As a shopper, access the store using a public-accessible URL
  • Add this subscription to your cart
  • Go to any checkout page
  • Confirm express checkout buttons are shown
  • Confirm you can complete the purchase
  • As a merchant, confirm you can renew the subscription in the WP-Admin

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Changelog entry

  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Comment

Comment

Post merge

@wjrosa wjrosa self-assigned this Aug 4, 2025
@wjrosa wjrosa added the status: blocked The issue is blocked from progressing, waiting for another piece of work to be done. label Aug 5, 2025
@wjrosa wjrosa removed the status: blocked The issue is blocked from progressing, waiting for another piece of work to be done. label Aug 26, 2025
@wjrosa wjrosa marked this pull request as ready for review September 5, 2025 15:17
@wjrosa wjrosa requested review from a team, malithsen and Mayisha and removed request for a team September 5, 2025 15:24
Copy link
Contributor

@Mayisha Mayisha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this long awaiting feature @wjrosa 🎉

I can see the ECE buttons for free trial subscriptions now on product, block cart and block checkout page. I could successfully purchase a free trial subscription using block checkout. However, I do not see the ECE button on classic cart and classic checkout pages. Could you check if this is the same for you?

@@ -1,6 +1,7 @@
*** Changelog ***

= 9.9.0 - xxxx-xx-xx =
* Add - Allow the purchase of free trials using the Express Payment methods when the product does not require shipping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: why is it supported only for the products that do not require shipping? Is there any catch with the shippable products?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am honestly not sure. The original comment was included by you here. I just kept the limitation 😅 . However, maybe it is not needed at all (I can't imagine any reasons why it would be). Original code:

// Don't show if the total price is 0.
		// ToDo: support free trials. Free trials should be supported if the product does not require shipping.
		if ( ( ! ( $this->is_pay_for_order_page() || $this->is_product() ) && 0.0 === (float) WC()->cart->get_total( false ) )
			|| ( $this->is_product() && 0.0 === (float) $this->get_product()->get_price() )
		) {
			return false;
		}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try to remember the reason 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so I don't exactly remember the reason but I remembered following what we have in WooPayments. I found this epic where item 3 says the expected behavior is ECE would be hidden. This epic was created later but there were something in WooPayments that I followed at that time 🤔
Not a blocker for this PR, but we should assess separately if support for shippable products should/can be added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the additional context! Yeah, I think we can tackle this specific rule later. I created STRIPE-715 for that

Copy link
Contributor

@malithsen malithsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I think Mayisha's review captured everything pretty well. This works well on the Blocks checkout. I am not certain how much of an effort it would be to support shortcode, but if we want to ship the current work first, let's update the changelog entry to reflect that.

@wjrosa
Copy link
Contributor Author

wjrosa commented Sep 12, 2025

Thanks for the review, folks! The shortcode checkout should be fixed by ea853ca

@wjrosa wjrosa requested review from malithsen and Mayisha September 12, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants