krokedil / klarna-payments-for-woocommerce

GNU General Public License v3.0
10 stars 19 forks source link

[critical?] Klarna order flow fails if a previous payment attempt with Stripe failed #67

Closed edvinbrobeck closed 6 years ago

edvinbrobeck commented 6 years ago

This is a bit hard to explain. In essence, if a customer tries to use stripe as payment method, and if fails, and they then try to pay using KCO - the customer is charged by klarna, but the order flow in woocommerce fails. This is critical due to the fact that the customer gets charged, but WC deems the order as failed hence not completing any following automated actions (emails etc)

How to reproduce

  1. Try and fulfill an order using stripe but fail the attempt with the "card_declined" reason, using a test card 4000 0000 0000 0002. This happens i.e. when a swedish customers bank need 3d_secure and to sign using BankID.
  2. Switch payment method to Klarna and try to complete the order.

Expected result

The order should be able to fulfill using KCO instead of Stripe.

What happens

An order object is created during 1. with a status of failed, and when trying to fulfill the klarna flow the "Thankyou page" is never rendered due to a fatal PHP error Uncaught Error: Call to a member function get_user_id() on boolean in /var/www/html/content/plugins/woocommerce-gateway-klarna/includes/checkout/thank-you.php:109

See screenshot https://ibb.co/bwyvFc

I dug a bit further and the thank you page is unable to render due to that there is no Order ID for it to use. According to the code there should be a $_GET var named order-received but the URL that is redirected is: <kco-checkout-url>?klarna_order=7ZPWKWCN8SS75R8OMSYFK9JFF9Y&scountry=SE&thankyou=yes and thus missing the required variable.

This ends up with an order in WooCommerce with the status failed, but an invoice is created and sent by klarna.

edvinbrobeck commented 6 years ago

Follow up: The invoice created in Klarna is created and can be found in the "Incoming" section, however if using credit card as KCO method, the customer is charged (unverified, but according to customer).

kristibarbosky commented 6 years ago

@edvinbrobeck - This GitHub repo is for the klarna-payments-for-woocommerce plugin (which is not the plugin you are referencing). Could you instead please create this ticket under this repo: https://github.com/krokedil/woocommerce-gateway-klarna/issues

When Klarna Checkout is installed on a Woo store, it replaces the original Woo checkout though (and also accepts customer payment via card), so how is the customer paying by Stripe and then switching to KCO?

edvinbrobeck commented 6 years ago

Oh, thank you @kristibarbosky I will create it over there. Well you are not forced to replace the standard checkout, it works very well for us at mapiful.com