@mangopay/vault-sdk
v1.1.11
Published
Mangopay SDK - Vault
Downloads
17,705
Readme
MangopayVault SDK - User integration guide
Installation
The MangoPay MangopayVault SDK is available on npm. See @mangopay/vault-sdk for an API reference.
npm install --save @mangopay/vault-sdk
# or
yarn add @mangopay/vault-sdk
Create a Card Registration
Send the request to https://api.mangopay.com/v2.01/clientId/cardregistrations with the input JSON data, where clientId is the ID of your MangoPay client account.
CreateCardRegistrationResult
Promise<CreateCardRegistrationResult>;
| Prop | Type | | ----------------------------------------------------------------------------- | ------------- | | Id | String | | CardRegistrationURL The URL to submit the card details form to | String | | AccessKey A special key to use when registering a card | String | | PreregistrationData A specific value to pass to the CardRegistrationURL | String | | errors | MgpTypedError |
MgpTypedError
type MgpTypedError<T> = {
[Property in keyof T]: string;
};
Initialisation
import { MangopayVault } from '@mangopay/vault-sdk';
const options = {
clientId: 'MANGOPAY_CLIENT_ACCOUNT_ID',
environment: 'SANDBOX | PRODUCTION',
};
const vault = MangopayVault.initialize(options);
How it works
The MangopayVault API provides you with tokenizePaymentMethod( );
Tokenize Payment Method
CardInfoObject
| Prop | Type | | ------------------------------------------------------------------------ | ------ | | cardNumber The card number, as a string without any separators | String | | cardExpirationDate Card expiration date - should be in format MMYY | String | | cardCvx Card security code | String |
const cardInfoObject = {
cardNumber: '4970107111111119',
cardExpirationDate: '1127',
cardCvx: '123',
};
const preregistrationData = {
id: createCardRegistrationResult.Id,
cardRegistrationURL: createCardRegistrationResult.CardRegistrationURL,
accessKeyRef: createCardRegistrationResult.AccessKey,
data: createCardRegistrationResult.PreregistrationData,
};
const tokenizePaymentMethodResult = await vault.tokenizePaymentMethod(cardInfoObject, preregistrationData);
TokenizePaymentMethodResult
Promise<UpdateCardRegistrationOutput>;
UpdateCardRegistrationOutput
| Prop | Type | | ----------------------------------------------------------------------------- | ------------- | | Id | String | | CardRegistrationURL The URL to submit the card details form to | String | | AccessKey A special key to use when registering a card | String | | PreregistrationData A specific value to pass to the CardRegistrationURL | String | | CardId The ID of a card | String | | errors | MgpTypedError |