Browse Source

Maj V3 Sumup

feature/rotating_product
Guillaume Bourgeois 8 months ago
parent
commit
ebd941611c
2 changed files with 25 additions and 10 deletions
  1. +10
    -7
      common/components/Tiller/TillerClientV3.php
  2. +15
    -3
      domain/Order/Order/TillerManager.php

+ 10
- 7
common/components/Tiller/TillerClientV3.php View File



public function postOrder($params) public function postOrder($params)
{ {
$response = $this->client->request('POST', $this->urlApi.'purchase-requests/v1/requests', [
'query' => [
'storeId' => $this->storeId
],
'body' => json_encode($params),
'headers' => $this->headers
]);
try {
$response = $this->client->request('POST', $this->urlApi.'purchase-requests/v1/requests?storeId='.$this->storeId, [
'body' => json_encode($params),
'headers' => $this->headers
]);
}
catch (RequestException $exception) {
print_r($exception);
die();
}


return $response->getBody()->getContents(); return $response->getBody()->getContents();
} }

+ 15
- 3
domain/Order/Order/TillerManager.php View File

foreach ($order->productOrder as $productOrder) { foreach ($order->productOrder as $productOrder) {
// v3 // v3
if($apiVersion == 'v3') { if($apiVersion == 'v3') {
$amount = round($this->productOrderSolver->getPriceWithTax($productOrder) * 100);

// classique
if(is_int($productOrder->quantity)) {
$quantity = $productOrder->quantity;
}
// vrac
else {
$amount = $amount * $productOrder->quantity;
$quantity = 1;
}

$lines[] = [ $lines[] = [
'name' => $productOrder->product->name, 'name' => $productOrder->product->name,
'unitPrice' => [ 'unitPrice' => [
'amount' => $this->productOrderSolver->getPriceWithTax($productOrder) * 100,
'amount' => $amount,
], ],
'taxRate' => $productOrder->taxRate->value * 100, 'taxRate' => $productOrder->taxRate->value * 100,
'quantity' => $productOrder->quantity
'quantity' => $quantity
]; ];
} }
// v2 // v2
'payments' => [ 'payments' => [
[ [
'externalId' => ''.$order->id, 'externalId' => ''.$order->id,
'amount' => $this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_PAID) * 100,
'amount' => round($this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_PAID) * 100),
] ]
] ]
] ]

Loading…
Cancel
Save