paytrail / paytrail-for-woocommerce

Paytrail payment service for WooCommerce
MIT License
4 stars 10 forks source link

Payment selection not working on payment method change #165

Open villesiltala opened 3 months ago

villesiltala commented 3 months ago

Describe the bug

With WooCommerce Subscriptions plugin a customer can change the selected payment method after an initial purchase. The payment method selection does not work on the user acocunt page.

Steps to Reproduce

An existing customer can change their selected payment method with the WooCommerce Subscription plugin. The view can be found from my account under the user's subscriptions page. When clicking the "Change payment method" button next to an subscription, the user is taken to a page similar to the checkout page. On a Finnish site, the URL is something as follows:

/kassa/maksa/16212/?pay_for_order=true&key=wc_order_nSBlUcMx7tY3s&change_payment_method=16212&_wpnonce=770b152749

The script used for the toggle functionality of the payment provider groups does not work on the page. It is assumed, the method selection does not work either.

Expected behaviour

The payment provider group selection and payment method selection are visually and functionally comparable to the checkout page.

Actual behaviour

The CSS and JS do not function on the payment method selection page.

kotivuori commented 3 months ago

Hi! Paytrail supports card payments as saved payment methods. Therefore, this page doesn’t display other payment methods like bank or mobile payments, as they can’t be used as saved payment methods.

When you click "Add payment method" are you redirected to Paytrail card form?

villesiltala commented 4 weeks ago

Hi!

I am not sure if I understood the question. The page I am referring to is a generic feature for the Subscriptions plugin where you can change your selected payment method for an existing subscription. Please refer to the official documentation for the feature: https://woocommerce.com/document/subscriptions/customers-view/subscriber-payment-methods/#change-subscription-payment-method

As described in my initial bug report, the only issue in the payment method change view at the moment seems to be that the JS and CSS are not loaded as they are on the checkout page.

kotivuori commented 2 weeks ago

Hi, This is what the page is suppose to look like if you have previously saved cards. Other payment methods are not rendered since they don't support tokenization that is a requirement for subscription payments.

Screenshot 2024-11-06 at 16 01 29
villesiltala commented 2 weeks ago

Hi!

WooCommerce Subscription also supports manual payments. This is also a supported feature in the Paytrail for WooCommerce plugin. If the WooCommerce site is not using card payments and allows manual renewals for subscriptions, the customer can access the payment selection page on their account as described above. This is not be confused with the card payment process.

The same issue is visible also on the payment page where the customer is redirected after an erroneous payment. The following screenshot is taken on a page where the customer is redirected after cancelling the payment. The url is formatted as follows:

/kassa/maksa/xxx/?pay_for_order=true&key=wc_order_xxx&checkout-account=xxx&checkout-algorithm=sha256&checkout-amount=xxx&checkout-stamp=xxx&checkout-reference=xxx&checkout-status=fail&checkout-provider=osuuspankki&checkout-transaction-id=xxx
Screenshot 2024-11-06 at 17 48 24

Here the list of payment providers is not displayed correctly and you can't select a payment method. Again, CSS and JS are not functioning as they are on the regular payment page.

Please look into the enqueue and triggering processes for both the CSS and JS and ensure they work in different payment views used by WooCommerce and the WooCommerce Subscription plugin. Thanks!

villesiltala commented 2 weeks ago

The same view is also reachable from the admin side for orders with a status of "pending payment". In the following screenshot, the link "Asiakkaan maksusivu" takes you to the payment page with broken payment method selection form.

Screenshot 2024-11-06 at 18 06 46
kotivuori commented 2 weeks ago

Thanks for additional details. Manual payment with subscriptions is something we need to look into, since payment method groups are displayed based on checks done at ProviderForm.php https://github.com/paytrail/paytrail-for-woocommerce/blob/d8ea41d1fdacf5f9e8cc40157a6e190cba2effad/src/View/ProviderForm.php#L74 This shouldn't have any affect on cancelled payments or orders created from the admin. In our tests paytrail-woocommerce-payment-fields script and style is successfully enqueued. Could you provide additional details about this store to tech@paytrail.com?