1

I'm trying set up paypal express checkout using SOAP 2.0 API in ASP.NET C# code. First I try to use sandbox, I created seller/buyer test accounts, imported web service and then I try to get token, in my C# code I have:

        // Create the request object
        SetExpressCheckoutRequestType pp_request = new SetExpressCheckoutRequestType();

        // Create the request details object
        pp_request.SetExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType();
        pp_request.SetExpressCheckoutRequestDetails.PaymentAction = paymentAction;
        pp_request.SetExpressCheckoutRequestDetails.PaymentActionSpecified = true;

        pp_request.SetExpressCheckoutRequestDetails.OrderTotal = new BasicAmountType();

        pp_request.SetExpressCheckoutRequestDetails.OrderTotal.currencyID = currencyCodeType;
        pp_request.SetExpressCheckoutRequestDetails.OrderTotal.Value = paymentAmount;

        pp_request.SetExpressCheckoutRequestDetails.CancelURL = cancelURL;
        pp_request.SetExpressCheckoutRequestDetails.ReturnURL = returnURL;

        SetExpressCheckoutResponseType response = (SetExpressCheckoutResponseType) caller.Call("SetExpressCheckout", pp_request);

but on the last line of that code it throws an error:

The request was aborted: Could not create SSL/TLS secure channel.

That I'm doing wrong? Thanks.

ihorko
  • 6,855
  • 25
  • 77
  • 116

1 Answers1

1

Your code certainly seems correct but the PayPal API can be finicky when it comes to a few things. One thing to look out for is that it will generate exceptions when the payment amount is not rounded to 2 decimal places - can you try ensuring this is the case?

Also ensure that your configuration values are correct. Aside from that the code you have posted is exactly what I used to use for the SOAP API.

I stopped using the SOAP API a while ago in favour of the NVP API, which in my mind is a bit easier to deal with: https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_NVPAPIOverview

I made available a library to do all the work for you: https://github.com/davidduffett/Moolah

The instructions here show exactly how to use PayPal Express Checkout: https://github.com/davidduffett/Moolah#paypal-express-checkout

David Duffett
  • 3,145
  • 2
  • 26
  • 27
  • Hi David, I tried your library and it give me an exception " The request was aborted: Could not create SSL/TLS secure channel." Can you please guide me to fix the problem? – Sarim Shekhani Jan 22 '16 at 17:08
  • Dude, amazing work with the library!, but look for Sarim's comment. There is indeed a small modification that needs to be made. @SarimShekhani: See here! http://stackoverflow.com/a/34950820/1057052 – Jose A Feb 14 '16 at 22:21
  • Wait! Nailed it! Thanks a million. Remember the link from my previous comment? Well, we just need to add ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; before using "SetExpressCheckout". In my case, just to be safe, I uput it before var gateway = new PayPalExpressCheckout(configuration) – Jose A Feb 14 '16 at 22:29