Skip to content

Instantly share code, notes, and snippets.

@drunkhacker
Created June 28, 2022 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drunkhacker/2244deaec8fefd04b36c7322b91f7ced to your computer and use it in GitHub Desktop.
Save drunkhacker/2244deaec8fefd04b36c7322b91f7ced to your computer and use it in GitHub Desktop.
const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
const config = new Config();
config.apiKey = 'REDACTED';
config.merchantAccount = 'MVL_TADAECOM';
const client = new Client({config});
client.setEnvironment('TEST');
const checkout = new CheckoutAPI(client);
(async function() {
const amount = {currency: 'SGD', value: 2000};
const paymentMethodsRes = await checkout.paymentMethods({
merchantAccount: config.merchantAccount,
countryCode: 'SG',
amount,
channel: 'Web'
});
console.log('available payment methods:');
paymentMethodsRes.paymentMethods.forEach((pm) => {
console.log('type:', pm.type);
console.log('name:', pm.name);
console.log('brands:', pm.brands);
});
const paymentDetail = {
type: 'scheme',
"encryptedCardNumber": "test_4917610000000000",
"encryptedExpiryMonth": "test_03",
"encryptedExpiryYear": "test_2030",
"encryptedSecurityCode": "test_737",
};
const paymentRes = await checkout.payments({
merchantAccount: config.merchantAccount,
paymentMethod: paymentDetail,
amount,
reference: 'baadc0ffee1',
returnUrl: 'https://localhost:3000/checkout',
storePaymentMethod: true,
shopperInteraction: 'Ecommerce',
recurringProcessingModel: 'UnscheduledCardOnFile',
shopperReference: 'myshopper-12345',
authenticationData: {
attemptAuthentication: 0,
}
});
console.dir(paymentRes);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment