CONF_MEL_FROM, 'name' => 'Client Giant'), // To array(0 => array('email' => CONF_MEL_TO, 'name' => 'Support'))); } // --------------------------------------------------------------------------- // // getProviderId // --------------------------------------------------------------------------- // function getProviderId($pays) { switch ($pays) { case 'BE': return '001'; case 'NL': return '003'; default: print 'Erreur sur le pays'; exit; } } // --------------------------------------------------------------------------- // // getClient // --------------------------------------------------------------------------- // function getClient($pays, $service) { $service_header = new StdClass; $service_header->ConsumerId = '006'; $service_header->Provider = new StdClass; $service_header->Provider->CountryCode = $pays; $service_header->Provider->ProviderId = getProviderId($pays); $service_header->TimeStamp = date('Y-m-d\TH:i:s'); $service_header->TestIndication = true; $soap_header = new SoapHeader('http://services.giant-net.com/'. 'schema/services/shared/1.0', 'ServiceHeader', $service_header); $soap_client = new SoapClient('https://giant-tst.graydon.nl/'.$service.'/v1?wsdl', array('soap_version' => SOAP_1_1, 'login' => '006', 'password' => 'ClaudeMonet', 'trace' => true)); $soap_client->__setSoapHeaders($soap_header); return $soap_client; } // --------------------------------------------------------------------------- // // giantErreurSoap // --------------------------------------------------------------------------- // function giantErreurSoap(&$client, &$faute, $debug = false) { if ($debug == true || DEBUG_SOAP) { print_r($faute); print '

'; print 'Requete: '.htmlspecialchars($client->__getLastRequest()); print '

'; print 'Reponse: '.htmlspecialchars($client->__getLastResponse()); } else { envoieCourriel('SoapFault giantclient', print_r($faute, true). '\n\nRequete: '. htmlspecialchars($client->__getLastRequest()). '\n\nReponse: '. htmlspecialchars($client->__getLastResponse())); print 'Une erreur s\'est produite'; print 'Un courriel a été envoyé à l\'administrateur.'; print 'Veuillez essayer ultérieurement.'; } } // --------------------------------------------------------------------------- // // giantEtatDeCommande // --------------------------------------------------------------------------- // function giantEtatDeCommande(&$commande) { $client = getClient($commande->CountryCode, 'credit-data'); $o = new StdClass; $o->ProviderOrderId = $commande->ProviderOrderId; $o->InternalOrderId = $commande->InternalOrderId; try { $O = $client->__call('RetrieveOrderStatus', array($o)); } catch (SoapFault $f) { giantErreurSoap($client, $f, true); } $status = $O->Order->OrderStatus; if ($status == 'Undeliverable') { $commande->OrderStatus = 'Undeliverable'; $commande->save(); } else if ($status == 'Completed' && $commande->OrderStatus == 'Pending') { try { $O = $client->__call('RetrieveDataSet', array($o)); } catch (SoapFault $f) { giantErreurSoap($client, $f, true); } $r = new Rapports; $r->ProviderId = $commande->ProviderId; $r->CountryCode = $commande->CountryCode; $r->CompanyId = $commande->CompanyId; $r->ServiceLevelName = $commande->ServiceLevelName; $r->DataSetType = $commande->DataSetType; $r->LanguageCode = $commande->LanguageCode; $r->DataSet = serialize($O->DataSet); $r->OrderId = $commande->OrderId; $r->User = $commande->User; $r->DateTime = date('Y-m-d\TH:i:s'); $r->save(); $commande->OrderStatus = 'Completed'; $commande->DateTimeCompleted = $r->DateTime; $commande->ReportId = $r->ReportId; $commande->save(); } return $status; } ?>