DoVoid() public method

public DoVoid ( DoVoidReq doVoidReq ) : DoVoidResponseType
doVoidReq PayPal.PayPalAPIInterfaceService.Model.DoVoidReq
return PayPal.PayPalAPIInterfaceService.Model.DoVoidResponseType
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object
            DoVoidRequestType request =
                new DoVoidRequestType();
            // (Required) Original authorization ID specifying the authorization to void or, to void an order, the order ID.
            // Important: If you are voiding a transaction that has been reauthorized, use the ID from the original authorization, and not the reauthorization.
            request.AuthorizationID = authorizationId.Value;
            // (Optional) Informational note about this void that is displayed to the buyer in email and in their transaction history.
            if (note.Value != string.Empty)
            {
                request.Note = note.Value;
            }

            // Invoke the API
            DoVoidReq wrapper = new DoVoidReq();
            wrapper.DoVoidRequest = 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 DoVoid method in service wrapper object
            DoVoidResponseType doVoidResponse =
                    service.DoVoid(wrapper);

            // Check for API return status
            setKeyResponseObjects(service, doVoidResponse);
        }
Esempio n. 2
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            // Create request object
            DoVoidRequestType request =
                new DoVoidRequestType();
            request.AuthorizationID = authorizationId.Value;
            if (note.Value != "")
            {
                request.Note = note.Value;
            }

            // Invoke the API
            DoVoidReq wrapper = new DoVoidReq();
            wrapper.DoVoidRequest = request;
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
            DoVoidResponseType doVoidResponse =
                    service.DoVoid(wrapper);

            // Check for API return status
            setKeyResponseObjects(service, doVoidResponse);
        }
        public ActionResult VoidOrder(string authorizationId)
        {
            var service = new PayPalAPIInterfaceServiceService();

            var request = new GetTransactionDetailsReq
            {
                GetTransactionDetailsRequest = new GetTransactionDetailsRequestType
                {
                    TransactionID = authorizationId
                }
            };

            var transactionDetailsResponse = service.GetTransactionDetails(request);

            if (transactionDetailsResponse.Ack == AckCodeType.SUCCESS)
            {
                //if(transactionDetailsResponse.PaymentTransactionDetails.PaymentInfo.PaymentStatus == PaymentStatusCodeType.)

                var voidRequest = new DoVoidReq()
                {
                    DoVoidRequest = new DoVoidRequestType
                    {
                        AuthorizationID = authorizationId,
                    }
                };

                var voidResponse = service.DoVoid(voidRequest);

                if (voidResponse.Ack == AckCodeType.SUCCESS)
                {
                    return RedirectToAction("OrderVoided", new { transactionId = authorizationId });
                }
                else
                {
                    foreach (var error in voidResponse.Errors)
                    {
                        ModelState.AddModelError("__FORM", error.LongMessage);
                    }
                }
            }
            else
            {
                foreach (var error in transactionDetailsResponse.Errors)
                {
                    ModelState.AddModelError("__FORM", error.LongMessage);
                }
            }

            return View("Error");
        }
		public override VoidProcessPaymentResult VoidProcessPayment(VoidProcessPaymentEvaluationContext context)
		{
			if (context.Payment == null)
				throw new ArgumentNullException("context.Payment is null");

			VoidProcessPaymentResult retVal = new VoidProcessPaymentResult();

			if(!context.Payment.IsApproved && context.Payment.PaymentStatus == PaymentStatus.Authorized)
			{
				try
				{
					var config = GetConfigMap();
					var service = new PayPalAPIInterfaceServiceService(config);
					var doVoidResponse = service.DoVoid(new DoVoidReq { DoVoidRequest = new DoVoidRequestType { AuthorizationID = context.Payment.OuterId, Note = "Cancel payment" } });

					CheckResponse(doVoidResponse);

					if(context.Payment.OuterId == doVoidResponse.AuthorizationID)
					{
						retVal.NewPaymentStatus = context.Payment.PaymentStatus = PaymentStatus.Voided;
						context.Payment.VoidedDate = context.Payment.CancelledDate = DateTime.UtcNow;
						context.Payment.IsCancelled = true;
						retVal.IsSuccess = true;
					}
				}
				catch(Exception ex)
				{
					retVal.ErrorMessage = ex.Message;
				}
			}

			return retVal;
		}
    //#DoVoid API Operation
    //#Void an order or an authorization. 
    public DoVoidResponseType DoVoidAPIOperation() 
    {
        // Create the DoVoidResponseType object
        DoVoidResponseType responseDoVoidResponseType = new DoVoidResponseType();

        try
        {
            // Create the DoVoidReq object
            DoVoidReq doVoid = new DoVoidReq();

            // DoVoidRequest which takes mandatory params:
            //
            // * `Authorization ID` - Original authorization ID specifying the
            // authorization to void or, to void an order, the order ID.
            // `Important:
            // If you are voiding a transaction that has been reauthorized, use the
            // ID from the original authorization, and not the reauthorization.`
            DoVoidRequestType doVoidRequest = new DoVoidRequestType("9B2288061E685550E");
            doVoid.DoVoidRequest = doVoidRequest;

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

            // # API call
            // Invoke the DoVoid method in service wrapper object
            responseDoVoidResponseType = service.DoVoid(doVoid);

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

                // # Success values
                if (responseDoVoidResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // Authorization identification number you specified in the request
                    logger.Info("Authorization ID : " + responseDoVoidResponseType.AuthorizationID + "\n");
                    Console.WriteLine("Authorization ID : " + responseDoVoidResponseType.AuthorizationID + "\n");

                }
                // # Error Values
                else
                {
                    List<ErrorType> errorMessages = responseDoVoidResponseType.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 responseDoVoidResponseType;
    }