Loading src/KlarnaManager.php +16 −1 Original line number Diff line number Diff line Loading @@ -103,8 +103,14 @@ class KlarnaManager implements KlarnaManagerInterface { * {@inheritdoc} */ public function acknowledgeKlarnaOrder(string $klarna_order_id, ?OrderInterface $order = NULL) { try { // Try getting the order from the Klarna checkout endpoint. $klarna_order = (array) $this->loadOrder($klarna_order_id); } catch (\Exception $exception) { // Fallback to loading it from the order management API. $klarna_order = (array) $this->loadCompletedOrder($klarna_order_id); } if (!$order) { $order_storage = $this->entityTypeManager->getStorage('commerce_order'); $order = $order_storage->load($klarna_order['merchant_reference2']); Loading Loading @@ -164,6 +170,15 @@ class KlarnaManager implements KlarnaManagerInterface { return $klarna_order; } /** * {@inheritdoc} */ public function loadCompletedOrder(string $klarna_order_id) { $klarna_order = new KlarnaOrderManagement($this->connector, $klarna_order_id); $klarna_order->fetch(); return $klarna_order; } /** * {@inheritdoc} */ Loading src/KlarnaManagerInterface.php +14 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,20 @@ interface KlarnaManagerInterface { */ public function loadOrder($klarna_order_id); /** * Loads an order from the Klarna order management API. * * Once the customer has completed the purchase, the order should be loaded * from this endpoint. * * @param string $klarna_order_id * The Klarna order ID. * * @return \Klarna\Rest\OrderManagement\Order * The Klarna order (retrieved from the order management API). */ public function loadCompletedOrder(string $klarna_order_id); /** * Updates the order in Klarna. * Loading Loading
src/KlarnaManager.php +16 −1 Original line number Diff line number Diff line Loading @@ -103,8 +103,14 @@ class KlarnaManager implements KlarnaManagerInterface { * {@inheritdoc} */ public function acknowledgeKlarnaOrder(string $klarna_order_id, ?OrderInterface $order = NULL) { try { // Try getting the order from the Klarna checkout endpoint. $klarna_order = (array) $this->loadOrder($klarna_order_id); } catch (\Exception $exception) { // Fallback to loading it from the order management API. $klarna_order = (array) $this->loadCompletedOrder($klarna_order_id); } if (!$order) { $order_storage = $this->entityTypeManager->getStorage('commerce_order'); $order = $order_storage->load($klarna_order['merchant_reference2']); Loading Loading @@ -164,6 +170,15 @@ class KlarnaManager implements KlarnaManagerInterface { return $klarna_order; } /** * {@inheritdoc} */ public function loadCompletedOrder(string $klarna_order_id) { $klarna_order = new KlarnaOrderManagement($this->connector, $klarna_order_id); $klarna_order->fetch(); return $klarna_order; } /** * {@inheritdoc} */ Loading
src/KlarnaManagerInterface.php +14 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,20 @@ interface KlarnaManagerInterface { */ public function loadOrder($klarna_order_id); /** * Loads an order from the Klarna order management API. * * Once the customer has completed the purchase, the order should be loaded * from this endpoint. * * @param string $klarna_order_id * The Klarna order ID. * * @return \Klarna\Rest\OrderManagement\Order * The Klarna order (retrieved from the order management API). */ public function loadCompletedOrder(string $klarna_order_id); /** * Updates the order in Klarna. * Loading