Show payment result

The YocoSDK.showPaymentResult() is an optional API flow that will show the user a success or error screen.

When calling the YocoSDK.showPaymentResult() method without passing in a ActivityResultLauncher callback, but rather handling the PaymentResult in the onActivityResult call instead, the PaymentResult will be assigned the PaymentResultInfo.RequestCode.LAST_TRANSACTION_RESULT_REQUEST value.

Usage

Before calling the YocoSDK.showPaymentResult() method, retrieve the PaymentResult by calling the YocoSDK.getPaymentResult() method. Pass the PaymentResult as parameter to YocoSDK.showPaymentResult() to show the user a success or error screen based on the state of the transaction.

If no users are authenticated, the login flow will start. Once completed, the payment flow will continue.

Showing a payment result
1import com.yoco.payments.sdk.YocoSDK
2import com.yoco.payments.sdk.data.result.PaymentResult
3import com.yoco.payments.sdk.data.params.PaymentParameters
4
5// Required:
6val paymentResult: PaymentResult = <Result from Yoco.getPaymentResult()>
7
8
9// Optional: Params containing additional for advanced functionality
10val params = PaymentParameters()
11
12// Initiating showing the Payment Result
13YocoSDK.showPaymentResult(
14 context = requireContext(),
15 paymentResult = paymentResult,
16 paymentParameters = params,
17 result = lastTransactionResult
18)

Handling the result

When calling the YocoSDK.showPaymentResult() method without a ActivityResultLauncher callback, when handling the PaymentResult in the onActivityResult call, the RequestCode will be assigned the PaymentResultInfo.RequestCode.REFUND_REQUEST value.

To handle the result using the ActivityResultLauncher contract, see how to handle the result.