예제 #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);
                }
            }
            displayResponse(context, "GetVerifiedStatus", keyResponseParams, service.getLastRequest(), service.getLastResponse(),
                resp.error, redirectUrl);
        }
        /// <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);
        }
예제 #3
0
 public static bool isReceiverEmailVerified(string email)
 {
     AdaptiveAccountsService adapAccount = new AdaptiveAccountsService(GetHeader());
     PayPal.AdaptiveAccounts.Model.RequestEnvelope envelope = new PayPal.AdaptiveAccounts.Model.RequestEnvelope()
     {
         errorLanguage = "en_US",
         detailLevel = PayPal.AdaptiveAccounts.Model.DetailLevelCode.RETURNALL
     };
     PayPal.AdaptiveAccounts.Model.GetVerifiedStatusRequest verifyModel = new PayPal.AdaptiveAccounts.Model.GetVerifiedStatusRequest()
     {
         emailAddress = email,
         requestEnvelope = envelope,
         matchCriteria = "NONE"
     };
     var response = adapAccount.GetVerifiedStatus(verifyModel);
     return response.responseEnvelope.ack == PayPal.AdaptiveAccounts.Model.AckCode.SUCCESS &&
            response.accountStatus == "VERIFIED";
 }