Пример #1
0
        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);
        }
Пример #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);
        }
        /// <summary>
        /// Voids a payment
        /// </summary>
        /// <param name="voidPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public VoidPaymentResult Void(VoidPaymentRequest voidPaymentRequest)
        {
            var result = new VoidPaymentResult();

            string transactionId = voidPaymentRequest.Order.AuthorizationTransactionId;
            if (String.IsNullOrEmpty(transactionId))
                transactionId = voidPaymentRequest.Order.CaptureTransactionId;

            var req = new DoVoidReq();
            req.DoVoidRequest = new DoVoidRequestType();
            req.DoVoidRequest.Version = GetApiVersion();
            req.DoVoidRequest.AuthorizationID = transactionId;

            var service = GetService();
            DoVoidResponseType response = service.DoVoid(req);

            string error;
            bool success = PaypalHelper.CheckSuccess(response, out error);
            if (success)
            {
                result.NewPaymentStatus = PaymentStatus.Voided;
                //result.VoidTransactionID = response.RefundTransactionID;
            }
            else
            {
                result.AddError(error);
            }
            return result;
        }
Пример #4
0
        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");
        }
        /// <summary>
        /// 
        /// </summary>
        ///<param name="doVoidReq"></param>
        ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> 
        public DoVoidResponseType DoVoid(DoVoidReq doVoidReq, ICredential credential)
        {
            setStandardParams(doVoidReq.DoVoidRequest);
            DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(this.config, doVoidReq.ToXMLString(null, "DoVoidReq"), null, null);
            IAPICallPreHandler apiCallPreHandler = new MerchantAPICallPreHandler(this.config, defaultHandler, credential);
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
            ((MerchantAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
            ((MerchantAPICallPreHandler) apiCallPreHandler).PortName = "PayPalAPIAA";

            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(Call(apiCallPreHandler));
            return new DoVoidResponseType(
                xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='DoVoidResponse']")
            );
        }
 /// <summary> 
 /// 
 /// </summary>
 ///<param name="doVoidReq"></param>
 public DoVoidResponseType DoVoid(DoVoidReq doVoidReq)
 {
     return DoVoid(doVoidReq,(string) null);
 }
 /**
   *AUTO_GENERATED
  	  */
 public DoVoidResponseType DoVoid(DoVoidReq doVoidReq, string apiUserName)
 {
     IAPICallPreHandler apiCallPreHandler = null;
      		string portName = "PayPalAPIAA";
     setStandardParams(doVoidReq.DoVoidRequest);
     DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(doVoidReq.ToXMLString(null, "DoVoidReq"), null, null);
     apiCallPreHandler = new MerchantAPICallPreHandler(defaultHandler, apiUserName, getAccessToken(), getAccessTokenSecret());
     ((MerchantAPICallPreHandler) apiCallPreHandler).SDKName = SDKName;
     ((MerchantAPICallPreHandler) apiCallPreHandler).SDKVersion = SDKVersion;
     ((MerchantAPICallPreHandler) apiCallPreHandler).PortName = portName;
     string response = Call(apiCallPreHandler);
     XmlDocument xmlDocument = new XmlDocument();
     xmlDocument.LoadXml(response);
     XmlNode xmlNode = xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='DoVoidResponse']");
     return new DoVoidResponseType(xmlNode);
 }
        public ITransactionVoidResult Void(ITransactionVoidRequest request)
        {
            //to void a transaction, we'll need capture id or authorization id previously obtained from paypal
            var transactionId = request.GetParameterAs<string>(PaymentParameterNames.AuthorizationId);
            if(string.IsNullOrEmpty(transactionId))
                transactionId = request.GetParameterAs<string>(PaymentParameterNames.CaptureId);

            //create a capture request for paypal
            var doVoidRequest = new DoVoidReq() {
                DoVoidRequest = new DoVoidRequestType() {
                    Version = ApiVersion,
                    AuthorizationID = transactionId
                }
            };

            //get the service for paypal api
            var service = GetPayPalApiInterfaceServiceService();
            var paypalResponse = service.DoVoid(doVoidRequest);

            var result = new TransactionResult();

            string error;
            var success = PayPalHelper.ParseResponseSuccess(paypalResponse, out error);
            if (success)
            {
                result.Success = true;
                result.SetParameter(PaymentParameterNames.RefundId, paypalResponse.AuthorizationID);
                result.SetParameter(PaymentParameterNames.RefundResult, paypalResponse.Ack);
            }
            else
            {
                result.SetParameter(PaymentParameterNames.ErrorMessage, error);
            }

            return result;
        }
 /**
   *AUTO_GENERATED
  	  */
 public DoVoidResponseType DoVoid(DoVoidReq doVoidReq, string apiUserName)
 {
     setStandardParams(doVoidReq.DoVoidRequest);
     string response = Call("DoVoid", doVoidReq.ToXMLString(), apiUserName);
     XmlDocument xmlDocument = new XmlDocument();
     xmlDocument.LoadXml(response);
     XmlNode xmlNode = xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='DoVoidResponse']");
     return new DoVoidResponseType(xmlNode);
 }
 public DoVoidResponseType DoVoid(DoVoidReq DoVoidReq)
 {
     return DoVoid(DoVoidReq, null);
 }
        /**
         *
         */
        public DoVoidResponseType DoVoid(DoVoidReq DoVoidReq, string apiUsername)
        {
            setStandardParams(DoVoidReq.DoVoidRequest);
            string resp = call("DoVoid", DoVoidReq.toXMLString(), apiUsername);

            return new DoVoidResponseType(resp);
        }
Пример #12
0
    //#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;
    }