после многих попыток я обнаружил, что с этой библиотекой возникла проблема, и попробую ее самостоятельно, следующий код работает для меня, и вы должны быть только уверены, что soap_client доступен на вашем компьютере
public function ZarinpalRequest($price, $size, $cardID)
{
$session = new Session();
$session->start();
/*zarinpal copy code*/
$MerchantID = 'xxxxxxxxxxxxxxxxxxxxxx'; //Required
$amount = ((int)$price);
$Description = 'test desc';
$Email = 'example@gmaol.com';
//callback url most be absolute url
$CallbackURL = $this->generateUrl('verifyTemplate', array(), UrlGeneratorInterface::ABSOLUTE_URL);
//this is sandbox mode gateway address
$client = new \SoapClient('https://sandbox.zarinpal.com/pg/services/WebGate/wsdl', ['encoding' => 'UTF-8']);
$result = $client->PaymentRequest(
[
'MerchantID' => $MerchantID,
'Amount' => $amount,
'Description' => $Description,
'Email' => $Email,
'CallbackURL' => $CallbackURL,
]
);
if ($result->Status == 100) {
$session->set('amount',$amount);
$session->set('authority',$result->Authority);
$session->set('cardID',$cardID);
$session->set('checked',true);
return new RedirectResponse("https://sandbox.zarinpal.com/pg/StartPay/".$result->Authority);
} else {
dd('ERR: ' . $result->Status) ;
}
}
public function ZarinpalResponse()
{
$session = new Session();
$session->start();
$MerchantID = 'xxxxxxxxxxxxxxxxxxxxx';
$Amount = $session->get('amount');
$check = $session->get('checked');
$Authority = $_GET['Authority'];
if ($_GET['Status'] == 'OK') {
$client = new \SoapClient('https://sandbox.zarinpal.com/pg/services/WebGate/wsdl', ['encoding' => 'UTF-8']);
$result = $client->PaymentVerification(
[
'MerchantID' => $MerchantID,
'Authority' => $Authority,
'Amount' => $Amount,
]);
if ($result->Status == 100 && $check ) {
$repository=$this->getDoctrine()->getRepository(Carts::class);
$cart=$repository->find($cardID);
if ($cart!==null){
//this is transaction number and should save it
$refid=$result->RefID
$this->sendEmail($cardID,$this->mailer,$this->helper);
$session->clear();
}
return $this->render('verify.twig',array('refID'=>$result->RefID));
} else {
return new Response('Transaction failed. Status:' . $result->Status) ;
}
} else {
return new Response('Transaction canceled by user') ;
}
}
и в вашем коде вызывайте только ZarrinpalRequest с правильным параметром