­10. Sample codes

Please find below sample of requests and responses in different languages to submit a credit card order.

10.1. cURL

Request:

curl -d "secret=input_your_secret&pbtoken=input_your_token&order=1234567890&payment_method=C&product_name=Product+Test+(1+license)&customer_name=José+da+Silva&customer_taxid=91051605962&customer_email=josedasilvamyemail.com.br&customer_phone=113328.9999&customer_ip=255.255.255.255&address_street=AvPaulista,+100&address_zip=01311100&address_city=São+Paulo&address_state=SP&amount_brl=3950&cc_installments=1&cc_holder=joaoda+silva&cc_number=4984123412341234&cc_expiration=1219&cc_cvv=123&soft_descriptor=TEST&cc_save=0&cc_prevsaved=&cc_auth=0&param_url=customer_id12345%26newsletter=yes&visitor_id=" -X POST "https://sandbox.pagbrasil.com/api/order/add"

10.2. PHP

Request:

<?php $servidor = "https://sandbox.pagbrasil.com/api/order/add"; $content = http_build_query( array( "secret" => 'input_your_secret', "pbtoken" => 'input_your_token', "order" => '1234567890', "payment_method" => 'C', "product_name" => 'Product Test (1 license)', "customer_name" => 'José da Silva', "customer_taxid" => '91051605962', "customer_email" => 'josedasilva@myemail.com.br', "customer_phone" => '11 3328.9999', "customer_ip" => '255.255.255.255', "address_street" => 'Av.Paulista, 100', "address_zip" => '01311100', "address_city" => 'São Paulo', "address_state" => 'SP', "amount_brl" => '39.50', "cc_installments" => '1', "cc_holder" => 'joao da silva', "cc_number" => '4984123412341234', "cc_expiration" => '12/29', "cc_cvv" => '123', "soft_descriptor" => 'TEST', "cc_save" => '0', "cc_prevsaved" => '', "cc_auth" => '0', "param_url" => 'customer_id=12345%26newsletter=yes', "visitor_id" => '' ) ); $context = stream_context_create(array( 'http' => array( 'method' => 'POST', 'header' => "Connection: close\r\n". "Content-type: application/x-www-form-urlencoded\r\n". "Content-Length: ".strlen($content)."\r\n", 'content' => $content ) )); $contents = file_get_contents($servidor, null, $context); ?>

10.3. .NET

Request:

using System.Net; using System.Collections.Specialized; using (var client = new WebClient()) { var values = new NameValueCollection(); values["secret"] = "input_your_secret"; values["pbtoken"] = "input_your_token"; values["order"] = "1234567890"; values["payment_method"] = "C"; values["product_name"] = "Product Test (1 license)"; values["customer_name"] = "José da Silva"; values["customer_taxid"] = "91051605962"; values["customer_email"] = "josedasilva@myemail.com.br"; values["customer_phone"] = "11 3328.9999"; values["customer_ip"] = "255.255.255.25"; values["address_street"] = "Av.Paulista, 100"; values["address_zip"] = "01311100"; values["address_city"] = "S#227;o Paulo"; values["address_state"] = "SP"; values["amount_brl"] = "39.50"; values["cc_installments"] = "1"; values["cc_holder"] = "joao da silva"; values["cc_number"] = "4984123412341234"; values["cc_expiration"] = "12/29"; values["cc_cvv"] = "123"; values["soft_descriptor"] = "TEST"; values["cc_save"] = "0"; values["cc_prevsaved"] = ""; values["cc_auth"] = "0"; values["param_url"] = "customer_id=12345%26newsletter=yes"; values["visitor_id"] = ""; var response = client.UploadValues("https://sandbox.pagbrasil.com/api/order/add", values); var responseString = Encoding.DefaultGetString(response); }

10.4. Node.js

Request:


10.5. Response

CONFIDENTIAL