Create the Payment Token
The Payment Token object stores all the data collected via the Payment WebElement, along with any additional information added during the token generation.
IMPORTANT: This method is only used when tokenizing payment methods with the "Payment WebElement". For instructions on how to tokenize using the "Express Checkout Web Element", please see the "Listening to Express Checkout Token Generation" section in the Express Checkout Web Element Page
To create a Payment Token, use the following method gettrx.createToken(options?)
. The options parameter allows you to add extra information to the Payment token.
const paymentToken = await gettrx.createToken();
gettrx.createToken()
returns a Promise that resolves to a result object:
result
Field | Description |
---|---|
token | The Payment Token created. Indicates a successful generation of the Payment token. If the Payment token generation fails, this value will be null and the error field will be populated. |
error | Indicates an error occurred, including client-side validation errors, payment method errors, or invalid request errors. If a validation_error happens, show the message to the user and allow them to update their information and resubmit. |
result.error
Field | Type | Description |
---|---|---|
type | string | The type of the error returned."api_error" | "payment_error" | "invalid_request_error" | "validation_error" |
code | string | For errors that can be handled programmatically, an error code string will be provided. |
message | string | A human-readable message with details about the error. For validation_error, these messages can be displayed to the user. |
Updated 3 months ago