Пример #1
0
        /**
         *		 * Countries Supported:
         * AU - Australia
         * CA - Canada
         * FR - France
         * DE - Germany
         * IL - Israel
         * IT - Italy
         * NL - Netherlands
         * UK - United Kingdom
         * US - United States

         */
        public AddBankAccountResponse AddBankAccount(AddBankAccountRequest AddBankAccountRequest, string apiUsername)
        {
            string resp = call("AddBankAccount", AddBankAccountRequest.toNVPString(""), apiUsername);

            NVPUtil util = new NVPUtil();
            return new AddBankAccountResponse(util.parseNVPString(resp), "");
        }
        /// <summary>
        /// Countries Supported:
        /// AU - Australia
        /// CA - Canada
        /// FR -
        /// France
        /// DE - Germany
        /// IL - Israel
        /// IT - Italy
        /// NL - Netherlands
        /// UK - United
        /// Kingdom
        /// US - United States
        /// 
        /// 
        /// 
        /// 
        /// 
        /// </summary>
        ///<param name="addBankAccountRequest"></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 AddBankAccountResponse AddBankAccount(AddBankAccountRequest addBankAccountRequest, string apiUserName)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, addBankAccountRequest.ToNVPString(string.Empty), ServiceName, "AddBankAccount", apiUserName, getAccessToken(), getAccessTokenSecret());
               	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler) apiCallPreHandler).PortName = "AdaptiveAccounts";

            NVPUtil util = new NVPUtil();
            return AddBankAccountResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1);
        }
Пример #3
0
 public AddBankAccountResponse AddBankAccount(AddBankAccountRequest AddBankAccountRequest)
 {
     return AddBankAccount(AddBankAccountRequest, null);
 }
        /// <summary>
        /// Handle AddBankAccount API call
        /// </summary>
        /// <param name="context"></param>
        private void AddBankAccount(HttpContext context)
        {
            // # AddBankAccount API
            // The AddBankAccount API operation lets your application set up bank accounts as funding sources for PayPal accounts.
            NameValueCollection parameters = context.Request.Params;

            ConfirmationType confirmationType = (ConfirmationType)
                Enum.Parse(typeof(ConfirmationType), parameters["confirmationType"]);
            AddBankAccountRequest req = new AddBankAccountRequest(
                new RequestEnvelope(), parameters["bankCountryCode"], confirmationType);

            // set optional parameters
            // (Optional) The identification number of the PayPal account
            // for which a bank account is added. You must specify either
            // the accountId or emailAddress for this request.
            if (parameters["accountId"] != string.Empty)
                req.accountId = parameters["accountId"];

            // (Optional) The identification number of the PayPal account
            // for which a bank account is added. You must specify either
            // the accountId or emailAddress for this request.
            if (parameters["emailAddress"] != string.Empty)
                req.emailAddress = parameters["emailAddress"];
            if (parameters["createAccountKey"] != string.Empty)
                req.createAccountKey = parameters["createAccountKey"];

            // (Optional) The default value is UNKNOWN.
            if (parameters["bankName"] != string.Empty)
                req.bankName = parameters["bankName"];

            // (Optional) The bank's routing number.
            if (parameters["routingNumber"] != string.Empty)
                req.routingNumber = parameters["routingNumber"];

            // (Optional) The type of bank account to be added. Allowable
            // values are: CHECKING SAVINGS BUSINESS_SAVINGS
            // BUSINESS_CHECKINGS NORMAL UNKNOWN
            if (parameters["bankAccountType"] != string.Empty)
                req.bankAccountType =
                    (BankAccountType) Enum.Parse( typeof(BankAccountType), parameters["bankAccountType"]);
            // (Optional) The account number (BBAN) of the bank account to
            // be added.
            if (parameters["bankAccountNumber"] != string.Empty)
                req.bankAccountNumber = parameters["bankAccountNumber"];

            // (Optional) The IBAN for the bank.
            if (parameters["iban"] != string.Empty)
                req.iban = parameters["iban"];

            // CLABE represents the bank information for countries like
            // Mexico.
            if (parameters["clabe"] != string.Empty)
                req.clabe = parameters["clabe"];

            // (Optional) The Bank/State/Branch number for the bank.
            if (parameters["bsbNumber"] != string.Empty)
                req.bsbNumber = parameters["bsbNumber"];

            // (Optional) The branch location.
            if (parameters["branchLocation"] != string.Empty)
                req.branchLocation = parameters["branchLocation"];

            // (Optional) The branch sort code.
            if (parameters["sortCode"] != string.Empty)
                req.sortCode = parameters["sortCode"];

            // (Optional) The transit number of the bank.
            if (parameters["bankTransitNumber"] != string.Empty)
                req.bankTransitNumber = parameters["bankTransitNumber"];

            // (Optional) The institution number for the bank.
            if (parameters["institutionNumber"] != string.Empty)
                req.institutionNumber = parameters["institutionNumber"];

            // (Optional) The branch code for the bank.
            if (parameters["branchCode"] != string.Empty)
                req.branchCode = parameters["branchCode"];
            if (parameters["agencyNumber"] != string.Empty)
                req.agencyNumber = parameters["agencyNumber"];

            // (Optional) The code that identifies the bank where the
            // account is held.
            if (parameters["bankCode"] != string.Empty)
                req.bankCode = parameters["bankCode"];

            // (Optional) The RIB key for the bank.
            if (parameters["ribKey"] != string.Empty)
                req.ribKey = parameters["ribKey"];

            // (Optional) The control digits for the bank.
            if (parameters["controlDigit"] != string.Empty)
                req.controlDigit = parameters["controlDigit"];
            if (parameters["taxIdType"] != string.Empty)
                req.taxIdType = parameters["taxIdType"];
            if (parameters["taxIdNumber"] != string.Empty)
                req.taxIdNumber = parameters["taxIdNumber"];

            // (Optional) The date of birth of the account holder in
            // YYYY-MM-DDZ format, for example 1970-01-01Z.
            if (parameters["accountHolderDateOfBirth"] != string.Empty)
                req.accountHolderDateOfBirth = parameters["accountHolderDateOfBirth"];

            // (Optional) Additional structure to define the URLs for the
            // cancellation and return web flows.
            if ( confirmationType == ConfirmationType.WEB &&
                (parameters["returnURL"] != string.Empty || parameters["returnURLDescription"] != string.Empty
                || parameters["cancelURL"] != string.Empty || parameters["cancelURLDescription"] != string.Empty))
            {
                req.webOptions = new WebOptionsType();

                // (Optional) The URL to which bank account/payment card holders
                // return after they add the account or payment card.
                if (parameters["returnURL"] != string.Empty)
                    req.webOptions.returnUrl = parameters["returnURL"];
                if (parameters["returnURLDescription"] != string.Empty)
                    req.webOptions.returnUrlDescription = parameters["returnURLDescription"];

                // (Optional) The URL to which bank account/payment card holders
                // return when they cancel the bank account addition flow.
                if (parameters["cancelURL"] != string.Empty)
                    req.webOptions.cancelUrl = parameters["cancelURL"];
                if (parameters["cancelURLDescription"] != string.Empty)
                    req.webOptions.cancelUrlDescription = parameters["cancelURLDescription"];
            }

            // Create the AdaptiveAccounts service object to make the API call
            AdaptiveAccountsService service = null;
            AddBankAccountResponse resp = null;
            try
            {
                // Configuration map containing signature credentials and other required configuration.
                // For a full list of configuration parameters refer in wiki page
                // (https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters)
                Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig();

                // Creating service wrapper object to make an API call and loading
                // configuration map for your credentials and endpoint
                service = new AdaptiveAccountsService(configurationMap);

                // # API call
                // Invoke the CreateAccount method in service wrapper object
                resp = service.AddBankAccount(req);
            }
            catch (System.Exception e)
            {
                context.Response.Write(e.Message);
                return;
            }

            // Display response values.
            Dictionary<string, string> keyResponseParams = new Dictionary<string, string>();
            string redirectUrl = null;
            if (!(resp.responseEnvelope.ack == AckCode.FAILURE) &&
                !(resp.responseEnvelope.ack == AckCode.FAILUREWITHWARNING))
            {
                redirectUrl =  resp.redirectURL;
                keyResponseParams.Add("Execution status", resp.execStatus.ToString());
                keyResponseParams.Add("Funding source key", resp.fundingSourceKey);

                //Selenium Test Case
                keyResponseParams.Add("Acknowledgement", resp.responseEnvelope.ack.ToString());
                keyResponseParams.Add("Redirect To PayPal", resp.redirectURL);
            }
            displayResponse(context, "AddBankAccount", keyResponseParams, service.getLastRequest(), service.getLastResponse(),
                resp.error, redirectUrl);
        }
Пример #5
0
        /// <summary>
        /// Handle AddBankAccount API call
        /// </summary>
        /// <param name="context"></param>
        private void AddBankAccount(HttpContext context)
        {
            NameValueCollection parameters = context.Request.Params;

            ConfirmationType confirmationType = (ConfirmationType)
                Enum.Parse(typeof(ConfirmationType), parameters["confirmationType"]);
            AddBankAccountRequest req = new AddBankAccountRequest(
                new RequestEnvelope(), parameters["bankCountryCode"], confirmationType);
            // set optional parameters
            if (parameters["accountId"] != "")
                req.accountId = parameters["accountId"];
            if (parameters["emailAddress"] != "")
                req.emailAddress = parameters["emailAddress"];
            if (parameters["createAccountKey"] != "")
                req.createAccountKey = parameters["createAccountKey"];
            if (parameters["bankName"] != "")
                req.bankName = parameters["bankName"];
            if (parameters["routingNumber"] != "")
                req.routingNumber = parameters["routingNumber"];
            if (parameters["bankAccountType"] != "")
                req.bankAccountType =
                    (BankAccountType) Enum.Parse( typeof(BankAccountType), parameters["bankAccountType"]);
            if (parameters["bankAccountNumber"] != "")
                req.bankAccountNumber = parameters["bankAccountNumber"];
            if (parameters["iban"] != "")
                req.iban = parameters["iban"];
            if (parameters["clabe"] != "")
                req.clabe = parameters["clabe"];
            if (parameters["bsbNumber"] != "")
                req.bsbNumber = parameters["bsbNumber"];
            if (parameters["branchLocation"] != "")
                req.branchLocation = parameters["branchLocation"];
            if (parameters["sortCode"] != "")
                req.sortCode = parameters["sortCode"];
            if (parameters["bankTransitNumber"] != "")
                req.bankTransitNumber = parameters["bankTransitNumber"];
            if (parameters["institutionNumber"] != "")
                req.institutionNumber = parameters["institutionNumber"];
            if (parameters["branchCode"] != "")
                req.branchCode = parameters["branchCode"];
            if (parameters["agencyNumber"] != "")
                req.agencyNumber = parameters["agencyNumber"];
            if (parameters["bankCode"] != "")
                req.bankCode = parameters["bankCode"];
            if (parameters["ribKey"] != "")
                req.ribKey = parameters["ribKey"];
            if (parameters["controlDigit"] != "")
                req.controlDigit = parameters["controlDigit"];
            if (parameters["taxIdType"] != "")
                req.taxIdType = parameters["taxIdType"];
            if (parameters["taxIdNumber"] != "")
                req.taxIdNumber = parameters["taxIdNumber"];
            if (parameters["accountHolderDateOfBirth"] != "")
                req.accountHolderDateOfBirth = parameters["accountHolderDateOfBirth"];
            if ( confirmationType == ConfirmationType.WEB &&
                (parameters["returnURL"] != "" || parameters["returnURLDescription"] != ""
                || parameters["cancelURL"] != "" || parameters["cancelURLDescription"] != ""))
            {
                req.webOptions = new WebOptionsType();
                if (parameters["returnURL"] != "")
                    req.webOptions.returnUrl = parameters["returnURL"];
                if (parameters["returnURLDescription"] != "")
                    req.webOptions.returnUrlDescription = parameters["returnURLDescription"];
                if (parameters["cancelURL"] != "")
                    req.webOptions.cancelUrl = parameters["cancelURL"];
                if (parameters["cancelURLDescription"] != "")
                    req.webOptions.cancelUrlDescription = parameters["cancelURLDescription"];
            }

            // All set. Fire the request
            AdaptiveAccountsService service = new AdaptiveAccountsService();
            AddBankAccountResponse resp = null;
            try
            {
                resp = service.AddBankAccount(req);
            }
            catch (System.Exception e)
            {
                context.Response.Write(e.Message);
                return;
            }

            // Display response values.
            Dictionary<string, string> keyResponseParams = new Dictionary<string, string>();
            string redirectUrl = null;
            if (!(resp.responseEnvelope.ack == AckCode.FAILURE) &&
                !(resp.responseEnvelope.ack == AckCode.FAILUREWITHWARNING))
            {
                redirectUrl = ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"]
                    + resp.redirectURL;
                keyResponseParams.Add("Execution status", resp.execStatus.ToString());
                keyResponseParams.Add("Funding source key", resp.fundingSourceKey);
            }
            displayResponse(context, "AddBankAccount", keyResponseParams, service.getLastRequest(), service.getLastResponse(),
                resp.error, redirectUrl);
        }
 /// <summary> 
 /// Countries Supported:
 /// AU - Australia
 /// CA - Canada
 /// FR -
 /// France
 /// DE - Germany
 /// IL - Israel
 /// IT - Italy
 /// NL - Netherlands
 /// UK - United
 /// Kingdom
 /// US - United States
 /// 
 /// 
 /// 
 /// 
 /// 
 /// </summary>
 ///<param name="addBankAccountRequest"></param>
 public AddBankAccountResponse AddBankAccount(AddBankAccountRequest addBankAccountRequest)
 {
     return AddBankAccount(addBankAccountRequest,(string) null);
 }
Пример #7
0
 /**
   * Countries Supported:
   *     AU - Australia
   *     CA - Canada
   *     FR - France
   *     DE - Germany
   *     IL - Israel
   *     IT - Italy
   *     NL - Netherlands
   *     UK - United Kingdom
   *     US - United States
   *
   *
   *
   *
   *
  	  */
 public AddBankAccountResponse AddBankAccount(AddBankAccountRequest addBankAccountRequest, string apiUserName)
 {
     string response = Call("AddBankAccount", addBankAccountRequest.ToNVPString(""), apiUserName);
     NVPUtil util = new NVPUtil();
     return AddBankAccountResponse.CreateInstance(util.ParseNVPString(response), "", -1);
 }