Skip to content

Tokenization

Our library is easy to use and versatile; you can use it with various frameworks and with pure JavaScript on your frontend.

See the diagram below.

Alt text

We will present examples of how to use our library. However, please note that these are introductory examples and may not necessarily be the right choice in terms of architecture. This will depend on the specifics of your product and your team.

Including paag-tokenization.js

Info

<script
  type="text/javascript"
  src="https://js.paag.io/paag-tokenization-min.js"
></script>

Creating a Credit Card Token

Info

Paag.createPaymentToken(
  {
    first_name: "João",
    last_name: "Doe",
    number: "4111111111111111",
    verification_value: "123",
    expiration: "12/26",
  },
  function (response) {
    if (response.errors) {
      alert("Erro salvando cartão");
    } else {
      alert("Token criado:" + response.id);
    }
  }
);

Creating a CreditCard object

Info

cc = Paag.CreditCard(
  "4111111111111111",
  "12",
  "2017",
  "Nome",
  "Sobrenome",
  "123"
);

Their parameters are, respectively:

  • Credit Card Number
  • Maturity Month
  • Maturity Year
  • First name
  • Surname
  • CVV

The CreditCard object has a valid() function that validates the credit card and returns a bool (true or false).

Utility Functions

Validate Credit Card Number

Info

Paag.utils.validateCreditCardNumber("4111111111111111"); // Returns true
Paag.utils.validateCreditCardNumber("3213"); // Returns false

Validate CVV

Validates the verification number according to the flag.

Supported flags are "visa", "mastercard", "amex", "diners" and "elo".

Info

Paag.utils.validateCVV("123", "visa"); // Returns true
Paag.utils.validateCVV("1234", "amex"); // Returns true
Paag.utils.validateCVV("3213", "mastercard"); // Returns false

Validate Expiration

Validates the expiration date with the month and year.

Assuming today's date to be December 2013, we have the following examples:

Info

Paag.utils.validateExpiration(12, 2018); // Returns true
Paag.utils.validateExpiration(11, 2016); // Returns false
Paag.utils.validateExpiration(11, 2019); // Returns true

Validate Expiration String

Validates the due date with a string in DD/YYYY or DD/YY format.

Assuming today's date to be December 2013, we have the following examples:

Info

Paag.utils.validateExpirationString("12/2018"); // Returns true
Paag.utils.validateExpirationString("11/2016"); // Returns false
Paag.utils.validateExpirationString("11/19"); // Returns true

Is Blocked By AdBlock

Returns if there is any adBlock preventing paag-tokenization.js from working correctly

Info

Paag.utils.isBlockedByAdBlock(); // Returns true if there is an adBlock preventing correct operation, and false otherwise.

Get Brand By Credit Card Number

Info

Paag.utils.getBrandByCreditCardNumber("4111111111111111"); // Returns "visa"
Paag.utils.getBrandByCreditCardNumber("5555555555554444"); // Returns "mastercard"
Paag.utils.getBrandByCreditCardNumber("123321"); // Returns false