/// <summary> /// Example for performing simple refund request. /// Payment has to be in captured state in order to refund be successful. /// </summary> public void SimpleRefund() { //Reserving and capturing payment in order to refund method example could be successful CaptureResult captureResult = ReserveAndCapture(Amount.Get(1200.00, Currency.EUR), AuthType.payment); //Transaction ID is returned from the gateway when payment request was successful string transactionId = captureResult.Payment.TransactionId; //initialize refund request class, this class is used for forwarding all the data needed for refund request //for simple refund requests transaction ID is mandatory field RefundRequest refundRequest = new RefundRequest { PaymentId = transactionId }; //call refund method RefundResult refundResult = _api.Refund(refundRequest); //Result property contains information if the request was successful or not if (refundResult.Result == Result.Success) { //refund was successful Transaction transaction = refundResult.Payment; } else { //refund unsuccessful //error messages contain information about what went wrong string errorMerchantMessage = refundResult.ResultMerchantMessage; string errorMessage = refundResult.ResultMessage; } }
public void RefundingACapturedPayment(Boolean callReservationOfFixedAmount) { PaymentResult result = GetMerchantApiResult(Guid.NewGuid().ToString(), 1.23, callReservationOfFixedAmount); Assert.AreEqual("captured", result.Payment.TransactionStatus); result = _api.Refund(new RefundRequest() { PaymentId = result.Payment.PaymentId, OrderLines = new List <PaymentOrderLine>() { new PaymentOrderLine() { ItemId = "123456", Description = "Test product", UnitPrice = 24.33 } } }); Assert.AreEqual("refunded", result.Payment.TransactionStatus); }