I am implementing the transparent pagseguro checkout, however it says that all the variables I am sending are empty returning several errors. Here is the code:
$parametros = "email=$EcommerceEmail&token=$EcommerceToken&paymentMode=default&paymentMethod=creditCard¤cy=BRL$PagseguroProdutos¬ificationURL=http://meusite.me/pagseguro_notificacao.php?request=$IdRequest&reference=$IdRequest&senderName=$CustomerName&senderCPF=$CustomerCPF&senderAreaCode=$CustomerAreaCode&senderPhone=$CustomerPhone&[email protected]&senderHash=$senderHash&creditCardToken=$cartaoToken&installmentQuantity=$pagamentoParcela&installmentValue=$pagamentoValorParcela&noInterestInstallmentQuantity=$EcommerceInstallment&creditCardHolderName=$cartaoNome&creditCardHolderCPF=$cartaoCPF&creditCardHolderBirthDate=cartaoNascimento&creditCardHolderAreaCode=$cartaoAreaCode&creditCardHolderPhone=$cartaoPhone&billingAddressStreet=$cartaoRua&billingAddressNumber=$cartaoNumeroResidencial&billingAddressDistrict=cartaoBairro&billingAddressPostalCode=$cartaoCEP&billingAddressCity=$cartaoCidade&billingAddressState=$cartaoEstado&billingAddressCountry=BRA";
//pega o email e token do lojista
$post['email'] = $EcommerceEmail;
$post['token'] = $EcommerceToken;
//executa a compra
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_HTTPHEADER, Array('Content-Type: application/x-www-form-urlencoded; charset=UTF-8'));
curl_setopt($curl, CURLOPT_URL, "https://ws.sandbox.pagseguro.uol.com.br/v2/transactions?$parametros");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
$response = simplexml_load_string($response);
$PagseguroSessionID = $response->id;
Payout Return:
object(SimpleXMLElement)#1 (1) { ["error"]=> array(28) { [0]=> object(SimpleXMLElement)#2 (2) { ["code"]=> string(5) "53005" ["message"]=> string(21) "currency is required." } [1]=> object(SimpleXMLElement)#3 (2) { ["code"]=> string(5) "53018" ["message"]=> string(29) "sender area code is required." } [2]=> object(SimpleXMLElement)#4 (2) { ["code"]=> string(5) "53020" ["message"]=> string(25) "sender phone is required." } [3]=> object(SimpleXMLElement)#5 (2) { ["code"]=> string(5) "53118" ["message"]=> string(38) "sender cpf or sender cnpj is required." } [4]=> object(SimpleXMLElement)#6 (2) { ["code"]=> string(5) "53013" ["message"]=> string(24) "sender name is required." } [5]=> object(SimpleXMLElement)#7 (2) { ["code"]=> string(5) "53010" ["message"]=> string(25) "sender email is required." } [6]=> object(SimpleXMLElement)#8 (2) { ["code"]=> string(5) "53031" ["message"]=> string(34) "shipping address city is required." } [7]=> object(SimpleXMLElement)#9 (2) { ["code"]=> string(5) "53033" ["message"]=> string(35) "shipping address state is required." } [8]=> object(SimpleXMLElement)#10 (2) { ["code"]=> string(5) "53024" ["message"]=> string(36) "shipping address street is required." } [9]=> object(SimpleXMLElement)#11 (2) { ["code"]=> string(5) "53022" ["message"]=> string(41) "shipping address postal code is required." } [10]=> object(SimpleXMLElement)#12 (2) { ["code"]=> string(5) "53029" ["message"]=> string(38) "shipping address district is required." } [11]=> object(SimpleXMLElement)#13 (2) { ["code"]=> string(5) "53035" ["message"]=> string(37) "shipping address country is required." } [12]=> object(SimpleXMLElement)#14 (2) { ["code"]=> string(5) "53026" ["message"]=> string(36) "shipping address number is required." } [13]=> object(SimpleXMLElement)#15 (2) { ["code"]=> string(5) "53037" ["message"]=> string(30) "credit card token is required." } [14]=> object(SimpleXMLElement)#16 (2) { ["code"]=> string(5) "53053" ["message"]=> string(40) "billing address postal code is required." } [15]=> object(SimpleXMLElement)#17 (2) { ["code"]=> string(5) "53062" ["message"]=> string(33) "billing address city is required." } [16]=> object(SimpleXMLElement)#18 (2) { ["code"]=> string(5) "53045" ["message"]=> string(35) "credit card holder cpf is required." } [17]=> object(SimpleXMLElement)#19 (2) { ["code"]=> string(5) "53066" ["message"]=> string(36) "billing address country is required." } [18]=> object(SimpleXMLElement)#20 (2) { ["code"]=> string(5) "53042" ["message"]=> string(36) "credit card holder name is required." } [19]=> object(SimpleXMLElement)#21 (2) { ["code"]=> string(5) "53060" ["message"]=> string(37) "billing address district is required." } [20]=> object(SimpleXMLElement)#22 (2) { ["code"]=> string(5) "53038" ["message"]=> string(33) "installment quantity is required." } [21]=> object(SimpleXMLElement)#23 (2) { ["code"]=> string(5) "53064" ["message"]=> string(34) "billing address state is required." } [22]=> object(SimpleXMLElement)#24 (2) { ["code"]=> string(5) "53040" ["message"]=> string(30) "installment value is required." } [23]=> object(SimpleXMLElement)#25 (2) { ["code"]=> string(5) "53057" ["message"]=> string(35) "billing address number is required." } [24]=> object(SimpleXMLElement)#26 (2) { ["code"]=> string(5) "53055" ["message"]=> string(35) "billing address street is required." } [25]=> object(SimpleXMLElement)#27 (2) { ["code"]=> string(5) "53047" ["message"]=> string(41) "credit card holder birthdate is required." } [26]=> object(SimpleXMLElement)#28 (2) { ["code"]=> string(5) "53051" ["message"]=> string(37) "credit card holder phone is required." } [27]=> object(SimpleXMLElement)#29 (2) { ["code"]=> string(5) "53049" ["message"]=> string(41) "credit card holder area code is required." } } }