Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Drivers/Asanpardakht/Asanpardakht.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct(Invoice $invoice, $settings)
*/
public function purchase()
{
$this->invoice->uuid(crc32($this->invoice->getUuid()));
$this->invoice->uuid($this->invoice->getUuid(true));

$result = $this->token();

Expand Down Expand Up @@ -339,9 +339,9 @@ protected function purchaseFailed($status)
];

if (array_key_exists($status, $translations)) {
throw new PurchaseFailedException($translations[$status]);
throw new PurchaseFailedException($translations[$status], $status);
} else {
throw new PurchaseFailedException('خطای ناشناخته ای رخ داده است.');
throw new PurchaseFailedException('خطای ناشناخته ای رخ داده است.', $status);
}
}
}
4 changes: 2 additions & 2 deletions src/Drivers/Etebarino/Etebarino.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(Invoice $invoice, $settings)
*/
public function purchase()
{
$this->invoice->uuid(crc32($this->invoice->getUuid()));
$this->invoice->uuid($this->invoice->getUuid(true));

$result = $this->token();

Expand Down Expand Up @@ -149,7 +149,7 @@ public function token(): array
'terminalUser' => $this->settings->username,
'merchantCode' => $this->settings->merchantId,
'terminalPass' => $this->settings->password,
'merchantRefCode' => $this->invoice->getUuid(),
'merchantRefCode' => $this->invoice->getUuid(true),
"description" => $this->invoice->getDetail('description'),
"returnUrl" => $this->settings->callbackUrl,
'paymentItems' => $this->getItems(),
Expand Down
6 changes: 3 additions & 3 deletions src/Drivers/Irankish/Irankish.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public function purchase()
'merchantId' => $this->settings->merchantId,
'description' => $description,
'revertURL' => $this->settings->callbackUrl,
'invoiceNo' => crc32($this->invoice->getUuid()),
'paymentId' => crc32($this->invoice->getUuid()),
'specialPaymentId' => crc32($this->invoice->getUuid()),
'invoiceNo' => $this->invoice->getUuid(true),
'paymentId' => $this->invoice->getUuid(true),
'specialPaymentId' => $this->invoice->getUuid(true),
);

$soap = new \SoapClient(
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/Nextpay/Nextpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function purchase()
{
$data = array(
'api_key' => $this->settings->merchantId,
'order_id' => intval(1, time()).crc32($this->invoice->getUuid()),
'order_id' => intval(1, time()).$this->invoice->getUuid(true),
'amount' => $this->invoice->getAmount(),
'callback_uri' => $this->settings->callbackUrl,
);
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/Parsian/Parsian.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected function preparePurchaseData()
return array(
'LoginAccount' => $this->settings->merchantId,
'Amount' => $this->invoice->getAmount() * 10, // convert to rial
'OrderId' => crc32($this->invoice->getUuid()),
'OrderId' => $this->invoice->getUuid(),
'CallBackUrl' => $this->settings->callbackUrl,
'AdditionalData' => $description,
);
Expand Down
4 changes: 3 additions & 1 deletion src/Drivers/Pasargad/Pasargad.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,14 @@ protected function prepareInvoiceData(): array
$terminalCode = $this->settings->terminalCode;
$amount = $this->invoice->getAmount(); //rial
$redirectAddress = $this->settings->callbackUrl;
$invoiceNumber = crc32($this->invoice->getUuid()) . rand(0, time());

$invoiceNumber = $this->invoice->getUuid(true) . rand(0, time());

$iranTime = new DateTime('now', new DateTimeZone('Asia/Tehran'));
$timeStamp = $iranTime->format("Y/m/d H:i:s");
$invoiceDate = $iranTime->format("Y/m/d H:i:s");


if (!empty($this->invoice->getDetails()['date'])) {
$invoiceDate = $this->invoice->getDetails()['date'];
}
Expand Down
4 changes: 2 additions & 2 deletions src/Drivers/Sadad/Sadad.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(Invoice $invoice, $settings)
public function purchase()
{
$terminalId = $this->settings->terminalId;
$orderId = crc32($this->invoice->getUuid());
$orderId = $this->invoice->getUuid(true);
$amount = $this->invoice->getAmount() * 10; // convert to rial
$key = $this->settings->key;

Expand Down Expand Up @@ -213,7 +213,7 @@ protected function encrypt_pkcs7($str, $key)

return base64_encode($ciphertext);
}

/**
* Retrieve payment mode.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/Saman/Saman.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function verify(): ReceiptInterface

$receipt = $this->createReceipt($data['RefNum']);
$receipt->detail([
'traceNo' => Request::input('TraceNo'),
'traceNo' => Request::input('TRACENO'),
'referenceNo' => Request::input('RRN'),
'transactionId' => Request::input('RefNum'),
'cardNo' => Request::input('SecurePan'),
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/Yekpay/Yekpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function purchase()
$data->merchantId = $this->settings->merchantId;
$data->amount = $this->invoice->getAmount();
$data->callback = $this->settings->callbackUrl;
$data->orderNumber = intval(1, time()).crc32($this->invoice->getUuid());
$data->orderNumber = intval(1, time()).$this->invoice->getUuid(true);

$data->fromCurrencyCode = (int) $this->settings->fromCurrencyCode;
$data->toCurrencyCode = (int) $this->settings->toCurrencyCode;
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/Zibal/Zibal.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function purchase()
// convert to toman
$toman = $this->invoice->getAmount() * 10;

$orderId = crc32($this->invoice->getUuid()).time();
$orderId = $this->invoice->getUuid(true).time();
if (!empty($details['orderId'])) {
$orderId = $details['orderId'];
} elseif (!empty($details['order_id'])) {
Expand Down
6 changes: 5 additions & 1 deletion src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,19 @@ public function uuid($uuid = null)
}

$this->uuid = $uuid;
return $this;
}

/**
* Get invoice uuid
*
* @return string
*/
public function getUuid()
public function getUuid($needNumericUuid = false)
{
if ($needNumericUuid) {
$this->uuid = !is_numeric($this->uuid) ? crc32($this->uuid) : $this->uuid;
}
return $this->uuid;
}

Expand Down