bug fix in pec gatepay
This commit is contained in:
parent
8eadcc8a86
commit
90b2b8a06c
|
@ -25,11 +25,23 @@ class PayMGR
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* function to generate random strings
|
||||||
|
* @param int $length number of characters in the generated string
|
||||||
|
* @return string a new string is created with random characters of the desired length
|
||||||
|
*/
|
||||||
|
private function RandomString($length = 32)
|
||||||
|
{
|
||||||
|
return substr(str_shuffle(str_repeat($x = '123456789', ceil($length / strlen($x)))), 1, $length);
|
||||||
|
}
|
||||||
|
|
||||||
public function createRequest($price, $callback_url, $des = '', $orderID = 0): array
|
public function createRequest($price, $callback_url, $des = '', $orderID = 0): array
|
||||||
{
|
{
|
||||||
$res = [
|
$res = [
|
||||||
'Success' => false,
|
'Success' => false,
|
||||||
];
|
];
|
||||||
|
if ($orderID == 0)
|
||||||
|
$orderID = $this->RandomString(15);
|
||||||
$activeGateway = $this->registry->get('system', 'activeGateway');
|
$activeGateway = $this->registry->get('system', 'activeGateway');
|
||||||
if ($activeGateway == 'zarinpal') {
|
if ($activeGateway == 'zarinpal') {
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@ -79,18 +91,19 @@ class PayMGR
|
||||||
"Originator" => ''
|
"Originator" => ''
|
||||||
);
|
);
|
||||||
$client = new \SoapClient($url);
|
$client = new \SoapClient($url);
|
||||||
|
|
||||||
|
$result = $client->SalePaymentRequest(array(
|
||||||
|
"requestData" => $params
|
||||||
|
));
|
||||||
|
if ($result->SalePaymentRequestResult->Token && $result->SalePaymentRequestResult->Status === 0) {
|
||||||
|
$res['code'] = 100;
|
||||||
|
$res['Success'] = true;
|
||||||
|
$res['gate'] = 'pec';
|
||||||
|
$res['message'] = 'OK';
|
||||||
|
$res['authkey'] = $result->SalePaymentRequestResult->Token;
|
||||||
|
$res['targetURL'] = 'https://pec.shaparak.ir/NewIPG/?Token=' . $result->SalePaymentRequestResult->Token;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$result = $client->SalePaymentRequest(array(
|
|
||||||
"requestData" => $params
|
|
||||||
));
|
|
||||||
if ($result->SalePaymentRequestResult->Token && $result->SalePaymentRequestResult->Status === 0) {
|
|
||||||
$res['code'] = 100;
|
|
||||||
$res['Success'] = true;
|
|
||||||
$res['gate'] = 'zarinpal';
|
|
||||||
$res['message'] = 'OK';
|
|
||||||
$res['authkey'] = $result->SalePaymentRequestResult->Token;
|
|
||||||
$res['targetURL'] = 'https://pec.shaparak.ir/NewIPG/?Token=' . $result->SalePaymentRequestResult->Token;
|
|
||||||
}
|
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,7 +112,7 @@ class PayMGR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function verify($price,$token, Request $request): array
|
public function verify($price, $token, Request $request): array
|
||||||
{
|
{
|
||||||
$res = [
|
$res = [
|
||||||
'Success' => false
|
'Success' => false
|
||||||
|
@ -133,14 +146,14 @@ class PayMGR
|
||||||
$res['status'] = 100;
|
$res['status'] = 100;
|
||||||
$res['refID'] = $result['data']['ref_id'];
|
$res['refID'] = $result['data']['ref_id'];
|
||||||
$res['card_pan'] = $result['data']['card_pan'];
|
$res['card_pan'] = $result['data']['card_pan'];
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($activeGateway == 'pec') {
|
} elseif ($activeGateway == 'pec') {
|
||||||
$confirmUrl = 'https://pec.shaparak.ir/NewIPGServices/Confirm/ConfirmService.asmx?WSDL';
|
$confirmUrl = 'https://pec.shaparak.ir/NewIPGServices/Confirm/ConfirmService.asmx?WSDL';
|
||||||
$params = array(
|
$params = array(
|
||||||
"LoginAccount" => $this->registry->get('system', 'parsianGatewayAPI'),
|
"LoginAccount" => $this->registry->get('system', 'parsianGatewayAPI'),
|
||||||
"Token" => $token
|
"Token" => $token
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -152,7 +165,7 @@ class PayMGR
|
||||||
if ($result->ConfirmPaymentResult->Status == '0') {
|
if ($result->ConfirmPaymentResult->Status == '0') {
|
||||||
$res['Success'] = true;
|
$res['Success'] = true;
|
||||||
$res['status'] = 100;
|
$res['status'] = 100;
|
||||||
$res['refID'] = $_POST ["RRN"];
|
$res['refID'] = $_POST["RRN"];
|
||||||
$res['card_pan'] = $result->CardNumberMasked;
|
$res['card_pan'] = $result->CardNumberMasked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue