-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adyen doesn't show #248
Comments
Can you give more information? I just tested and Adyen is working for me. Does your terminal show any errors? |
Terminal doesn't show any errors, it's just Ayden doesn't appear on the payment options (ss above) |
Could you check the browser console too for any errors. It's highly likely a config issue given it's working perfectly fine for me. |
Quick question: How do I implement this on my version? I tried putting the code, doesn't work. |
Could you show the config where you are turning on Adyen? Maybe even share your Adyen config with the sensitive parts removed? |
Alr, and also to let you know I modified the code but I am not sure if it was the one causing the error, so I was trying to add GCash as an payment option for the site and here's the modified code (not really much modified) // adyen.js btw
const express = require('express');
const { indexOrders } = require('../indexing');
const numeral = require('numeral');
const { Client, CheckoutAPI } = require('@adyen/api-library');
const { getId, sendEmail, getEmailTemplate } = require('../common');
const { getPaymentConfig } = require('../config');
const { emptyCart } = require('../cart');
const router = express.Router();
router.post('/setup', async (req, res, next) => {
const adyenConfig = getPaymentConfig('adyen');
const client = new Client({
apiKey: adyenConfig.apiKey,
environment: adyenConfig.environment
});
const checkout = new CheckoutAPI(client);
let paymentsResponse;
try{
paymentsResponse = await checkout.paymentMethods({
amount: {
currency: 'PHP',
value: 0
},
countryCode: 'PH',
channel: 'Web',
merchantAccount: adyenConfig.merchantAccount
});
}catch(ex){
console.log('Exception getting supported payment methods', ex.message);
res.status(400).json({ message: `Failed to retrieve payment methods.${ex.message}` });
}
res.status(200).json({
paymentsResponse,
environment: adyenConfig.environment,
originKey: adyenConfig.originKey
});
});
router.post('/checkout_action', async (req, res, next) => {
const db = req.app.db;
const config = req.app.config;
const adyenConfig = getPaymentConfig('adyen');
const client = new Client({
apiKey: adyenConfig.apiKey,
environment: adyenConfig.environment
});
// Rest are the same code as in the repo |
Used wrong link - here's the correct link: https://docs.adyen.com/payment-methods/gcash/api-only |
I've updated the Adyen integration to the latest and greatest here: 7c29782. Note: The configuration changes: I can't test the specific payment method you are trying to use. Let me know how you get on. |
There was come config values which were removed. Check your config matches the |
Here is my current config for adyen {
"description": "Card payment",
"environment": "test",
"apiKey": "API here",
"clientKey": "key here",
"merchantAccount": "Account here",
"currency": "AUD",
"countryCode": "AU"
} |
I think the payment type you want is quite niche and I'm not sure most will benefit by me adding it to master. Re-reading the guide, is seems the GCash payment method isn't supported on the drop-in UI/integration which I've built for. It looks easy enough to integrate though. You can simply add something like this code to your Then something like this (not tested at all) in if($('#dropin-container').length > 0){
$.ajax({
method: 'POST',
url: '/adyen/setup'
})
.done(async function(response){
$('#adyen-gcash-link').attr('href', response.action.url);
})
.fail(function(msg){
showNotification(msg.responseJSON.message, 'danger');
});
};
Then in <div>
<a href="#" class="btn btn-primary" id="adyen-gcash-link"></a>
</div> |
Alright, but in the code that you sent me, should I replace it with the current code in the script or just add those? And for the GCash API, I think all are already except for the // COMMON.JS
if($('#dropin-container').length > 0){
$.ajax({
method: 'POST',
url: '/adyen/setup'
})
.done(async function(response){
const configuration = {
environment: response.environment,
clientKey: response.clientKey,
session: {
id: response.paymentsResponse.id,
sessionData: response.paymentsResponse.sessionData
},
onPaymentCompleted: (result, component) => {
console.log('result', result);
console.log('component', component);
if($('#shipping-form').validator('validate').has('.has-error').length === 0){
$.ajax({
type: 'POST',
url: '/adyen/checkout_action',
data: {
paymentCode: result.resultCode,
paymentId: component._id
}
}).done((response) => {
window.location = '/payment/' + response.paymentId;
}).fail((response) => {
showNotification('Failed to complete transaction', 'danger', true);
});
}
},
onError: (error, component) => {
console.log(error.name, error.message, error.stack, component);
},
paymentMethodsConfiguration: {
hasHolderName: false,
holderNameRequired: false,
billingAddressRequired: false
}
};
const checkout = await AdyenCheckout(configuration);
checkout.create('dropin').mount('#dropin-container');
})
.fail(function(msg){
showNotification(msg.responseJSON.message, 'danger');
});
}; |
Ok. I've had a quick play and got it working.
router.post('/setup', async (req, res, next) => {
const config = req.app.config;
const adyenConfig = getPaymentConfig('adyen');
const payload = {
merchantAccount: adyenConfig.merchantAccount,
amount: { currency: 'PHP', value: 1000 },
paymentMethod: {
type: 'gcash'
},
returnUrl: `${config.baseUrl}/adyen/checkout_return`,
reference: Object.keys(req.session.cart)[0]
};
let paymentsResponse;
try{
paymentsResponse = await got.post(`https://checkout-${adyenConfig.environment}.adyen.com/v67/payments'`, {
headers: {
'content-type': 'application/json',
'x-API-key': adyenConfig.apiKey
},
json: payload
});
paymentsResponse = JSON.parse(paymentsResponse.body);
}catch(ex){
console.log('Exception getting supported payment methods', ex.message);
res.status(400).json({ message: `Failed to retrieve payment methods.${ex.message}` });
return;
}
res.status(200).json({
paymentsResponse,
environment: adyenConfig.environment
});
});
if($('#adyen-gcash-container').length > 0){
$.ajax({
method: 'POST',
url: '/adyen/setup'
})
.done(async function(response){
$('#adyen-gcash-link').attr('href', response.paymentsResponse.action.url);
$('#adyen-gcash-link').text('Pay GCash');
})
.fail(function(msg){
showNotification(msg.responseJSON.message, 'danger');
});
};
<div>
<div class="mb-2">{{@root.paymentConfig.adyen.description}}</div>
<div id="adyen-gcash-container">
<a href="#" class="btn btn-primary" id="adyen-gcash-link">Loading...</a>
</div>
</div>
|
Adyen Payment option doesn't show in payment, I added Adyen in the settings and filled out the keys
The text was updated successfully, but these errors were encountered: