Mobile SDK
...
Transactions
Gratuity
3 min
built in flow when gratuity is enabled in your toroconfig , the ongratuityconfirmed callback will be triggered after the customer confirms a gratuity amount ongratuityconfirmed { amount, percentage in // amount is in the smallest unit of currency (e g , pence) // percentage is the whole number percentage (e g , 15 for 15%) let totalamount = amount + gratuityamount updatetotal(totalamount) } the gratuity menu will be shown on the miura device as soon as the device has connected after calling toro starttransaction() you can set whatever options you want using the toroconfig gratuitypercentages property, which takes a list of integers representing the gratuity percentages custom flow it is also possible to implement your own custom gratuity flow if the built in one does not meet your requirements it could either be a screen you show in your application before the transaction starts, or you could take advantage of the docid\ m1esz6odohs6ihc zimbj and display a menu on the miura device once the customer has selected a gratuity amount, you can call toro starttransaction() ensuring you pass in a transactionmetadata object with the gratuityamount set to the selected amount // create this when customer has confirmed gratuity amount let metadata = transactionmetadata( gratuityamount 100 // £1 00 ) toro starttransaction( amount 1000, // £10 00 total amount, £1 00 of which gratuity type purchase, currency gbp, metadata metadata, // other transaction parameters ) the amount parameter in starttransaction() must be the total amount of the transaction, including gratuity the ongratuityconfirmed callback is not applicable when using a custom gratuity flow
