Mobile SDK
...
Transactions
Purchase
3 min
starting a purchase once a device has been selected, you can start a transaction using the starttransaction method on your toroclient instance toro starttransaction( amount = 1000, // £10 00 type = transactiontype purchase currencycode = currencycode gbp, metadata = transactionmetadata( salereferenceid = "order 123", ), oncompleted = { receipt > // handle successful transaction println("transaction completed ${receipt transactionid}") }, oncancelled = { cancellationtype > when (cancellationtype) { cancellationtype attendant > println("transaction cancelled in app") cancellationtype customer > println("transaction cancelled on miura device") } }, onerror = { error > when (error) { is devicenotselected > handledeviceerror(error) is deviceconnectionfailed > reconnectdevice() is devicedisconnected > showreconnectionprompt() else > showerrormessage(error message) } }, ongratuityconfirmed = { gratuityamount, gratuitypercentage > // handle gratuity confirmation println("gratuity added £${gratuityamount / 100 0} ($gratuitypercentage%)") } )toro starttransaction( 1000, // £10 00 transactiontype purchase, currencycode gbp, new transactionmetadata( "order 123", 0, null, collections emptymap() ), result > { // handle successful transaction system out println("transaction completed " + result); return null; }, cancellationtype > { if (cancellationtype == cancellationtype attendant) { system out println("transaction cancelled in app"); } else if (cancellationtype == cancellationtype customer) { system out println("transaction cancelled on miura device"); } return null; }, error > { if (error instanceof toroexception devicenotselected) { handledeviceerror((toroexception devicenotselected) error); } else if (error instanceof toroexception deviceconnectionfailed) { reconnectdevice(); } else if (error instanceof toroexception devicedisconnected) { showreconnectionprompt(); } else { showerrormessage(error getmessage()); } return null; }, (gratuityamount, gratuitypercentage) > { // handle gratuity confirmation system out println("gratuity added £" + (gratuityamount / 100 0) + " (" + gratuitypercentage + "%)"); return null; } ); parameters true 153,289,104left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type
