Guest User

Untitled

a guest
Oct 18th, 2024
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | Source Code | 0 0
  1. public function getVoucher($voucher, $certified_ssl, $service_url, $pem_passphrase, $wsdl, $piva_merchant, $test_mode, $debug, $uri){
  2.  
  3. if ($test_mode == 1) {
  4. $soapOpt = array(
  5. 'location' => $service_url,
  6. 'uri' => $uri,
  7. 'style' => SOAP_RPC,
  8. 'use' => SOAP_ENCODED,
  9. 'soap_version' => SOAP_1_1,
  10. 'stream_context' => stream_context_create(array(
  11. 'ssl' => array(
  12. 'crypto_method' =>
  13. STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
  14. )
  15. )),
  16. 'stream_context'=> stream_context_create(array('ssl'=> array(
  17. 'verify_peer'=>false,
  18. 'verify_peer_name'=>false,
  19. 'allow_self_signed' => true
  20. ))),
  21. 'local_cert' => $certified_ssl,
  22. 'passphrase' => $pem_passphrase
  23. );
  24.  
  25. if ($debug == 1) {
  26. // "Debug: ".$service_url.", ".$certified_ssl.", ".$pem_passphrase."<br>";
  27. }
  28.  
  29. } else {
  30. $soapOpt = array(
  31. 'location' => $service_url,
  32. 'uri' => $uri,
  33. 'style' => SOAP_RPC,
  34. 'use' => SOAP_ENCODED,
  35. 'soap_version' => SOAP_1_1,
  36. 'stream_context' => stream_context_create(array(
  37. 'ssl' => array(
  38. 'crypto_method' =>
  39. STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
  40. )
  41. )),
  42. 'local_cert' => $certified_ssl,
  43. 'passphrase' => $pem_passphrase
  44. );
  45. if ($debug == 1) {
  46. // "Produttive mode: ".$service_url.", ".$certified_ssl.", ".$pem_passphrase."<br>";
  47. }
  48. }
  49.  
  50.  
  51.  
  52. $client = new SoapClient($wsdl, $soapOpt);
  53. try {
  54. $item = $client->Check(array("checkReq"=>array("tipoOperazione"=>"1","codiceVoucher"=>$voucher, 'partitaIvaEsercente' => $piva_merchant)));
  55. $resp = new STDClass();
  56. $resp->beneficiario = $item->checkResp->nominativoBeneficiario;
  57. $resp->pivaEsercente = $item->checkResp->partitaIvaEsercente;
  58. $resp->ambito = $item->checkResp->ambito;
  59. $resp->bene = $item->checkResp->bene;
  60. $resp->importo = $item->checkResp->importo;
  61. $resp->exceptionCode = 0;
  62.  
  63.  
  64. } catch(SoapFault $e) {
  65.  
  66. $resp = new STDClass();
  67. $resp->exceptionCode = $e->detail->FaultVoucher->exceptionCode;
  68. $resp->exceptionMessage = $e->detail->FaultVoucher->exceptionMessage;
  69.  
  70. }
  71. return $resp;
  72. }
  73.  
  74. public function confirmVoucher($voucher, $certified_ssl, $service_url, $pem_passphrase, $wsdl, $amount, $test_mode, $debug, $uri){
  75.  
  76.  
  77. if ($test_mode == 1) {
  78. $soapOpt = array(
  79. 'location' => $service_url,
  80. 'uri' => $uri,
  81. 'style' => SOAP_RPC,
  82. 'use' => SOAP_ENCODED,
  83. 'soap_version' => SOAP_1_1,
  84. 'stream_context' => stream_context_create(array(
  85. 'ssl' => array(
  86. 'crypto_method' =>
  87. STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
  88. )
  89. )),
  90. 'stream_context'=> stream_context_create(array('ssl'=> array(
  91. 'verify_peer'=>false,
  92. 'verify_peer_name'=>false,
  93. 'allow_self_signed' => true
  94. ))),
  95. 'local_cert' => $certified_ssl,
  96. 'passphrase' => $pem_passphrase
  97. );
  98. if ($debug == 1) {
  99. // "Debug: ".$service_url.", ".$certified_ssl.", ".$pem_passphrase."<br>";
  100. }
  101.  
  102. } else {
  103. $soapOpt = array(
  104. 'location' => $service_url,
  105. 'uri' => pSQL($uri),
  106. 'style' => SOAP_RPC,
  107. 'use' => SOAP_ENCODED,
  108. 'soap_version' => SOAP_1_1,
  109. 'stream_context' => stream_context_create(array(
  110. 'ssl' => array(
  111. 'crypto_method' =>
  112. STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
  113. )
  114. )),
  115. 'local_cert' => $certified_ssl,
  116. 'passphrase' => $pem_passphrase
  117. );
  118. if ($debug == 1) {
  119. // "Debug: ".$service_url.", ".$certified_ssl.", ".$pem_passphrase."<br>";
  120. }
  121.  
  122. }
  123.  
  124.  
  125.  
  126. $client = new SoapClient($wsdl, $soapOpt);
  127. try {
  128. $item = $client->Confirm(array("checkReq"=>array("tipoOperazione"=>"1","codiceVoucher"=>$voucher, 'importo' => $amount)));
  129. $resp = new STDClass();
  130. $resp->esito = $item->checkResp->esito;
  131. $resp->exceptionCode = 0;
  132.  
  133. } catch(SoapFault $e) {
  134. $resp = new STDClass();
  135. $resp->exceptionCode = 1;
  136. $resp->exceptionMessage = $e->detail->FaultVoucher->exceptionMessage;
  137. }
  138.  
  139. return $resp;
  140. }
Advertisement
Add Comment
Please, Sign In to add comment