Having all the parameters defined, you will be able to execute the desired action using the following methods.
All functions return "this" to allow chaining of functions together.
Please check the sample codes in this documentation for further reference.
5.1. doAddToken (function callBackSuccess, function callBackError)
Tokenize the credit card information previously defined with setCard. You only need to use this method if you want to store a tokenized credit card to charge it in a future moment.
Required methods:
setMerchant (see item 4.1).
setCard (see item 4.5).
Callback functions:
callBackSuccess: The function's parameter is a JSON with the token, as in the following example.
{"token":"xxxxxxx"}
callBackError: The function's parameter is a JSON with the error, as in the following example.
{"error":"xxxxxxx"}
5.2. doAddOrder (function callBackSuccess, function callBackError)
Process the payment.
Required methods:
setMerchant (see item 4.1).
setCustomer (see item 4.2).
setOrder (see item 4.3).
setPayment (see item 4.4).
setCard (only when payment method is credit card or Débito Flash™; see item 4.5).
Callback functions:
callBackSuccess: The function's parameter is a JSON with the order information below.
Parameter | Description | Length |
---|---|---|
order | Order number | 64 |
order_token | Tokenized order number | 80 |
payment_method | C = Credit card | 1 |
submission_date | Date the order was submitted to PagBrasil. | 10 |
url_boleto | URL to view/print the Boleto Bancário. Only available when payment_method equal to "B" or "F". | 80 |
url_payment | URL that redirects the customer to the bank's page to complete the payment. Only available when payment_method equal to "R", "E", "U" or "S". | 80 |
company_code | Company code. Only available when payment_method equal to "P". | 10 |
payment_id | Payment identification. Only available when payment_method equal to "P". | 17 |
payment_instructions | Payment instructions in Portuguese. Only available when payment_method equal to "P". | 254 |
expiration_date | Last date to pay the PagBrasil Pix. | 10 |
expiration_time | Maximum time within the expiration date the PagBrasil Pix will be allowed to be paid. | 5 |
pix_image | Pix QR Code image link. | 80 |
pix_code | Alternative code for mobile users to complete the payment when they cannot scan the code (QR Code payload data). | 254 |
order_status | WP = Payment requested but not processed yet | 2 |
authorization_code | Authorization code provided by the card issuer. Only available when payment_method equal to "C" or "D" and order has been authorized. | 9 |
payment_date | Date the payment was completed. | 10 |
product_name | Product name | 254 |
customer_name | Customer's name | 128 |
customer_taxid | CPF if an individual, or CNPJ if the customer is a company | 14 |
customer_email | Customer's e-mail address | 128 |
customer_phone | Customer's phone number (including the 2-digit area code) | 40 |
address_street | Customer's street address | 200 |
address_zip | Customer's postal code (in Brazil called CEP) | 8 |
address_city | Customer's city | 40 |
address_state | Customer's state (official abbreviation) | 2 |
amount_brl | Amount in Brazilian Real | 7.2 |
amount_paid | Amount paid by the customer in Brazilian Real | 7.2 |
cc_installments | Number of installments (1 to 12). Only available when payment_method equal to "C" or "D". | 2 |
cc_brand | Card brand. Only available when payment_method equal to "C" or "D". See note "j" | 1 |
cc_holder | Card holder's name. Only available when payment_method equal to "C" or "D". | 30 |
cc_number | Card number truncated. Only available when payment_method equal to "C" or "D". | 14 - 19 |
soft_descriptor | Text identification that will appear on the customer's credit card statement next to the payee name (PB). Only available when payment_method equal to "C" or "D". | 13 |
amount_refunded | Used when order_status equal to RR or RP. Amount requested to be refunded (Brazilian Real). | 7.2 |
refund_date | Used when order_status equal to RP. | 10 |
refund_info | Used when order_status equal to RR or RP. See item 6.2, note "c". | 128 |
error_code | Used when order_status equal to PF or PR, and payment_method equal to "C" or "D". See table in item 7. | 2 |
callBackError: The function's parameter is a JSON with the error, as in the following example.
{"error":"xxxxxxx"}
5.3. doGetOrder (function callBackSuccess, function callBackError)
Request information about an order.
Required methods:
setMerchant (see item 4.1).
setOrder (with only the parameters order and order_token; see item 4.3).
Callback functions:
callBackSuccess: The function's parameter is a JSON with the order information below.
Parameter | Description | Length |
---|---|---|
order | Order number | 64 |
order_token | Tokenized order number | 80 |
payment_method | C = Credit card | 1 |
submission_date | Date the order was submitted to PagBrasil. | 10 |
url_boleto | URL to view/print the Boleto Bancário. Only available when payment_method equal to "B" or "F". | 80 |
url_payment | URL that redirects the customer to the bank's page to complete the payment. Only available when payment_method equal to "R", "E", "U" or "S". | 80 |
company_code | Company code. Only available when payment_method equal to "P". | 10 |
payment_id | Payment identification. Only available when payment_method equal to "P". | 17 |
payment_instructions | Payment instructions in Portuguese. Only available when payment_method equal to "P". | 254 |
expiration_date | Last date to pay the PagBrasil Pix. | 10 |
expiration_time | Maximum time within the expiration date the PagBrasil Pix will be allowed to be paid. | 5 |
pix_image | Pix QR Code image link. | 80 |
pix_code | Alternative code for mobile users to complete the payment when they cannot scan the code (QR Code payload data). | 254 |
order_status | WP = Payment requested but not processed yet | 2 |
authorization_code | Authorization code provided by the card issuer. Only available when payment_method equal to "C" or "D" and order has been authorized. | 9 |
payment_date | Date the payment was completed. | 10 |
product_name | Product name | 254 |
customer_name | Customer's name | 128 |
customer_taxid | CPF if an individual, or CNPJ if the customer is a company | 14 |
customer_email | Customer's e-mail address | 128 |
customer_phone | Customer's phone number (including the 2-digit area code) | 40 |
address_street | Customer's street address | 200 |
address_zip | Customer's postal code (in Brazil called CEP) | 8 |
address_city | Customer's city | 40 |
address_state | Customer's state (official abbreviation) | 2 |
amount_brl | Amount in Brazilian Real | 7.2 |
amount_paid | Amount paid by the customer in Brazilian Real | 7.2 |
cc_installments | Number of installments (1 to 12). Only available when payment_method equal to "C" or "D". | 2 |
cc_brand | Card brand. Only available when payment_method equal to "C" or "D". See note "j" | 1 |
cc_holder | Card holder's name. Only available when payment_method equal to "C" or "D". | 30 |
cc_number | Card number truncated. Only available when payment_method equal to "C" or "D". | 14 - 19 |
soft_descriptor | Text identification that will appear on the customer's credit card statement next to the payee name (PB). Only available when payment_method equal to "C" or "D". | 13 |
amount_refunded | Used when order_status equal to RR or RP. Amount requested to be refunded (Brazilian Real). | 7.2 |
refund_date | Used when order_status equal to RP. | 10 |
refund_info | Used when order_status equal to RR or RP. See item 6.2, note "c". | 128 |
error_code | Used when order_status equal to PF or PR, and payment_method equal to "C" or "D". See table in item 7. | 2 |
callBackError: The function's parameter is a JSON with the error, as in the following example.
{"error":"xxxxxxx"}
5.4. doAuthenticate
Used only to authenticate a Débito Flash™ transaction that is going to be captured using the API. If you are not integrating using our API, please use the method doAddOrder to authenticate and authorize Débito Flash™ transactions in one step.
Required methods:
setMerchant (see item 4.1).
setCustomer (see item 4.2).
setOrder (see item 4.3).
setPayment (see item 4.4).
setCard (see item 4.5).
setCallbackAuthenticateSuccess (callbackSuccess), where callbackSuccess is a function that is going to be called when the authentication is successful.
setCallbackAuthenticateFail (callbackFail), where callbackFail is a function that is going to be called when the authentication has failed.