Skip to content

Commit

Permalink
php7.4 compatible format
Browse files Browse the repository at this point in the history
  • Loading branch information
khanzadimahdi committed Dec 26, 2019
1 parent 4dacf82 commit c622ff0
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/Drivers/Ipay/Idpay.php
Expand Up @@ -59,13 +59,36 @@ public function purchase()
{
$details = $this->invoice->getDetails();

$phone = null;
if (!empty($details['phone'])) {
$phone = $details['phone'];
} else if (!empty($details['mobile'])) {
$phone = $details['mobile'];
}

$mail = null;
if (!empty($details['mail'])) {
$mail = $details['mail'];
} else if (!empty($details['email'])) {
$mail = $details['email'];
}

$desc = null;
if (!empty($details['desc'])) {
$desc = $details['desc'];
} else if (!empty($details['description'])) {
$desc = $details['description'];
} else {
$desc = $this->settings->description;
}

$data = array(
'order_id' => $this->invoice->getUuid(),
'amount' => $this->invoice->getAmount(),
'name' => $details['name'] ?? null,
'phone' => $details['mobile'] ?? $details['phone'] ?? null,
'mail' => $details['email'] ?? $details['mail'] ?? null,
'desc' => $details['description'] ?? $details['desc'] ?? $this->settings->description,
'phone' => $phone,
'mail' => $mail,
'desc' => $desc,
'callback' => $this->settings->callbackUrl,
'reseller' => $details['reseller'] ?? null,
);
Expand All @@ -87,7 +110,6 @@ public function purchase()
);

$body = json_decode($response->getBody()->getContents(), true);

if (empty($body['id'])) {
// error has happened
$message = $body['error_message'] ?? 'خطا در هنگام درخواست برای پرداخت رخ داده است.';
Expand Down

0 comments on commit c622ff0

Please sign in to comment.