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 = { gratuityamount, gratuitypercentage > // gratuityamount is in the smallest unit of currency (e g , pence) // gratuitypercentage is the whole number percentage (e g , 15 for 15%) val 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 an activity you show in your application before the transaction starts, or you could take advantage of the docid\ hqspji6i6fch0dhijkvb7 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 val metadata = transactionmetadata( gratuityamount = 100 // £1 00 ) toro starttransaction( amount = 1000, // £10 00 total amount, £1 00 of which gratuity type = transactiontype purchase, currencycode = currencycode gbp, metadata = metadata, // other transaction parameters ) // create this when customer has confirmed gratuity amount transactionmetadata metadata = new transactionmetadata( null, 100, // £1 00 null, collections emptymap() ); toro starttransaction( 1000, // £10 00 total amount, £1 00 of which gratuity transactiontype purchase, currencycode gbp, 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
