Showing Payment Result
When calling YocoSDK.showPaymentResult()
without passing in a ActivityResultLauncher
and handling the PaymentResult
in onActivityResult
, it will be assigned the PaymentResultInfo.RequestCode.LAST_TRANSACTION_RESULT_REQUEST
code
The YocoSDK.showPaymentResult()
is an optional API flow that will show the user a success or error screen.
Parameters
context: Context
- The calling Activity/Fragment initiating the paymentpaymentResult: PaymentResult
- result returned from [YocoSDK.getPaymentResult()
]paymentParameters: PaymentParameters
- (Optional) Provides additional info regarding the paymentreceiptDelegate: ReceiptDelegate?
- (Deprecated) Receipt screen callback handler and util
result: ActivityResultLauncher<Intent>?
- (Optional) activity result handler contract to handle intent result
The context
that is passed as a parameter MUST be calling activity/fragment's context and NOT the application context.
Usage
Before calling the SDK showPaymentResult()
method, you will first need to retrieve the PaymentResult
from the SDK getPaymentResult()
, which can then be passed as a parameter to show the user a success or error screen based on that transaction.
import com.yoco.payments.sdk.YocoSDK
import com.yoco.payments.sdk.data.result.PaymentResult
import com.yoco.payments.sdk.data.params.PaymentParameters
// Required:
val paymentResult: PaymentResult = <Result from Yoco.getPaymentResult()>
// Optional: Params containing additional for advanced functionality
val params = PaymentParameters()
// Initiating showing the Payment Result
YocoSDK.showPaymentResult(
context = requireContext(),
paymentResult = paymentResult,
paymentParameters = params,
result = lastTransactionResult
)
If no user has logged in, you WILL be prompted to login using your Yoco account details. If successful, it will continue to the payment flow.