/// <summary>
        /// Creates (and processes) a new Capture Transaction added as a related resource.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="capture">Capture</param>
        /// <returns>Capture</returns>
        public Capture Capture(APIContext apiContext, Capture capture)
        {
            if (apiContext == null)
            {
                throw new ArgumentNullException("APIContext cannot be null");
            }
            if (string.IsNullOrEmpty(apiContext.AccessToken))
            {
                throw new ArgumentNullException("AccessToken cannot be null or empty");
            }
            if (apiContext.HTTPHeaders == null)
            {
                apiContext.HTTPHeaders = new Dictionary <string, string>();
            }
            apiContext.HTTPHeaders.Add(BaseConstants.ContentTypeHeader, BaseConstants.ContentTypeHeaderJson);
            apiContext.SdkVersion = new SDKVersionImpl();
            if (this.id == null)
            {
                throw new ArgumentNullException("Id cannot be null");
            }
            if (capture == null)
            {
                throw new ArgumentNullException("capture cannot be null");
            }
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payments/authorization/{0}/capture";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = capture.ConvertToJson();

            return(PayPalResource.ConfigureAndExecute <Capture>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext CurrContext = HttpContext.Current;
            Capture capture = null;
            try
            {
                // ### Api Context
                // Pass in a `APIContext` object to authenticate 
                // the call and to send a unique request id 
                // (that ensures idempotency). The SDK generates
                // a request id if you do not pass one explicitly. 
                // See [Configuration.cs](/Source/Configuration.html) to know more about APIContext.
                APIContext apiContext = Configuration.GetAPIContext();
                                
                // ###Authorization
                // Retrieve a Authorization object
                // by making a Payment with intent
                // as `authorize`
                Authorization authorization = Common.CreateAuthorization(apiContext);

                // ###Amount
                // Let's you specify a capture amount.
                Amount amnt = new Amount();
                amnt.currency = "USD";
                amnt.total = "4.54";

                capture = new Capture();
                capture.amount = amnt;

                // ##IsFinalCapture
                // If set to true, all remaining 
                // funds held by the authorization 
                // will be released in the funding 
                // instrument. Default is `false`.
                capture.is_final_capture = true;                      
                
                // Capture an authorized payment by POSTing to
                // URI v1/payments/authorization/{authorization_id}/capture
                Capture responseCapture = authorization.Capture(apiContext, capture);
                CurrContext.Items.Add("ResponseJson", JObject.Parse(responseCapture.ConvertToJson()).ToString(Formatting.Indented));
            }
            catch (PayPal.Exception.PayPalException ex)
            {
                CurrContext.Items.Add("Error", ex.Message);
            }

            if (capture != null)
            {
                CurrContext.Items.Add("RequestJson", JObject.Parse(capture.ConvertToJson()).ToString(Formatting.Indented));
            }

            Server.Transfer("~/Response.aspx");

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext CurrContext = HttpContext.Current;
            Capture capture = null;
            try
            {
                // ###AccessToken
                // Retrieve the access token from
                // OAuthTokenCredential by passing in
                // ClientID and ClientSecret
                // It is not mandatory to generate Access Token on a per call basis.
                // Typically the access token can be generated once and
                // reused within the expiry window
                string accessToken = new OAuthTokenCredential(ConfigManager.Instance.GetProperties()["ClientID"], ConfigManager.Instance.GetProperties()["ClientSecret"]).GetAccessToken();

                // ###Authorization
                // Retrieve a Authorization object
                // by making a Payment with intent
                // as 'authorize'
                Authorization authorization = GetAuthorization(accessToken);

                // ###Amount
                // Let's you specify a capture amount.
                Amount amnt = new Amount();
                amnt.currency = "USD";
                amnt.total = "4.54";

                capture = new Capture();
                capture.amount = amnt;

                // ##IsFinalCapture
                // If set to true, all remaining
                // funds held by the authorization
                // will be released in the funding
                // instrument. Default is ‘false’.
                capture.is_final_capture = true;

                // Capture by POSTing to
                // URI v1/payments/authorization/{authorization_id}/capture
                Capture responseCapture = authorization.Capture(accessToken, capture);
                CurrContext.Items.Add("ResponseJson", JObject.Parse(responseCapture.ConvertToJson()).ToString(Formatting.Indented));

            }
            catch (PayPal.Exception.PayPalException ex)
            {
                CurrContext.Items.Add("Error", ex.Message);
            }
            CurrContext.Items.Add("RequestJson", JObject.Parse(capture.ConvertToJson()).ToString(Formatting.Indented));

            Server.Transfer("~/Response.aspx");
        }
        /// <summary>
        /// Creates (and processes) a new Capture Transaction added as a related resource.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="capture">Capture</param>
        /// <returns>Capture</returns>
        public Capture Capture(APIContext apiContext, Capture capture)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");
            ArgumentValidator.Validate(capture, "capture");

            // Configure and send the request
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payments/authorization/{0}/capture";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = capture.ConvertToJson();

            return(PayPalResource.ConfigureAndExecute <Capture>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
        /// <summary>
        /// Creates (and processes) a new Capture Transaction added as a related resource.
        /// </summary>
        public Capture Capture(APIContext apiContext, Capture capture)
        {
            if (string.IsNullOrEmpty(apiContext.AccessToken))
            {
                throw new ArgumentNullException("AccessToken cannot be null or empty");
            }
            if (this.id == null)
            {
                throw new ArgumentNullException("Id cannot be null");
            }
            if (capture == null)
            {
                throw new ArgumentNullException("capture cannot be null");
            }
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payments/authorization/{0}/capture";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = capture.ConvertToJson();

            return(PayPalResource.ConfigureAndExecute <Capture>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
 /// <summary>
 /// Creates (and processes) a new Capture Transaction added as a related resource.
 /// </summary>
 /// <param name="apiContext">APIContext used for the API call.</param>
 /// <param name="capture">Capture</param>
 /// <returns>Capture</returns>
 public Capture Capture(APIContext apiContext, Capture capture)
 {
     if (string.IsNullOrEmpty(apiContext.AccessToken))
     {
         throw new ArgumentNullException("AccessToken cannot be null or empty");
     }
     if (this.id == null)
     {
         throw new ArgumentNullException("Id cannot be null");
     }
     if (capture == null)
     {
         throw new ArgumentNullException("capture cannot be null");
     }
     object[] parameters = new object[] {this.id};
     string pattern = "v1/payments/authorization/{0}/capture";
     string resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
     string payLoad = capture.ConvertToJson();
     return PayPalResource.ConfigureAndExecute<Capture>(apiContext, HttpMethod.POST, resourcePath, payLoad);
 }
		/// <summary>
		/// Creates (and processes) a new Capture Transaction added as a related resource.
		/// </summary>
		/// <param name="apiContext">APIContext used for the API call.</param>
		/// <param name="capture">Capture</param>
		/// <returns>Capture</returns>
		public Capture Capture(APIContext apiContext, Capture capture)
		{
			if (apiContext == null)
			{
				throw new ArgumentNullException("APIContext cannot be null");
			}
			if (string.IsNullOrEmpty(apiContext.AccessToken))
			{
				throw new ArgumentNullException("AccessToken cannot be null or empty");
			}
			if (apiContext.HTTPHeaders == null)
			{
				apiContext.HTTPHeaders = new Dictionary<string, string>();
			}
			apiContext.HTTPHeaders.Add(BaseConstants.ContentTypeHeader, BaseConstants.ContentTypeHeaderJson);
			apiContext.SdkVersion = new SDKVersionImpl();
			if (this.id == null)
			{
				throw new ArgumentNullException("Id cannot be null");
			}
			if (capture == null)
			{
				throw new ArgumentNullException("capture cannot be null");
			}
			object[] parameters = new object[] {this.id};
			string pattern = "v1/payments/authorization/{0}/capture";
			string resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
			string payLoad = capture.ConvertToJson();
			return PayPalResource.ConfigureAndExecute<Capture>(apiContext, HttpMethod.POST, resourcePath, payLoad);
		}