The authorization identification number of the payment you want to capture. Required Character length and limits: 19 single-byte characters maximum
Inheritance: AbstractRequestType
コード例 #1
0
ファイル: DoCapture.aspx.cs プロジェクト: kashyapkk/SDKs
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object

            DoCaptureRequestType request =
                new DoCaptureRequestType();

            request.AuthorizationID = authorizationId.Value;
            CurrencyCodeType currency = (CurrencyCodeType)
                Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
            request.Amount = new BasicAmountType(currency, amount.Value);
            if (completeType.SelectedIndex != 0)
            {
                request.CompleteType = (CompleteCodeType)
                    Enum.Parse(typeof(CompleteCodeType), completeType.SelectedValue);
            }
            if (note.Value != "")
            {
                request.Note = note.Value;
            }
            if (invoiceId.Value != "")
            {
                request.InvoiceID = invoiceId.Value;
            }
            if (softDescriptor.Value != "")
            {
                request.Descriptor = softDescriptor.Value;
            }

            // Invoke the API
            DoCaptureReq wrapper = new DoCaptureReq();
            wrapper.DoCaptureRequest = request;
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
            DoCaptureResponseType doCaptureResponse =
                    service.DoCapture(wrapper);

            // Check for API return status
            setKeyResponseObjects(service, doCaptureResponse);
        }
コード例 #2
0
		public IPaymentResult CapturePayment(IInvoice invoice, IPayment payment, decimal amount, bool isPartialPayment)
		{
			var service = GetPayPalService();
			var authorizationId = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.AuthorizationId);
			var currency = PayPalCurrency(invoice.CurrencyCode());
			var currencyDecimals = CurrencyDecimals(currency);
			
			// do express checkout
			var doCaptureRequest = new DoCaptureRequestType() 
				{
					AuthorizationID = authorizationId,
					Amount = new BasicAmountType(currency, PriceToString(amount, currencyDecimals)),
					CompleteType = (isPartialPayment ? CompleteCodeType.NOTCOMPLETE : CompleteCodeType.COMPLETE)
				};
			var doCaptureReq = new DoCaptureReq() { DoCaptureRequest = doCaptureRequest };

			//if (payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.PaymentCaptured) != "true") {
				DoCaptureResponseType doCaptureResponse;
				try {
					doCaptureResponse = service.DoCapture(doCaptureReq);
					if (doCaptureResponse.Ack != AckCodeType.SUCCESS && doCaptureResponse.Ack != AckCodeType.SUCCESSWITHWARNING) {
						return new PaymentResult(Attempt<IPayment>.Fail(payment, CreateErrorResult(doCaptureResponse.Errors)), invoice, false);
					}
				} catch (Exception ex) {
					return new PaymentResult(Attempt<IPayment>.Fail(payment, ex), invoice, false);
				}
			
				payment.ExtendedData.SetValue(Constants.ExtendedDataKeys.TransactionId, doCaptureResponse.DoCaptureResponseDetails.PaymentInfo.TransactionID);
				payment.ExtendedData.SetValue(Constants.ExtendedDataKeys.PaymentCaptured, "true");	
			//}
			
			payment.Authorized = true;
			payment.Collected = true;
			return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true);
			
		}
コード例 #3
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object

            DoCaptureRequestType request =
                new DoCaptureRequestType();

            // (Required) Authorization identification number of the payment you want to capture. This is the transaction ID returned from DoExpressCheckoutPayment, DoDirectPayment, or CheckOut. For point-of-sale transactions, this is the transaction ID returned by the CheckOut call when the payment action is Authorization.
            request.AuthorizationID = authorizationId.Value;

            // (Required) Amount to capture.
            // Note: You must set the currencyID attribute to one of the three-character currency codes for any of the supported PayPal currencies.
            CurrencyCodeType currency = (CurrencyCodeType)
                Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
            request.Amount = new BasicAmountType(currency, amount.Value);

            // (Required) Indicates whether or not this is your last capture. It is one of the following values:
            // * Complete – This is the last capture you intend to make.
            // * NotComplete – You intend to make additional captures.
            if (completeType.SelectedIndex != 0)
            {
                request.CompleteType = (CompleteCodeType)
                    Enum.Parse(typeof(CompleteCodeType), completeType.SelectedValue);
            }
            // (Optional) An informational note about this settlement that is displayed to the buyer in email and in their transaction history.
            if (note.Value != string.Empty)
            {
                request.Note = note.Value;
            }
            // (Optional) Your invoice number or other identification number that is displayed to you and to the buyer in their transaction history. The value is recorded only if the authorization you are capturing is an Express Checkout order authorization.
            // Note: This value on DoCapture overwrites a value previously set on DoAuthorization.
            if (invoiceId.Value != string.Empty)
            {
                request.InvoiceID = invoiceId.Value;
            }
            // (Optional) Per transaction description of the payment that is passed to the buyer's credit card statement.
            //If you provide a value in this field, the full descriptor displayed on the buyer's statement has the following format:
            //<PP * | PAYPAL *><Merchant descriptor as set in the Payment Receiving Preferences><1 space><soft descriptor>
            //Character length and limitations: The soft descriptor can contain only the following characters:
            //Alphanumeric characters
            //- (dash)
            //* (asterisk)
            //. (period)
            //{space}
            //If you pass any other characters (such as ","), PayPal returns an error code.
            //The soft descriptor does not include the phone number, which can be toggled between your customer service number and PayPal's Customer Service number.
            //The maximum length of the soft descriptor is 22 characters. Of this, the PayPal prefix uses either 4 or 8 characters of the data format. Thus, the maximum length of the soft descriptor information that you can pass in this field is:
            //22 - len(<PP * | PAYPAL *>) - len(<Descriptor set in Payment Receiving Preferences> + 1)
            //For example, assume the following conditions:
            //The PayPal prefix toggle is set to PAYPAL * in PayPal's administration tools.
            //The merchant descriptor set in the Payment Receiving Preferences is set to EBAY.
            //The soft descriptor is passed in as JanesFlowerGifts LLC.
            //The resulting descriptor string on the credit card is:
            //PAYPAL *EBAY JanesFlow
            if (softDescriptor.Value != string.Empty)
            {
                request.Descriptor = softDescriptor.Value;
            }

            // Invoke the API
            DoCaptureReq wrapper = new DoCaptureReq();
            wrapper.DoCaptureRequest = request;

            // 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();

            // Create the PayPalAPIInterfaceServiceService service object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            // # API call
            // Invoke the DoCapture method in service wrapper object
            DoCaptureResponseType doCaptureResponse =
                    service.DoCapture(wrapper);

            // Check for API return status
            setKeyResponseObjects(service, doCaptureResponse);
        }
コード例 #4
0
    // # DoCapture API Operation 
    // Captures an authorized payment. 
    public DoCaptureResponseType DoCaptureAPIOperation()
    {
        // Create the DoCaptureResponseType object
        DoCaptureResponseType responseDoCaptureResponseType = new DoCaptureResponseType();

        try
        {
            // Create the DoCapture object
            DoCaptureReq doCapture = new DoCaptureReq();

            // `Amount` to capture which takes mandatory params:
            //
            // * `currencyCode`
            // * `amount`
            BasicAmountType amount = new BasicAmountType(CurrencyCodeType.USD, "4.00");

            // `DoCaptureRequest` which takes mandatory params:
            //
            // * `Authorization ID` - Authorization identification number of the
            // payment you want to capture. This is the transaction ID returned from
            // DoExpressCheckoutPayment, DoDirectPayment, or CheckOut. For
            // point-of-sale transactions, this is the transaction ID returned by
            // the CheckOut call when the payment action is Authorization.
            // * `amount` - Amount to capture
            // * `CompleteCode` - Indicates whether or not this is your last capture.
            // It is one of the following values:
            // * Complete – This is the last capture you intend to make.
            // * NotComplete – You intend to make additional captures.
            // `Note:
            // If Complete, any remaining amount of the original authorized
            // transaction is automatically voided and all remaining open
            // authorizations are voided.`
            DoCaptureRequestType doCaptureRequest = new DoCaptureRequestType("O-4VR15106P7416533H", amount, CompleteCodeType.NOTCOMPLETE);
            doCapture.DoCaptureRequest = doCaptureRequest;

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

            // # API call
            // Invoke the DoCapture method in service wrapper object
            responseDoCaptureResponseType = service.DoCapture(doCapture);

            if (responseDoCaptureResponseType != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "DoCapture API Operation - ";
                acknowledgement += responseDoCaptureResponseType.Ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseDoCaptureResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // Authorization identification number
                    logger.Info("Authorization ID : " + responseDoCaptureResponseType.DoCaptureResponseDetails.AuthorizationID + "\n");
                    Console.WriteLine("Authorization ID : " + responseDoCaptureResponseType.DoCaptureResponseDetails.AuthorizationID + "\n");

                }
                // # Error Values
                else
                {
                    List<ErrorType> errorMessages = responseDoCaptureResponseType.Errors;
                    foreach (ErrorType error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.LongMessage);
                        Console.WriteLine("API Error Message : " + error.LongMessage + "\n");
                    }
                }
            }
        }
        // # Exception log    
        catch (System.Exception ex)
        {
            // Log the exception message       
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }
        return responseDoCaptureResponseType;
    }
コード例 #5
0
        /// <summary>
        /// Handles DoCapture
        /// </summary>
        /// <param name="contextHttp"></param>
        private void DoCapture(HttpContext contextHttp)
        {
            NameValueCollection parameters = contextHttp.Request.Params;

            // 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 by loading configuration map.
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            // ## DoCaptureReq
            DoCaptureReq req = new DoCaptureReq();
            // 'Amount' to capture which takes mandatory params:
            //
            // * 'currencyCode'
            // * 'amount'
            BasicAmountType amount = new BasicAmountType(((CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"])), parameters["amt"]);

            // 'DoCaptureRequest' which takes mandatory params:
            //
            // * 'Authorization ID' - Authorization identification number of the
            // payment you want to capture. This is the transaction ID returned from
            // DoExpressCheckoutPayment, DoDirectPayment, or CheckOut. For
            // point-of-sale transactions, this is the transaction ID returned by
            // the CheckOut call when the payment action is Authorization.
            // * 'amount' - Amount to capture
            // * 'CompleteCode' - Indicates whether or not this is your last capture.
            // It is one of the following values:
            // * Complete – This is the last capture you intend to make.
            // * NotComplete – You intend to make additional captures.
            // 'Note:
            // If Complete, any remaining amount of the original authorized
            // transaction is automatically voided and all remaining open
            // authorizations are voided.'
            DoCaptureRequestType reqType = new DoCaptureRequestType
            (
                    parameters["authID"],
                    amount,
                    (CompleteCodeType)Enum.Parse(typeof(CompleteCodeType), parameters["completeCodeType"])
            );

            req.DoCaptureRequest = reqType;
            DoCaptureResponseType response = null;
            try
            {
                response = service.DoCapture(req);
            }
            catch (System.Exception ex)
            {
                contextHttp.Response.Write(ex.StackTrace);
                return;
            }

            Dictionary<string, string> responseValues = new Dictionary<string, string>();
            string redirectUrl = null;
            responseValues.Add("Acknowledgement", response.Ack.ToString().Trim().ToUpper());

            Display(contextHttp, "DoCapture", "DoCapture", responseValues, service.getLastRequest(), service.getLastResponse(), response.Errors, redirectUrl);
        }