Mobile SDK
iOS
Transactions
7 min
states these are the possible states when processing a docid\ mkssy1onfv6v3fuyrrt3m or docid\ gtbwf4c5p 1eyuv 2busw public enum transactionstate { /// transaction is idle and ready to start case ready /// attempting connection to the toroclient selecteddevice case connectingtodevice /// awaiting confirmation of gratuity amount from the customer /// only applicable if toroconfig gratuityenabled is true case awaitinggratuity /// awaiting customer to present card on any interface (contact, contactless, magswipe) case awaitingcard /// awaiting customer signature (in app or on device) /// seealso toroconfig signaturemode case awaitingsignature /// awaiting cardholder to enter pin on the ped case awaitingpinentry /// awaiting cardholder to confirm application to use for transaction case awaitingapplicationselection /// contacting the gateway to authorise the transaction case authorising /// transaction was completed successfully and an outcome was received (approved/declined) case completed /// transaction was cancelled by the user or operator case cancelled /// transaction failed due to an error case failed } transaction state listener to receive transaction state updates, you can implement the transactionstatelistener and register it with the toroclient instance class mytransactionstatelistener transactionstatelistener { var currenttransactionstate transactionstate = ready func ontransactionstatechanged( state torosdk transactionstate) { currenttransactionstate = state } } alternatively, you can use the transactionstate property on the toroclient instance to check the current state of the transaction let transactionstate = toro transactionstate metadata the transactionmetadata class allows you to include additional information with docid\ mkssy1onfv6v3fuyrrt3m or docid\ gtbwf4c5p 1eyuv 2busw public struct transactionmetadata { / custom id for the transaction this id will be returned in the `transactionreceipt` max length is 35 characters / let salereferenceid string? / the gratuity amount for the transaction the gratuity amount is added to the transaction amount specified in starttransaction() this is useful if you are wanting to use a custom gratuity flow outside of the sdk setting this will result in an error if gratuity is enabled in toroconfig / let gratuityamount int? / any other additional data you want returned in the `transactionreceipt` this data will be sent in the `acceptorauthorisationrequest` accptrauthstnreq/authstnreq/tx/txdtls/addtlinf / let additionalinformation \[string any?]? / details of the original transaction that is being refunded not applicable for purchases / let originaltransactiondetails originaltransactiondetails? } cancelling an in progress transaction to cancel an in progress docid\ xftyvcscnepqsmjfz6o4a or docid\ ezdh0uhdpd1bvbgcddqio , you can call the canceltransaction method on the toroclient instance toro canceltransaction() this will also close the bluetooth session with the miura device if it is open signatures the sdk provides two different methods for collecting cardholder signatures the method used depends on the signaturemode set in the toroconfig see docid\ h18 v1clry140imrfldm for more information signaturemode device the signature will be captured on the miura device this is only applicable to devices which have a touch screen (e g , m021) signaturemode app the signature will be captured in the app through the sdks built in signatureview in both cases, signatures are requesed automatically by the sdk when the transactionstate is awaitingsignature no additional configuration is required in your app for it to work receipt public struct transactionreceipt { / unique reference number to identify the transaction can be set in transactionmetadata / public let salereferenceid string? / the total amount of the transaction represented in the smallest unit of the currency, e g cents for usd, pence for gbp / public let amount int / the amount of the transaction that was authorised by the acquirer in most cases the same as amount, but can differ e g partial approvals / public let authorisedamount int? / the type of transaction purchase, refund / public let type transactiontype / gratuity amount confirmed by the customer this can be set either through transactionmetadata or when toroconfig gratuityenabled is set to true and the built in gratuity flow is used / public let gratuityamount int / the currency of the transaction / public let currency currencycode / the authorisation code set by the acquirer / public let authcode string? / the result of the authorisation (acquirer decision) typically approved or declined / public let responsecode responsecode / the reason for the responsecode / public let responsereason string? / cardholder verification method / public let authenticationmethod authenticationmethod8? / additional response information (from gateway or acquirer) / public let additionalresponseinformation string? / also known as the authorisation response code emv tag 8a set by the acquirer / public let actioncode string? / application identifier of the card that was presented / public let aid string? / application label of the card that was presented / public let applicationlabel string? / the payment interface used to process the transaction e g contactless / public let paymentinterface paymentinterface / the first 6 or 8 digits of the primary account number (pan) aka bank identification number (bin) / public let panstart string? / the last 4 digits of the primary account number (pan) / public let panlastfour string? / identifier set by the recipient (acquirer) to reference the transaction this can be the same as the initiatortransactionid depending on the acquirer / public let recipienttransactionid string? / identifier set by the initiator (merchant) to reference the transaction the toro sdk handles this internally and cannot be overridden by the host application / public let initiatortransactionid string? / unique identification of the transaction assigned by the poi (point of interaction) / public let transactionreference string? / the date and time the transaction occurred in iso 8601 format / public let datetime string? / the serial number of the terminal the transaction was processed on / public let terminalserialnumber string / cardholder signature base64 encoded if applicable / public let signaturebase64 string? / indicates whether the signature verification failed, either due to merchant rejection or customer cancellation during signature entry / public let signatureverificationfailed bool / whether the transaction was captured by the acquirer / public let captured bool / the latitude of the device at the point of transaction / public let longitude string? / the longitude of the device at the point of transaction / public let latitude string? / the custom data set in transactionmetadata / public let additionalinformation \[string any?]? }
