Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Card payment fails with WooCommerce Subscriptions #66

Open
villesiltala opened this issue Dec 14, 2020 · 4 comments
Open

Card payment fails with WooCommerce Subscriptions #66

villesiltala opened this issue Dec 14, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@villesiltala
Copy link
Contributor

Describe the bug
The purchase process fails when adding a new card as a payment method when purchasing a WooCommerce Subscriptions product. The card form is shown as excepted, but returning to the shop's success handler produces the following error:

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://api.checkout.fi/tokenization/a20ab661-7ca0-4223-85b2-ec56b47eaecd` resulted in a `422 Unprocessable Entity` response: {"status":"error","message":"Unexpected response code: 200.118"} in /data/wordpress/htdocs/wp-content/plugins/op-payment-service-for-woocommerce/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /data/wordpress/htdocs/wp-content/plugins/op-payment-service-for-woocommerce/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /data/wordpress/htdocs/wp-content/plugins/op-payment-service-for-woocommerce/vendor/guzzlehttp/promises/src/FulfilledPromise.php(39): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /data/wordpress/htdocs/wp-content/plugins/op-payment-service-for-woocommerce/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Fu in /data/wordpress/htdocs/wp-content/plugins/op-payment-service-for-woocommerce/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

To Reproduce
Use the following versions:

  • WordPress 5.6
  • WooCommerce 4.8.0
  • OP Payment Service for WooCommerce 1.5.11
  • WooCommerce Subscriptions 3.0.11

Activate the payment gateway and use the test credentials. Create a subscriptions product on the admin side. Log out and do not use an existing user on the front-end. Add the subscriptions product to cart. Go to checkout and add the required customer information. Try to purchase the product by adding a new card payment method.

Expected behavior
A new card payment method is added for the current user and the subscription product is successfully purchased using this newly added method.

Additional context
The error was produced on a local machine using the test shop credentials and both Visa and Mastercard test credentials for the card payment. Debug log contains the following:

DEBUG OpMerchantServices: check_checkout_response, no status or reference found for reference:

URL path for the error:

/op-payment-service/card-success/checkout/?checkout-account=375917&checkout-algorithm=sha256&checkout-method=GET&checkout-status=ok&checkout-tokenization-id=f39afacf-91d0-409c-a5b7-e904db6bbca0&signature=8181725b76012643aa4a292bf9fa26ece45e336fa7780b57b2982037ee913add
@villesiltala villesiltala added the bug Something isn't working label Dec 14, 2020
@villesiltala
Copy link
Contributor Author

Does the card payment method require remote access to the server? That is obviously not available for a local machine. I also tested this on a virtual staging environment where there is no access to the server without a specific cookie set for all HTTP requests (Seravo) so I'm currently unable to test this on a remote server.

@loueranta
Copy link
Member

Thanks for reporting, we will investigate this.

The remote access is required only for callback calls, but those are obsolete if you return correctly from payment service to webshop after paying.

@villesiltala
Copy link
Contributor Author

I've pinpointed this error to be caused by the merchant not having enabled card payments for their Checkout subscription. Checkout API probably will not return the card payment method for this type of merchant, but the issue is in the way the plugin is handling subscription product payments. The current code base forces the payment method to be credit card if the Subscription plugin is active and the cart contains subscription products. This processing is incomplete and requires more steps:

  1. Card payments should not be used for merchants with card payments disabled.
  2. Token/card payment should be optional if the merchant allows manual renewals.

The second step means that the end user should be allowed to select automatic renewals using a card payment or manual renewals if another payment method is selected. Currently, the plugin forces automatic renewals and only the card payment is available.

@loueranta
Copy link
Member

loueranta commented Aug 5, 2021

Thanks for the input.

  1. There is already a plan to implement this, as Starttipaketti merchants are unable to use tokenization. However, implementing it will require some further development of our API, as we can't currently identify if tokenization is possible or not based on the API response.
  2. We've had some trouble when merchant is unaware of this manual renewal process and think all our payment methods can be used for automatic recurring payments, which they are not. It's the reason why we decided to disable manual renewals. But of course adding an option to allow manual renewals could be implemented and I'll add the idea to our backlog.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants