Nabla Android Scheduling Payments

Add a payment step

If you enabled payments on the Nabla Console, you need to handle them by adding a step to the appointment booking process in the SDK.

The payment is handled by registering your own implementation of PaymentActivityContract. Check the Android documentation of ActivityResultContract.
This is the contract for your payment step Activity that the SDK will launch as a last step of booking a paid appointment.
Your Activity will receive details about the pending appointment (pending because waiting for payment). Typically, you’ll show a paywall on this Activity and handle the payment using the solution of your choice.

When the payment is done and your server has successfully called Nabla's REST API to mark the appointment as paid you can finish your Activity with result as [PaymentActivityContract.Result.Succeeded].

Here is an example of how to register a payment step.

class MyApp : Application() {
    override fun onCreate() {

        /* Basic Nabla SDK setup — you probably already call that */

        /* register your payments Activity as soon as possible and necessarily before user starts booking an appointment */
            object : PaymentActivityContract() {
                 * The intent to start MyPaymentActivity.
                override fun createIntent(context: Context, input: PendingAppointment): Intent {
                    return Intent(context, {
                        /* pass whatever info you need */

                 * Translate to Nabla's SDK what MyPaymentActivity finished with as result code and intent.
                override fun parseResult(resultCode: Int, intent: Intent?): Result {
                    return if (resultCode == RESULT_OK) Result.Succeeded else Result.ShouldRetry