Guest User

Untitled

a guest
Oct 21st, 2024
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use Illuminate\Http\Request;
  6. use App\Bambino;
  7. use App\CentroEstivo;
  8. use Carbon\Carbon;
  9. use Illuminate\Support\Facades\Auth;
  10. use Illuminate\Support\Facades\Log;
  11.  
  12. use SoapClient;
  13. use SoapFault;
  14.  
  15. ini_set('soap.wsdl_cache_enabled', 0);
  16. ini_set('soap.wsdl_cache_ttl', 0);
  17.  
  18. class CartaDocenteController extends Controller
  19. {
  20. public function checkVoucher(Request $request) {
  21. if (strlen($request['voucher']) != 8)
  22. return redirect()->back()->with('error', 'Il voucher inserito non รจ valido');
  23.  
  24. $wsdl = base_path() . '/CartaDocente/VerificaVoucher.wsdl';
  25. $endpoint = 'https://ws.cartadeldocente.istruzione.it/VerificaVoucherDocWEB/VerificaVoucher';
  26. $certificate = base_path() . '/CartaDocente/'***********.p12';
  27. $password = '';
  28. $partitaIva = '***********';
  29.  
  30. $options = [
  31. 'location' => $endpoint,
  32. 'local_cert' => $certificate,
  33. 'passphrase' => $password,
  34. 'cache_wsdl' => WSDL_CACHE_NONE,
  35. ];
  36.  
  37. $client = new SoapClient($wsdl, $options);
  38.  
  39. try {
  40. $result = $client->Check(array(
  41. 'checkReq' => array(
  42. 'tipoOperazione' => '1',
  43. 'codiceVoucher' => '11aa22bb',
  44. 'partitaIvaEsercente' => $partitaIva
  45. )
  46. ));
  47.  
  48. $result = json_decode(json_encode($result), true);
  49.  
  50. Log::info($result);
  51. } catch (SoapFault $e) {
  52. throw new \Exception('SOAP Fault: ' . $e->getMessage());
  53. } catch (Exception $e) {
  54. throw new \Exception('Richiesta SOAP fallita: ' . $e);
  55. }
  56. finally {
  57. Log::info("Response:\n" . $client->__getLastResponse() . "\n");
  58. }
  59. }
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment