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 GetEndPoint()
 {
     credential = credentialMngr.GetCredentials(UnitTestConstants.CertificateAPIUserName);
     MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(defaultSoapHandler, credential);
     string endpoint = soapHandler.GetEndPoint();
     Assert.AreEqual(UnitTestConstants.APIEndpointNVP, endpoint);
 }
        public void GetEndpointForDefaultModeWithoutEndpoint()
        {
            Dictionary<string, string> config = new Dictionary<string, string>(accountConfig);

            credential = credentialMngr.GetCredentials(config, UnitTestConstants.CertificateAPIUserName);
            MerchantAPICallPreHandler soapHandler = new MerchantAPICallPreHandler(config, defaultSoapHandler, credential);
            soapHandler.GetEndPoint();
        }
        /// <summary>
        /// 
        /// </summary>
        ///<param name="cancelInvoiceRequest"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public CancelInvoiceResponse CancelInvoice(CancelInvoiceRequest cancelInvoiceRequest, ICredential credential)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, cancelInvoiceRequest.ToNVPString(string.Empty), ServiceName, "CancelInvoice", credential);
               	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler) apiCallPreHandler).PortName = "Invoice";

            NVPUtil util = new NVPUtil();
            return CancelInvoiceResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1);
        }
 /**
   *AUTO_GENERATED
  	  */
 public CancelPermissionsResponse CancelPermissions(CancelPermissionsRequest cancelPermissionsRequest, ICredential credential)
 {
     IAPICallPreHandler apiCallPreHandler = null;
     apiCallPreHandler = new PlatformAPICallPreHandler(cancelPermissionsRequest.ToNVPString(string.Empty), ServiceName, "CancelPermissions", credential);
        	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
     ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
     string response = Call(apiCallPreHandler);
     NVPUtil util = new NVPUtil();
     return CancelPermissionsResponse.CreateInstance(util.ParseNVPString(response), string.Empty, -1);
 }
 public void GetHeaderMapCertificateWithoutTokenTest()
 {
     credentialMngr = CredentialManager.Instance;
     credential = credentialMngr.GetCredentials(UnitTestConstants.CertificateAPIUserName);
     platformAPIHandler = new PlatformAPICallPreHandler("payload", "servicename", "method", credential);
     Dictionary<string, string> header = platformAPIHandler.GetHeaderMap();
     Assert.AreEqual(UnitTestConstants.CertificateAPIUserName, header[BaseConstants.PAYPAL_SECURITY_USERID_HEADER]);
     Assert.AreEqual(UnitTestConstants.CertificateAPIPassword, header[BaseConstants.PAYPAL_SECURITY_PASSWORD_HEADER]);
     Assert.AreEqual(UnitTestConstants.ApplicationID, header[BaseConstants.PAYPAL_APPLICATION_ID]);
     Assert.AreEqual(BaseConstants.NVP, header[BaseConstants.PAYPAL_REQUEST_DATA_FORMAT_HEADER]);
     Assert.AreEqual(BaseConstants.NVP, header[BaseConstants.PAYPAL_RESPONSE_DATA_FORMAT_HEADER]);
 }
 public void GetHeaderMapSignature()
 {
     credential = credentialMngr.GetCredentials(UnitTestConstants.APIUserName);
     soapHandler = new MerchantAPICallPreHandler(defaultSoapHandler, credential);
     Dictionary<String, String> headers = soapHandler.GetHeaderMap();
     Assert.IsNotNull(headers);
     Assert.IsTrue(headers.Count > 0);
     Assert.AreEqual(UnitTestConstants.APIUserName, headers[BaseConstants.PAYPAL_SECURITY_USERID_HEADER]);
     Assert.AreEqual(UnitTestConstants.APIPassword, headers[BaseConstants.PAYPAL_SECURITY_PASSWORD_HEADER]);
     Assert.AreEqual(UnitTestConstants.APISignature, headers[BaseConstants.PAYPAL_SECURITY_SIGNATURE_HEADER]);
     Assert.AreEqual(BaseConstants.SOAP, headers[BaseConstants.PAYPAL_REQUEST_DATA_FORMAT_HEADER]);
     Assert.AreEqual(BaseConstants.SOAP, headers[BaseConstants.PAYPAL_RESPONSE_DATA_FORMAT_HEADER]);
 }
 public void LoadSignatureCredential()
 {
     string apiUsername = UnitTestConstants.APIUserName;
     credentialMngr = CredentialManager.Instance;
     credential = credentialMngr.GetCredentials(apiUsername);
     Assert.NotNull(credential);
     Assert.IsInstanceOf(typeof(SignatureCredential), credential);
     SignatureCredential signCredential = (SignatureCredential) credential;
     Assert.AreEqual(apiUsername, signCredential.UserName);
     Assert.AreEqual(UnitTestConstants.APIPassword, signCredential.Password);
     Assert.AreEqual(UnitTestConstants.APISignature, signCredential.Signature);
     Assert.AreEqual(UnitTestConstants.ApplicationID, signCredential.ApplicationID);
 }
 public void LoadSignatureCredential()
 {
     string apiUsername = Constants.APIUserName;
     credentialMngr = CredentialManager.Instance;
     credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), apiUsername);
     Assert.IsNotNull(credential);
     Assert.IsInstanceOfType(credential, typeof(SignatureCredential));
     SignatureCredential signCredential = (SignatureCredential)credential;
     Assert.AreEqual(apiUsername, signCredential.UserName);
     Assert.AreEqual(Constants.APIPassword, signCredential.Password);
     Assert.AreEqual(Constants.APISignature, signCredential.Signature);
     Assert.AreEqual(Constants.ApplicationId, signCredential.ApplicationId);
 }
 public void LoadCertificateCredential()
 {
     string apiUsername = UnitTestConstants.CertificateAPIUserName;
     credentialMngr = CredentialManager.Instance;
     credential = credentialMngr.GetCredentials(apiUsername);
     Assert.NotNull(credential);
     Assert.IsInstanceOf(typeof(CertificateCredential), credential);
     CertificateCredential certCredential = (CertificateCredential)credential;
     Assert.AreEqual(apiUsername, certCredential.UserName);
     Assert.AreEqual(UnitTestConstants.CertificateAPIPassword, certCredential.Password);
     Assert.AreEqual(UnitTestConstants.CertificatePath, certCredential.CertificateFile);
     Assert.AreEqual(UnitTestConstants.CertificatePassword, certCredential.PrivateKeyPassword);
     Assert.AreEqual(UnitTestConstants.ApplicationID, certCredential.ApplicationID);
 }
 public void LoadCertificateCredential()
 {
     string apiUsername = Constants.CertificateAPIUserName;
     credentialMngr = CredentialManager.Instance;
     credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), apiUsername);
     Assert.NotNull(credential);
     Assert.IsInstanceOf(typeof(CertificateCredential), credential);
     CertificateCredential certCredential = (CertificateCredential)credential;
     Assert.AreEqual(apiUsername, certCredential.UserName);
     Assert.AreEqual(Constants.CertificateAPIPassword, certCredential.Password);
     Assert.AreEqual(Path.GetFileName(Constants.CertificatePath), Path.GetFileName(certCredential.CertificateFile));
     Assert.AreEqual(Constants.CertificatePassword, certCredential.PrivateKeyPassword);
     Assert.AreEqual(Constants.ApplicationId, certCredential.ApplicationId);
 }
        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());
        }
 /**
   *AUTO_GENERATED
  	  */
 public AddressVerifyResponseType AddressVerify(AddressVerifyReq addressVerifyReq, ICredential credential)
 {
     IAPICallPreHandler apiCallPreHandler = null;
      		string portName = "PayPalAPI";
     setStandardParams(addressVerifyReq.AddressVerifyRequest);
     DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(addressVerifyReq.ToXMLString(null, "AddressVerifyReq"), null, null);
     apiCallPreHandler = new MerchantAPICallPreHandler(defaultHandler, credential);
     ((MerchantAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
     ((MerchantAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
     ((MerchantAPICallPreHandler) apiCallPreHandler).PortName = portName;
     string response = Call(apiCallPreHandler);
     XmlDocument xmlDocument = new XmlDocument();
     xmlDocument.LoadXml(response);
     XmlNode xmlNode = xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='AddressVerifyResponse']");
     return new AddressVerifyResponseType(xmlNode);
 }
 public void GetPayLoadForCertificate()
 {
     credential = credentialMngr.GetCredentials(UnitTestConstants.CertificateAPIUserName);
     soapHandler = new MerchantAPICallPreHandler(defaultSoapHandler, credential);
     string payload = soapHandler.GetPayLoad();
     XmlDocument xmlDoc = GetXmlDocument(payload);
     XmlNodeList xmlNodeListUsername = xmlDoc.GetElementsByTagName("Username");
     Assert.IsTrue(xmlNodeListUsername.Count > 0);
     Assert.AreEqual(UnitTestConstants.CertificateAPIUserName, xmlNodeListUsername[0].InnerXml);
     XmlNodeList xmlNodeListPassword = xmlDoc.GetElementsByTagName("Password");
     Assert.IsTrue(xmlNodeListPassword.Count > 0);
     Assert.AreEqual(UnitTestConstants.CertificateAPIPassword, xmlNodeListPassword[0].InnerXml);
     XmlNodeList xmlNodeListRequest = xmlDoc.GetElementsByTagName("Request");
     Assert.IsTrue(xmlNodeListRequest.Count > 0);
     Assert.AreEqual("test", xmlNodeListRequest[0].InnerXml);
 }
        /// <summary>
        /// 
        /// </summary>
        ///<param name="doReferenceTransactionReq"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public DoReferenceTransactionResponseType DoReferenceTransaction(DoReferenceTransactionReq doReferenceTransactionReq, ICredential credential)
        {
            setStandardParams(doReferenceTransactionReq.DoReferenceTransactionRequest);
            DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(this.config, doReferenceTransactionReq.ToXMLString(null, "DoReferenceTransactionReq"), null, null);
            IAPICallPreHandler apiCallPreHandler = new MerchantAPICallPreHandler(this.config, defaultHandler, credential);
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((MerchantAPICallPreHandler) apiCallPreHandler).PortName = "PayPalAPIAA";

            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(Call(apiCallPreHandler));
            return new DoReferenceTransactionResponseType(
                xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='DoReferenceTransactionResponse']")
            );
        }
        /// <summary>
        /// 
        /// </summary>
        ///<param name="createRecurringPaymentsProfileReq"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public CreateRecurringPaymentsProfileResponseType CreateRecurringPaymentsProfile(CreateRecurringPaymentsProfileReq createRecurringPaymentsProfileReq, ICredential credential)
        {
            setStandardParams(createRecurringPaymentsProfileReq.CreateRecurringPaymentsProfileRequest);
            DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(this.config, createRecurringPaymentsProfileReq.ToXMLString(null, "CreateRecurringPaymentsProfileReq"), null, null);
            IAPICallPreHandler apiCallPreHandler = new MerchantAPICallPreHandler(this.config, defaultHandler, credential);
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((MerchantAPICallPreHandler) apiCallPreHandler).PortName = "PayPalAPIAA";

            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(Call(apiCallPreHandler));
            return new CreateRecurringPaymentsProfileResponseType(
                xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='CreateRecurringPaymentsProfileResponse']")
            );
        }
        /// <summary>
        /// 
        /// </summary>
        ///<param name="updateAccessPermissionsReq"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public UpdateAccessPermissionsResponseType UpdateAccessPermissions(UpdateAccessPermissionsReq updateAccessPermissionsReq, ICredential credential)
        {
            setStandardParams(updateAccessPermissionsReq.UpdateAccessPermissionsRequest);
            DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(this.config, updateAccessPermissionsReq.ToXMLString(null, "UpdateAccessPermissionsReq"), null, null);
            IAPICallPreHandler apiCallPreHandler = new MerchantAPICallPreHandler(this.config, defaultHandler, credential);
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((MerchantAPICallPreHandler) apiCallPreHandler).PortName = "PayPalAPIAA";

            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(Call(apiCallPreHandler));
            return new UpdateAccessPermissionsResponseType(
                xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='UpdateAccessPermissionsResponse']")
            );
        }
        /// <summary>
        /// 
        /// </summary>
        ///<param name="setMobileCheckoutReq"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public SetMobileCheckoutResponseType SetMobileCheckout(SetMobileCheckoutReq setMobileCheckoutReq, ICredential credential)
        {
            setStandardParams(setMobileCheckoutReq.SetMobileCheckoutRequest);
            DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(this.config, setMobileCheckoutReq.ToXMLString(null, "SetMobileCheckoutReq"), 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 SetMobileCheckoutResponseType(
                xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='SetMobileCheckoutResponse']")
            );
        }
        /// <summary>
        /// 
        /// </summary>
        ///<param name="getBillingAgreementCustomerDetailsReq"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public GetBillingAgreementCustomerDetailsResponseType GetBillingAgreementCustomerDetails(GetBillingAgreementCustomerDetailsReq getBillingAgreementCustomerDetailsReq, ICredential credential)
        {
            setStandardParams(getBillingAgreementCustomerDetailsReq.GetBillingAgreementCustomerDetailsRequest);
            DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(this.config, getBillingAgreementCustomerDetailsReq.ToXMLString(null, "GetBillingAgreementCustomerDetailsReq"), null, null);
            IAPICallPreHandler apiCallPreHandler = new MerchantAPICallPreHandler(this.config, defaultHandler, credential);
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((MerchantAPICallPreHandler) apiCallPreHandler).PortName = "PayPalAPIAA";

            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(Call(apiCallPreHandler));
            return new GetBillingAgreementCustomerDetailsResponseType(
                xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='GetBillingAgreementCustomerDetailsResponse']")
            );
        }
        /// <summary>
        /// 
        /// </summary>
        ///<param name="externalRememberMeOptOutReq"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public ExternalRememberMeOptOutResponseType ExternalRememberMeOptOut(ExternalRememberMeOptOutReq externalRememberMeOptOutReq, ICredential credential)
        {
            setStandardParams(externalRememberMeOptOutReq.ExternalRememberMeOptOutRequest);
            DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(this.config, externalRememberMeOptOutReq.ToXMLString(null, "ExternalRememberMeOptOutReq"), null, null);
            IAPICallPreHandler apiCallPreHandler = new MerchantAPICallPreHandler(this.config, defaultHandler, credential);
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((MerchantAPICallPreHandler) apiCallPreHandler).PortName = "PayPalAPIAA";

            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(Call(apiCallPreHandler));
            return new ExternalRememberMeOptOutResponseType(
                xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='ExternalRememberMeOptOutResponse']")
            );
        }
 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 LoadCredentialForNonExistentAccount()
 {
     credentialMngr = CredentialManager.Instance;
     credential = credentialMngr.GetCredentials(ConfigManager.Instance.GetProperties(), "i-do-not-exist_api1.paypal.com");
 }
 /**
   *AUTO_GENERATED
  	  */
 public UpdateRecurringPaymentsProfileResponseType UpdateRecurringPaymentsProfile(UpdateRecurringPaymentsProfileReq updateRecurringPaymentsProfileReq, ICredential credential)
 {
     IAPICallPreHandler apiCallPreHandler = null;
      		string portName = "PayPalAPIAA";
     setStandardParams(updateRecurringPaymentsProfileReq.UpdateRecurringPaymentsProfileRequest);
     DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(updateRecurringPaymentsProfileReq.ToXMLString(null, "UpdateRecurringPaymentsProfileReq"), null, null);
     apiCallPreHandler = new MerchantAPICallPreHandler(defaultHandler, credential);
     ((MerchantAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
     ((MerchantAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
     ((MerchantAPICallPreHandler) apiCallPreHandler).PortName = portName;
     string response = Call(apiCallPreHandler);
     XmlDocument xmlDocument = new XmlDocument();
     xmlDocument.LoadXml(response);
     XmlNode xmlNode = xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='UpdateRecurringPaymentsProfileResponse']");
     return new UpdateRecurringPaymentsProfileResponseType(xmlNode);
 }
 /**
   *AUTO_GENERATED
  	  */
 public ManagePendingTransactionStatusResponseType ManagePendingTransactionStatus(ManagePendingTransactionStatusReq managePendingTransactionStatusReq, ICredential credential)
 {
     IAPICallPreHandler apiCallPreHandler = null;
      		string portName = "PayPalAPIAA";
     setStandardParams(managePendingTransactionStatusReq.ManagePendingTransactionStatusRequest);
     DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(managePendingTransactionStatusReq.ToXMLString(null, "ManagePendingTransactionStatusReq"), null, null);
     apiCallPreHandler = new MerchantAPICallPreHandler(defaultHandler, credential);
     ((MerchantAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
     ((MerchantAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
     ((MerchantAPICallPreHandler) apiCallPreHandler).PortName = portName;
     string response = Call(apiCallPreHandler);
     XmlDocument xmlDocument = new XmlDocument();
     xmlDocument.LoadXml(response);
     XmlNode xmlNode = xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='ManagePendingTransactionStatusResponse']");
     return new ManagePendingTransactionStatusResponseType(xmlNode);
 }
        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 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]);
 }
 /// <summary>
 ///  SOAPAPICallPreHandler decorating basic IAPICallPreHandler using ICredential
 /// </summary>
 /// <param name="apiCallHandler"></param>
 /// <param name="credential"></param>
 public MerchantAPICallPreHandler(Dictionary<string, string> config, IAPICallPreHandler apiCallHandler, ICredential credential)
     : this(apiCallHandler, config)
 {
     if (credential == null)
     {
         throw new ArgumentException("Credential is null in SOAPAPICallPreHandler");
     }
     this.credential = credential;
 }
示例#28
0
        /// <summary>
        /// Validate API Credentials
        /// </summary>
        /// <param name="apiCredentials"></param>
        public void ValidateCredentials(ICredential apiCredentials)
        {
            if (string.IsNullOrEmpty(apiCredentials.APIUsername))
            {
                throw new InvalidCredentialException(BaseConstants.ErrorMessages.err_username);
            }
            if (string.IsNullOrEmpty(apiCredentials.APIPassword))
            {
                throw new InvalidCredentialException(BaseConstants.ErrorMessages.err_passeword);
            }
            if (string.IsNullOrEmpty(apiCredentials.ApplicationID))
            {
                throw new InvalidCredentialException(BaseConstants.ErrorMessages.err_appid);
            }

            if ((apiCredentials is SignatureCredential))
            {
                if (string.IsNullOrEmpty(((SignatureCredential)apiCredentials).APISignature))
                {
                    throw new InvalidCredentialException(BaseConstants.ErrorMessages.err_signature);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(((CertificateCredential)apiCredentials).CertificateFile))
                {
                    throw new InvalidCredentialException(BaseConstants.ErrorMessages.err_certificate);
                }

                if (string.IsNullOrEmpty(((CertificateCredential)apiCredentials).PrivateKeyPassword))
                {
                    throw new InvalidCredentialException(BaseConstants.ErrorMessages.err_privatekeypassword);
                }

            }
        }
 /// <summary>
 /// Initializes the instance of ICredential
 /// </summary>
 private void InitCredential()
 {
     try
     {
         if (credential == null)
         {
             credential = GetCredentials();
         }
     }
     catch(System.Exception ex)
     {
         throw ex;
     }
 }
 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);
 }