Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getVoucher($voucher, $certified_ssl, $service_url, $pem_passphrase, $wsdl, $piva_merchant, $test_mode, $debug, $uri){
- if ($test_mode == 1) {
- $soapOpt = array(
- 'location' => $service_url,
- 'uri' => $uri,
- 'style' => SOAP_RPC,
- 'use' => SOAP_ENCODED,
- 'soap_version' => SOAP_1_1,
- 'stream_context' => stream_context_create(array(
- 'ssl' => array(
- 'crypto_method' =>
- STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
- )
- )),
- 'stream_context'=> stream_context_create(array('ssl'=> array(
- 'verify_peer'=>false,
- 'verify_peer_name'=>false,
- 'allow_self_signed' => true
- ))),
- 'local_cert' => $certified_ssl,
- 'passphrase' => $pem_passphrase
- );
- if ($debug == 1) {
- // "Debug: ".$service_url.", ".$certified_ssl.", ".$pem_passphrase."<br>";
- }
- } else {
- $soapOpt = array(
- 'location' => $service_url,
- 'uri' => $uri,
- 'style' => SOAP_RPC,
- 'use' => SOAP_ENCODED,
- 'soap_version' => SOAP_1_1,
- 'stream_context' => stream_context_create(array(
- 'ssl' => array(
- 'crypto_method' =>
- STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
- )
- )),
- 'local_cert' => $certified_ssl,
- 'passphrase' => $pem_passphrase
- );
- if ($debug == 1) {
- // "Produttive mode: ".$service_url.", ".$certified_ssl.", ".$pem_passphrase."<br>";
- }
- }
- $client = new SoapClient($wsdl, $soapOpt);
- try {
- $item = $client->Check(array("checkReq"=>array("tipoOperazione"=>"1","codiceVoucher"=>$voucher, 'partitaIvaEsercente' => $piva_merchant)));
- $resp = new STDClass();
- $resp->beneficiario = $item->checkResp->nominativoBeneficiario;
- $resp->pivaEsercente = $item->checkResp->partitaIvaEsercente;
- $resp->ambito = $item->checkResp->ambito;
- $resp->bene = $item->checkResp->bene;
- $resp->importo = $item->checkResp->importo;
- $resp->exceptionCode = 0;
- } catch(SoapFault $e) {
- $resp = new STDClass();
- $resp->exceptionCode = $e->detail->FaultVoucher->exceptionCode;
- $resp->exceptionMessage = $e->detail->FaultVoucher->exceptionMessage;
- }
- return $resp;
- }
- public function confirmVoucher($voucher, $certified_ssl, $service_url, $pem_passphrase, $wsdl, $amount, $test_mode, $debug, $uri){
- if ($test_mode == 1) {
- $soapOpt = array(
- 'location' => $service_url,
- 'uri' => $uri,
- 'style' => SOAP_RPC,
- 'use' => SOAP_ENCODED,
- 'soap_version' => SOAP_1_1,
- 'stream_context' => stream_context_create(array(
- 'ssl' => array(
- 'crypto_method' =>
- STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
- )
- )),
- 'stream_context'=> stream_context_create(array('ssl'=> array(
- 'verify_peer'=>false,
- 'verify_peer_name'=>false,
- 'allow_self_signed' => true
- ))),
- 'local_cert' => $certified_ssl,
- 'passphrase' => $pem_passphrase
- );
- if ($debug == 1) {
- // "Debug: ".$service_url.", ".$certified_ssl.", ".$pem_passphrase."<br>";
- }
- } else {
- $soapOpt = array(
- 'location' => $service_url,
- 'uri' => pSQL($uri),
- 'style' => SOAP_RPC,
- 'use' => SOAP_ENCODED,
- 'soap_version' => SOAP_1_1,
- 'stream_context' => stream_context_create(array(
- 'ssl' => array(
- 'crypto_method' =>
- STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
- )
- )),
- 'local_cert' => $certified_ssl,
- 'passphrase' => $pem_passphrase
- );
- if ($debug == 1) {
- // "Debug: ".$service_url.", ".$certified_ssl.", ".$pem_passphrase."<br>";
- }
- }
- $client = new SoapClient($wsdl, $soapOpt);
- try {
- $item = $client->Confirm(array("checkReq"=>array("tipoOperazione"=>"1","codiceVoucher"=>$voucher, 'importo' => $amount)));
- $resp = new STDClass();
- $resp->esito = $item->checkResp->esito;
- $resp->exceptionCode = 0;
- } catch(SoapFault $e) {
- $resp = new STDClass();
- $resp->exceptionCode = 1;
- $resp->exceptionMessage = $e->detail->FaultVoucher->exceptionMessage;
- }
- return $resp;
- }
Advertisement
Add Comment
Please, Sign In to add comment