/// <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);
        }
예제 #2
0
        /// <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) + "....");
            }
            displayResponse(context, "GetUserAgreement", keyResponseParams, service.getLastRequest(), service.getLastResponse(),
                resp.error, redirectUrl);
        }