Пример #1
0
        /// <summary>
        /// Handle GetVerifiedStatus API call
        /// </summary>
        /// <param name="context"></param>
        private void GetVerifiedStatus(HttpContext context)
        {
            NameValueCollection      parameters = context.Request.Params;
            GetVerifiedStatusRequest req        = new GetVerifiedStatusRequest(
                new RequestEnvelope(), parameters["emailAddress"], parameters["matchCriteria"]);

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

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

            try
            {
                resp = service.GetVerifiedStatus(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("Account status", resp.accountStatus);
                if (resp.userInfo != null)
                {
                    keyResponseParams.Add("Account Id", resp.userInfo.accountId);
                    keyResponseParams.Add("Account type", resp.userInfo.accountType);

                    //Selenium Test Case
                    keyResponseParams.Add("Acknowledgement", resp.responseEnvelope.ack.ToString());
                }
            }
            displayResponse(context, "GetVerifiedStatus", keyResponseParams, service.getLastRequest(), service.getLastResponse(),
                            resp.error, redirectUrl);
        }
Пример #2
0
        /// <summary>
        /// Checks the account verification.
        /// </summary>
        /// <param name="userFirstName">First name of the user.</param>
        /// <param name="userLastName">Last name of the user.</param>
        /// <param name="userEmailAddress">The user email address.</param>
        /// <returns></returns>
        public GetVerifiedStatusResponse CheckAccountVerification(string userFirstName, string userLastName,
                                                                  string userEmailAddress)
        {
            //AdaptiveAccounts SDK

            GetVerifiedStatusRequest verifiedStatusRequest = new GetVerifiedStatusRequest {
                emailAddress  = userEmailAddress,
                firstName     = userFirstName,
                lastName      = userLastName,
                matchCriteria = "NAME"
            };

            var service = new AdaptiveAccountsService(Config.ToDictionary());

            return(service.GetVerifiedStatus(verifiedStatusRequest));
        }
        /// <summary>
        /// Handle GetVerifiedStatus API call
        /// </summary>
        /// <param name="context"></param>
        private void GetVerifiedStatus(HttpContext context)
        {
            // # GetVerifiedStatus API
            // The GetVerifiedStatus API operation lets you determine whether the specified PayPal account's status is verified or unverified.
            NameValueCollection      parameters = context.Request.Params;
            GetVerifiedStatusRequest req        = new GetVerifiedStatusRequest(new RequestEnvelope(), parameters["matchCriteria"]);

            //(Required) The first name of the PayPal account holder.
            // Required if matchCriteria is NAME.
            if (parameters["firstName"] != string.Empty)
            {
                req.firstName = parameters["firstName"];
            }

            // (Required) The last name of the PayPal account holder.
            // Required if matchCriteria is NAME.
            if (parameters["lastName"] != string.Empty)
            {
                req.lastName = parameters["lastName"];
            }

            if (parameters["emailAddress"] != string.Empty)
            {
                // (Optional - must be present if the emailAddress field above
                // is not) The identifier of the PayPal account holder. If
                // present, must be one (and only one) of these account
                // identifier types: 1. emailAddress 2. mobilePhoneNumber 3.
                // accountId
                AccountIdentifierType accntIdentifierType = new AccountIdentifierType();

                // (Required)Email address associated with the PayPal account:
                // one of the unique identifiers of the account.
                accntIdentifierType.emailAddress = parameters["emailAddress"];
                req.accountIdentifier            = accntIdentifierType;
            }

            // Create the AdaptiveAccounts service object to make the API call
            AdaptiveAccountsService   service = null;
            GetVerifiedStatusResponse 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.GetVerifiedStatus(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("Account status", resp.accountStatus);
                if (resp.userInfo != null)
                {
                    keyResponseParams.Add("Account Id", resp.userInfo.accountId);
                    keyResponseParams.Add("Account type", resp.userInfo.accountType);

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