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); }
public void SDKVersion() { credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), Constants.CertificateAPIUserName); MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(ConfigManager.Instance.GetProperties(), defaultSoapHandler, credential); soapHandler.SDKVersion = "1.0.0"; Assert.AreEqual("1.0.0", soapHandler.SDKVersion); }
public void SDKName() { credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), UnitTestConstants.CertificateAPIUserName); MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(ConfigManager.Instance.GetProperties(), defaultSoapHandler, credential); soapHandler.SDKName = "testsdk"; Assert.AreEqual("testsdk", soapHandler.SDKName); }
public void GetEndpointForDefaultModeWithoutEndpoint() { Dictionary <string, string> config = new Dictionary <string, string>(accountConfig); credential = credentialMngr.GetCredentials(config, Constants.CertificateAPIUserName); MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); soapHandler.GetEndpoint(); }
public void GetHeaderMapCertificate() { credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), UnitTestConstants.CertificateAPIUserName); soapHandler = new MerchantAPICallPreHandler(ConfigManager.Instance.GetProperties(), defaultSoapHandler, credential); Dictionary <String, String> headers = soapHandler.GetHeaderMap(); Assert.IsNotNull(headers); Assert.IsTrue(headers.Count > 0); Assert.AreEqual(UnitTestConstants.CertificateAPIUserName, headers[BaseConstants.PAYPAL_SECURITY_USERID_HEADER]); Assert.AreEqual(UnitTestConstants.CertificateAPIPassword, headers[BaseConstants.PAYPAL_SECURITY_PASSWORD_HEADER]); Assert.AreEqual(BaseConstants.SOAP, headers[BaseConstants.PAYPAL_REQUEST_DATA_FORMAT_HEADER]); Assert.AreEqual(BaseConstants.SOAP, headers[BaseConstants.PAYPAL_RESPONSE_DATA_FORMAT_HEADER]); Assert.AreEqual(soapHandler.SDKName + "-" + soapHandler.SDKVersion, headers[BaseConstants.PAYPAL_REQUEST_SOURCE_HEADER]); }
public void GetHeaderMapCertificate() { credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), Constants.CertificateAPIUserName); soapHandler = new MerchantAPICallPreHandler(ConfigManager.Instance.GetProperties(), defaultSoapHandler, credential); Dictionary <string, string> headers = soapHandler.GetHeaderMap(); Assert.IsNotNull(headers); Assert.IsTrue(headers.Count > 0); Assert.AreEqual(Constants.CertificateAPIUserName, headers[BaseConstants.PayPalSecurityUserIdHeader]); Assert.AreEqual(Constants.CertificateAPIPassword, headers[BaseConstants.PayPalSecurityPasswordHeader]); Assert.AreEqual(BaseConstants.SOAP, headers[BaseConstants.PayPalRequestDataFormatHeader]); Assert.AreEqual(BaseConstants.SOAP, headers[BaseConstants.PayPalResponseDataFormatHeader]); Assert.AreEqual(soapHandler.SDKName + "-" + soapHandler.SDKVersion, headers[BaseConstants.PayPalRequestSourceHeader]); }
public void GetEndpointForLiveMode() { Dictionary <string, string> config = new Dictionary <string, string>(accountConfig); config.Add(BaseConstants.ApplicationModeConfig, BaseConstants.SandboxMode); credential = credentialMngr.GetCredentials(config, Constants.CertificateAPIUserName); MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); Assert.AreEqual(BaseConstants.MerchantCertificateSandboxEndpoint, soapHandler.GetEndpoint()); credential = credentialMngr.GetCredentials(config, Constants.APIUserName); soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); Assert.AreEqual(BaseConstants.MerchantSignatureSandboxEndpoint, soapHandler.GetEndpoint()); }
public void GetEndpointForLiveMode() { Dictionary <string, string> config = new Dictionary <string, string>(accountConfig); config.Add(BaseConstants.APPLICATION_MODE_CONFIG, BaseConstants.SANDBOX_MODE); credential = credentialMngr.GetCredentials(config, UnitTestConstants.CertificateAPIUserName); MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); Assert.AreEqual(BaseConstants.MERCHANT_CERTIFICATE_SANDBOX_ENDPOINT, soapHandler.GetEndPoint()); credential = credentialMngr.GetCredentials(config, UnitTestConstants.APIUserName); soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); Assert.AreEqual(BaseConstants.MERCHANT_SIGNATURE_SANDBOX_ENDPOINT, soapHandler.GetEndPoint()); }
public void GetEndpointForDefaultModeWithExplicitEndpoint() { Dictionary <string, string> config = new Dictionary <string, string>(accountConfig); config.Add(BaseConstants.EndpointConfig, Constants.APIEndpointNVP); credential = credentialMngr.GetCredentials(config, Constants.CertificateAPIUserName); MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); Assert.AreEqual(Constants.APIEndpointNVP, soapHandler.GetEndpoint()); config.Add("PayPalAPI", Constants.APIEndpointSOAP); credential = credentialMngr.GetCredentials(config, Constants.CertificateAPIUserName); soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); soapHandler.PortName = "PayPalAPI"; Assert.AreEqual(Constants.APIEndpointSOAP, soapHandler.GetEndpoint()); }
/// <summary> /// /// </summary> ///<param name="bMGetInventoryReq"></param> ///<param name="apiUserName">API Username that you want to authenticate this call against. This username and the corresponding 3-token/certificate credentials must be available in Web.Config/App.Config</param> public BMGetInventoryResponseType BMGetInventory(BMGetInventoryReq bMGetInventoryReq, string apiUserName) { setStandardParams(bMGetInventoryReq.BMGetInventoryRequest); DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(this.config, bMGetInventoryReq.ToXMLString(null, "BMGetInventoryReq"), null, null); IAPICallPreHandler apiCallPreHandler = new MerchantAPICallPreHandler(this.config, defaultHandler, apiUserName, getAccessToken(), getAccessTokenSecret()); ((MerchantAPICallPreHandler)apiCallPreHandler).SDKName = SDKName; ((MerchantAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion; ((MerchantAPICallPreHandler)apiCallPreHandler).PortName = "PayPalAPI"; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(Call(apiCallPreHandler)); return(new BMGetInventoryResponseType( xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='BMGetInventoryResponse']") )); }
/// <summary> /// /// </summary> ///<param name="bMCreateButtonReq"></param> ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> public BMCreateButtonResponseType BMCreateButton(BMCreateButtonReq bMCreateButtonReq, ICredential credential) { setStandardParams(bMCreateButtonReq.BMCreateButtonRequest); DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(this.config, bMCreateButtonReq.ToXMLString(null, "BMCreateButtonReq"), null, null); IAPICallPreHandler apiCallPreHandler = new MerchantAPICallPreHandler(this.config, defaultHandler, credential); ((MerchantAPICallPreHandler)apiCallPreHandler).SDKName = SDKName; ((MerchantAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion; ((MerchantAPICallPreHandler)apiCallPreHandler).PortName = "PayPalAPI"; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(Call(apiCallPreHandler)); return(new BMCreateButtonResponseType( xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='BMCreateButtonResponse']") )); }
public void GetPayloadForCertificate() { credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), Constants.CertificateAPIUserName); soapHandler = new MerchantAPICallPreHandler(ConfigManager.Instance.GetProperties(), defaultSoapHandler, credential); string payload = soapHandler.GetPayload(); XmlDocument xmlDoc = GetXmlDocument(payload); XmlNodeList xmlNodeListUsername = xmlDoc.GetElementsByTagName("Username"); Assert.IsTrue(xmlNodeListUsername.Count > 0); Assert.AreEqual(Constants.CertificateAPIUserName, xmlNodeListUsername[0].InnerXml); XmlNodeList xmlNodeListPassword = xmlDoc.GetElementsByTagName("Password"); Assert.IsTrue(xmlNodeListPassword.Count > 0); Assert.AreEqual(Constants.CertificateAPIPassword, xmlNodeListPassword[0].InnerXml); XmlNodeList xmlNodeListRequest = xmlDoc.GetElementsByTagName("Request"); Assert.IsTrue(xmlNodeListRequest.Count > 0); Assert.AreEqual("test", xmlNodeListRequest[0].InnerXml); }
public void GetHeaderMapSignature() { credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), Constants.APIUserName); soapHandler = new MerchantAPICallPreHandler(ConfigManager.Instance.GetProperties(), defaultSoapHandler, credential); Dictionary<string, string> headers = soapHandler.GetHeaderMap(); Assert.IsNotNull(headers); Assert.IsTrue(headers.Count > 0); Assert.AreEqual(Constants.APIUserName, headers[BaseConstants.PayPalSecurityUserIdHeader]); Assert.AreEqual(Constants.APIPassword, headers[BaseConstants.PayPalSecurityPasswordHeader]); Assert.AreEqual(Constants.APISignature, headers[BaseConstants.PayPalSecuritySignatureHeader]); Assert.AreEqual(BaseConstants.SOAP, headers[BaseConstants.PayPalRequestDataFormatHeader]); Assert.AreEqual(BaseConstants.SOAP, headers[BaseConstants.PayPalResponseDataFormatHeader]); }
public void GetPayloadSignature() { credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), Constants.APIUserName); soapHandler = new MerchantAPICallPreHandler(ConfigManager.Instance.GetProperties(), defaultSoapHandler, credential); string payload = soapHandler.GetPayload(); XmlDocument xmlDoc = GetXmlDocument(payload); XmlNodeList xmlNodeListUsername = xmlDoc.GetElementsByTagName("Username"); Assert.IsTrue(xmlNodeListUsername.Count > 0); Assert.AreEqual(Constants.APIUserName, xmlNodeListUsername[0].InnerXml); XmlNodeList xmlNodeListPassword = xmlDoc.GetElementsByTagName("Password"); Assert.IsTrue(xmlNodeListPassword.Count > 0); Assert.AreEqual(Constants.APIPassword, xmlNodeListPassword[0].InnerXml); XmlNodeList xmlNodeListSignature = xmlDoc.GetElementsByTagName("Signature"); Assert.IsTrue(xmlNodeListSignature.Count > 0); Assert.AreEqual(Constants.APISignature, xmlNodeListSignature[0].InnerXml); XmlNodeList xmlNodeListRequest = xmlDoc.GetElementsByTagName("Request"); Assert.IsTrue(xmlNodeListRequest.Count > 0); Assert.AreEqual("test", xmlNodeListRequest[0].InnerXml); }
public void GetEndpointForSandboxMode() { Dictionary<string, string> config = new Dictionary<string, string>(accountConfig); config.Add(BaseConstants.ApplicationModeConfig, BaseConstants.LiveMode); credential = credentialMngr.GetCredentials(config, Constants.CertificateAPIUserName); MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); Assert.AreEqual(BaseConstants.MerchantCertificateLiveEndpoint, soapHandler.GetEndpoint()); credential = credentialMngr.GetCredentials(config, Constants.APIUserName); soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); Assert.AreEqual(BaseConstants.MerchantSignatureLiveEndpoint, soapHandler.GetEndpoint()); }
public void GetEndpointForDefaultModeWithoutEndpoint() { Dictionary<string, string> config = new Dictionary<string, string>(accountConfig); credential = credentialMngr.GetCredentials(config, Constants.CertificateAPIUserName); MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); soapHandler.GetEndpoint(); }
public void GetEndpointForDefaultModeWithExplicitEndpoint() { Dictionary<string, string> config = new Dictionary<string, string>(accountConfig); config.Add(BaseConstants.EndpointConfig, Constants.APIEndpointNVP); credential = credentialMngr.GetCredentials(config, Constants.CertificateAPIUserName); MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); Assert.AreEqual(Constants.APIEndpointNVP, soapHandler.GetEndpoint()); config.Add("PayPalAPI", Constants.APIEndpointSOAP); credential = credentialMngr.GetCredentials(config, Constants.CertificateAPIUserName); soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential); soapHandler.PortName = "PayPalAPI"; Assert.AreEqual(Constants.APIEndpointSOAP, soapHandler.GetEndpoint()); }