Skip to content
payrocdevelopers

Add a tip

Add a predefined tip or a custom tip to a Tap to Pay on iPhone sale using the CoreTip object.

Prerequisites: Authentication · Run a sale

If you want to add a tip to a sale, you can add a tip that you've predefined in the terminal, or you can add a custom tip amount.

Note: A sale can include only one tip at a time. If you assign a predefined tip, it replaces any tip amount that you previously set, including a custom tip amount.

Add a predefined tip

You can use the SDK to add a tip that you've already set up in the terminal. Your predefined tips are available in terminal.settings.tipListArray. Each entry is a CoreTip with a tipType of either PERCENTAGE or FIXED_AMOUNT. You don't need to carry out any calculations. Our gateway automatically adds the tip amount for you.

Note: tipListArray can be empty if there are no predefined tips in your terminal. Check that a tip is available before you select one. To create a tip, go to Create a predefined tip on the Self-Care Portal.

In your app, let the customer choose which tip to apply to the sale. The following code selects the first tip in the list:

Swift

swift
if let tips = terminal.settings.tipListArray, tips.count > 0 {
    sale.tip = tips[0] as? CoreTip
}

Objective-C

objectivec
sale.tip = [[WTPSTerminal singleton] getSettings].tipListArray.firstObject;

The following example runs a complete sale with a predefined tip:

Swift

swift
guard terminal.getDevice() != NODEVICE else {
    return
}

let sale = CoreSale()
sale.amount = 42.00
sale.transactionInputMethod = TAP
sale.orderId = "YOUR_ORDER_REFERENCE"

if let tips = terminal.settings.tipListArray, tips.count > 0 {
    sale.tip = tips[0] as? CoreTip
}

terminal.processSale(sale)

Objective-C

objectivec
if ([[WTPSTerminal singleton] getDevice] == NODEVICE) {
    return;
}

CoreSale *sale = [[CoreSale alloc] init];
sale.amount = [NSNumber numberWithDouble:42.00];
sale.transactionInputMethod = TAP;
sale.orderId = @"YOUR_ORDER_REFERENCE";

sale.tip = [[WTPSTerminal singleton] getSettings].tipListArray.firstObject;

[[WTPSTerminal singleton] processSale:sale];

Add a custom tip

You can use the SDK to add a custom tip that's specific to each sale. The SDK accepts only an amount for a custom tip, and doesn't accept a percentage. To specify the value of the custom tip, use addTipWithAmount. The following example adds a tip amount of $5.00 to a sale:

Swift

swift
sale.addTip(withAmount: 5.00)

Objective-C

objectivec
[sale addTipWithAmount:@5.00];

The following example runs a complete sale with a custom tip:

Swift

swift
guard terminal.getDevice() != NODEVICE else {
    return
}

let sale = CoreSale()
sale.amount = 42.00
sale.transactionInputMethod = TAP
sale.orderId = "YOUR_ORDER_REFERENCE"
sale.addTip(withAmount: 5.00)

terminal.processSale(sale)

Objective-C

objectivec
if ([[WTPSTerminal singleton] getDevice] == NODEVICE) {
    return;
}

CoreSale *sale = [[CoreSale alloc] init];
sale.amount = [NSNumber numberWithDouble:42.00];
sale.transactionInputMethod = TAP;
sale.orderId = @"YOUR_ORDER_REFERENCE";
[sale addTipWithAmount:[NSNumber numberWithDouble:5.00]];

[[WTPSTerminal singleton] processSale:sale];

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