Problem/Motivation

Some times a successful klarna payment produces two payments and fires two times the checkout completed for the order.
This causes:
- order receipt sent twice
- order number generated twice and the older one gets lost.

Steps to reproduce

- not found so far

Has anyone else a similar problem?

CommentFileSizeAuthor
#3 order-transactions.png313.32 KBelex
#3 order-log.png483.84 KBelex

Comments

elex created an issue. See original summary.

tuutti’s picture

Hi!

With "order receipt" do you mean commerce's default order receipt or something that is sent by Klarna?

elex’s picture

StatusFileSize
new483.84 KB
new313.32 KB

Hi,

I mean the commerce's default order receipt, see attached the commerce order log and transactions.

tuutti’s picture

I don't think this is caused by #3043180: The changes made to the order on the onNotify method are not applied on the onReturn method because the notification URL is only called on pending orders: https://docs.klarna.com/order-management/integration-guide/pending-orders/

I'm wondering if this is some kind of a race condition in our OrderTransitionSubscriber since we subscribe to multiple pre_transition events.

What checkout workflow are you using (Commerce -> Configuration -> Order types -> Edit your order type -> Workflow)?

elex’s picture

I am using the Fulfillment (order_fulfillment) Workflow. But it is not happening all the times.
Maybe it is a good start to log the causing event in onOrderPlace?

tuutti’s picture

Hmm, onOrderPlace is not called until you fulfill the order, so it's not actually caused by that.

elex’s picture

Hm ... as I have two order transactions, they must be created by the PaymentGateway\Klarna createPayment function? And this is called by?

tuutti’s picture

createPayment() is called by Klarna::onReturn().

In theory this could be caused by misbehaving browser back button, like if the user presses back button at the same time as they've been redirected back to onReturn() callback, causing similar issue as described in #3043180: The changes made to the order on the onNotify method are not applied on the onReturn method.

agoradesign’s picture

The back button problem seems to happen quite often, at least at the website, we have added Klarna a few weeks ago

agoradesign’s picture

Happened again... quite every day now.. one thing, I missed out to add: we never have a second payment entity, but checkout complete event is triggered twice, which triggers the order place transition twice, and any event subscriber will trigger twice. So the customer will receive 2 e-mails with two different order numbers, etc