Created
June 28, 2022 12:33
-
-
Save drunkhacker/2244deaec8fefd04b36c7322b91f7ced to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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