PayPal.SOAP.MerchantAPICallPreHandler.GetEndpoint C# (CSharp) Method

GetEndpoint() public method

Returns the endpoint url
public GetEndpoint ( ) : string
return string
        public string GetEndpoint()
        {
            string endpoint = null;
            if (PortName != null && config.ContainsKey(PortName) && !string.IsNullOrEmpty(config[PortName]))
            {
                endpoint = config[PortName];
            }
            else if (config.ContainsKey(BaseConstants.EndpointConfig))
            {
                endpoint = apiCallHandler.GetEndpoint();
            }
            else if (config.ContainsKey(BaseConstants.ApplicationModeConfig))
            {
                switch (config[BaseConstants.ApplicationModeConfig].ToLower())
                {
                    case BaseConstants.LiveMode:
                        if (credential is SignatureCredential)
                        {
                            endpoint = BaseConstants.MerchantSignatureLiveEndpoint;
                        }
                        else if (credential is CertificateCredential)
                        {
                            endpoint = BaseConstants.MerchantCertificateLiveEndpoint;
                        }
                        break;
                    case BaseConstants.SandboxMode:
                        if (credential is SignatureCredential)
                        {
                            endpoint = BaseConstants.MerchantSignatureSandboxEndpoint;
                        }
                        else if (credential is CertificateCredential)
                        {
                            endpoint = BaseConstants.MerchantCertificateSandboxEndpoint;
                        }
                        break;
                    case BaseConstants.TestSandboxMode:
                        if (credential is SignatureCredential)
                        {
                            endpoint = BaseConstants.MerchantSignatureTestSandboxEndpoint;
                        }
                        else if (credential is CertificateCredential)
                        {
                            endpoint = BaseConstants.MerchantCertificateTestSandboxEndpoint;
                        }
                        break;
                    default:
                        throw new ConfigException("You must specify one of mode(live/sandbox) OR endpoint in the configuration");
                }
            }
            else
            {
                throw new ConfigException("You must specify one of mode(live/sandbox) OR endpoint in the configuration");
            }
            return endpoint;
        }

Usage Example

 public void GetEndpoint()
 {
     credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), Constants.CertificateAPIUserName);
     MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(ConfigManager.Instance.GetProperties(), defaultSoapHandler, credential);
     string endpoint = soapHandler.GetEndpoint();
     Assert.AreEqual(Constants.APIEndpointNVP, endpoint);
 }
All Usage Examples Of PayPal.SOAP.MerchantAPICallPreHandler::GetEndpoint