Skip to content

Commit

Permalink
Merge pull request #102 from imanghafoori1/dev
Browse files Browse the repository at this point in the history
Code Clean up
  • Loading branch information
hpakdaman authored Feb 21, 2018
2 parents 9de70a9 + 094e2c7 commit 60d8f88
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 29 deletions.
6 changes: 6 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
preset: laravel

linting: true

disabled:
- single_class_element_per_statement
18 changes: 10 additions & 8 deletions src/Sadad/Sadad.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,17 @@ protected function verifyPayment()
private function getMessage($code, $message)
{
$result = SadadResult::codeResponse($code, $message);
if (!$result) {
$result = array(
'code' => SadadResult::UNKNOWN_CODE,
'message' => SadadResult::UNKNOWN_MESSAGE,
'fa' => 'خطای ناشناخته',
'en' => 'Unknown Error',
'retry' => false
);
if ($result) {
return $result;
}
$result = array(
'code' => SadadResult::UNKNOWN_CODE,
'message' => SadadResult::UNKNOWN_MESSAGE,
'fa' => 'خطای ناشناخته',
'en' => 'Unknown Error',
'retry' => false
);


return $result;
}
Expand Down
42 changes: 21 additions & 21 deletions src/Saman/Saman.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,32 +141,32 @@ protected function verifyPayment()

$response = intval($response);

if ($response != $this->amount) {

//Reverse Transaction
if($response>0){
try {
$soap = new SoapClient($this->serverUrl);
$response = $soap->ReverseTransaction($fields["RefNum"], $fields["merchantID"], $fields["password"], $response);

} catch (\SoapFault $e) {
$this->transactionFailed();
$this->newLog('SoapFault', $e->getMessage());
throw $e;
}
}
if ($response == $this->amount) {
$this->transactionSucceed();
return true;
}

//
$this->transactionFailed();
$this->newLog($response, SamanException::$errors[$response]);
throw new SamanException($response);
//Reverse Transaction
if($response>0){
try {
$soap = new SoapClient($this->serverUrl);
$response = $soap->ReverseTransaction($fields["RefNum"], $fields["merchantID"], $fields["password"], $response);

} catch (\SoapFault $e) {
$this->transactionFailed();
$this->newLog('SoapFault', $e->getMessage());
throw $e;
}
}

//
$this->transactionFailed();
$this->newLog($response, SamanException::$errors[$response]);
throw new SamanException($response);


$this->transactionSucceed();

return true;
}


}
}

0 comments on commit 60d8f88

Please sign in to comment.