@@ -59,12 +59,20 @@ public function __invoke($orderId, Request $request)
59
59
/** @var Cart|Model $cart */
60
60
$ this ->cart = Cart::findOneBy ('klarna_order_id ' , $ orderId );
61
61
62
+ $ billingAddress = $ data ->billing_address ;
62
63
$ shippingAddress = $ data ->shipping_address ;
63
64
$ checkoutModule = ModuleModel::findById ($ this ->cart ->klarna_checkout_module );
64
65
if (null === $ checkoutModule ) {
65
66
$ this ->errorResponse ();
66
67
}
67
68
69
+ // Set billing address
70
+ $ address = $ this ->cart ->getBillingAddress ();
71
+ $ address = $ address ?? Address::createForProductCollection ($ this ->cart );
72
+ $ address = $ this ->updateAddressByApiResponse ($ address , (array )$ billingAddress );
73
+
74
+ $ this ->cart ->setBillingAddress ($ address );
75
+
68
76
// Set shipping address
69
77
$ address = $ this ->cart ->getShippingAddress ();
70
78
$ address = $ address ?? Address::createForProductCollection ($ this ->cart );
@@ -90,8 +98,8 @@ public function __invoke($orderId, Request $request)
90
98
91
99
// Update order since shipping method may get updated
92
100
$ data ->shipping_options = $ shippingOptions ;
93
- $ data ->order_amount = $ this ->cart ->getTotal () * 100 ;
94
- $ data ->order_tax_amount = ( $ this ->cart ->getTotal () - $ this ->cart ->getTaxFreeTotal ()) * 100 ;
101
+ $ data ->order_amount = round ( $ this ->cart ->getTotal () * 100 ) ;
102
+ $ data ->order_tax_amount = round (( $ this ->cart ->getTotal () - $ this ->cart ->getTaxFreeTotal ()) * 100 ) ;
95
103
$ data ->order_lines = $ this ->orderLines ();
96
104
97
105
$ response = new JsonResponse ($ data );
0 commit comments