LkS 0 Denunciar post Postado Abril 16, 2012 Estou tentando fazer uma integração basica com a api de php, inicialmente será sempre somente um item e um valor, a quantidade também será um. Depois vou melhorando, só que da forma que fiz (seguindo o exemplo da api) estou recebendo erro http 500 no servidor do pagseguro. Segue meu codigo: <?php require_once "PagSeguroLibrary/PagSeguroLibrary.php"; class createPaymentRequest { public static function main () { // Instantiate a new payment request $paymentRequest = new PagSeguroPaymentRequest(); // Sets the currency $paymentRequest->setCurrency("BRL"); // Add an item for this payment request $paymentRequest->addItem('0001', $_POST["produto"], $_POST["valor"], '1.00'); // Sets a reference code for this payment request, it is useful to identify this payment in future notifications. $paymentRequest->setReference("REF1234"); // Sets shipping information for this payment request $CODIGO_SEDEX = PagSeguroShippingType::getCodeByType('SEDEX'); $paymentRequest->setShippingType($CODIGO_SEDEX); $paymentRequest->setShippingAddress('01452002', 'Av. Brig. Faria Lima', '1384', 'apto. 114', 'Jardim Paulistano', 'São Paulo', 'SP', 'BRA'); // Sets your customer information. $paymentRequest->setSender($_POST["cliente"]); $paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br"); try { /* * #### Crendencials ##### * Substitute the parameters below with your credentials (e-mail and token) * You can also get your credentails from a config file. See an example: * $credentials = PagSeguroConfig::getAccountCredentials(); */ $credentials = new PagSeguroAccountCredentials("(censurado)", "(censurado)"); // Register this payment request in PagSeguro, to obtain the payment URL for redirect your customer. $url = $paymentRequest->register($credentials); self::printPaymentUrl($url); } catch (PagSeguroServiceException $e) { die($e->getMessage()); } } public static function printPaymentUrl($url) { if ($url) { echo "<h2>Criando requisição de pagamento</h2>"; echo "<p>URL do pagamento: <strong>$url</strong></p>"; echo "<p><a title=\"URL do pagamento\" href=\"$url\">Ir para URL do pagamento.</a></p>"; } } } createPaymentRequest::main(); ?> O "engraçado" é que só dá o erro http 500, internal server erro, nao diz aonde está o problema. :( Compartilhar este post Link para o post Compartilhar em outros sites
alcaidedigital 57 Denunciar post Postado Abril 16, 2012 Tenta fazer requisição usando esse tutorial: http://sounoob.com.br/2011/11/09/criando-uma-requisicao-de-pagamento-do-pagseguro-via-parametros-http-usando-php-sem-utilizar-a-biblioteca-oficial/ Compartilhar este post Link para o post Compartilhar em outros sites
LkS 0 Denunciar post Postado Abril 16, 2012 agradeço a ajuda mas preciso que seja pela api. Compartilhar este post Link para o post Compartilhar em outros sites
alcaidedigital 57 Denunciar post Postado Abril 18, 2012 Como mostrei no tutorial é realizado com a API também, a unica diferença é que não estou usando a biblioteca do PagSeguro, e você tem a possibilidade de entender tudo o que o código irá fazer, dessa forma uma manutenção será mais fácil. Creio que a biblioteca seja desnecessária para quem já sabe realizar as conexões, uma vez que não traz nenhuma outra vantagem. Compartilhar este post Link para o post Compartilhar em outros sites