krokedil / klarna-checkout-for-woocommerce

Klarna Checkout for WooCommerce plugin
16 stars 23 forks source link

Support subscriptions/recurring orders for KCOv3 #48

Closed kristibarbosky closed 5 years ago

kristibarbosky commented 6 years ago

v3: https://developers.klarna.com/en/gb/kco-v3/checkout/extra-merchant-data

https://developers.klarna.com/api/#checkout-api__create-a-new-orderattachment__body__subscription

Attach the subscription info into the 'attachment' field when initialize the checkout, there will be one order created and payment will be taken automatically

kristibarbosky commented 6 years ago

KCOv3 subscriptions will soon be available for Sweden, Norway, & Finland (similar to KCOv2). Order should be created in Woo by our plugin, using the token returned for the 1st order. Also: https://developers.klarna.com/api/#customer-token-api-read-customer-tokens-details

kristibarbosky commented 6 years ago

@MichaelBengtsson - I've updated to allow recurring for SE, GB, and DE for K500956

image

add following to the create_order KCOv3 call: "recurring": true, "recurring_description": "Test Recurring",

in the response of KCO you should get a recurring_token parameter

NiklasHogefjord commented 6 years ago

Thanks for the info and for adding recurring to our account @kristibarbosky, we will look into this. Hopefully we can start next week.

kristibarbosky commented 6 years ago

@MichaelBengtsson - please add the Klarna order id to the Woo order

NiklasHogefjord commented 6 years ago

@MichaelBengtsson I see that you have added it as an order note in 1a8e4daf54b3a0d187b712aa188ba5fca278ee10, however you also need to set it in __transactionid so we can use it for order management. Just as with a regular order.

NiklasHogefjord commented 6 years ago
MichaelBengtsson commented 6 years ago

@NiklasHogefjord $renewal_order->set_transaction_id( $klarna_order_id ); on row 170 of the subscription class in that commit. I set the transaction id there.

NiklasHogefjord commented 6 years ago

@MichaelBengtsson Ah, sorry. Didn't see that.

kristibarbosky commented 6 years ago

Note: for some reason, K500956 doesn't work for recurring (gets a 403 error), but testing did work for PK00383 (order_id=97af3291-3e84-6d54-9e7c-c012e6c270b3) and also for K501850

kristibarbosky commented 6 years ago

Order number is shown on recurring order: image

cturnbull commented 6 years ago

Hello, I have a request with regards to recurring payments that I would like to submit here for your consideration.

Subscription switching functionality (upgrades, downgrades, "crossgrades") compatibility: this is a useful feature of WooCommerce Subscriptions that applies mostly to variable subscription and grouped products, but also with non-subscription products given subscription schemes via the mini WCS extension Subscribe All The Things.

I could not get this working successfully with the older v2 KCO plugin, so I wondered if this was an perhaps an oversight, and whether this will be possible with the more WC-standardised checkout flow that this new plugin features (which looks really good, by the way).

mrtnsn commented 5 years ago

Hi, what's the status on this? I'm using this plugin for a new site we're developing and i'm running into Bad value: recurring.

From what I can tell it's due to create_extra_merchant_data() not being fully implemented, is that correct?

kristibarbosky commented 5 years ago

@mrtnsn - we have tested recurring with KCOv3 and it was working successfully. Regarding your error, can you provide your MID and/or your correlation_id so we can review the error in the Klarna logs? Extra merchant data is not required for KCOv3.

Please note: by default, Klarna MIDs are not configured to support recurring orders. Playground MIDs require updates to support recurring testing; production MIDs require contracts for recurring. Has your MID been configured for recurring?

mrtnsn commented 5 years ago

I will have a chat with our customer about that. I'm guessing that's the cause of the issue. Thank you for a very swift response.

cturnbull commented 5 years ago

@mrtnsn @kristibarbosky I have been burned by this, thinking recurring payments was now a solution offered by Klarna, but after a great deal of waiting for the integration department to get back to me, it is apparently not ready (at least in Norway, see below for the answer I received from integration department). I am still waiting to see if I can even get a playground agreement to have recurring payment support added.

Fascinatingly, there is an article here saying recurring payments is now "ready":

Since the launch of Klarna Checkout, one of the most eagerly awaited features has been support for recurring payments. It’s happening now, in KCO V3. [...] So, we are very happy to be able to say that we now support recurring payments in KCO, v3.

... with no date for said support to be made live. One is led to believe that it is in fact ready. Article then links to a developer article here:

This feature is only available in Nordics and DACH at the present time, if you have a need for more markets contact your Klarna rep

Via email correspondence with integration department, per 1. November:

From Klarna's end we have not actively started with agreements yet for recurring payments with v3.

The agent is aware, afaik, that this is for a Norwegian merchant agreement.

There is so much contradicting information from Klarna on the subject of recurring payments that I don't know who to believe anymore. According to merchant support, recurring payments for v3 is only available for UK at the moment (contradicting the dev article on the subject).

Maybe you could clear this up for us once and for all @kristibarbosky?

NiklasHogefjord commented 5 years ago

@mrtnsn @cturnbull

Recurring payments via WooCommerce Subscriptions have been implemented in this plugin since of version 1.7.0.

At the moment the following countries are supported:

Documentation can be found here: https://docs.woocommerce.com/document/klarna-checkout-recurring-payments/

If Klarnas sales team give you the answer that recurring payments isn't ready for KCO v3 yet I think it's better that you get in direct contact with us at Krokedil (at support@krokedil.com) and we will try to help you in the right direction when it comes to talking to the right Klarna representative.

I will close this issue now since I don't think this is a technical issue.

kristibarbosky commented 5 years ago

@cturnbull - thank you for documenting this and I apologize for your frustration. I've escalated this mismatch of information internally.