7. Requesting a recurring charge
7.1. Sending the request
Your POST must be sent to https://sandbox.pagbrasil.com/api/order/add setting the content-type of the request header and body as "x-www-form-urlencoded".
Please note that this URL shall only be used for integration and testing procedures. Once the Payment Service Agreement is signed, you will receive the production environment's URL when you request your account to go live.
Request parameters:
Field | Description | Required | Length |
|---|---|---|---|
secret | Secret phrase as defined in the PagBrasil Dashboard | Yes | 128 |
pbtoken | Token assigned to your merchant account. Your token is displayed at the PagBrasil Dashboard, menu Account > Settings. | Yes | 32 |
order | Order number. See note "e" | Yes | 64 |
payment_method | X = PagBrasil Pix | Yes | 1 |
product_name | Product name. See note "m" | Yes | 254 |
products | JSON structure with the list of products or service in the subscription. See note “l“ | Yes | Unlimited |
customer_name | Customer's full name if an individual, or "razão social" if the customer is a company. See note "k" | Yes | 128 |
customer_taxid | CPF if an individual, or CNPJ if the customer is a company. See note "j" | Yes | 14 |
customer_email | Customer's e-mail address | Yes | 128 |
customer_phone | Customer's phone number (including the 2-digit area code) | Yes | 40 |
address_street | Customer's street address | Yes | 200 |
address_zip | Customer's postal code (in Brazil called CEP). Only digits, do not include the dash. | Yes | 8 |
address_city | Customer's city | Yes | 40 |
address_state | Customer's state. See note "i" | Yes | 2 |
amount_brl | Amount in Brazilian Real. See note "c" | Yes | 7.2 |
pix_rec_id | Recurrence identifier. | Yes | 64 |
pix_rec_recurrence_date | Recurring charge date. See note “f” | Yes | 10 |
param_url | A string that can be concatenated to the URL our server posts the response to. See note "h" | No | 254 |
Notes:
a) All fields are required except when noted otherwise.
b) If a parameter is sent with a size greater than the maximum allowed, process will not be aborted but the value will be truncated.
c) Banks set daily limits that each customer is allowed to transfer to another account. Limits are set on a customer basis and may vary depending on each bank account.
d) The response for the "/api/order/add" call will be an XML with the order details, in exactly the same format as a "/api/order/get" response (see item 10.2).
e) The order number must be unique for a specific customer. If you try to submit two different transactions with the same order number but a different customer_taxid, our server will respond with the message "Duplicated order.". Our server will also respond with "Duplicated order." if you try to re-submit an order that is already paid. If parameters order and customer_taxid are equal to a previously submitted unpaid order, the previous order will be updated with the new information provided and the response will be the URL that you will need to redirect the customer to (see note "d").
Characters allowed in the parameter order (regular expression): [a-zA-Z0-9\.\-\_\/]
f) The request must be sent between 2 and 10 days prior to the recurring charge date.
h) The URL our server posts the response to for an "/api/order/add" call consists of a fixed and a dynamic part. The first part is defined at the PagBrasil Dashboard, menu Account > Settings. The second part is defined using param_url (optional). For example, if you define at the PagBrasil Dashboard the URL as "https://www.test.com/script.asp" and param_url as "?customer_id=12345&newsletter=yes" we will post the authorization response to: "https://www.test.com/script.asp?customer_id=12345&newsletter=yes"
i) The parameter address_state must be the official abbreviation used in Brazil. To prevent customer from entering an invalid state, please see table below to create a select object (drop-down list).
State | Abbreviation |
|---|---|
Acre | AC |
Alagoas | AL |
Amapá | AP |
Amazonas | AM |
Bahia | BA |
Ceará | CE |
Distrito Federal | DF |
Espírito Santo | ES |
Goias | GO |
Maranhão | MA |
Mato Grosso | MT |
Mato Grosso do Sul | MS |
Minas Gerais | MG |
Pará | PA |
Paraíba | PB |
Paraná | PR |
Pernambuco | PE |
Piauí | PI |
Rio de Janeiro | RJ |
Rio Grande do Norte | RN |
Rio Grande do Sul | RS |
Rondônia | RO |
Roraima | RR |
Santa Catarina | SC |
São Paulo | SP |
Sergipe | SE |
Tocantins | TO |
CONFIDENTIAL