Create tokens
Create a token by passing the paymentMethod
to the createToken
method. The paymentMethod
can be a JSON object or an
HTMLFormElement
. It must contain all of the required information. See
Create the paymentMethod object.
Tokens expire after 15 minutes.
Use the following template to create tokens:
const pmToken = undefined;
adPayment.createToken(paymentMethod)
.then(function(response) {
// response.paymentMethod.accountDisplay
// save the token for later or use it immediately
pmToken = response.result.paymentMethod.id;
})
.error(function(error) {
// handle the error
});
Response object
The response
object has the following structure. The token is value of
the "id"
property.
{
"id": "pm_0838a859-dfa6-4863-aa38-042d50a9e69a",
"expiration": "2018-04-112T19:15:00Z",
"paymentMethod": {
"accountDisplay": "1111",
"paymentMethodType": "CARD",
"properties": {
"cardHolderName": "John Doe",
"expirationMonth": "1",
"expirationYear": "2021",
"brand": "VISA",
"number": "1111"
},
"billingAddress": {
"street1": "123 Main St.",
"city": "Springfield",
"state": "MA",
"country": "US",
"zip": "20156"
}
}
}
Error object
The error object has the following structure.
{
"status": 400,
"code": "VALIDATION_ERROR",
"message": "Missing required parameters"
}
Was this page helpful?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!