Giter Site home page Giter Site logo

Comments (9)

plutov avatar plutov commented on July 24, 2024

Hi @emigr2k1,
Can you please share the example of code and how you do type assert? Maybe we need to change how errors are returned. Thank you!

from paypal.

emigr2k1 avatar emigr2k1 commented on July 24, 2024

Hi, @plutov.
I'm sorry I didn't reply before. I didn't get the notification.
I was testing the library when I posted this issue and I don't have the code anymore.
The error I got was coming from:

func (c *Client) ExecuteApprovedPayment(paymentID string, payerID string) (*ExecuteResponse, error){...}

in payment.go but maybe this happens in other methods aswell
As you can see this function returns a normal error interface. To have access to the fields we have to use:

err.(*paypalsdk.ErrorResponse).Details

from paypal.

plutov avatar plutov commented on July 24, 2024

Hi @emigr2k1 are you able to provide a PR to solve this? But please keep error return value to be compatible.

from paypal.

emigr2k1 avatar emigr2k1 commented on July 24, 2024

I could but this and this recommend to return a normal error instead of a custom error and then use type assert.
So, probably the best way to solve this is just to add a section in the documentation showing how to handle the returned errors to get access to the ErrorResponse struct fields.
I'll provide a PR with examples handling errors if you think it's ok. Or maybe edit the example_test.go file and change:

if err != nil {
    panic(err)
}

To something like:

if err != nil {
    errDetails := err.(*ErrorResponse).Details
    panic(errDetails)
}

from paypal.

plutov avatar plutov commented on July 24, 2024

Or maybe we should format an error with correct description using Details inside the package, so panic(err) will be easy to understand.

from paypal.

emigr2k1 avatar emigr2k1 commented on July 24, 2024

Yes. I think that's better.

from paypal.

archana-iron avatar archana-iron commented on July 24, 2024

I am facing the same error, why this error occured?
I am not able to find the solution

from paypal.

archana-iron avatar archana-iron commented on July 24, 2024

Also need to confirm one more thing, the credit card details we are adding here are of which account? I mean of some other customer, or merchant of app itself?
Thanks in advance!

from paypal.

emigr2k1 avatar emigr2k1 commented on July 24, 2024

@archana-iron, try printing the error with:

err.(*paypalsdk.ErrorResponse).Details

About the credit card, it is the credit card of the payer but if I recall correctly, you can't use credit card method for payments. Try using

PaymentMethod: "paypal",

In the Payer field of a payment.
Check the official docs of paypal for more info. And you should create a new issue.

from paypal.

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.