Paypal Refund in C# - Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mudassir
    New Member
    • May 2012
    • 85

    Paypal Refund in C# - Error

    Hi every one,
    i am using paypal sdk to refund a payment in c#. the code i wrote to refund is as follow

    Code:
    string ClientId = "my client id";
            string ClientSecret = "my client secret";
    
            OAuthTokenCredential tokenCredential = new OAuthTokenCredential(ClientId, ClientSecret);
            string accessToken = tokenCredential.GetAccessToken();
            APIContext apicontext = new APIContext(accessToken);
            Sale sale = Sale.Get(apicontext, "paypl transaction id");
            Amount amount = new Amount();
            amount.total = "2.34";
            amount.currency = "USD";
    
            Refund refund = new Refund();
            refund.amount = amount;
            Refund newRefund = sale.Refund(apicontext, refund);
    but when i execute this code, it gives erro at line Refund newRefund = sale.Refund(api context, refund); and the error is "The remote server returned an error: (400) Bad Request."

    Any help on this will be greatly appreciated.

    Thank you.
  • Kara Hewett
    New Member
    • Apr 2014
    • 27

    #2
    400 Bad request Error will cause due to authentication entries has incorrect.

    Check your API URL is correct or wrong. Don't leave any spaces front or at end.
    check your username and password are valid one. Please check any spell mistake while entering.

    Note: Mostly due to Incorrect authentication entries due to spell changes will occur 400 Bad request.

    Comment

    Working...