Vault – Web
Introduction
The Mangopay Vault SDK allows you to securely tokenize an end user’s payment card for use in your application. A tokenized card is a virtual and secure version of the card that can be used for payment.
It is very highly recommended that you use the Mangopay Vault SDK, rather than integrating the API endpoints directly. By doing so, you:
- Avoid sensitive card details transiting your system
- Benefit from PCI-DSS compliance
- Receive ongoing support and updates
To use the Mangopay Vault SDK, you’ll need:
- A Mangopay
ClientId
and API key (get a Sandbox API key for free) - A User to register the card for (see Testing - Payment methods for test cards)
Installation
You can install the Mangopay Vault SDK using npm or yarn.
Creating the Card Registration
In your backend, create the Card Registration via the Mangopay API, using the Id
of the user as the UserId
.
You must also define the currency and type of the card at this stage.
The data obtained in the response will be used in the preregistrationData
defined below.
Initializing the SDK
Initialize the SDK with your ClientId
and select your environment (Sandbox or Production).
Providing data for tokenization
The SDK requires the following information to tokenize the card:
- The end user’s card details (
cardInfoObject
) entered on the payment page (see Testing - Payment methods for test cards) - The Card Registration data (
preregistrationData
) previously returned by the Mangopay API
cardInfoObject
Property | Type | Description |
---|---|---|
cardNumber | string | The card number to be tokenized, without any separators. |
cardExpirationDate | string (Format: “MMYY”) | The expiration date of the card. |
cardCvx | string | The card verification code (on the back of the card, usually 3 digits). |
preregistrationData
Property | Type | Description |
---|---|---|
Id | string | The unique identifier of the Card Registration object. |
CardRegistrationURL | string | The URL to which the card details are sent to be tokenized. |
AccessKey | string | The secure value used when tokenizing the card. |
PreregistrationData | string | A specific value passed to the CardRegistrationURL . |
errors | MgpTypedError | A generic type describing the error report that is returned in case of an error. |
Tokenizing the card
You can now tokenize the card with the card data obtained previously using the frontend SDK.
The SDK automatically updates the Card Registration object to provide you with a CardId
that can be used for payments.
Property | Type | Description |
---|---|---|
AccessKey | string | The secure value used when tokenizing the card. |
CardId | string | The unique identifier of the Card object. |
CardRegistrationURL | string | The URL to which the card details are sent to be tokenized. |
CardType | string | The type of the card. |
CreationDate | timestamp | The date and time at which the object was created. |
Currency | string | The currency of the card. |
Id | string | The unique identifier of the Card Registration object. |
PreregistrationData | string | A specific value passed to the CardRegistrationURL . |
RegistrationData | string | The string returned by the tokenization server after tokenizing the card. |
ResultCode | string | The code indicating the result of the operation. This information is mostly used to handle errors or for filtering purposes. |
ResultMessage | string | The explanation of the result code. |
Status | string | The status of the card registration:
|
Tag | string | Custom data that can be added to this object. In the case of the Card Registration, this parameter can be used to facilitate the link between the User object and its equivalent on your platform for instance. This value will be inherited by the Card object |
UserId | string | The unique identifier of the user the card belongs to. |
errors` | MgpTypedError | A generic type describing the error report that is returned in case of an error. |
Managing cards
You can use the following endpoints to manage cards:
- View a Card provides key information about the card, including its Fingerprint which can be used as an anti-fraud tool
- Deactivate a Card allows you to irreversibly set the card as inactive
Warning – End user’s approval needed to save card details
Under no circumstances should card information be kept without the end user’s approval.
If you don’t have the end user’s approval, you need to deactivate the card systematically after use in your implementation.
Making card payments
You can use a registered card (CardId
) for pay-ins with the following objects:
- The Direct Card PayIn object, for one-shot card payments
- The Recurring PayIn Registration object, for recurring card payments
- The Preauthorization object, for 7-day preauthorized card payments
- The Deposit Preauthorization object, for 30-day preauthorized card payments
Caution – Card validation within 24 hours
A successful transaction (preauthorization, pay-in, or recurring) within 24 hours of the card registration is required to validate a card. Otherwise, the card remains invalid and a new card registration will be necessary to make a payment.