Apple Pay SDK Setup
The setup and show functions create and initialize the Paysafe.js payment methods inside the selected HTML element containers (typically div elements) on your payment page. To initialize Paysafe JS with Apple Pay you should add applePay field. in the options.fields section.
Example of initializing Paysafe JS with ApplePay:
const options = {
accountId: accountId,
environment: 'TEST',
fields: {
applePay: {
selector: '#apple-pay',
type: 'buy',
label: 'Demo JS',
color: 'white-outline',
}
},
currencyCode: currencyCode
}
let hostedFieldsInstance;
paysafe.fields.setup(apikey, options)
.then(instance => {
hostedFieldsInstance = instance;
return hostedFieldsInstance.show();
}).then(paymentMethods => {
if (paymentMethods.applePay && !paymentMethods.applePay.error) {
// Subscribe for click event on applePay button
}
})
.catch((error) => {/** Process any errors during the setup*/})
async setupPaysafeJS() {
const options = {
accountId: accountId,
environment: 'TEST',
fields: {
applePay: {
selector: '#apple-pay',
type: 'buy',
label: 'Demo JS',
color: 'white-outline',
}
},
currencyCode: currencyCode
}
try {
const instance = await paysafe.fields.setup(apikey, options)
const paymentMethods = instance.show()
if (paymentMethods.applePay && !paymentMethods.applePay.error) {
// Subscribe for click event on applePay button
}
} catch(error) {
/** Process any errors during the setup*/
}
Was this page helpful?
On this Page