Skip to content

Commit 0f17875

Browse files
committed
unwanted crc32 uuid bug fixed.
1 parent 8db9d79 commit 0f17875

File tree

11 files changed

+20
-17
lines changed

11 files changed

+20
-17
lines changed

src/Drivers/Asanpardakht/Asanpardakht.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function __construct(Invoice $invoice, $settings)
7373
*/
7474
public function purchase()
7575
{
76-
$this->invoice->uuid(crc32($this->invoice->getUuid()));
76+
$this->invoice->uuid($this->invoice->getUuid(true));
7777

7878
$result = $this->token();
7979

@@ -339,9 +339,9 @@ protected function purchaseFailed($status)
339339
];
340340

341341
if (array_key_exists($status, $translations)) {
342-
throw new PurchaseFailedException($translations[$status]);
342+
throw new PurchaseFailedException($translations[$status], $status);
343343
} else {
344-
throw new PurchaseFailedException('خطای ناشناخته ای رخ داده است.');
344+
throw new PurchaseFailedException('خطای ناشناخته ای رخ داده است.', $status);
345345
}
346346
}
347347
}

src/Drivers/Etebarino/Etebarino.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(Invoice $invoice, $settings)
4848
*/
4949
public function purchase()
5050
{
51-
$this->invoice->uuid(crc32($this->invoice->getUuid()));
51+
$this->invoice->uuid($this->invoice->getUuid(true));
5252

5353
$result = $this->token();
5454

@@ -149,7 +149,7 @@ public function token(): array
149149
'terminalUser' => $this->settings->username,
150150
'merchantCode' => $this->settings->merchantId,
151151
'terminalPass' => $this->settings->password,
152-
'merchantRefCode' => $this->invoice->getUuid(),
152+
'merchantRefCode' => $this->invoice->getUuid(true),
153153
"description" => $this->invoice->getDetail('description'),
154154
"returnUrl" => $this->settings->callbackUrl,
155155
'paymentItems' => $this->getItems(),

src/Drivers/Irankish/Irankish.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public function purchase()
6161
'merchantId' => $this->settings->merchantId,
6262
'description' => $description,
6363
'revertURL' => $this->settings->callbackUrl,
64-
'invoiceNo' => crc32($this->invoice->getUuid()),
65-
'paymentId' => crc32($this->invoice->getUuid()),
66-
'specialPaymentId' => crc32($this->invoice->getUuid()),
64+
'invoiceNo' => $this->invoice->getUuid(true),
65+
'paymentId' => $this->invoice->getUuid(true),
66+
'specialPaymentId' => $this->invoice->getUuid(true),
6767
);
6868

6969
$soap = new \SoapClient(

src/Drivers/Nextpay/Nextpay.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function purchase()
6161
{
6262
$data = array(
6363
'api_key' => $this->settings->merchantId,
64-
'order_id' => intval(1, time()).crc32($this->invoice->getUuid()),
64+
'order_id' => intval(1, time()).$this->invoice->getUuid(true),
6565
'amount' => $this->invoice->getAmount(),
6666
'callback_uri' => $this->settings->callbackUrl,
6767
);

src/Drivers/Parsian/Parsian.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ protected function preparePurchaseData()
170170
return array(
171171
'LoginAccount' => $this->settings->merchantId,
172172
'Amount' => $this->invoice->getAmount() * 10, // convert to rial
173-
'OrderId' => crc32($this->invoice->getUuid()),
173+
'OrderId' => $this->invoice->getUuid(),
174174
'CallBackUrl' => $this->settings->callbackUrl,
175175
'AdditionalData' => $description,
176176
);

src/Drivers/Pasargad/Pasargad.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ protected function prepareInvoiceData(): array
193193
$terminalCode = $this->settings->terminalCode;
194194
$amount = $this->invoice->getAmount(); //rial
195195
$redirectAddress = $this->settings->callbackUrl;
196-
$invoiceNumber = crc32($this->invoice->getUuid()) . rand(0, time());
196+
$invoiceNumber = $this->invoice->getUuid(true) . rand(0, time());
197197
$timeStamp = date("Y/m/d H:i:s");
198198
$invoiceDate = date("Y/m/d H:i:s");
199199

src/Drivers/Sadad/Sadad.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(Invoice $invoice, $settings)
6060
public function purchase()
6161
{
6262
$terminalId = $this->settings->terminalId;
63-
$orderId = crc32($this->invoice->getUuid());
63+
$orderId = $this->invoice->getUuid(true);
6464
$amount = $this->invoice->getAmount() * 10; // convert to rial
6565
$key = $this->settings->key;
6666

@@ -210,7 +210,7 @@ protected function encrypt_pkcs7($str, $key)
210210

211211
return base64_encode($ciphertext);
212212
}
213-
213+
214214
/**
215215
* Retrieve payment mode.
216216
*

src/Drivers/Saman/Saman.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function verify(): ReceiptInterface
124124

125125
$receipt = $this->createReceipt($data['RefNum']);
126126
$receipt->detail([
127-
'traceNo' => Request::input('TraceNo'),
127+
'traceNo' => Request::input('TRACENO'),
128128
'referenceNo' => Request::input('RRN'),
129129
'transactionId' => Request::input('RefNum'),
130130
'cardNo' => Request::input('SecurePan'),

src/Drivers/Yekpay/Yekpay.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function purchase()
7373
$data->merchantId = $this->settings->merchantId;
7474
$data->amount = $this->invoice->getAmount();
7575
$data->callback = $this->settings->callbackUrl;
76-
$data->orderNumber = intval(1, time()).crc32($this->invoice->getUuid());
76+
$data->orderNumber = intval(1, time()).$this->invoice->getUuid(true);
7777

7878
$data->fromCurrencyCode = (int) $this->settings->fromCurrencyCode;
7979
$data->toCurrencyCode = (int) $this->settings->toCurrencyCode;

src/Drivers/Zibal/Zibal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function purchase()
6363
// convert to toman
6464
$toman = $this->invoice->getAmount() * 10;
6565

66-
$orderId = crc32($this->invoice->getUuid()).time();
66+
$orderId = $this->invoice->getUuid(true).time();
6767
if (!empty($details['orderId'])) {
6868
$orderId = $details['orderId'];
6969
} elseif (!empty($details['order_id'])) {

src/Invoice.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ public function uuid($uuid = null)
6666
*
6767
* @return string
6868
*/
69-
public function getUuid()
69+
public function getUuid($needNumericUuid = false)
7070
{
71+
if($needNumericUuid){
72+
$this->uuid = !is_numeric($this->uuid) ? crc32($this->uuid) : $this->uuid;
73+
}
7174
return $this->uuid;
7275
}
7376

0 commit comments

Comments
 (0)