Promise based wrapper client for Adyen Web SDK for Javascript.
npm i @spbrewery/adyen
The methods return promises which are compatible to be used on async/await functions. The default configuration settings can be overridden on the constructor of BreweryAdyen
.
const { BreweryAdyen } = require('@spbrewery/adyen');
const breweryAdyenClient = new BreweryAdyen({
apiKey: 'YOUR-API-KEY',
apiUrl: 'https://your.redirect.url',
checkoutUrl: 'https://checkout-test.adyen.com/checkout/v40/', // default value
merchantAccount: 'YOUR MERCHANT ACCOUNT',
sdkVersion: '1.6.5', // default value
});
adyenClient.paymentSession({
countryCode: 'PH',
...restOfParameters,
})
.then((data) => {
console.log(data);
})
.catch(error) => {
console.log(error);
});
adyenClient
/**
* Initiate a payment session with Adyen.
*
* @param {string} amountCurrency - The currency code of the amount to be paid
* @param {number} amountValue - The amount to be paid
* @param {string} countryCode - The country code of the payer
* @param {string} reference - Unique identifier for the transaction
* @param {string} returnUrl - The URL to be used as landing page after the transaction
* @param {string} shopperReference - Unique identifier of the payer
*
* @returns {Object}
*/
.paymentSession({
amountCurrency: '',
amountValue: '',
countryCode: '',
reference: '',
returnUrl: '',
shopperLocale: '',
})
/**
* Verify the payment result.
*
* @param {string} payload - The encrypted payment result data to be verified
*
* @returns {Object}
*/
.paymentResult({
payload: '',
});
These are auxillary methods that are exported with the package.
/**
* Decode the given JWT string.
*/
const { decodeJwt } = require('@spbrewery/adyen');
decodeJwt('eyJjaGVja291dHNob3BwZXJCYXNlVXJsIjoiaHR0...');