Example #1
0
 public PreapprovalDetailsResponse PreapprovalDetails(PreapprovalDetailsRequest PreapprovalDetailsRequest)
 {
     return PreapprovalDetails(PreapprovalDetailsRequest, null);
 }
        /// <summary>
        /// Handle PreapprovalDetails API call
        /// </summary>
        /// <param name="context"></param>
        private void PreapprovalDetails(HttpContext context)
        {
            NameValueCollection parameters = context.Request.Params;
            PreapprovalDetailsRequest req = new PreapprovalDetailsRequest(new RequestEnvelope("en_US"),
                parameters["preapprovalKey"]);
            // set optional parameters
            if (parameters["getBillingAddress"] != "")
                req.getBillingAddress = Boolean.Parse(parameters["getBillingAddress"]);

            // All set. Fire the request
            AdaptivePaymentsService service = new AdaptivePaymentsService();
            PreapprovalDetailsResponse resp = null;
            try
            {
                resp = service.PreapprovalDetails(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("Status", resp.status);
                keyResponseParams.Add("Starting date", resp.startingDate);
                keyResponseParams.Add("Ending date", resp.endingDate);
                keyResponseParams.Add("Sender email", resp.senderEmail);
                keyResponseParams.Add("Currency code", resp.currencyCode);
                keyResponseParams.Add("Maximum amount (across all payments)", resp.maxTotalAmountOfAllPayments.ToString());

                //Selenium Test Case
                keyResponseParams.Add("Acknowledgement", resp.responseEnvelope.ack.ToString());
            }
            displayResponse(context, "PreapprovalDetails", keyResponseParams, service.getLastRequest(), service.getLastResponse(),
                resp.error, redirectUrl);
        }
Example #3
0
        /**
         *
         */
        public PreapprovalDetailsResponse PreapprovalDetails(PreapprovalDetailsRequest PreapprovalDetailsRequest, string apiUsername)
        {
            string resp = call("PreapprovalDetails", PreapprovalDetailsRequest.toNVPString(""), apiUsername);

            NVPUtil util = new NVPUtil();
            return new PreapprovalDetailsResponse(util.parseNVPString(resp), "");
        }
	 	/// <summary>
		/// 
	 	/// </summary>
		///<param name="preapprovalDetailsRequest"></param>
		///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
	 	public PreapprovalDetailsResponse PreapprovalDetails(PreapprovalDetailsRequest preapprovalDetailsRequest, ICredential credential)
	 	{	 			 		
			IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, preapprovalDetailsRequest.ToNVPString(string.Empty), ServiceName, "PreapprovalDetails", credential);
	   	 	((PlatformAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
			((PlatformAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
			((PlatformAPICallPreHandler) apiCallPreHandler).PortName = "AdaptivePayments";

			NVPUtil util = new NVPUtil();
			return PreapprovalDetailsResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1);
			
	 	}
	 	/// <summary> 
		/// 
	 	/// </summary>
		///<param name="preapprovalDetailsRequest"></param>
	 	
	 	public PreapprovalDetailsResponse PreapprovalDetails(PreapprovalDetailsRequest preapprovalDetailsRequest)
	 	{
	 		return PreapprovalDetails(preapprovalDetailsRequest,(string) null);
	 	}
        /// <summary>
        /// Handle PreapprovalDetails API call
        /// </summary>
        /// <param name="contextHttp"></param>
        private void PreapprovalDetails(HttpContext contextHttp)
        {
            NameValueCollection parameters = contextHttp.Request.Params;
            // error language : (Required) RFC 3066 language in which error messages are returned; by default it is en_US, which is the only language currently supported. 
            // preapproval key : (Required) A preapproval key that identifies the preapproval for which you want to retrieve details. The preapproval key is returned in the PreapprovalResponse message
            PreapprovalDetailsRequest request = new PreapprovalDetailsRequest(new RequestEnvelope("en_US"), 
                parameters["preapprovalKey"]);
            
            //  (Optional) An option that lets you retrieve a list of billing addresses for the sender.
            //     true – Includes the billing address in the response
            //     false – Omits the billing address from the response (default)
            // Note:
            // This field is available only to API callers with advanced permission levels. For information, refer to the section Adaptive Payments Permission Levels.
            if (parameters["getBillingAddress"] != string.Empty)
                request.getBillingAddress = Convert.ToBoolean(parameters["getBillingAddress"]);
           
            AdaptivePaymentsService service = null;
            PreapprovalDetailsResponse response = 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 AdaptivePaymentsService(configurationMap);
                response = service.PreapprovalDetails(request);
            }
            catch (System.Exception e)
            {
                contextHttp.Response.Write(e.Message);
                return;
            }

            Dictionary<string, string> responseValues = new Dictionary<string, string>();
            string redirectUrl = null;
            if (!(response.responseEnvelope.ack == AckCode.FAILURE) &&
                !(response.responseEnvelope.ack == AckCode.FAILUREWITHWARNING))
            {
                //Whether this preapproval is active, represented by the following values:
                //  ACTIVE – The preapproval is active
                //  CANCELED – The preapproval was explicitly canceled by the sender or by PayPal
                //  DEACTIVATED – The preapproval is not active; you can reactivate it by resetting the personal identification number (PIN) or by contacting PayPal
                responseValues.Add("Status", response.status);

                // First date for which the preapproval is valid.
                responseValues.Add("Starting date", response.startingDate);
                
                // Last date for which the preapproval is valid. Time is currently not supported.
                // Note:
                // You must specify a value unless you have specific permission from PayPal to 
                // omit this value.
                responseValues.Add("Ending date", response.endingDate);

                // Sender’s email address. If not specified, the email address of 
                // the sender who logs in to approve the request becomes the email 
                // address associated with the preapproval key.
                responseValues.Add("Sender email", response.senderEmail);

                responseValues.Add("Currency code", response.currencyCode);

                // The preapproved maximum total amount of all payments.
                // Note:
                // You must specify a value unless you have specific permission from PayPal to omit this value.
                responseValues.Add("Maximum amount (across all payments)", response.maxTotalAmountOfAllPayments.ToString());

                
                responseValues.Add("Acknowledgement", response.responseEnvelope.ack.ToString());
            }
            Display(contextHttp, "PreapprovalDetails", responseValues, service.getLastRequest(), service.getLastResponse(),
                response.error, redirectUrl);
        }
Example #7
0
 /**
   *AUTO_GENERATED
  	  */
 public PreapprovalDetailsResponse PreapprovalDetails(PreapprovalDetailsRequest preapprovalDetailsRequest, string apiUserName)
 {
     string response = Call("PreapprovalDetails", preapprovalDetailsRequest.ToNVPString(""), apiUserName);
     NVPUtil util = new NVPUtil();
     return PreapprovalDetailsResponse.CreateInstance(util.ParseNVPString(response), "", -1);
 }
        // # PreapprovalDetails API Operation
        // Use the PreapprovalDetails API operation to obtain information about an agreement between you and a sender for making payments on the sender’s behalf.
        public PreapprovalDetailsResponse PreapprovalDetailsAPIOperation(string preapprovalKey)
        {
            // Create the PreapprovalDetailsResponse object
            var responsePreapprovalDetails = new PreapprovalDetailsResponse();

            try
            {
                // # PreapprovaDetailslRequest
                // The code for the language in which errors are returned
                var envelopeRequest = new RequestEnvelope {errorLanguage = "en_US"};

                // PreapprovalDetailsRequest object which takes mandatory params:
                //
                // * `Request Envelope` - Information common to each API operation, such
                // as the language in which an error message is returned.
                // * `Preapproval Key` - A preapproval key that identifies the
                // preapproval for which you want to retrieve details. The preapproval
                // key is returned in the PreapprovalResponse message.
                var preapprovDetailsRequest = new PreapprovalDetailsRequest(
                envelopeRequest, preapprovalKey);

                // Create the service wrapper object to make the API call
                var service = new AdaptivePaymentsService();

                // # API call
                // Invoke the PreapprovalDetails method in service wrapper object
                responsePreapprovalDetails = service.PreapprovalDetails(preapprovDetailsRequest);

                if (responsePreapprovalDetails != null)
                {

                    // # Success values
                    if (responsePreapprovalDetails.responseEnvelope != null && responsePreapprovalDetails.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                    {
                        // First date for which the preapproval is valid.
                        Console.WriteLine("Starting Date : " + responsePreapprovalDetails.startingDate + "\n");
                    }
                    // # Error Values
                    else
                    {
                        List<ErrorData> errorMessages = responsePreapprovalDetails.error;
                        foreach (ErrorData error in errorMessages)
                        {
                            Console.WriteLine("API Error Message : " + error.message + "\n");
                        }
                    }
                }
            }
            // # Exception log
            catch (Exception ex)
            {
                // Log the exception message
                Console.WriteLine("Error Message : " + ex.Message);
            }
            return responsePreapprovalDetails;
        }