From ec45f6eed5802695af31b71dc50d23088dccc2b1 Mon Sep 17 00:00:00 2001 From: Pixobit Solutions Date: Mon, 21 Oct 2019 17:35:20 +0800 Subject: [PATCH] Convert ItemBag to array before processing request json_encode removes the ItemBag completely from the data, therefore it never gets sent to the API, and will result in bad request --- src/Message/TokenPurchaseRequest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Message/TokenPurchaseRequest.php b/src/Message/TokenPurchaseRequest.php index bcb75e5..5aff35b 100644 --- a/src/Message/TokenPurchaseRequest.php +++ b/src/Message/TokenPurchaseRequest.php @@ -78,7 +78,14 @@ public function getData() // remove amount parameter if lineItem attributes / cart is set unset($data['total']); - $data['lineItems'] = $this->getCart(); + $cartItems = $this->getCart(); + foreach($cartItems as $item) { + $data['lineItems'] []= [ + 'name' => $item->getName(), + 'quantity' => $item->getQuantity(), + 'price' => $item->getPrice() + ]; + } } // remove null values item from $data['billingAddr']