create Moment
Opens a Moment, a Forage-hosted page for a customer to complete a task (like entering their EBT Card PIN). It renders as a full screen over activity.
Only one moment can be open at a time. Cancelling the calling coroutine closes the moment.
// Example createMoment call in a Fragment
lifecycleScope.launch {
val result = ForageSDK().createMoment(
requireActivity(),
CreateMomentParams(
forageConfig = ForageConfig(merchantId, sessionToken),
moment = Moment.PaymentCollectPin(paymentRef = snapPaymentRef)
)
)
when (result) {
MomentResult.Completed -> // capture the payment from your server
MomentResult.Dismissed -> // the customer closed the moment
is MomentResult.Failed -> // handle result.error
}
}Content copied to clipboard
Return
A MomentResult. Failures are returned as MomentResult.Failed, not thrown.
Parameters
activity
The activity to show the moment over.
params
A CreateMomentParams model with the ForageConfig and the Moment to open.