From 04717282811c87cdb793ec00ad0a02f218247bc1 Mon Sep 17 00:00:00 2001 From: Justus Laske Date: Thu, 7 Jan 2021 21:09:00 +0100 Subject: [PATCH] discount added to UpdateOrderApi and Spec --- spec/Api/UpdateOrderApiSpec.php | 2 ++ src/Api/UpdateOrderApi.php | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/spec/Api/UpdateOrderApiSpec.php b/spec/Api/UpdateOrderApiSpec.php index ed040e17..e6874323 100644 --- a/spec/Api/UpdateOrderApiSpec.php +++ b/spec/Api/UpdateOrderApiSpec.php @@ -58,6 +58,7 @@ function it_updates_pay_pal_order_with_given_new_total( $order->getTotal()->willReturn(1122); $order->getCurrencyCode()->willReturn('USD'); $order->getShippingTotal()->willReturn(22); + $order->getOrderPromotionTotal()->willReturn(0); $shippingAddress->getFullName()->willReturn('John Doe'); $shippingAddress->getStreet()->willReturn('Main St. 123'); @@ -115,6 +116,7 @@ function it_updates_digital_order( $order->getTotal()->willReturn(1122); $order->getCurrencyCode()->willReturn('USD'); $order->getShippingTotal()->willReturn(0); + $order->getOrderPromotionTotal()->willReturn(0); $order->isShippingRequired()->willReturn(false); diff --git a/src/Api/UpdateOrderApi.php b/src/Api/UpdateOrderApi.php index ae20975f..85002527 100644 --- a/src/Api/UpdateOrderApi.php +++ b/src/Api/UpdateOrderApi.php @@ -74,6 +74,10 @@ public function update( 'currency_code' => $order->getCurrencyCode(), 'value' => $payPalItemData['total_tax'], ], + 'discount' => [ + 'currency_code' => $order->getCurrencyCode(), + 'value' => abs($order->getOrderPromotionTotal()) / 100, + ], ], ], 'payee' => [