Skip to content
payrocdevelopers

Run a refund

Run a referenced refund with the Tap to Pay on iPhone SDK using the uniqueRef of the original sale.

Prerequisites: Authentication · Run a sale

Important: You can't run an unreferenced refund with the Tap to Pay on iPhone SDK. For more information about refund types, go to Refunds and reversals.

A referenced refund returns funds to the same card that the customer used for the original sale. You don't need the customer to tap their card again. If you refund a sale that hasn't settled yet, our gateway reverses the sale instead.

Before you begin, you need the uniqueRef of the sale that you want to refund. If you don't have it, go to Retrieve transactions.

Integration steps

  1. Register the refund listener.
  2. Run the refund.

Step 1. Register the refund listener

The SDK returns refund results to onRefundResponse: on your CoreAPIRefundListener. To register your refund listener when your view appears, and unregister it when the view disappears, use the following code:

Swift

swift
// viewWillAppear:
terminal.register(self as CoreAPIRefundListener)

// viewWillDisappear:
terminal.unRegister(self as CoreAPIRefundListener)

Objective-C

objectivec
// viewWillAppear:
[[WTPSTerminal singleton] registerCoreAPIRefundListener:self];

// viewWillDisappear:
[[WTPSTerminal singleton] unRegisterCoreAPIRefundListener:self];

Step 2. Run the refund

To run a refund, create a CoreRefund, and then call processRefund:.

CoreRefund includes the following properties:

PropertyDescriptionRequired or optional
uniqueRefUnique ID of the sale that you want to refund.Required
reasonReason for the refund.Required
amountAmount that you want to refund.Required
orderIdYour identifier for the order.Optional
previousTxnDateTimeThe date and time of the original transaction.Optional
autoCaptureWhether to capture the refund automatically. The default value is true.Optional

The following example refunds a sale:

Swift

swift
let refund = CoreRefund()
refund.uniqueRef = "ORIGINAL_UNIQUE_REF"
refund.reason = "Customer request"
refund.amount = 42.00

terminal.processRefund(refund)

Objective-C

objectivec
CoreRefund *refund = [[CoreRefund alloc] init];
refund.uniqueRef = @"ORIGINAL_UNIQUE_REF";
refund.reason = @"Customer request";
refund.amount = [NSNumber numberWithDouble:42.00];

[[WTPSTerminal singleton] processRefund:refund];

The SDK returns the result to onRefundResponse:.

Note: If the SDK reversed the sale instead of refunding it, onRefundResponse: returns a CoreSaleResponse instead of a CoreRefundResponse.

Refund errors

CoreAPIRefundListener uses the same onError:withDescription: signature as the sale listener. For more information, go to Handle errors.

Browse guides

Search documentation

API reference169
Guides118
Knowledge38
legal1
Solutions32
Workflows74
↑↓highlight↵openView all search results

Menu

Theme

Sign out

Your saved plans remain in your organization. This browser’s private draft and account view will be cleared.

Talk to an engineer