Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
fix saman issues
  • Loading branch information
hpakdaman authored Nov 1, 2019
1 parent a3c24eb commit d8e3c0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/Saman/Saman.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Larabookir\Gateway\Saman;

use Carbon\Carbon;
use Illuminate\Support\Facades\Request;
use SoapClient;
use Larabookir\Gateway\PortAbstract;
Expand All @@ -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}
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions src/Saman/SamanException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => 'چنین صادر کننده کارتی وجود ندارد',
Expand Down

0 comments on commit d8e3c0d

Please sign in to comment.