var refundParameters = new TransactionParameters.Builder() .Refund("<transactionIdentifier>") // For partial refunds, also specify refund amount and currency // .AmountAndCurrency(10.00m, Currency.EUR) .Build(); // delegate methods are similar to start transaction var process = PosClient.GetTransactionModule().AmendTransaction(refundParameters, (transaction, transactionProcessDetails, abortable) => { // transaction update information }, (transaction, transactionStateDetails, error) => { // check for error if (error != null) { // error indicates that there was a problem refunding the transaction // check error.Type and error.Message for more information } else { // Let the merchant know that they can return the goods to the shopper // You can access details of the refund in transaction.RefundDetails Console.WriteLine("Refund successful"); // Provide a refund receipt: // Get all refundTransactions from the CHARGE transaction List<Payworks.PayClient.Transactions.RefundTransaction> refundTransactions = transaction.RefundDetails.RefundTransactions; // Access the last refund transaction (usually there is only one) RefundTransaction lastRefund = refundTransactions.Last(); if(lastRefund != null && lastRefund.Status == TransactionStatus.APPROVED) { // Get REFUND transaction includung receipt data PosClient.GetTransactionModule().GetTransaction(lastRefund.Identifier, (refundTransaction, err) => { if(err == null) { // Provide a printed REFUND receipt to the merchant and shopper // refundTransaction.MerchantReceipt // refundTransaction.CustomerReceipt } }); } } });
var transactionParameters = new TransactionParameters.Builder() .Refund(10.00m, Currency.EUR) .Subject("Refund of previous charge") .CustomIdentifier("yourReferenceForTheTransaction") .Build(); var transactionProcessParameters = new TransactionProcessParameters.Builder().Build(); InteractiveProcess = PosClient.GetTransactionModule().StartTransaction(Device, transactionParameters, transactionProcessParameters, (transaction, transactionProcessDetails, abortable) => { // transaction update information // abortable indicates if the transaction can be aborted in the current state // transactionProcessDetails.Information array indicates human-readable the state information: // always show those two status lines in your merchant-facing UI // transactionProcessDetails.Information[0] // transactionProcessDetails.Information[1] }, (actionType) => { // Can be left empty, refunds will not raise an action }, (transaction, transactionProcessDetails, error) => { // check for error if (error != null) { // error indicates that there was a error with the transaction processing // check error.Type and error.Message for more information } else { // Inspect the transaction.Status to get the overall result / transaction completed if (transaction.Status == TransactionStatus.APPROVED) // DECLINED / ABORTED { Console.WriteLine("APPROVED: " + transaction.Identifier); // Provide printed refund receipts to the merchant and shopper // transaction.MerchantReceipt // transaction.CustomerReceipt } } } );