public static function createCheckoutRequest(Credentials $credentials, PaymentRequest $paymentRequest)
 {
     LogPagSeguro::info("PaymentService.Register(" . $paymentRequest->toString() . ") - begin");
     $connectionData = new PagSeguroConnectionData($credentials, self::serviceName);
     try {
         $connection = new HttpConnection();
         $connection->post(self::buildCheckoutRequestUrl($connectionData), PaymentParser::getData($paymentRequest), $connectionData->getServiceTimeout(), $connectionData->getCharset());
         $httpStatus = new HttpStatus($connection->getStatus());
         switch ($httpStatus->getType()) {
             case 'OK':
                 $PaymentParserData = PaymentParser::readSuccessXml($connection->getResponse());
                 $paymentUrl = self::buildCheckoutUrl($connectionData, $PaymentParserData->getCode());
                 LogPagSeguro::info("PaymentService.Register(" . $paymentRequest->toString() . ") - end {1}" . $PaymentParserData->getCode());
                 break;
             case 'BAD_REQUEST':
                 $errors = PaymentParser::readErrors($connection->getResponse());
                 $e = new PagSeguroServiceException($httpStatus, $errors);
                 LogPagSeguro::error("PaymentService.Register(" . $paymentRequest->toString() . ") - error " . $e->getOneLineMessage());
                 throw $e;
                 break;
             default:
                 $e = new PagSeguroServiceException($httpStatus);
                 LogPagSeguro::error("PaymentService.Register(" . $paymentRequest->toString() . ") - error " . $e->getOneLineMessage());
                 throw $e;
                 break;
         }
         return isset($paymentUrl) ? $paymentUrl : false;
     } catch (PagSeguroServiceException $e) {
         throw $e;
     } catch (Exception $e) {
         LogPagSeguro::error("Exception: " . $e->getMessage());
         throw $e;
     }
 }
Example #2
0
$count_failed = 0;
if (!empty($_POST['url_single'])) {
    $url_array[] = $_POST['url_single'];
} else {
    //Lectura del xml
    echo "<p>Leyendo fichero xml</p>";
    $url_array = leyendo_xml($url_xml);
}
$http = new HttpConnection();
//$http->setCookiePath("cookies/");
$http->init();
/*$registration = array('email'=>'*****@*****.**','passwd'=>"Ayudasmayores",'back'=>"my-account","SubmitLogin"=>"");
	$http->post("http://cosmomedica.com/shop/autenticacion",$registration,true,true);*/
if (isset($user) && isset($pass)) {
    $registration = array('email' => $user, 'passwd' => $pass, 'back' => "my-account", "SubmitLogin" => "");
    $http->post($site_url, $registration, true, true);
    echo "<p>registrandose en la aplicacion</p>";
} else {
    $http->get($site_url, true);
}
$ref_shop = '';
try {
    $DOM = new DOMDocument();
    include $script;
} catch (Exception $e) {
    echo "Procesando url: " . $my_url . "<br />";
    echo "Caught Exception (" . $e->getMessage() . ")\n{$e}\n";
} finally {
    if (count($url_array) > 0) {
        file_put_contents("file/url_list.ccd", "");
        while (count($url_array) > 0) {