# Cancel or refund a transaction

## Cancel or refund with a PSP reference

### Method

Call cancelOrRefundTransactionWithPSPReference to cancel or refund a transaction where the transaction was processed online successfully and generated a PSP reference. The response from the server indicates if the cancel or refund was received, not if it was performed.

If the request is successful, if the pspReference of the original transaction is valid, and if the transaction was not already cancelled or refunded, the cancel or refund will always be performed. When the transactions are retrieved and their refunds are examined, each refund will have a processingState to indicate whether a cancelOrRefund request was sent.

### Parameters

Name Type Required Description
pspReference merchantReference PSP reference of the original transaction.
merchantReference NSString Reference for the merchant, used in reporting.
refundState ADYProcessingState Indicates whether a cancelOrRefund request was sent.
error NSError Information about any errors that occurred.

## Cancel or refund with a tender reference

### Method

Call cancelOrRefundTransactionWithTenderReference to cancel or refund a transaction. This is used where the transaction was offline with the provided combination of tenderReference and UniqueTerminalId (Model-SerialNumber). The response from the server indicates if the cancel or refund was received, not if it was performed.

If the request is successful, if the he combination of tenderReference and UniqueTerminalId of the original transaction is valid of the original transaction is valid, and if the transaction was not already cancelled or refunded, the cancel or refund will always be performed. When the transactions are retrieved and their refunds are examined, each refund will have a processingState to indicate whether a cancelOrRefund request was sent.

### Parameters

NameTypeRequiredDescription
tenderReferenceNSStringReference for the transaction, used as the PSP reference is not available.
uniqueTerminalIdNSStringUnique terminal ID to reference the PED that is processing the request.
merchantReferenceNSStringReference for the merchant, used in reporting.
refundStateADYProcessingState

Indicates whether a cancelOrRefund request was sent.

errorNSErrorInformation about any errors that occurred.

* When the transactions are retrieved and their refunds are examined, each refund will have a processingState * to indicate whether a scheduleRefund-request was sent. * */ - (void)refundTransactionWithPSPReferece:(NSString *)pspReference amountToRefund:(ADYAmount *)amount terminalIdentifier:(NSString *)terminalIdentifier merchantReference:(NSString *)merchantReference tenderReference:(NSString *)tenderReference onCompletion:(void (^)(ADYProcessingState, NSError *))completion;

## Partially refund a transaction

### Method

Call refundTransactionWithPSPReferece to partially refund a transaction with the provided combination of pspReference, amount, terminalIdentifier, merchantReference and tenderReference  The response from the server indicates if the scheduleRefund request was received, not if it was performed.

If the request is successful, if the combination of tenderReference and UniqueTerminalId of the original transaction is valid of the original transaction is valid, and if the transaction was not already cancelled or refunded, the cancel or refund will always be performed. When the transactions are retrieved and their refunds are examined, each refund will have a processingState to indicate whether a scheduleRefund request was sent.

### Parameters

NameTypeRequiredDescription
pspReferencemerchantReference

PSP reference of the original transaction.

amount

A container for the amount that needs to be refunded.
tenderReferenceNSStringReference for the transaction, used as the PSP reference is not available.
terminalIdentifier
NSStringUnique terminal ID to reference the PED that is processing the request.
merchantReferenceNSStringReference for the merchant, used in reporting.
refundStateADYProcessingState

Indicates whether a scheduleRefund request was sent.

onCompletion

completion

Information about any errors that occurred.

## Cancel or refund from the terminal transaction list

Use this method cancel or refund a transaction from the terminal transaction list, and receive a receipt on the POS or on the PED.

You can only use this method for transactions that:

• have been completed on the terminal that is receiving the cancel or refund request.
• are still within the terminal storage – this is currently limited to 100 tenders.

### Method

Call cancelOrRefundWithRequest on the selected ADYDevice:

(void)cancelOrRefundWithRequest:(ADYCancelOrRefundRequest *)request completion:(void (^)(ADYProcessingState state, NSArray<ADYReceipt *> *receipts, NSError *error))completion;

The response from the device indicates whether the request was received, not whether it was performed.

### Parameters

NameTypeRequiredDescription
requestADYCancelOrRefundRequest

Object containing information about the transaction that you want to cancel or refund.

completionBlock

This block called when the request was processed. Parameters:

• state: contains the processing state of the cancel or refund.
• receipts: an array that contains cancel/refund receipts if the processing state is ADYProcessingStateProcessed
• error: contains an NSError if the request failed.

reference String The tender reference for the transaction that you want to cancel or refund.
handleReceipt Boolean Specifies that the POS handles and prints receipts. If omitted, it is required that the PED prints the receipt. If there is no printer unit, the transaction will fail.
additionalData NSMutableDictionary Contains key/value pairs that you can use to specify additional data to be passed to the terminal.