Hosted Tokenization Form

The Tokenization Form securely captures the customer's credit or debit card information and converts sensitive data into a token. The token can then be used to process transactions without storing card information directly on the merchant's systems.

The Tokenization Form securely captures customer card details and generates a token for safe payment processing. By using this form, non-PCI compliant merchants can accept payments without directly handling sensitive credit card data, reducing risk and simplifying compliance requirements.


📘

If you're searching for documentation on older version of the Tokenization Form, please contact your Technical Account Manager.


Tokenization Workflow

The following diagram illustrates the complete tokenization flow using the hosted form:

  1. Customer clicks the payment button.
  2. Merchant's website invokes the tokenization form from Bamboo.
  3. Bamboo returns the hosted form to the browser.
  4. The form is rendered on the page.
  5. Customer enters card data.
  6. Card data is securely sent to Bamboo.
  7. Bamboo generates the token.
  8. Token is returned to the merchant’s browser.
  9. The merchant creates the purchase using the token.
  10. Bamboo processes the payment and sends confirmation.
  11. Customer receives confirmation.


Integrating the Hosted Tokenization Form

To integrate the Tokenization Form into your checkout flow, simply embed it in your web or mobile application. Once implemented, the form will handle all sensitive card data securely and return a token that you can use for payments through the Bamboo API.


Importing the JavaScript Library

To integrate the Tokenization Form into your website, it's necessary to include a script that points to the form's URL. This allows access to the BambooForm object containing the methods needed to render Bamboo forms.

Staging_


//STAGE - Test Environment:
<script src="https://capture.stage.bamboopayment.com/"
		integrity="sha256-X8C6kzz5r0uxNzqtXB8q2tAkorRayzErzeIUm1f0xm4= sha384-Vt+ySpe3/DHlyv34xym7TY55eJ49WxXv6d2cHasu/GG/7h22MGUESq+3kQeHOaLC sha512-B132Bu3DX6JkgamkFER/g2rcsfdTzrwNWOY5O2Wsfe8lm/H7TD1uGdnEuPvudq4ZRdCQDrWk6PwCVkgP1o2Szg=="
		crossorigin="anonymous">
</script>

Production

//PRODUCTION:
<script src="https://capture.bamboopayment.com"
		integrity="sha256-E4GdhdwL0BVk9Xq/21s9qxvjh+anbzbgDVtfH6iCu7E= sha384-vbOT5y4OCop26UzV2VOfg0IAK+ToPU+mR09IcQChnn5kfD5W7b3YQNWXkJob3WWs sha512-j9jTPXduda6zgSUmoTvy9xEOlJOnYS2fKO0dEMiSK5VSB4bGfmKWfSHFLe7pjsFj3lu0K426c9F+7lXf/810Kg=="
		crossorigin="anonymous">
</script>

Render the Hosted Form

Once the Script pointing to Bamboo forms is imported, you'll have access to the renderTokenizationForm method that renders the Tokenization Form in your application, allowing your users to securely enter their cards.


BambooForm.renderTokenizationForm(configuration);

Request Example

<script> 
BambooForm.renderTokenizationForm({
  containerId: 'MERCHANT_PAGE_CONTAINER_ID',
  metadata: {
    publicKey: 'MERCHANT_PUBLIC_KEY',
    targetCountryISO: 'UY',
    customer: {
      email: '[email protected]',
      cardHolderName: 'Juan Pérez'
    },
    locale: 'es',
    logoUrl: '<https://mieshop.com/logo.png>'
  },
  hooks: {
    onOperationSuccess: (token) => {
      console.log('Token received:', token);
    },
    onOperationError: (error) => {
      console.error('Error:', error);
    }
  }
});
</script>

Customize the Form

ParameterTypeMandatory?Description
containerIdstringNoHTML container ID where the form will be displayed. If sent, the form is embedded in that container. If omitted, the form opens as a full-screen modal with a close button.
metadataobjectYesConfigures information related to the customer and transaction.
stylesobjectNoColors of the form. See Customize the look | styles object below.
hooksobjectYesCallback functions to handle form events.

Customize your Tokenization Form | metadata object

You can customize the tokenization form with your logo and preferred language, besides pre-fill data already provided by your customer, or restrict the tokenization to specific cards.

ParameterTypeMandatory?Description
metadata → publicKeystringYesMerchant's public key, necessary for secure tokenization.
metadata → amountnumberNoTransaction amount. When sent, the form shows the amount formatted in the currency defined in currencyIsoCode.
metadata → currencyIsoCodestringNoTransaction currency. When amount is sent, the form shows the amount formatted in this currency.
metadata → targetCountryISOstringYesISO code of the country where the transaction will be processed.
metadata → customerobjectYesCustomer information. Must always be sent, even as an empty object. Its fields (uniqueId, email, cardHolderName) are optional.
metadata → localestringNoForm language, using ISO code Spanish: 'es' (default) English: 'en'
metadata → logoUrlstringNoURL of the logo that will appear on the form. If not defined, it's shown without a logo in the header
metadata → filtersobjectNoAllows restricting the card entered by the user to a specific issuing bank or card type

Customer Information

ParameterTypeMandatory?Description
metadata → customer → uniqueIdstringNoUnique customer identifier. Indicates if a single-use or recurring Token is generated Token Types. Customer's SessionId.
metadata → customer → emailstringNoCustomer's email. It's pre-loaded in the form and allows editing if there are syntax errors that prevent token generation
metadata → customer → cardHolderNamestringNoCardholder's name. It's pre-loaded in the form without editing option.

Tokenization restricted to specific Cards

ParameterTypeMandatory?Description
metadata → filters → paymentMediaTypenumberNoIdentifier of the payment method type (credit card, debit card, etc.). (See payment media ids)
metadata → filters → brandnumberNoIssuing brandId identifier. (See brands)

Example

metadata: {
  filters: {
    paymentMediaType: 1, // only credit cards
    brand: 1
  }
}

Customize the look | styles object

You can change the colors of the form with the optional styles object. It is sent at the top level of the configuration, next to containerId, metadata and hooks. The same object, with the same properties and default values, is available in the Tokenization Form and in the CVV Form.

All properties are optional strings.

PropertyDescriptionDefault
backgroundColorBackground color of the form window#FFFFFF
buttonColorBackground color of the action button#26282B
buttonHoverColorBackground color of the action button on hover#454649
buttonTextColorText color of the action button#FFFFFF
buttonTextHoverColorText color of the action button on hover#FFFFFF
inputBackgroundColorBackground color of the text fields#FFFFFF
inputTextColorText color of the text fields#26282B
inputErrorColorBorder color of a text field with an error#DC3545
inputAddonBackgroundColorBackground color of the text fields' icons#EEEEEE
labelColorText color of labels and the title#26282B
  • Colors are hexadecimal RGB values, with or without the leading #.
  • Only these colors can be changed. Fonts, sizes, borders, texts and custom CSS are not supported.

Example

BambooForm.renderTokenizationForm({
  containerId: 'MERCHANT_PAGE_CONTAINER_ID',
  metadata: {
    publicKey: 'MERCHANT_PUBLIC_KEY',
    targetCountryISO: 'UY'
  },
  styles: {
    backgroundColor: '#FFFFFF',
    buttonColor: '#0057FF',
    buttonHoverColor: '#0046CC',
    buttonTextColor: '#FFFFFF',
    labelColor: '#26282B'
  },
  hooks: {
    onOperationSuccess: (token) => { console.log('Token received:', token); }
  }
});

Handle customer interactions | hooks object

ParameterTypeMandatory?Description
hooks → onOperationSuccessfunctionYesCallback executed upon successful tokenization. Receives the token as a parameter.
hooks → onOperationFinalizefunctionNoOptional callback executed when the operation is finalized.
hooks → onOperationErrorfunctionNoOptional callback that handles errors during tokenization.
hooks → onApplicationLoadedfunctionNoCallback executed when the form has been loaded correctly.
hooks → onExitFormfunctionNoCallback executed when the form is closed. Receives the close reason as a string. When the customer closes the modal, the reason is onUserRequestExitModal.

Successful tokenization | Token object

The token object is returned in the onOperationSuccess hook executed upon successful tokenization and contains the following parameters.

PropertyTypeDescription
TokenIdstringToken identifier.
CreatedtimestampToken creation date and time.
BrandstringCard brand or payment method used.
IssuerBankstringCard Issuing Bank.
OwnerstringCardholder's name.
Binnumeric[6-9]Card identifier.
Last4numeric[4]Last four digits of the card.
CardTypestringPayment method or card type, possible values: CreditCard, DebitCard, PrePaid
CardExpMonthnumeric[2]Card expiration month.
CardExpYearnumeric[2]Card expiration year.

Response Example

{
  "TokenId": "OT__Vzt3fxGvyyTgbUbsPrMN__em6gAAHYAAA",
  "CardType": "CreditCard",
  "Created": "2025-10-21T14:35:54.971",
  "Brand": "VISA",
  "Owner": "John Doe",
  "Last4": "0001",
  "Bin": "424242",
  "CardExpMonth": 12,
  "CardExpYear": 29,
  "IssuerBank": "Itaú"
}

Unsuccessful tokenization | Error object

When tokenization cannot be completed, the onOperationError hook is triggered.

This callback receives an error object with information about the failure. You can either:

  • render the value returned in Message directly to the customer, optionally including Error.ErrorCode, or
  • interpret the error response and display a custom message based on the merchant’s own UX rules.

This allows you to decide whether to show Bamboo's returned message or replace it with a friendlier message adapted to your checkout experience.

Error object structure

PropertyTypeDescription
Error.ErrorCodestringBamboo error identifier.
Error.MessagestringMain error message. Recommended field to render to the customer.

Response Example

{
  "raw": {
    "ErrorCode": "TK014",
    "Message": "The payment method is disabled"
  }
}

Merchant rendering recommendations

The recommended approach is to display the value of Error.Message in the UI to inform the customer about the error.

Example implementation

onOperationError: (errorResponse) => {
  const message = errorResponse?.Error?.Message || 'Tokenization failed';

  const errorContainer = document.getElementById('error-message');
  if (errorContainer) {
    errorContainer.innerText = message;
    errorContainer.style.display = 'block';
  }

  console.error('Tokenization error:', errorResponse);
}

Example HTML container

<div id="error-message" style="display:none; color:red; margin-top:10px;"></div>

Best practice

It is recommended to display a user-friendly message and allow the customer to retry the tokenization process.


CVV Form

The CVV Form is specifically designed to capture the Card Verification Value (CVV) found on the back of the physical card. This form is used when it's necessary to validate a transaction with the CVV, generally in recurring payments or purchases where the card information has already been previously tokenized.

Typical use: When a customer has previously stored their credit card through the tokenization process but is asked to enter their CVV to validate or complete a transaction, providing an additional layer of security.

Method renderCVVForm

Once you've imported the script that points to the Bamboo forms, you'll have access to the renderCVVForm method, which renders a form dedicated exclusively to capturing the customer's CVV.

BambooForm.renderCVVForm(url, configurationCVV);

Configuration Parameters

ParameterTypeMandatory?Description
urlstringYesThe URL containing the session data and the customer's payment profile information. Includes key, session_id, paymentProfileId, brand, and the last four digits of the card. This URL is received as a response when attempting to execute a purchase if CVV verification is required.
containerIdstringNoID of the HTML container where the form will be displayed. If sent, the form is embedded in that container. If omitted, the form opens as a full-screen modal with a close button.
metadataobjectYesConfigures information related to the session and the transaction.
metadata → logoUrlstringNoURL of the logo that will appear on the form.
metadata → localestringNoLanguage of the form, using an ISO locale code. Spanish: 'es' (default), English: 'en'.
stylesobjectNoColors of the form. Same object, properties and default values as in the Tokenization Form.
hooksobjectYesCallback functions to handle form events.
hooks → onOperationSuccessfunctionYesCallback executed upon successful CVV validation. Receives a confirmation string as a parameter (for example OperationSuccess: true), not a token.
hooks → onOperationFinalizefunctionNoOptional callback executed when the operation is finalized.
hooks → onOperationErrorfunctionNoOptional callback that handles errors during CVV validation.
hooks → onApplicationLoadedfunctionNoCallback executed when the form has been loaded correctly.
hooks → onExitFormfunctionNoCallback executed when the form is closed. Receives the close reason as a string. When the customer closes the modal, the reason is onUserRequestExitModal.

To change the colors of the CVV Form, send the styles object described in Customize the look | styles object. It accepts the same properties and uses the same default values as in the Tokenization Form.


Usage Example

<script>
BambooForm.renderCVVForm(
  '<https://api.stage.bamboopayment.com/v1/Capture/?key=FEdJ84hzdIKBY0gyC7-NDG_I56ONV7HQ&session_id=CA_51864eaf-1603-4fe8-8720-ae8c569ea702&paymentProfileId=375108&brand=MasterCard&lastFour=4008>',
  {
    metadata: {
      locale: 'es',
      logoUrl: '<http://www.example.com/>'
    },
    hooks: {
      onOperationSuccess: () => {
        console.log('Operation successful');
      },
      onOperationError: (error) => {
        console.error('Error in CVV validation:', error);
      }
    }
  }
);
</script>

Payment Media Types

Payment Media Type IdName
1CreditCard
2DebitCard
4PrePaid

Brands

Brand IdName
1VISA
2Mastercard
3OCA
4Diners
5American Express
6Discover
9Creditel
10Creditos Directos
11PassCard
12Líder
13Club del Este
14Cabal
103Anda

Next Steps

After you obtain the token, you can pass it into Bamboo’s Purchase API instead of handling card details directly. This allows you to authorize, capture, or cancel transactions.


Did this page help you?