Пример #1
0
        /**
         * To be updated.
         *    Countries Supported:
         *     AU - Australia
         *     AT - Austria
         *     BE - Belgium
         *     BR - Brazil
         *     CA - Canada
         *     CZ - Czech Republic
         *     FR - France
         *     DE - Germany
         *     GR - Greece
         *     HK - Hong Kong
         *     IE - Ireland
         *     IT - Italy
         *     JP - Japan
         *     LU - Luxembourg
         *     MX - Mexico
         *     NL - Netherlands
         *     NZ - New Zealand (Aotearoa)
         *     PL - Poland
         *     PT - Portugal
         *     RU - Russian Federation
         *     SG - Singapore
         *     ZA - South Africa
         *     ES - Spain
         *     CH - Switzerland
         *     UK - United Kingdom
         *     US - United States
         *
         *
         *
         *
         *
         */
        public SetFundingSourceConfirmedResponse SetFundingSourceConfirmed(SetFundingSourceConfirmedRequest setFundingSourceConfirmedRequest, string apiUserName)
        {
            string  response = Call("SetFundingSourceConfirmed", setFundingSourceConfirmedRequest.ToNVPString(""), apiUserName);
            NVPUtil util     = new NVPUtil();

            return(SetFundingSourceConfirmedResponse.CreateInstance(util.ParseNVPString(response), "", -1));
        }
        /// <summary>
        /// To be updated.
        /// Countries Supported:
        /// AU - Australia
        /// AT - Austria
        /// BE - Belgium
        /// BR - Brazil
        /// CA - Canada
        /// CZ - Czech Republic
        /// FR
        /// - France
        /// DE - Germany
        /// GR - Greece
        /// HK - Hong Kong
        /// IE - Ireland
        /// IT - Italy
        /// JP - Japan
        /// LU - Luxembourg
        /// MX - Mexico
        /// NL - Netherlands
        /// NZ - New Zealand
        /// (Aotearoa)
        /// PL - Poland
        /// PT - Portugal
        /// RU - Russian Federation
        /// SG -
        /// Singapore
        /// ZA - South Africa
        /// ES - Spain
        /// CH - Switzerland
        /// UK - United
        /// Kingdom
        /// US - United States
        ///
        ///
        ///
        ///
        ///
        /// </summary>
        ///<param name="setFundingSourceConfirmedRequest"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param>
        public SetFundingSourceConfirmedResponse SetFundingSourceConfirmed(SetFundingSourceConfirmedRequest setFundingSourceConfirmedRequest, ICredential credential)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, setFundingSourceConfirmedRequest.ToNVPString(string.Empty), ServiceName, "SetFundingSourceConfirmed", credential);

            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKName    = SDKName;
            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler)apiCallPreHandler).PortName   = "AdaptiveAccounts";

            NVPUtil util = new NVPUtil();

            return(SetFundingSourceConfirmedResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1));
        }
Пример #3
0
        /// <summary>
        /// Handle SetFundingSourceConfirmed API call
        /// </summary>
        /// <param name="context"></param>
        private void SetFundingSourceConfirmed(HttpContext context)
        {
            NameValueCollection parameters       = context.Request.Params;
            SetFundingSourceConfirmedRequest req =
                new SetFundingSourceConfirmedRequest(new RequestEnvelope(), parameters["fundingSourceKey"]);

            // set optional parameters
            if (parameters["accountId"] != "")
            {
                req.accountId = parameters["accountId"];
            }
            if (parameters["emailAddress"] != "")
            {
                req.emailAddress = parameters["emailAddress"];
            }

            // All set. Fire the request
            AdaptiveAccountsService           service = new AdaptiveAccountsService();
            SetFundingSourceConfirmedResponse resp    = null;

            try
            {
                resp = service.SetFundingSourceConfirmed(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))
            {
                // nothing to add
            }
            displayResponse(context, "SetFundingSourceConfirmed", keyResponseParams, service.getLastRequest(), service.getLastResponse(),
                            resp.error, redirectUrl);
        }
Пример #4
0
        public SetFundingSourceConfirmedResponse SetFundingSourceConfirmed(SetFundingSourceConfirmedRequest request)
        {
            SetFundingSourceConfirmedResponse SetFundingSourceConfirmedResponse = null;

            PayLoad = null;

            try
            {
                APIProfile.EndPointAppend = Endpoint + "SetFundingSourceConfirmed";

                if (APIProfile.RequestDataformat == "SOAP11")
                {
                    PayLoad = SoapEncoder.Encode(request);
                }
                else if (APIProfile.RequestDataformat == "XML")
                {
                    PayLoad = PayPal.Platform.SDK.XMLEncoder.Encode(request);
                }
                else
                {
                    PayLoad = PayPal.Platform.SDK.JSONSerializer.ToJavaScriptObjectNotation(request);
                }
                res = CallAPI();

                if (APIProfile.RequestDataformat == "JSON")
                {
                    object obj = JSONSerializer.JsonDecode(res.ToString(), typeof(PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse));
                    if (obj.GetType() == typeof(PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse))
                    {
                        SetFundingSourceConfirmedResponse = (PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse)obj;
                    }
                    string name = Enum.GetName(SetFundingSourceConfirmedResponse.responseEnvelope.ack.GetType(), SetFundingSourceConfirmedResponse.responseEnvelope.ack);
                    if (name == "Failure")
                    {
                        this.result = "FAILURE";
                        TransactionException tranactionEx = new TransactionException(PayLoadFromat.JSON, res.ToString());
                        this.lastError = tranactionEx;
                    }
                }

                else if (res.ToString().ToUpper().Replace("<ACK>FAILURE</ACK>", "").Length != res.ToString().Length)
                {
                    this.result = "FAILURE";

                    if (APIProfile.RequestDataformat == "SOAP11")
                    {
                        TransactionException tranactionEx = new TransactionException(PayLoadFromat.SOAP11, res.ToString());
                        this.lastError = tranactionEx;
                    }
                    else if (APIProfile.RequestDataformat == "XML")
                    {
                        TransactionException tranactionEx = new TransactionException(PayLoadFromat.XML, res.ToString());
                        this.lastError = tranactionEx;
                    }
                    else
                    {
                        TransactionException tranactionEx = new TransactionException(PayLoadFromat.JSON, res.ToString());
                        this.lastError = tranactionEx;
                    }
                }
                else
                {
                    if (APIProfile.RequestDataformat == "SOAP11")
                    {
                        SetFundingSourceConfirmedResponse = (PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse)SoapEncoder.Decode(res.ToString(), typeof(PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse));
                    }
                    else if (APIProfile.RequestDataformat == "XML")
                    {
                        SetFundingSourceConfirmedResponse = (PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse)XMLEncoder.Decode(res.ToString(), typeof(PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse));
                    }
                    else
                    {
                        object obj = JSONSerializer.JsonDecode(res.ToString(), typeof(PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse));
                        if (obj.GetType() == typeof(PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse))
                        {
                            SetFundingSourceConfirmedResponse = (PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse)obj;
                        }
                    }
                    this.result = "SUCCESS";
                }
            }
            catch (FATALException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new FATALException("Error occurred in AdapativePayments ->  method.", ex);
            }
            return(SetFundingSourceConfirmedResponse);
        }
        /// <summary>
        /// Handle SetFundingSourceConfirmed API call
        /// </summary>
        /// <param name="context"></param>
        private void SetFundingSourceConfirmed(HttpContext context)
        {
            // # SetFundingSourceConfirmed API
            // The SetFundingSourceConfirmed API operation lets your application set up bank accounts as funding sources for PayPal accounts.
            NameValueCollection parameters = context.Request.Params;

            // (Required) The funding source key returned in the AddBankAccount or AddPaymentCard response.
            SetFundingSourceConfirmedRequest req =
                new SetFundingSourceConfirmedRequest(new RequestEnvelope(), parameters["fundingSourceKey"]);

            //(Optional) The merchant account Id of the PayPal account to
            // which the funding source was added in the AddPaymentCard or
            // AddBankAccount request. You must specify either the accountId
            // or mailAddress when making this request, but never both in
            // the same request.
            if (parameters["accountId"] != string.Empty)
            {
                req.accountId = parameters["accountId"];
            }

            // (Optional) The email address of the PayPal account to which
            // the funding source was added in the AddPaymentCard or
            // AddBankAccount request. You must specify either the accountId
            // or mailAddress when making this request, but never both in
            // the same request.
            if (parameters["emailAddress"] != string.Empty)
            {
                req.emailAddress = parameters["emailAddress"];
            }

            // Create the AdaptiveAccounts service object to make the API call
            AdaptiveAccountsService           service = null;
            SetFundingSourceConfirmedResponse 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.SetFundingSourceConfirmed(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))
            {
                // nothing to add
            }
            displayResponse(context, "SetFundingSourceConfirmed", keyResponseParams, service.getLastRequest(), service.getLastResponse(),
                            resp.error, redirectUrl);
        }