Skip to content

Commit

Permalink
Add amount check in saman driver verify function (#294)
Browse files Browse the repository at this point in the history
* Add amount check in saman driver verify function

* Update Saman.php

---------

Co-authored-by: mahdikhanzadi <[email protected]>
  • Loading branch information
soroux and khanzadimahdi authored Feb 20, 2025
1 parent c2ac768 commit 04a5a07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
'apiPaymentUrl' => 'https://sep.shaparak.ir/payment.aspx',
'apiVerificationUrl' => 'https://sep.shaparak.ir/payments/referencepayment.asmx?WSDL',
'merchantId' => '',
'password' => '',
'callbackUrl' => '',
'description' => 'payment using saman',
'currency' => 'T', //Can be R, T (Rial, Toman)
Expand Down
9 changes: 9 additions & 0 deletions src/Drivers/Saman/Saman.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function verify(): ReceiptInterface
$data = [
'RefNum' => Request::input('RefNum'),
'merchantId' => $this->settings->merchantId,
'password' => $this->settings->password,
];

$soap = new \SoapClient(
Expand All @@ -138,6 +139,13 @@ public function verify(): ReceiptInterface
$this->notVerified($status);
}

$verifiedAmount = $status; // if status is bigger than 0 , it represents amount
if ($verifiedAmount !== $this->invoice->getAmount()) {
$soap->ReverseTransaction($data["RefNum"], $data["merchantId"], $data["password"], $verifiedAmount);
$status = -100;
$this->notVerified($status);
}

$receipt = $this->createReceipt($data['RefNum']);
$receipt->detail([
'traceNo' => Request::input('TraceNo'),
Expand Down Expand Up @@ -220,6 +228,7 @@ private function notVerified(int $status): void
-16 => 'خطای داخلی سیستم',
-17 => 'برگشت زدن جزیی تراکنش مجاز نمی باشد.',
-18 => 'IP Address فروشنده نا معتبر است و یا رمز تابع بازگشتی (reverseTransaction) اشتباه است.',
-100 => 'مبلغ برگشتی با مبلغ فاکتور همخوانی ندارد.',
];

if (array_key_exists($status, $translations)) {
Expand Down

0 comments on commit 04a5a07

Please sign in to comment.