From d8e3c0db38417479e4e648ff5a832d90dc6d3025 Mon Sep 17 00:00:00 2001 From: Hamed Date: Fri, 1 Nov 2019 20:13:59 +0330 Subject: [PATCH] Add files via upload fix saman issues --- src/Saman/Saman.php | 34 +++++++++++++++++++++------------- src/Saman/SamanException.php | 3 +++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/Saman/Saman.php b/src/Saman/Saman.php index 240169fd..5fa9ccdf 100644 --- a/src/Saman/Saman.php +++ b/src/Saman/Saman.php @@ -2,6 +2,7 @@ namespace Larabookir\Gateway\Saman; +use Carbon\Carbon; use Illuminate\Support\Facades\Request; use SoapClient; use Larabookir\Gateway\PortAbstract; @@ -22,7 +23,12 @@ class Saman extends PortAbstract implements PortInterface * * @var string */ - protected $serverUrl = 'https://sep.shaparak.ir/payments/referencepayment.asmx?wsdl'; + +// protected $serverVerifyUrl = "https://sep.shaparak.ir/payments/referencepayment.asmx?WSDL"; + protected $serverVerifyUrl = "http://banktest.ir/gateway/saman/payments/referencepayment?wsdl"; + +// protected $gateUrl = "https://sep.shaparak.ir/Payment.aspx"; + protected $gateUrl = "http://banktest.ir/gateway/saman/gate"; /** * {@inheritdoc} @@ -71,7 +77,7 @@ public function redirect() $data = array_merge($main_data, $this->optional_data); - return \View::make('gateway::saman-redirector')->with($data); + return \View::make('gateway::saman-redirector')->with($data)->with('gateUrl',$this->gateUrl); } /** @@ -121,11 +127,18 @@ function getCallback() */ protected function userPayment() { - $this->refId = Request::input('RefNum'); $this->trackingCode = Request::input('TRACENO'); - $this->cardNumber = Request::input('SecurePan'); + // $this->cardNumber = Request::input('SecurePan'); , will cause mysql error : Data too long for column 'card_number' ! $payRequestRes = Request::input('State'); - $payRequestResCode = Request::input('StateCode'); + $payRequestResCode = Request::input('Status'); + + $this->refId = Request::input('RefNum'); + $this->getTable()->whereId($this->transactionId)->update([ + 'ref_id' => $this->refId, + 'tracking_code' => $this->trackingCode, + // 'card_number' => $this->cardNumber, will cause mysql error : Data too long for column 'card_number' ! + 'updated_at' => Carbon::now(), + ]); if ($payRequestRes == 'OK') { return true; @@ -153,9 +166,8 @@ protected function verifyPayment() "password" => $this->config->get('gateway.saman.password'), ); - try { - $soap = new SoapClient($this->serverUrl); + $soap = new SoapClient($this->serverVerifyUrl); $response = $soap->VerifyTransaction($fields["RefNum"], $fields["merchantID"]); } catch (\SoapFault $e) { @@ -167,18 +179,14 @@ protected function verifyPayment() $response = intval($response); if ($response == $this->amount) { - $this->transactionSucceed([ - 'ref_id' => $this->refId, - 'tracking_code' => $this->trackingCode, - 'card_number' => $this->cardNumber - ]); + $this->transactionSucceed(); return true; } //Reverse Transaction if($response>0){ try { - $soap = new SoapClient($this->serverUrl); + $soap = new SoapClient($this->serverVerifyUrl); $response = $soap->ReverseTransaction($fields["RefNum"], $fields["merchantID"], $fields["password"], $response); } catch (\SoapFault $e) { diff --git a/src/Saman/SamanException.php b/src/Saman/SamanException.php index 6d52bd37..d8663f80 100644 --- a/src/Saman/SamanException.php +++ b/src/Saman/SamanException.php @@ -11,6 +11,9 @@ class SamanException extends BankException "OK" => "پرداخت با موفقیت انجام شد", 'Canceled By User' => 'تراکنش توسط خریدار کنسل شد', 'Invalid Amount' => 'مبلغ سند برگشتی از مبلغ تراکنش اصلی بیشتر است', + 'Merchant Invalid' => 'پذیرنده فروشگاهی نامعتبر است', + 'Do Not Honour' => 'از انجام تراکنش صرف نظر شد', + 'Honour With Identification' => 'با تشخیص هویت دارنده کارت،تراکنش موفق می باشد', 'Invalid Transaction' => 'درخواست برگشت تراکنش رسیده است در حالی که تراکنش اصلی پیدا نمی شود', 'Invalid Card Number' => 'شماره کارت اشتباه است', 'No Such Issuer' => 'چنین صادر کننده کارتی وجود ندارد',