Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
173 stars 69 forks source link

Synchronized Subscriptions Requiring Shipping Can't Be Purchased with Apple Pay #3742

Open billrobbins opened 2 years ago

billrobbins commented 2 years ago

Describe the bug

This is using the main WooCommerce Subscriptions extension and not WooCommerce Payments subscriptions.

If a customer tries to purchase a synchronized subscription that requires shipping with Apple Pay, the transaction will be canceled and an "Invalid recurring shipping method" notice added.

This works as expected for virtual subscription products.

To Reproduce

  1. Enable the WooCommerce Subscriptions extension on a site using WooCommerce Payments.
  2. Create a simple subscription product with "Synchronise renewals" set for a day other than today.
  3. Add the item to the cart and try to pay with Apple Pay.
  4. Notice how the transaction is canceled and the error message appears.

Actual behavior

The payment can not be completed.

Screenshots

apple-pay

invalid-shipping-method

Expected behavior

I expect to be able to purchase a synchronized subscription with Apple Pay.

Desktop (please complete the following information):

Additional context

4741498-zen

haszari commented 2 years ago

Labelling as high priority:

haszari commented 2 years ago

Linking in another issue with payment request and subscriptions. Not sure how related, but likely affecting similar groups of shoppers.

haszari commented 2 years ago

Leaving this at high priority for now, but noting that if this is synchronised subscriptions only then that reduces the impact (as not all stores use that feature).

mattallan commented 2 years ago

This issue came up in woo-devs: p1659001667421639-slack-C7U3Y3VMY

I believe this issue is an oversight and when we added this code which didn't factor in Synced subscriptions as well.

Inside our payment request class we have the code below that specifically doesn't allow Trial Subscriptions with a shipping method to be purchased with Apple Pay and Google Pay, however, I think we should update this function/condition to add some conditions around synchronized subscription purchases.

// Trial subscriptions with shipping are not supported.
if ( class_exists( 'WC_Subscriptions_Product' ) && WC_Subscriptions_Product::is_subscription( $_product ) && $_product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $_product ) > 0 ) {
    return false;
}

(link to code)

I'm not sure what the problems are specifically with physical Trial subscriptions but I'm guessing it has to do with the $0 initial purchase?

If that's the case, we will need to check if the synced subscription is being purchased on the sync date (meaning the checkout will be a non-zero amount and/or check if prorating sync purchases is enabled.

marklifeboxfood commented 2 years ago

Hi team, any chance this bug will meet it's maker before the December period?

marklifeboxfood commented 1 year ago

Hi Team, as an alternative could you please suggest if there is a way to hide the Express Payment options if a certain product type is in the cart / product page? In this case, a Synchronised Subscription product. It would be great to be able to show the button for all the other products on our site, but not show for these products. Right now we have to disable it globally and that's costing us conversions across the board. Thank you so much for your consideration

WildPress commented 1 year ago

Hey @marklifeboxfood this was my workaround to disable it temporarily on the checkout page. I'm sure it can be extended to the cart and product pages with the appropriate filters. Hope it helps!

/**
 * Disable Google Pay and Apple Pay for carts containing XXX
 *
 * Temporary fix for:
 * https://github.com/woocommerce/woocommerce-gateway-stripe/issues/2395
 * https://github.com/Automattic/woocommerce-payments/issues/3742
 */
add_filter( 'wc_stripe_show_payment_request_on_checkout', function ( $should_show_on_checkout_page, $post ) {
    if ( is_checkout() ) {
        $cart = WC()->cart;
        foreach ( $cart->get_cart_contents() as $cart_item ) {
            $product = $cart_item['data'];
            if ( $product === YOUR_FILTER_HERE ) {
                $should_show_on_checkout_page = false;
            }
        }
    }

    return $should_show_on_checkout_page;
}, 10, 2 );
marklifeboxfood commented 1 year ago

Thank you so much for your suggestion, very kind of you to help me out. It worked a charm with product ID's and did I similar for the product pages.

add_filter( 'wc_stripe_hide_payment_request_on_product_page', function( $hide, $post ) { if ( $post->ID === 259133 ) { // Change this to the Product ID that you want to hide return true; } return $hide; }, 10, 2 );

It's a pity there isn't a filter in Stripe for "wc_stripe_show_payment_request_on_CART" which would work in a similar way to the checkout filter... at least I couldn't find a reference to one in https://woocommerce.com/document/stripe/ ... @WildPress could you?

BTW your work on the cocktail society looks great... looks like a very similar setup to the company I run with my partner - hence our shared interest in this issue!

WildPress commented 1 year ago

Nice, glad to hear it! Glad you like the Society website too.

I had a look through the changelog and it appears that these functions may have been deprecated, in favour of the buttons on the settings page. So I guess they aren't meant to be used and may be removed in a future release.

* Tweak - Deprecated the 'wc_stripe_hide_payment_request_on_product_page', 'wc_stripe_show_payment_request_on_checkout', and 'wc_stripe_show_payment_request_on_cart' filters in favor of the UI-driven approach in the plugin settings.

There is this in the codebase though: $should_show_on_cart_page = apply_filters( 'wc_stripe_show_payment_request_on_cart', true ); woocommerce-gateway-stripe/woocommerce-gateway-stripe.php Line 318

So I guess you can use it for the cart page for the time being!

WillBrubaker commented 1 year ago

42108163-hc

pierorocca commented 11 months ago

@bummytime is this something Quark could look at or comment on? This looks to have gone stale despite the high priority label and importance of supporting Apple Pay.

bummytime commented 11 months ago

however, I think we should update this function/condition to add some conditions around synchronized subscription purchases. ... we will need to check if the synced subscription is being purchased on the sync date (meaning the checkout will be a non-zero amount and/or check if prorating sync purchases is enabled.

@diegocurbelo & @mattallan — let's add this one (and perhaps also https://github.com/woocommerce/woocommerce-gateway-stripe/issues/2395) to Quark's backlog.