Environment: Visual Studio 2010 Professional .NET Framework 4 C #
Added a service link using the following WSDL: https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl
Problem 1 : when compiling just like that, get a bunch of errors from the Reference.cs file. Looks like namespace errors. It mentions that he cannot find the reference namespace in the project namespace. So I went into the Reference.cs file, and if I got this error, I deleted the project namespace before the method name and now it compiles.
Finally, access all classes. Created and populated DoDirectPaymentReq and CustomSecurityHeader objects with the required properties. Created an instance of the PayPalAPIAAInterfaceClient class, which contains the DoDirectPayment method, which takes arguments of the type CustomSecurityHeader and DoDirectPaymentReq. Looks like that:
using (var client = new **PayPalAPIAAInterfaceClient**()) { var credentials = new CustomSecurityHeaderType { Credentials = new UserIdPasswordType { Username = " xxxxxxxx@xxxxxx.com ", Password = "xxxxxxx", Signature = "jksadfuhasfweakjhasf" } }; _doDirectPaymentResponseType = client.DoDirectPayment(ref credentials, _doDirectPaymentReq); }
Problem 2 : after writing TestMethod for a method that contains the above code, I get an error as follows:
System.InvalidOperationException: Could not find default endpoint element that references contract 'Paypal.PayPalAPIAAInterface' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName) at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration) at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName) at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address) at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory() at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait) at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef() at System.ServiceModel.ClientBase`1..ctor() at PaymentEngine.Paypal.PayPalAPIAAInterfaceClient..ctor() in Reference.cs: line 30063
Therefore, so far I have not been able to complete a successful transaction using the PayPal SOAP protocol using WSDL in C #.
I got the impression that it is very simple. Just add a link to the service and use the classes with their properties and methods created in the proxy from WSDL.
Where am I going wrong?
Am I using the wrong WSDL? First I would like to test Sandbox, and then go to Live.
If I'm right with WSDL, it looks like the PayPalAPIAAInterfaceClient class does not know the endpoint , which I do not know if I intend to install manually or not, since its already there definition of WSDL at the end (check it). I think the class itself needs to know which endpoint to call, depending on whether I use a signature or certificate to populate CustomSecurityHeaderType.
But how does the PayPalAPIAAInterfaceClient class know if I'm trying to call the Sandbox (testing) or is it a direct transaction?
PayPal used two different WSDLs for the sandbox and for the Live. You can find them here: -> https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_soap_PayPalSOAPAPIArchitecture
After talking with their support, I was asked to use the following WSDL for Sandbox and Live: -> https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl
But how can I tell the PayPalAPIAAInterfaceClient class when it should run Live or Sandbox tests. As well as which endpoint to use depending on my SOAP and Signature method. PayPal endpoints are mentioned here:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_api_endpoints
HELP!