diff --git a/src/Drivers/Azki/Azki.php b/src/Drivers/Azki/Azki.php index b9f0773..670983f 100644 --- a/src/Drivers/Azki/Azki.php +++ b/src/Drivers/Azki/Azki.php @@ -66,6 +66,7 @@ public function __construct(Invoice $invoice, $settings) $this->invoice($invoice); $this->settings = (object)$settings; $this->client = new Client(); + $this->convertAmountItems(); } public function purchase() @@ -82,7 +83,10 @@ public function purchase() $merchant_id = $this->settings->merchantId; $callback = $this->settings->callbackUrl; - $fallback = $this->settings->fallbackUrl; + $fallback = + $this->settings->fallbackUrl != 'http://yoursite.com/path/to' && $this->settings->fallbackUrl == '' + ? $this->settings->fallbackUrl + : $callback; $sub_url = self::subUrls['purchase']; $url = $this->settings->apiPaymentUrl . $sub_url; @@ -153,7 +157,7 @@ private function makeSignature($sub_url, $request_method = 'POST') return bin2hex($digest); } - private function getItems() + private function convertAmountItems() { /** * example data @@ -175,7 +179,16 @@ private function getItems() * */ - return $this->invoice->getDetails()['items']; + $new_items = array_map( + function ($item) { + $item['amount'] *= 10; // convert toman to rial + return $item; + }, + $this->invoice->getDetails()['items'] ?? [] + ); + + $this->invoice->detail('items', $new_items); + return $new_items; } /**