Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use App\Bambino;
- use App\CentroEstivo;
- use Carbon\Carbon;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Log;
- use SoapClient;
- use SoapFault;
- ini_set('soap.wsdl_cache_enabled', 0);
- ini_set('soap.wsdl_cache_ttl', 0);
- class CartaDocenteController extends Controller
- {
- public function checkVoucher(Request $request) {
- if (strlen($request['voucher']) != 8)
- return redirect()->back()->with('error', 'Il voucher inserito non รจ valido');
- $wsdl = base_path() . '/CartaDocente/VerificaVoucher.wsdl';
- $endpoint = 'https://ws.cartadeldocente.istruzione.it/VerificaVoucherDocWEB/VerificaVoucher';
- $certificate = base_path() . '/CartaDocente/'***********.p12';
- $password = '';
- $partitaIva = '***********';
- $options = [
- 'location' => $endpoint,
- 'local_cert' => $certificate,
- 'passphrase' => $password,
- 'cache_wsdl' => WSDL_CACHE_NONE,
- ];
- $client = new SoapClient($wsdl, $options);
- try {
- $result = $client->Check(array(
- 'checkReq' => array(
- 'tipoOperazione' => '1',
- 'codiceVoucher' => '11aa22bb',
- 'partitaIvaEsercente' => $partitaIva
- )
- ));
- $result = json_decode(json_encode($result), true);
- Log::info($result);
- } catch (SoapFault $e) {
- throw new \Exception('SOAP Fault: ' . $e->getMessage());
- } catch (Exception $e) {
- throw new \Exception('Richiesta SOAP fallita: ' . $e);
- }
- finally {
- Log::info("Response:\n" . $client->__getLastResponse() . "\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment