PayPal 400 Bad Request, more specific?

Is there a way to get a more specific PayPal error than 400 bad requests? I saw someone doing something like this:

if (ex.InnerException is ConnectionException)
{
    Response.Write(((ConnectionException) ex.InnerException).Response);
}
else
{
    Response.Write(ex.Message);
}

But for me it does not look like all the errors say: "The remote server responded to the error: (400)" Bad request. "

I read that this may have something to do with some kind of validation error, but I tried to change the data that I send to PayPal, but so far no luck.

Hope you help me, thanks!

EDIT:

Thanks to Aydin, I was able to find this error message in one of the HTTP requests via Fiddler:

{"name":"VALIDATION_ERROR","details":[{"field":"payer.funding_instruments[0].credit_card.number","issue":"Value is invalid"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"dd5f11f6e9c98"}
+4
source share
4 answers

, Fiddler, , HTTP-, , , , .

, example.com. , , , ... HTTP- .

image of fiddler

+3

Fiddler ( , ), catch , :

try
{
    var payment = Payment.Create(...);
}
catch(PayPalException ex)
{
    if(ex is ConnectionException)
    {
        // ex.Response contains the response body details.
    }
    else
    {
        // ...
    }
}

... ...

try
{
    var payment = Payment.Create(...);
}
catch(ConnectionException ex)
{
    // ex.Response contains the response body details.
}
catch(PayPalException ex)
{
    // ...
}

, 1.4.3 ( ) SDK PayPal.NET, public static:

, SDK API.

+3

@JasonZ PayPalResource.LastResponseDetails.Value, , . , , , :

catch (PayPal.PaymentsException ex)
{
    context.Response.Write(ex.Response);
}

:

{"name":"VALIDATION_ERROR","details":[{"field":"start_date","issue":"Agreement start date is required, should be valid and greater than the current date. Should be consistent with ISO 8601 Format"}],"message":"Invalid request. See details.","information_link":"https://developer.paypal.com/docs/api/payments.billing-agreements#errors","debug_id":"8c56c13fccd49"}
+1

. , . . . ,

credit_card = new CreditCard()
                    {
                        billing_address = new Address()
                        {
                            city = "Johnstown",
                            country_code = "US",
                            line1 = "52 N Main ST",
                            postal_code = "43210",
                            state = "OH"
                        },
                        cvv2 = "874",
                        expire_month = 11,
                        expire_year = 2018,
                        first_name = "Joe",
                        last_name = "Shopper",
                        number = "4024007185826731", //New Credit card Number, Only Card type should match other details does not matter
                        type = "visa"
                    }

Note. All credit cards mentioned on the PayPal website do not work, which gives me the same problem. If it works for you, then it makes good use of the new credit card number for testing. Hope this helps someone.

Enjoy the coding!

0
source

All Articles