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);
|
||||||
try {
|
|
||||||
$result = $client->SalePaymentRequest(array(
|
$result = $client->SalePaymentRequest(array(
|
||||||
"requestData" => $params
|
"requestData" => $params
|
||||||
));
|
));
|
||||||
if ($result->SalePaymentRequestResult->Token && $result->SalePaymentRequestResult->Status === 0) {
|
if ($result->SalePaymentRequestResult->Token && $result->SalePaymentRequestResult->Status === 0) {
|
||||||
$res['code'] = 100;
|
$res['code'] = 100;
|
||||||
$res['Success'] = true;
|
$res['Success'] = true;
|
||||||
$res['gate'] = 'zarinpal';
|
$res['gate'] = 'pec';
|
||||||
$res['message'] = 'OK';
|
$res['message'] = 'OK';
|
||||||
$res['authkey'] = $result->SalePaymentRequestResult->Token;
|
$res['authkey'] = $result->SalePaymentRequestResult->Token;
|
||||||
$res['targetURL'] = 'https://pec.shaparak.ir/NewIPG/?Token=' . $result->SalePaymentRequestResult->Token;
|
$res['targetURL'] = 'https://pec.shaparak.ir/NewIPG/?Token=' . $result->SalePaymentRequestResult->Token;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue