Show Function
The show function loads the Paysafe.js payment methods inside the selected HTML element containers (typically div elements) on your payment page. This function has no parameters.
The function should be invoked immediately after the setup function on the hosted fields instance, which is returned on setup.
The function signature is as follows:
instance.show()
.then((paymentMethods) => {
/** Continue with events handling */
if (paymentMethods.card && !paymentMethods.card.error) {
// Card payment method is successfully initialized
}
if (paymentMethods.applePay && !paymentMethods.applePay.error) {
// Apple Pay payment method is successfully initialized
}
if (paymentMethods.googlePay && !paymentMethods.googlePay.error) {
// Google Pay payment method is successfully initialized
}
})
.catch((error) => {/** Process any errors during the show */})
Or you can use async-await:
async function showPaysafeJS() {
try {
const paymentMethods = await instance.show()
/** Continue with events handling */
if (paymentMethods.card && !paymentMethods.card.error) {
// Card payment method is successfully initialized
}
if (paymentMethods.applePay && !paymentMethods.applePay.error) {
// Apple Pay payment method is successfully initialized
}
if (paymentMethods.googlePay && !paymentMethods.googlePay.error) {
// Google Pay payment method is successfully initialized
}
} catch(error) {
/** Process any errors during the show */
}
}
The Show function return a Promise, which is then resolved in a payment methods object.
The paymentMethods object will contain a list of the provided payment methods on setup and the result from their initialization.
| Parameter | Optional | Type | Description |
|---|---|---|---|
| paymentMethods | |||
card | true | Object | An object that will contain an error only if such occurs during the initialization of the payment method. When the initialization of the method is successful, an empty object will be returned. |
| applePay | true | Object | An object that will contain an error only if such occurs during the initialization of the payment method. When the initialization of the method is successful, an empty object will be returned. |
| googlePay | true | object | An object that will contain an error only if such occurs during the initialization of the payment method. When the initialization of the method is successful, an empty object will be returned. |
Show Error Object
The show() will throw an error only if none of the provided methods is successfully initialized.
The following table describes the contents of the error object:
| Parameter | Required | Type | Description |
|---|---|---|---|
| code | true | String | Error Code |
| displayMessage | true | String | Error message for display to customers. |
| detailedMessage | true | String | A detailed description of the error (this information should not be displayed to customers). |
| correlationId | true | String | Unique error ID to be provided to Paysafe Support during an investigation. |
Expected Errors
| Code | Display Message | Detailed Message | Description |
|---|---|---|---|
9028 | There was an error (9028), please contact our support. | Failed to initialize Paysafe.js iframes. | The iframes used for the sensitive payment fields failed to initialize within 5 seconds. This could occur if the server that generates the HTML for the iframe is not available. |
| 9073 | There was an error (9073), please contact our support. | Account not configured correctly. | The error is a result of an improperly created merchant account configuration:
|
| 9055 | There was an error (9055), please contact our support. | Invalid currency parameter. | The currencyCode is not a valid ISO currency |
| 9084 | There was an error (9084), please contact our support. | Failed to load available payment methods. | There was a problem getting the merchant's payment methods. |
| Apple Pay and Google Pay specific errors | |||
| 9014 | There was an error (9014), please contact our support. | Unhandled error occurred. | The error was unexpected but it was logged and correlationId was set to help problem investigation. |
| 9066 | There was an error (9066), please contact our support. | Invalid label parameter. | Invalid Payment Request label option parameter. |
| 9071 | There was an error (9071), please contact our support. | Paysafe Request is already initialized. | Trying to show the Apple Pay button more than once. |
| 9191 | There was an error (9191), please contact our support. | Invalid buttonColor parameter. | Used when the supplied color is not supported by Apple Pay/ Google Pay. |
| 9077 | There was an error (9077), please contact our support. | Requested currency: [XXX] but Supported: [AAA, ...] | The merchant requested a currency via the init or update methods that is not enabled in its account (smart routing service). |
| 9080 | There was an error (9080), contact our support. | Insecure page. The page should be served over HTTPS and have a valid certificate. | The page where Apple/Google pay button is initialized is not secure. Make sure you are serving your page over HTTPS. |
| 9085 | There was an error (9085), please contact our support. | There are no available payment methods for this api key. | The merchant does not have APPLE/ GOOGLE PAY configured. |
| 9088 | There was an error (9088), please contact our support. | Unable to show buttons. Requested: [...] but Supported: [...] | Supported and requested payment methods do not match and the payment button fails to display. |
| 9091 | There was an error (9091), please contact our support. | Invalid buttonType parameter. | The options button type argument is invalid. |
| 9165 | There was an error (9165), please contact our support. | merchantCapabilities should be an array. | Google Pay's merchant capabilities are in an invalid format. The merchant capabilities are configured in the Paysafe Admin portal. Contact:
|
| 9166 | There was an error (9166), contact our support. | Invalid merchantCapabilities: ${invalid}. The supported values are {supported} | Google Pay/Apple Pay's merchant capabilities are invalid. Valid merchant capabilities for Google Pay are:
Valid merchant capabilities for Apple Pay are:
The merchant capabilities are configured in the Paysafe Admin portal. Please contact:
|
| Apple Pay specific errors | |||
| 9086 | There was an error (9086), please contact our support. | The browser does not support the payment methods, the user has no active card in the wallet, or the merchant domain is not validated with Apple. | The browser does not support the payment methods, the user has no active card in the wallet, or the merchant domain is not validated with Apple |
| 9180 | There was an error (9180), contact our support. | Invalid Apple Pay merchantId parameter. | The merchant ID is not provided. The Merchant ID is configured in the Paysafe Admin portal. Contact:
|
| Google Pay specific errors | |||
| 9195 | There was an error (9195), contact our support. | Failed to load Google Pay script ${error}. | Unable to load the Google Pay SDK. |
| 9197 | There was an error (9197), please contact our support. | Failed to invoke Google isReadyToPay: ${error}. | Unable to check if Google Pay is available. |
| 9189 | There was an error (9189), please contact our support. | Google Pay merchantId should be a string with length between 12 and 18. | The merchant ID should be between 12 and 18 symbols. The Merchant ID is configured in the Paysafe Admin portal. Contact:
|
| 9190 | There was an error (9190), contact our support. | Google Pay merchantOrigin should be a string. | The merchant domain is invalid. |
| 9193 | There was an error (9193), contact our support. | GooglePay allowedAuthMethods should be an array. | Google Pay's allowed auth methods are invalid. Valid allowed auth methods are:
The allowed auth methods are configured in the Paysafe Admin portal. Contact:
|
| 9194 | There was an error (9194), contact our support. | GooglePay allowedAuthMethods: ${invalid}. The supported values are PAN_ONLY, CRYPTOGRAM_3DS | Google Pay's allowed auth methods are in an invalid format. The allowed auth methods are configured in the Paysafe Admin portal. Contact:
|
| 9206 | There was an error (9206),contact our support. | Google Pay is not supported on this device. | Google Pay is not available for the device. |