Giter VIP home page Giter VIP logo

Comments (6)

kshirish avatar kshirish commented on August 25, 2024

@karthit Cannot encode value seems like a Firebase error. this.path is supposed to be undefined within the constructor ... only when you use a method on an instance (pg/payouts), its value gets set.

Could you share logs? Which method are you using and how are you invoking it?

from cashfree-sdk-nodejs.

karthit avatar karthit commented on August 25, 2024

const pg = new PaymentGateway(pgConfig); //path: undefined
await pg.refunds.initiateRefund({req.body});

since the value of path: undefined, instead of null or any default value, in Firebase cloud function this undefined value is creating this error message: Cannot encode value

from cashfree-sdk-nodejs.

kshirish avatar kshirish commented on August 25, 2024

@karthit

If you are literally doing this then it's wrong – what you are passing is an invalid object.

await pg.refunds.initiateRefund({req.body});

Below works for me:

const pgInstance = new PaymentGateway({
        env: 'TEST',
        apiVersion: '<API_VERSION>',
        appId: '<YOUR_APP_ID>',
        secretKey: '<YOUR_SECRET_KEY>',
});

const body = {
        orderId: 'ORDER123',
        referenceId: '13307',
        refundAmount: '102.00',
        refundNote: 'Sample Refund note',
        refundType: '',
        refundType: '',
        mode: '',
        accountNo: '',
        ifsc: '',
};

const response = await pgInstance.refunds.initiateRefund(body);

console.log(response);

Also, path is not an issue. It's getting set as /api/v1/order/refund later when you call .initiateRefund().

from cashfree-sdk-nodejs.

karthit avatar karthit commented on August 25, 2024

yes we are using same above lines of code, but while working with Firebase cloud functions the PaymentGateWay constructor returns undefined path, we are getting Cannot encode value error, it works with express but the issue is with only when deployed Firebase cloud functions.

Even though we set the path to different methods after this, Firebase cloud failed while returning this

const pgInstance = new PaymentGateway({
        env: 'TEST',
        apiVersion: '<API_VERSION>',
        appId: '<YOUR_APP_ID>',
        secretKey: '<YOUR_SECRET_KEY>',
});

pgInstance object { ..., path: undefined }

we expect this should be having some valid default values, like { ...., path: null } then Firebase cloud function can work with the null values returned in the object pgInstance, but not the undefined.

from cashfree-sdk-nodejs.

kshirish avatar kshirish commented on August 25, 2024

@karthit Why don't you try forking the repository and set a default value of path in the constructor as "" to see whether it works for you or not?

from cashfree-sdk-nodejs.

kshirish avatar kshirish commented on August 25, 2024

@karthit SDK has been updated. It will work now.

from cashfree-sdk-nodejs.

Related Issues (9)

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.