Usage

Rendering the Payment Form

Once you have generated an ecommerce entity on your backend and passed the ID to your Android app, render the payment form using render().

The form will consume the full width of its container. It is recommended to give the container a minimum height of 500dp.

Required Parameters

  • Name
    ecommerceId
    Type
    String
    Description

    A valid UUID identifying the ecommerce payment instance, generated via the Felloh API.

Throws IllegalArgumentException if the ecommerce ID is not a valid UUID.

The Render Method

payments.render(
    "550e8400-e29b-41d4-a716-446655440000"
);

Custom Pay Button

You can hide the built-in pay button and trigger payment from your own UI by setting payButton to false in PaymentDesign and calling the pay() method.

This is useful when you want to match your app's design language or add custom validation before submitting payment.

Custom Pay Button

PaymentOptions options = new PaymentOptions()
    .setDesign(
        new PaymentDesign(false, true)
    );

FellohPayments payments = new FellohPayments(
    container,
    "pk_live_YOUR_PUBLIC_KEY",
    options
);

payments.render("ecommerce-instance-uuid");

// Trigger from your own button
payButton.setOnClickListener(v -> {
    payments.pay();
});

Events

Register a PaymentEventListener to receive payment lifecycle events. All methods have default empty implementations, so you only need to override the ones you care about.

MethodFires when
onRender()The payment form finishes loading
onSuccess(TransactionData)Payment completes successfully
onDecline(TransactionData)Payment is declined
onProcessing(TransactionData)Payment is submitted and processing

Each callback receives a TransactionData object with a getTransactionId() method.

Event Listener

payments.setEventListener(
    new PaymentEventListener() {
        @Override
        public void onRender() {
            Log.d("Payment", "Form rendered");
        }

        @Override
        public void onSuccess(TransactionData data) {
            Log.d("Payment",
                "Success: " + data.getTransactionId()
            );
            // Navigate to confirmation
        }

        @Override
        public void onDecline(TransactionData data) {
            Log.d("Payment",
                "Declined: " + data.getTransactionId()
            );
            // Show error to user
        }

        @Override
        public void onProcessing(TransactionData data) {
            Log.d("Payment",
                "Processing: " + data.getTransactionId()
            );
            // Show loading indicator
        }
    }
);

Payment Status

You can check the current state of the payment form at any time via the getStatus() method.

StatusDescription
PRELOADThe form has not yet loaded
RENDEREDThe form is loaded and ready for input
PROCESSINGPayment has been submitted and is processing
SUCCESSPayment completed successfully
DECLINEDPayment was declined

Checking Status

PaymentStatus status = payments.getStatus();

switch (status) {
    case PRELOAD:
        Log.d("Payment", "Loading...");
        break;
    case RENDERED:
        Log.d("Payment", "Ready for payment");
        break;
    case PROCESSING:
        Log.d("Payment", "Processing...");
        break;
    case SUCCESS:
        Log.d("Payment", "Complete!");
        break;
    case DECLINED:
        Log.d("Payment", "Declined");
        break;
}

Cleanup

Call destroy() to remove the payment form and clean up resources. You should call this in your Activity or Fragment's onDestroy() lifecycle method.

Cleanup

@Override
protected void onDestroy() {
    super.onDestroy();
    payments.destroy();
}