Create a Purchase

Create a purchase using the API flow providing its basic information for PCI and Non-PCI Merchants.

Configuring the authentication

All methods used in Purchase API require the following authentication headers.

KeyValueComments
Content-Typeapplication/jsonWith this header, the request will be transmitted in JSON format.
AuthorizationBasic {{Merchant Private Key}}Send the {{Merchant Private Key}} (your merchant identifier) and the word Basic.
Example: Basic RVkeLr-86_iTzSMLvDtuyQ-1zqIcsmFG-oSzncn_uFv-nj7bhB3rtZg__

Setting the language of the response codes

You can receive the error description by relying on localization features. To do this, you need to send the lang header in your integration, using any of the following languages in ISO 639-1 format.

CodeLanguage
enEnglish.
This is the default language. If you don’t send this header or set a non-existent language, you will receive errors in this language.
esSpanish.
ptPortuguese.

Create a Purchase

After successfully tokenizing a card, you can proceed with generating a purchase using this method. The Purchase API is specifically designed for merchants who do not have PCI DSS certification, allowing them to process payments securely without handling sensitive card data directly.

For alternative payment methods such as cash payments or bank transfers, you only need to provide the corresponding payment method ID to initiate the transaction.

Request URL

You must invoke a POST request to the following URLs according to your needs.

  • Production: https://api.bamboopayment.com/v3/api/purchase
  • Stage: https://api.stage.bamboopayment.com/v3/api/purchase

Request parameters

ParameterTypeMandatory?Description
TrxTokenstringNo1Card token, previously generated through the tokenization flow. Used for card payment methods.
NetworkTokenobjectNo1Network token information used in the transaction. For more information, review the Network Tokenization Object.
PaymentMethodIdintegerNo1Payment method identifier. Used only for alternative payment methods (transfer, cash, etc.)
UniqueIDstringNoUnique identifier of the purchase.
This optional value allows you to identify a unique purchase and avoid duplication of transactions in case of communication errors. For more information, refer to Concepts.
CapturebooleanNoDefines whether the purchase should be performed in one or two steps.2
  • If false, only the authorization is processed, and the purchase is pre-authorized until the final confirmation through the capture and cancel calls.
  • If true, the transaction is authorized and captured.

All payment methods and countries may not support the pre-authorization feature.
TargetCountryISOstringYesThis parameter indicates the country where the payment will be processed.
Send the country using ISO-3166-1 format.
CurrencystringYesCurrency of the purchase, according to ISO-4217. Find the possible values in the Currencies table of each country.
Amountinteger (64 bits)YesAmount of the purchase. This value must be greater than zero.
If you must include decimals in the amount, concatenate the decimal places without the decimal point. Example 12,25 > 1225.
Tipinteger (64 bits)NoTip amount in the transaction. Value with two decimals, without points or commas.
TaxableAmountinteger (64 bits)NoTaxable amount of the transaction. Value with two decimals, without points or commas.
InstallmentsintegerNoNumber of installments.
OrderstringYesOrder number generated by the merchant.
InvoiceNumberstringNoInvoice number associated with the transaction.
DescriptionstringNo 4Optional description of the purchase.
AdditionalDatastringNoAdditional information that may be relevant to the transaction.
MetadataInobjectNoAdditional transaction data in key-value format.
CustomerobjectYes 3The Customer object provides the data of the person who performs the purchase.

Customer Object

ParameterTypeMandatory?Description
CustomerFirstNamestringNoCustomer’s first name.
CustomerLastNamestringNoCustomer’s last name.
CustomerReferenceCodestringNoReference code for the customer.
CustomerPhoneNumberstringNoCustomer’s phone number.
CustomerDocumentNumberstringNoCustomer’s document number.
CustomerDocumentTypestringNoDocument type. (Format DOCUMENT.COUNTRY)
CustomerEmailstringNoCustomer’s email address.
AddressobjectNoCustomer’s shipping address.

Address Object

ParameterTypeMandatory?Description
AddressCountrystringNoCountry of the customer address.
AddressCitystringNoCity of the customer address.
AddressStatestringNoState or region of the customer address.
AddressPostalCodestringNoPostal code of the customer address.
AddressAddressDetailstringNoAdditional details of the customer address.

Request example

{
    "TrxToken": "OT__6dHAgJo6qeg62qIroA7H7_f_NWZZ6IEx4jiYpVJ8SzQ_",
    "UniqueID": "paymentID3022",
    "Capture": true,
    "TargetCountryISO": "BR",
    "Currency": "BRL",
    "Amount": 25000,
    "Installments": 2,
    "Order": "CH2023-001",
    "Description": "Compra de teste",
    "Customer": {
        "FirstName": "João",
        "LastName": "Silva",
        "ReferenceCode": "JS-001",
        "PhoneNumber": "11987654321",
        "DocumentNumber": "12345678901",
        "DocumentType": "CPF.BR",
        "Email": "joao.silva@example.com",
        "Address": {
            "Country": "BR",
            "City": "São Paulo",
            "State": "SP",
            "PostalCode": "01310-200",
            "AddressDetail": "Avenida Paulista 1000"
        }
    }
}

Direct Purchase for PCI-Compliant Merchants

For merchants who have achieved PCI DSS compliance, Bamboo offers enhanced flexibility through the Direct Purchase method. This advanced option allows PCI-compliant merchants to handle card data directly within their secure environments.

Request URL

You must invoke a POST request to the following URLs according to your needs.

  • Production: https://secure-api.bamboopayment.com/v3/api/purchase
  • Stage: https://secure-api.stage.bamboopayment.com/v3/api/purchase

Request parameters

CardData Object
ParameterTypeMandatory?Description
CardHolderNamestringYesThe name of the cardholder as it appears on the card.
PanstringYesThe Primary Account Number (PAN) of the card.
CVVstringYesThe Card Verification Value (CVV) or Card Security Code.
ExpirationstringYesThe expiration date of the card in the format “MM/YY”.
EmailstringYesThe email associated with the cardholder.
DocumentstringNoThe identification document number of the cardholder.

Request example

{
    "CardData": {
        "CardHolderName": "João Silva",
        "Pan": "4507990000004905",
        "CVV": "123",
        "Expiration": "08/30",
        "Email": "joao.silva@example.com",
        "Document": "12345678901"
    },
    "UniqueID": "paymentID3022",
    "Capture": true,
    "TargetCountryISO": "BR",
    "Currency": "BRL",
    "Amount": 25000,
    "Installments": 2,
    "Order": "CH2023-001",
    "Description": "Compra de teste",
    "Customer": {
        "FirstName": "João",
        "LastName": "Silva",
        "ReferenceCode": "JS-001",
        "PhoneNumber": "11987654321",
        "DocumentNumber": "12345678901",
        "DocumentType": "CPF.BR",
        "Email": "joao.silva@example.com",
        "Address": {
            "Country": "BR",
            "City": "São Paulo",
            "State": "SP",
            "PostalCode": "01310-200",
            "AddressDetail": "Avenida Paulista 1000"
        }
    }
}

The fields CardData, PaymentMethodId, NetworkToken and TrxToken are not required; Nevertheless, one of them must be send depending of which flow to use.

Response

The response structure for Direct Purchase operations performed by PCI-compliant merchants is identical to the standard Purchase response. This ensures consistency across different transaction types and simplifies integration processes.

All fields, statuses, and error codes described in the standard Purchase response apply equally to Direct Purchase transactions.

ParameterTypeDescription
TransactionIdstringUnique identifier for the transaction. A 19-digit number sent as a string for compatibility.
ResultstringOutcome of the transaction. COMPLETED or ACTION_REQUIRED. See the “Action” object for instructions.
StatusstringCurrent status of the transaction (e.g., Approved, Rejected).
ErrorCodestringError code if the transaction was rejected.
ErrorDescriptionstringDetailed description of the error if the transaction was rejected.
CreatedstringTimestamp of when the transaction was created, in ISO 8601 format.
AuthorizationDatestringTimestamp of when the transaction was authorized, in ISO 8601 format.
AuthorizationCodestringUnique code provided by the issuer to confirm the transaction authorization.
AmountintegerTotal transaction amount.
CurrencystringCurrency code used for the transaction. May differ from the request currency based on business agreements.
InstallmentsintegerNumber of payment installments for the transaction.
TaxableAmountintegerAmount subject to taxes.
TipintegerTip amount.
UrlstringLink to access additional transaction details.
MetadataOutobjectAdditional metadata returned with the transaction response.
ActionobjectDetails of required actions when Result is “ACTION_REQUIRED”.
PaymentMethodobjectInformation about the payment method used for the transaction.

Action Object

The Action object provides information about additional steps required to complete a transaction. It is typically present when the transaction result is “ACTION_REQUIRED”, indicating that further action is needed from the user or merchant to finalize the payment process.

ParameterTypeDescription
SessionIdstringSession identifier related to the action. Informational value.
ReasonstringReason for the requested action. Possible values:
VERIFICATION_CODE_NEEDED: Transaction pending CVV, redirection to “URL” required to display CVV input form.
REDIRECTION_NEEDED_EXTERNAL_SERVICE: Redirection to “URL” required to complete transaction details.
URLstringRedirection URL to complete the required action.

PaymentMethod Object

The PaymentMethod object contains detailed information about the payment method used in the transaction. This includes card details (for card transactions) or other relevant payment method information.

ParameterTypeDescription
BrandstringBrand of the card used (e.g., MasterCard, Visa).
CardOwnerstringName of the cardholder.
BinstringFirst 6 digits of the card number.
IssuerBankstringIssuing bank of the card.
TypestringType of payment method (e.g., CreditCard, DebitCard).
ExpirationstringCard expiration date in yyyymm format.
Last4stringLast 4 digits of the card number.

Response examples



Result:COMPLETED - Status: APPROVED

{
    "TransactionId": "79632697147789184",
    "Result": "COMPLETED",
    "Status": "APPROVED",
    "ErrorCode": null,
    "ErrorDescription": null,
    "Created": "2024-08-07T17:51:54.620",
    "AuthorizationDate": "2024-08-07T17:51:56.879",
    "AuthorizationCode": "839936",
    "Amount": 25000,
    "Currency": "BRL",
    "Installments": 2,
    "TaxableAmount": null,
    "Tip": null,
    "Url": "https://api.stage.bamboopayment.com/Purchase/79632697147789184",
    "MetadataOut": null,
    "Action": null,
    "PaymentMethod": {
        "Brand": "Visa",
        "CardOwner": "João Silva",
        "Bin": "450799",
        "IssuerBank": "Banco do Brasil",
        "Type": "CreditCard",
        "Expiration": "203008",
        "Last4": "4905"
    }
}

Result:COMPLETED - Status: REJECTED

{
    "TransactionId": "79632697147789184",
    "Result": "COMPLETED",
    "Status": "REJECTED",
    "ErrorCode": "LP042",
    "ErrorDescription": "Insufficient balance.",
    "Created": "2024-08-07T17:51:54.620",
    "AuthorizationDate": "2024-08-07T17:51:56.879",
    "AuthorizationCode": "839936",
    "Amount": 25000,
    "Currency": "BRL",
    "Installments": 2,
    "TaxableAmount": null,
    "Tip": null,
    "Url": "https://api.stage.bamboopayment.com/Purchase/79632697147789184",
    "MetadataOut": null,
    "Action": null,
    "PaymentMethod": {
        "Brand": "Visa",
        "CardOwner": "João Silva",
        "Bin": "450799",
        "IssuerBank": "Banco do Brasil",
        "Type": "CreditCard",
        "Expiration": "203008",
        "Last4": "4905"
    }
}

Result:ACTION_REQUIRED - Status: PENDING

{
    "TransactionId": "79632697147789184",
    "Result": "ACTION_REQUIRED",
    "Status": "PENDING",
    "ErrorCode": null,
    "ErrorDescription": null,
    "Created": "2024-08-07T17:51:54.620",
    "AuthorizationDate": null,
    "AuthorizationCode": null,
    "Amount": 25000,
    "Currency": "BRL",
    "Installments": 2,
    "TaxableAmount": null,
    "Tip": null,
    "Url": "https://api.stage.bamboopayment.com/Purchase/79632697147789184",
    "MetadataOut": null,
    "Action": {
        "SessionId": "CA_a4032a2a-25ae-4f5f-a8bb-fb2e5ab2ae3c",
        "URL": "https://url_to_be_redirected.com/redirection_example",
        "Reason": "VERIFICATION_CODE_NEEDED"
    },
    "PaymentMethod": {
        "Brand": "Visa",
        "CardOwner": "João Silva",
        "Bin": "450799",
        "IssuerBank": "Banco do Brasil",
        "Type": "CreditCard",
        "Expiration": "203008",
        "Last4": "4905"
    }
}

{
   "ErrorCode": "PR001",
   "ErrorDescription": "The token sent is invalid, expired, or does not belong to the merchant."
}
footer
Last modified September 19, 2024

© Bamboo | All rights reserved 2024