Handling Payment Result
Every returning intent will return a serializable PaymentResult
object. It can be retrieved from the Intent data by using the PaymentResultInfo.ResultKeys.Transaction
key.
Parameters
clientTransactionId: String
- a unique identifier of this payment.amountInCents: Long
- The amount charged initially for the payment (the bill amount)tipInCents: Long
- The tip amount offered by the cardholdercurrency: SupportedCurrency
- currency that was usedfinalAmountInCents: Long
- The total amount charged from the cardholder (bill amount + tip amount)paymentType: PaymentType
- type of payment that was donestaffMember: YocoStaff?
- Optional: staff member performing the transactionuserInfo: Map<String, Any>?
- (Optional) user info map containing additional user info that is returned based on what was passed in if anyerrorMessage: String?
- (Optional) (Optional) error message when transaction fails/cancels/aborts
Response Result Codes
Every returning intent will pass back a result code which will provide specific info on the result of the transaction.
Result Code | Value |
---|---|
PaymentResultInfo.ResultCode.SUCCESSFUL | 1 |
PaymentResultInfo.ResultCode.IN_PROGRESS | 2 |
PaymentResultInfo.ResultCode.ERROR_TRANSACTION_FAILED | 3 |
PaymentResultInfo.ResultCode.ERROR_CANCELLED | 4 |
PaymentResultInfo.ResultCode.ERROR_PERMISSION_DENIED | 5 |
PaymentResultInfo.ResultCode.ERROR_NO_CONNECTIVITY | 6 |
PaymentResultInfo.ResultCode.ERROR_INVALID_TOKEN | 7 |
PaymentResultInfo.ResultCode.ERROR_BLUETOOTH_DISABLED | 8 |
PaymentResultInfo.ResultCode.ERROR_REFUND_FAILED | 9 |
PaymentResultInfo.ResultCode.ERROR_TRANSACTION_LOOKUP_FAILED | 10 |
PaymentResultInfo.ResultCode.ERROR_TRANSACTION_NOT_FOUND | 11 |
PaymentResultInfo.ResultCode.ERROR_PRINT_FAILED | 12 |
PaymentResultInfo.ResultCode.ERROR_TIMED_OUT | 13 |
Usage
After a successful or failed payment from YocoSDK.charge() flow an Intent result will be returned, containing info related to the transaction.
The standard way of handling an intent result:
Alternative Usage
So there is a new way to handle intent results, by using the Activity Results API with androidx.
Required Dependencies:
Instantiate the result contract, which may be passed to the YocoSDK
as the result. There is no need to use the request code, as we tie the contract to the charge()
implementation.