Skip to content

Commit 07a1c5a

Browse files
committed
send original transaction with correct format for Klarna MoR
1 parent 91561da commit 07a1c5a

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/Gateways/Klarna/KlarnaFulfillmentActions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ protected function dispatch_data_request(WC_Order $order, string $sdkMethod, str
134134
$response = $payment->method($gateway->getServiceCode($processor))->{$sdkMethod}(
135135
array_merge(
136136
$processor->getBody(),
137-
['originalTransactionKey' => $dataRequestKey]
137+
// Klarna's `klarna` service references the original reserve via
138+
// a service-level `DataRequestKey` parameter (the SDK's `Pay`
139+
// model exposes it as `dataRequestKey`).
140+
['dataRequestKey' => $dataRequestKey]
138141
)
139142
);
140143

src/Gateways/Klarna/KlarnaPayGateway.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ public function cancel_reservation(WC_Order $order)
110110
$payment->method($this->getServiceCode($processor))->cancelReserve(
111111
array_merge(
112112
$processor->getBody(),
113-
['originalTransactionKey' => $dataRequestKey]
113+
// Klarna's `klarna` service references the original reserve via
114+
// a service-level `DataRequestKey` parameter (the SDK's `Pay`
115+
// model exposes it as `dataRequestKey`).
116+
['dataRequestKey' => $dataRequestKey]
114117
)
115118
),
116119
$order

src/Gateways/Klarna/KlarnaProcessor.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ protected function getMethodBody(): array
2626
$dataRequestKey = get_post_meta($this->get_order()->get_id(), self::DATA_REQUEST_META_KEY, true);
2727

2828
if (is_string($dataRequestKey) && strlen($dataRequestKey) > 0) {
29-
$body['originalTransactionKey'] = $dataRequestKey;
29+
// Klarna's `klarna` service identifies a reservation by a service-level
30+
// `DataRequestKey` parameter (not the top-level `OriginalTransactionKey`).
31+
// Sending it as `originalTransactionKey` causes Buckaroo to reject the
32+
// capture with "originaltransaction is invalid for the action Pay".
33+
$body['dataRequestKey'] = $dataRequestKey;
3034
}
3135
}
3236

0 commit comments

Comments
 (0)