The init function creates and initializes the Paysafe Request instance. The Paysafe Request options are then validated and an asynchronous request is made to the backend to get the merchant information matching the API Key. This is the first step you should perform in your script. After calling this function - but before the user clicks the payment button - the updateOptions function can be used to change all the option parameters except environment.
The function signature is as follows:
The function parameters are described below.
The Base64-encoded version of the single-use token API key used to authenticate with the Customer Vault REST API.
This key can only be used to generate single-use tokens for use with the Card Payments API. It cannot be used for taking payments; and so can be exposed publicly in the user's browser.
|options||true||object||Settings to apply to the Paysafe Request, such as the the environment to use (Test or Live), the payment amount, the currency, the country, and parameters to personalize the payment form and provide addresses.|
Throws an exception with the following errors: 9013, 9014, 9015, 9017, 9055, 9054, 9066, 9068, 9069, 9070, 9071.
These are the init option parameters.
Payment amount in minor units to charge the customer's card. Use the correct minor units amount for the merchant account currency. For example, to process US $10.99, this value should be 1099. To process 1000 Japanese Yen, this value should be 1000. To process 10.139 Tunisian dinar, this value should be 10139. Payment amount has to be supplied as a positive number and shouldn't be longer than 9 digits.
|country||true||string||The two-uppercase-character ISO 3166 country code.|
|currency||true||string||Three character code for the payment currency; for example USD for US dollars|
Environment to which Paysafe Request is connected:
If you omit the environment object, by passing an empty or null value for this parameter, the Live environment will be used.
You cannot change this parameter using the updateOptions function.
|label||true (Apple Pay only)||string||Label displayed immediately after the "Pay" button on the Apple Pay page.|
Set to true to include the billing information in the onTokenization function callback response containing the token. The default value is false
Set to true to include the shipping information in the onTokenization function callback response containing the token. The default value is false
Apple Pay Example
This example in the TEST environment shows how to specify initialize a Paysafe Request instance. It does not include the showButtons or onTokenization code.