/**
         * Countries Supported:
         *     AU - Australia
         *     AT - Austria
         *     CA - Canada
         *     CZ - Czech Republic
         *     EU - European Union *
         *     FR - France
         *     DE - Germany
         *     GB - Great Britain
         *     GR - Greece
         *     IE - Ireland
         *     IL - Israel
         *     IT - Italy
         *     JP - Japan
         *     NL - Netherlands
         *     NZ - New Zealand (Aotearoa)
         *     PL - Poland
         *     PT - Portugal
         *     RU - Russian Federation
         *     SG - Singapore
         *     ZA - South Africa
         *     ES - Spain
         *     CH - Switzerland
         *     US - United States
         *     * technically a group of countries
         *
         *
         *
         *
         *
         */
        public GetUserAgreementResponse GetUserAgreement(GetUserAgreementRequest getUserAgreementRequest, string apiUserName)
        {
            string  response = Call("GetUserAgreement", getUserAgreementRequest.ToNVPString(""), apiUserName);
            NVPUtil util     = new NVPUtil();

            return(GetUserAgreementResponse.CreateInstance(util.ParseNVPString(response), "", -1));
        }
Beispiel #2
0
        /**
         *		 * Countries Supported:
         * AU - Australia
         * AT - Austria
         * CA - Canada
         * CZ - Czech Republic
         * EU - European Union *
         * FR - France
         * DE - Germany
         * GB - Great Britain
         * GR - Greece
         * IE - Ireland
         * IL - Israel
         * IT - Italy
         * JP - Japan
         * NL - Netherlands
         * NZ - New Zealand (Aotearoa)
         * PL - Poland
         * PT - Portugal
         * RU - Russian Federation
         * SG - Singapore
         * ZA - South Africa
         * ES - Spain
         * CH - Switzerland
         * US - United States
         * * technically a group of countries
         *
         */
        public GetUserAgreementResponse GetUserAgreement(GetUserAgreementRequest GetUserAgreementRequest, string apiUsername)
        {
            string resp = call("GetUserAgreement", GetUserAgreementRequest.toNVPString(""), apiUsername);

            NVPUtil util = new NVPUtil();

            return(new GetUserAgreementResponse(util.parseNVPString(resp), ""));
        }
        /// <summary>
        /// Countries Supported:
        /// AU - Australia
        /// AT - Austria
        /// CA
        /// - Canada
        /// CZ - Czech Republic
        /// EU - European Union *
        /// FR - France
        /// DE -
        /// Germany
        /// GB - Great Britain
        /// GR - Greece
        /// IE - Ireland
        /// IL - Israel
        /// IT -
        /// Italy
        /// JP - Japan
        /// NL - Netherlands
        /// NZ - New Zealand (Aotearoa)
        /// PL -
        /// Poland
        /// PT - Portugal
        /// RU - Russian Federation
        /// SG - Singapore
        /// ZA - South
        /// Africa
        /// ES - Spain
        /// CH - Switzerland
        /// US - United States
        /// * technically a
        /// group of countries
        ///
        ///
        ///
        ///
        ///
        /// </summary>
        ///<param name="getUserAgreementRequest"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param>
        public GetUserAgreementResponse GetUserAgreement(GetUserAgreementRequest getUserAgreementRequest, ICredential credential)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, getUserAgreementRequest.ToNVPString(string.Empty), ServiceName, "GetUserAgreement", credential);

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

            NVPUtil util = new NVPUtil();

            return(GetUserAgreementResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1));
        }
        /// <summary>
        /// Handle GetUserAgreement API call
        /// </summary>
        /// <param name="context"></param>
        private void GetUserAgreement(HttpContext context)
        {
            NameValueCollection     parameters = context.Request.Params;
            GetUserAgreementRequest req        = new GetUserAgreementRequest(new RequestEnvelope());

            // set optional parameters
            if (parameters["createAccountKey"] != "")
            {
                req.createAccountKey = parameters["createAccountKey"];
            }
            if (parameters["countryCode"] != "")
            {
                req.countryCode = parameters["countryCode"];
            }
            if (parameters["languageCode"] != "")
            {
                req.languageCode = parameters["languageCode"];
            }

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

            try
            {
                resp = service.GetUserAgreement(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))
            {
                keyResponseParams.Add("Agreement", resp.agreement.Substring(0, 100) + "....");

                //Selenium Test Case
                keyResponseParams.Add("Acknowledgement", resp.responseEnvelope.ack.ToString());
            }
            displayResponse(context, "GetUserAgreement", keyResponseParams, service.getLastRequest(), service.getLastResponse(),
                            resp.error, redirectUrl);
        }
Beispiel #5
0
 public GetUserAgreementResponse GetUserAgreement(GetUserAgreementRequest GetUserAgreementRequest)
 {
     return(GetUserAgreement(GetUserAgreementRequest, null));
 }
        /// <summary>
        /// Countries Supported:
        /// AU - Australia
        /// AT - Austria
        /// CA
        /// - Canada
        /// CZ - Czech Republic
        /// EU - European Union *
        /// FR - France
        /// DE -
        /// Germany
        /// GB - Great Britain
        /// GR - Greece
        /// IE - Ireland
        /// IL - Israel
        /// IT -
        /// Italy
        /// JP - Japan
        /// NL - Netherlands
        /// NZ - New Zealand (Aotearoa)
        /// PL -
        /// Poland
        /// PT - Portugal
        /// RU - Russian Federation
        /// SG - Singapore
        /// ZA - South
        /// Africa
        /// ES - Spain
        /// CH - Switzerland
        /// US - United States
        /// * technically a
        /// group of countries
        ///
        ///
        ///
        ///
        ///
        /// </summary>
        ///<param name="getUserAgreementRequest"></param>

        public GetUserAgreementResponse GetUserAgreement(GetUserAgreementRequest getUserAgreementRequest)
        {
            return(GetUserAgreement(getUserAgreementRequest, (string)null));
        }
        /// <summary>
        /// Returns the user agreement
        /// </summary>
        /// <param name="request">GetUserAgreementRequest</param>
        /// <returns>GetUserAgreementResponse</returns>
        public GetUserAgreementResponse GetUserAgreement(GetUserAgreementRequest request)
        {
            GetUserAgreementResponse GetUserAgreementResponse = null;

            PayLoad = null;

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

                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.GetUserAgreementResponse));
                    if (obj.GetType() == typeof(PayPal.Services.Private.AA.GetUserAgreementResponse))
                    {
                        GetUserAgreementResponse = (PayPal.Services.Private.AA.GetUserAgreementResponse)obj;
                    }
                    string name = Enum.GetName(GetUserAgreementResponse.responseEnvelope.ack.GetType(), GetUserAgreementResponse.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")
                    {
                        GetUserAgreementResponse = (PayPal.Services.Private.AA.GetUserAgreementResponse)SoapEncoder.Decode(res.ToString(), typeof(PayPal.Services.Private.AA.GetUserAgreementResponse));
                    }
                    else if (APIProfile.RequestDataformat == "XML")
                    {
                        GetUserAgreementResponse = (PayPal.Services.Private.AA.GetUserAgreementResponse)XMLEncoder.Decode(res.ToString(), typeof(PayPal.Services.Private.AA.GetUserAgreementResponse));
                    }
                    else
                    {
                        object obj = JSONSerializer.JsonDecode(res.ToString(), typeof(PayPal.Services.Private.AA.GetUserAgreementResponse));
                        if (obj.GetType() == typeof(PayPal.Services.Private.AA.SetFundingSourceConfirmedResponse))
                        {
                            GetUserAgreementResponse = (PayPal.Services.Private.AA.GetUserAgreementResponse)obj;
                        }
                    }
                    this.result = "SUCCESS";
                }
            }
            catch (FATALException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new FATALException("Error occurred in AdapativeAccounts -> GetUserAgreement method.", ex);
            }
            return(GetUserAgreementResponse);
        }
        /// <summary>
        /// Handle GetUserAgreement API call
        /// </summary>
        /// <param name="context"></param>
        private void GetUserAgreement(HttpContext context)
        {
            // #GetUserAgreement API
            // The GetUserAgreement API operation lets you retrieve the user agreement for the customer to approve the new PayPal account.
            NameValueCollection     parameters = context.Request.Params;
            GetUserAgreementRequest req        = new GetUserAgreementRequest(new RequestEnvelope());

            // (Optional) The key returned for this account in the
            // CreateAccountResponse message in the createAccountKey field.
            // If you specify this key, do not pass a country code or
            // language code. Doing so will result in an error.
            if (parameters["createAccountKey"] != string.Empty)
            {
                req.createAccountKey = parameters["createAccountKey"];
            }

            // (Optional) The code for the country in which the user account
            // is located. You do not need to provide this country code if
            // you are passing the createAccount key.
            if (parameters["countryCode"] != string.Empty)
            {
                req.countryCode = parameters["countryCode"];
            }

            // (Optional) The code indicating the language to be used for
            // the agreement.
            if (parameters["languageCode"] != string.Empty)
            {
                req.languageCode = parameters["languageCode"];
            }

            // Create the AdaptiveAccounts service object to make the API call
            AdaptiveAccountsService  service = null;
            GetUserAgreementResponse 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.GetUserAgreement(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))
            {
                keyResponseParams.Add("Agreement", resp.agreement.Substring(0, 100) + "....");

                //Selenium Test Case
                keyResponseParams.Add("Acknowledgement", resp.responseEnvelope.ack.ToString());
            }
            displayResponse(context, "GetUserAgreement", keyResponseParams, service.getLastRequest(), service.getLastResponse(),
                            resp.error, redirectUrl);
        }