PayPal REST API .net SDK - 400 Bad Requests

后端 未结 8 1436
庸人自扰
庸人自扰 2021-02-13 12:57

I\'m working in the sandbox and using the PayPal REST .net SDK method Payment.Create with a CreditCard object. When all parameters are valid and using the test CC number from h

8条回答
  •  长发绾君心
    2021-02-13 13:53

    I only started messing with the SDK and API today and ran into this issue right away. I mean, if I'm going to create my own form to handle payments, I'd like to give my user's feedback if anything went wrong.

    In any case, I did find some hidden info in the inner exception. Maybe this will help.

    catch (PayPal.Exception.PayPalException ex)
    {
        if (ex.InnerException is PayPal.Exception.ConnectionException)
        {
            context.Response.Write(((PayPal.Exception.ConnectionException)ex.InnerException).Response);
        }
        else
        {
            context.Response.Write(ex.Message);
        }
    }
    

    The resulting response:

    {"name":"VALIDATION_ERROR","details":[{"field":"payer.funding_instruments[0].credit_card.number","issue":"Must be numeric"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"0548e52ef9d95"} 
    

提交回复
热议问题