MyOnlineStore / omnipay-klarna-checkout

Klarna Checkout gateway for Omnipay

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

updateTransaction unnecessary data

davidrushton opened this issue · comments

Hi there. Hope you're keeping safe!

I've recently launched a new website with Klarna integration using your package - thanks for the resource.

The issue i'm having is that our checkout / order process only sets the merchant_reference1 once the Klarna checkout has been created and acknowledged. The code I'm using is:

$response = $this->gateway()->updateTransaction([
    'transactionReference' => $payment->identifier,
    'merchant_reference1' => $checkout->order->ref,
])->send();

However, that is returning a Klarna error:

{
  "error_code": "BAD_VALUE",
  "error_messages": [
    "Bad value: order_amount"
  ],
  "correlation_id": "1fcf6105-ed10-42b9-9723-27808c3446b6",
  "service_version": "1.0.20200320090732"
}

I believe it is because your data is always populated with amount, tax, currency, country, etc - https://github.com/MyOnlineStore/omnipay-klarna-checkout/blob/master/src/Message/UpdateTransactionRequest.php#L24. The body sent to Klarna for the above was:

{
  "order_amount": null,
  "order_tax_amount": 0,
  "order_lines": [],
  "purchase_currency": null,
  "purchase_country": null,
  "merchant_reference1": "1001"
}

Would a new Request type be the preferred approach for allowing only some fields to be sent to update an order, or would it be possible to update the existing TransactionRequest to handle?

Thanks,
David,

@davidrushton it seems that this repo is "dead" so created a new package for this with some changes. omnipay-klarna

one of the features that you ask about has a separate method updateMerchantReferences in my project.

@fred-jan @frankverhoeven @Feijs is the package still alive?