2017-01-30 21:40:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Ninja\PaymentDrivers;
|
2016-06-20 17:14:43 +03:00
|
|
|
|
|
|
|
|
class CheckoutComPaymentDriver extends BasePaymentDriver
|
|
|
|
|
{
|
|
|
|
|
public function createTransactionToken()
|
|
|
|
|
{
|
2020-02-17 06:52:43 +11:00
|
|
|
if( $this->invoice()->getCurrencyCode() == 'BHD')
|
|
|
|
|
{
|
|
|
|
|
$amount = $this->invoice()->getRequestedAmount()/10;
|
|
|
|
|
}
|
|
|
|
|
elseif($this->invoice()->getCurrencyCode() == 'KWD')
|
|
|
|
|
{
|
|
|
|
|
$amount = $this->invoice()->getRequestedAmount()*10;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
elseif($this->invoice()->getCurrencyCode() == 'OMR')
|
|
|
|
|
{
|
|
|
|
|
$amount = $this->invoice()->getRequestedAmount();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
$amount = $this->invoice()->getRequestedAmount();
|
|
|
|
|
|
2016-06-20 17:14:43 +03:00
|
|
|
$response = $this->gateway()->purchase([
|
2020-02-17 06:52:43 +11:00
|
|
|
'amount' => $amount,
|
2017-01-30 21:40:43 +02:00
|
|
|
'currency' => $this->client()->getCurrencyCode(),
|
2016-06-20 17:14:43 +03:00
|
|
|
])->send();
|
|
|
|
|
|
|
|
|
|
if ($response->isRedirect()) {
|
|
|
|
|
$token = $response->getTransactionReference();
|
|
|
|
|
|
|
|
|
|
$this->invitation->transaction_reference = $token;
|
|
|
|
|
$this->invitation->save();
|
|
|
|
|
|
|
|
|
|
return $token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-21 15:35:23 +03:00
|
|
|
protected function paymentDetails($paymentMethod = false)
|
2016-06-20 17:14:43 +03:00
|
|
|
{
|
|
|
|
|
$data = parent::paymentDetails();
|
|
|
|
|
|
|
|
|
|
if ($ref = array_get($this->input, 'token')) {
|
|
|
|
|
$data['transactionReference'] = $ref;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
}
|