Created
June 7, 2019 15:44
-
-
Save saber13812002/5214a510be146d53ac7a8f31676d1fc6 to your computer and use it in GitHub Desktop.
Laravel when add larabook/gateway (Mellat gateway), but I get below error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl' :
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Larautility\Gateway\Mellat; | |
use DateTime; | |
use Illuminate\Support\Facades\Input; | |
use Larautility\Gateway\Enum; | |
use SoapClient; | |
use Larautility\Gateway\PortAbstract; | |
use Larautility\Gateway\PortInterface; | |
class Mellat extends PortAbstract implements PortInterface | |
{ | |
/** | |
* Address of main SOAP server | |
* | |
* @var string | |
*/ | |
protected $serverUrl = 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl'; | |
/** | |
* {@inheritdoc} | |
*/ | |
public function set($amount) | |
{ | |
$this->amount = $amount; | |
return $this; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function ready() | |
{ | |
$this->sendPayRequest(); | |
return $this; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function redirect() | |
{ | |
$refId = $this->refId; | |
return \View::make('gateway::mellat-redirector')->with(compact('refId')); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function verify($transaction) | |
{ | |
parent::verify($transaction); | |
$this->userPayment(); | |
$this->verifyPayment(); | |
$this->settleRequest(); | |
return $this; | |
} | |
/** | |
* Sets callback url | |
* @param $url | |
*/ | |
function setCallback($url) | |
{ | |
$this->callbackUrl = $url; | |
return $this; | |
} | |
/** | |
* Gets callback url | |
* @return string | |
*/ | |
function getCallback() | |
{ | |
if (!$this->callbackUrl) | |
$this->callbackUrl = $this->config->get('gateway.mellat.callback-url'); | |
return $this->makeCallback($this->callbackUrl, ['transaction_id' => $this->transactionId()]); | |
} | |
/** | |
* Send pay request to server | |
* | |
* @return void | |
* | |
* @throws MellatException | |
*/ | |
protected function sendPayRequest() | |
{ | |
$dateTime = new DateTime(); | |
$this->newTransaction(); | |
$fields = array( | |
'terminalId' => $this->config->get('gateway.mellat.terminalId'), | |
'userName' => $this->config->get('gateway.mellat.username'), | |
'userPassword' => $this->config->get('gateway.mellat.password'), | |
'orderId' => $this->transactionId(), | |
'amount' => $this->amount, | |
'localDate' => $dateTime->format('Ymd'), | |
'localTime' => $dateTime->format('His'), | |
'additionalData' => '', | |
'callBackUrl' => $this->getCallback(), | |
'payerId' => 0, | |
); | |
try { | |
$context = stream_context_create( | |
[ | |
'ssl' => array( | |
'verify_peer' => false, | |
'verify_peer_name' => false | |
) | |
] | |
); | |
$soap = new SoapClient($this->serverUrl, [ | |
'stream_context' => $context | |
]); | |
//$soap = new \SoapClient($this->serverUrl); | |
$response = $soap->bpPayRequest($fields); | |
} catch (\SoapFault $e) { | |
$this->transactionFailed(); | |
$this->newLog('SoapFault', $e->getMessage()); | |
throw $e; | |
} | |
$response = explode(',', $response->return); | |
if ($response[0] != '0') { | |
$this->transactionFailed(); | |
$this->newLog($response[0], MellatException::$errors[$response[0]]); | |
throw new MellatException($response[0]); | |
} | |
$this->refId = $response[1]; | |
$this->transactionSetRefId(); | |
} | |
/** | |
* Check user payment | |
* | |
* @return bool | |
* | |
* @throws MellatException | |
*/ | |
protected function userPayment() | |
{ | |
$this->refId = Input::get('RefId'); | |
$this->trackingCode = Input::get('SaleReferenceId'); | |
$this->cardNumber = Input::get('CardHolderPan'); | |
$payRequestResCode = Input::get('ResCode'); | |
if ($payRequestResCode == '0') { | |
return true; | |
} | |
$this->transactionFailed(); | |
$this->newLog($payRequestResCode, @MellatException::$errors[$payRequestResCode]); | |
throw new MellatException($payRequestResCode); | |
} | |
/** | |
* Verify user payment from bank server | |
* | |
* @return bool | |
* | |
* @throws MellatException | |
* @throws SoapFault | |
*/ | |
protected function verifyPayment() | |
{ | |
$fields = array( | |
'terminalId' => $this->config->get('gateway.mellat.terminalId'), | |
'userName' => $this->config->get('gateway.mellat.username'), | |
'userPassword' => $this->config->get('gateway.mellat.password'), | |
'orderId' => $this->transactionId(), | |
'saleOrderId' => $this->transactionId(), | |
'saleReferenceId' => $this->trackingCode() | |
); | |
try { | |
$context = stream_context_create( | |
[ | |
'ssl' => array( | |
'verify_peer' => false, | |
'verify_peer_name' => false | |
) | |
] | |
); | |
$soap = new SoapClient($this->serverUrl, [ | |
'stream_context' => $context | |
]); | |
//$soap = new SoapClient($this->serverUrl); | |
$response = $soap->bpVerifyRequest($fields); | |
} catch (\SoapFault $e) { | |
$this->transactionFailed(); | |
$this->newLog('SoapFault', $e->getMessage()); | |
throw $e; | |
} | |
if ($response->return != '0') { | |
$this->transactionFailed(); | |
$this->newLog($response->return, MellatException::$errors[$response->return]); | |
throw new MellatException($response->return); | |
} | |
return true; | |
} | |
/** | |
* Send settle request | |
* | |
* @return bool | |
* | |
* @throws MellatException | |
* @throws SoapFault | |
*/ | |
protected function settleRequest() | |
{ | |
$fields = array( | |
'terminalId' => $this->config->get('gateway.mellat.terminalId'), | |
'userName' => $this->config->get('gateway.mellat.username'), | |
'userPassword' => $this->config->get('gateway.mellat.password'), | |
'orderId' => $this->transactionId(), | |
'saleOrderId' => $this->transactionId(), | |
'saleReferenceId' => $this->trackingCode | |
); | |
try { | |
$context = stream_context_create( | |
[ | |
'ssl' => array( | |
'verify_peer' => false, | |
'verify_peer_name' => false | |
) | |
] | |
); | |
$soap = new SoapClient($this->serverUrl, [ | |
'stream_context' => $context | |
]); | |
//$soap = new SoapClient($this->serverUrl); | |
$response = $soap->bpSettleRequest($fields); | |
} catch (\SoapFault $e) { | |
$this->transactionFailed(); | |
$this->newLog('SoapFault', $e->getMessage()); | |
throw $e; | |
} | |
if ($response->return == '0' || $response->return == '45') { | |
$this->transactionSucceed(); | |
$this->newLog($response->return, Enum::TRANSACTION_SUCCEED_TEXT); | |
return true; | |
} | |
$this->transactionFailed(); | |
$this->newLog($response->return, MellatException::$errors[$response->return]); | |
throw new MellatException($response->return); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
سلام
من هم همین مشکل دارم
این خطا را می دهد
Error
HTTP Error: cURL ERROR: 6: Could not resolve host: bpm.shaparak.ir; Unknown error
url: https://bpm.shaparak.ir:443/pgwchannel/services/pgw?wsdl
content_type:
http_code: 0
header_size: 0
request_size: 0
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 5.515265
namelookup_time: 0
connect_time: 0
pretransfer_time: 0
size_upload: 0
size_download: 0
speed_download: 0
speed_upload: 0
download_content_length: -1
upload_content_length: -1
starttransfer_time: 0
redirect_time: 0
redirect_url:
primary_ip:
certinfo: Array
primary_port: 0
local_ip:
local_port: 0