Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Please find below sample of requests and responses in different languages to create a subscription.

9.1. cURL

Request:

curl -d "secret=input_your_secret&pbtoken=input_your_token&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&address_street=Av.Paulista,+100&address_zip=01311100&address_city=São+Paulo&address_state=SP&amount_brl=39.50&next_billing_date=2020-12-01&frequency=M&cc_installments=1&cc_holder=joao+da+silva&cc_number=4984123412341234&cc_expiration=12/29&cc_cvv=123" -X POST "https://sandbox.pagbrasil.com/api/pagstream/subscription/add"

Response:

<?xml version="1.0" encoding="ISO-8859-1"?>
 <request>
 <subscription>1234567890</subscription>
 <status>2</status>
 <amount_brl>39.50</amount_brl>
 </request>

9.2. PHP

Request:

<?php

$servidor = "https://sandbox.pagbrasil.com/api/pagstream/subscription/add";

$content = http_build_query(
	array(
		"secret"            => 'input_your_secret',
		"pbtoken"           => 'input_your_token',
		"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',
		"address_street"    => 'Av.Paulista, 100',
		"address_zip"       => '01311100',
		"address_city"      => 'São Paulo',
		"address_state"     => 'SP',
		"amount_brl"        => '39.50',
		"next_billing_date" => '2020-12-01',
		"frequency"         => 'M',
		"cc_installments"   => '1',
		"cc_holder"         => 'joao da silva',
		"cc_number"         => '4984123412341234',
		"cc_expiration"     => '12/29',
		"cc_cvv"            => '123',
	)
);

$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);

?>

Response:

<?xml version="1.0" encoding="ISO-8859-1"?>
 <request>
 <subscription_>1234567890</subscription_>
 <status>2</status>
 <amount_brl>39.50</amount_brl>
 </request>

9.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["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["address_street"]    = "Av.Paulista, 100";
	values["address_zip"]       = "01311100";
	values["address_city"]      = "São Paulo";
	values["address_state"]     = "SP";
	values["amount_brl"]        = "39.50";
	values["next_billing_date"] = "2020-12-01";
	values["frequency"]         = "M";
	values["cc_installments"]   = "1";
	values["cc_holder"]         = "joao da silva";
	values["cc_number"]         = "4984123412341234";
	values["cc_expiration"]     = "12/29";
	values["cc_cvv"]            = "123";

	var response = client.UploadValues("https://sandbox.pagbrasil.com/api/pagstream/subscription/add", values);

	var responseString = Encoding.Default.GetString(response);
}

Response:

<?xml version="1.0" encoding="ISO-8859-1"?>
 <request>
 <subscription>1234567890</subscription>
 <status>2</status>
 <amount_brl>39.50</amount_brl>
 </request>

9.4. Node.js

Request:

var request = require('request');

request({
	url: 'https://sandbox.pagbrasil.com/api/pagstream/subscription/add',
	method: 'POST',
	form: {
		secret: 'input_your_secret',
		pbtoken: 'input_your_token',
		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',
		address_street: 'Av.Paulista, 100',
		address_zip: '01311100',
		address_city: 'São Paulo',
		address_state: 'SP',
		amount_brl: '39.50',
		next_billing_date: '2020-12-01',
		frequency: 'M',
		cc_installments: '1',
		cc_holder: 'joao da silva',
		cc_number: '4984123412341234',
		cc_expiration: '12/29',
		cc_cvv: '123'
		}},

	function (error, response, body) {
		if (!error && response.statusCode == 200) {
			console.log(body);
		}
	}
);

Response:

<?xml version="1.0" encoding="ISO-8859-1"?>
 <request>
 <subscription>1234567890</subscription>
 <status>2</status>
 <amount_brl>39.50</amount_brl>
 </request>

  • No labels