bug fix in pec gatepay

This commit is contained in:
Hesabix 2025-02-14 22:47:43 +00:00
parent 8eadcc8a86
commit 90b2b8a06c

View file

@ -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
{
$res = [
'Success' => false,
];
if ($orderID == 0)
$orderID = $this->RandomString(15);
$activeGateway = $this->registry->get('system', 'activeGateway');
if ($activeGateway == 'zarinpal') {
$data = array(
@ -79,18 +91,19 @@ class PayMGR
"Originator" => ''
);
$client = new \SoapClient($url);
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['gate'] = 'pec';
$res['message'] = 'OK';
$res['authkey'] = $result->SalePaymentRequestResult->Token;
$res['targetURL'] = 'https://pec.shaparak.ir/NewIPG/?Token=' . $result->SalePaymentRequestResult->Token;
}
try {
} catch (\Exception $ex) {
}