Git Product home page Git Product logo

Comments (18)

mrvautin avatar mrvautin commented on May 29, 2024

Can you give more information? I just tested and Adyen is working for me. Does your terminal show any errors?

from expresscart.

rodrigoricky avatar rodrigoricky commented on May 29, 2024

Terminal doesn't show any errors, it's just Ayden doesn't appear on the payment options (ss above)

from expresscart.

mrvautin avatar mrvautin commented on May 29, 2024

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.

from expresscart.

rodrigoricky avatar rodrigoricky commented on May 29, 2024

image

from expresscart.

rodrigoricky avatar rodrigoricky commented on May 29, 2024

Quick question: How do I implement this on my version? I tried putting the code, doesn't work.

from expresscart.

mrvautin avatar mrvautin commented on May 29, 2024

Quick question: How do I implement this on my version? I tried putting the code, doesn't work.

Added in 41c997e.

from expresscart.

mrvautin avatar mrvautin commented on May 29, 2024

Terminal doesn't show any errors, it's just Ayden doesn't appear on the payment options (ss above)

Could you show the config where you are turning on Adyen? Maybe even share your Adyen config with the sensitive parts removed?

from expresscart.

rodrigoricky avatar rodrigoricky commented on May 29, 2024

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

from expresscart.

rodrigoricky avatar rodrigoricky commented on May 29, 2024

Used wrong link - here's the correct link: https://docs.adyen.com/payment-methods/gcash/api-only

from expresscart.

mrvautin avatar mrvautin commented on May 29, 2024

I've updated the Adyen integration to the latest and greatest here: 7c29782.

Note: The configuration changes: /config/payment/config/adyen.json

I can't test the specific payment method you are trying to use. Let me know how you get on.

from expresscart.

rodrigoricky avatar rodrigoricky commented on May 29, 2024

So, I just filled out the new config of Adyen and I tried running it but returns this error while running it.

image

Edit: Nevermind, I accidentally added an old config line

from expresscart.

rodrigoricky avatar rodrigoricky commented on May 29, 2024

So I tried to setup the Adyen, and it still the same as earlier but now it has error on console:

image
image

Error only show when I am on checkout page

from expresscart.

mrvautin avatar mrvautin commented on May 29, 2024

There was come config values which were removed. Check your config matches the adyen.json example. Checking carefully there is no old configs that are no longer needed with the new version.

from expresscart.

rodrigoricky avatar rodrigoricky commented on May 29, 2024

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"
}

from expresscart.

mrvautin avatar mrvautin commented on May 29, 2024

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 /setup endpoint in adyen.js: https://docs.adyen.com/payment-methods/gcash/api-only#api-only-payments

Then something like this (not tested at all) in /public/javascripts/common.js:

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');
        });
    };

The idea is to get the response from /adyen/setup and set the URL of the link on the payment form.

Then in /views/partials/payments/adyen.hbs add something like:

<div>
    <a href="#" class="btn btn-primary" id="adyen-gcash-link"></a>
</div>

from expresscart.

rodrigoricky avatar rodrigoricky commented on May 29, 2024

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 paymentMethod right?

// 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');
        });
    };

from expresscart.

rodrigoricky avatar rodrigoricky commented on May 29, 2024

This is my current code on adyen.js

const payload = {
        merchantAccount: adyenConfig.merchantAccount,
        amount: {
            currency: adyenConfig.currency,
            value: numeral(req.session.totalCartAmount).format('0.00').replace('.', '')
        },
	paymentMethod: {
		type: 'gcash',
		storedPaymentMethodId: "7219687191761347"
			},
        returnUrl: `${config.baseUrl}/adyen/checkout_return`,
        reference: Object.keys(req.session.cart)[0],
        countryCode: adyenConfig.countryCode,
        shopperEmail: req.session.customerEmail
    };

I don't really know how it should be even though I read the docs
image

from expresscart.

mrvautin avatar mrvautin commented on May 29, 2024

Ok. I've had a quick play and got it working.

adyen.js:

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
    });
});

common.js:

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');
        });
};

adyen.hbs

<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>

Note: I have no idea what GCash actually is and how to test a payment so the /checkout_action return code will need some work

from expresscart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.