Embed Felloh payment forms in your Android application.
Add the JitPack repository to your project's settings.gradle:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}Add the dependency to your app's build.gradle:
dependencies {
implementation 'com.github.felloh-org:android-sdk:1.0.0'
}Before using the SDK, you need to:
- Create an API key — Get your publishable key from the Felloh Dashboard.
- Create a booking — Use the Felloh API to create a booking.
- Create an ecommerce instance — Use the Felloh API to create an ecommerce instance for the booking. This must be done server-side using your private key.
// In your Activity or Fragment
FrameLayout container = findViewById(R.id.payment_container);
PaymentOptions options = new PaymentOptions()
.setEnvironment(Environment.SANDBOX);
FellohPayments payments = new FellohPayments(container, "pk_live_...", options);
payments.setEventListener(new PaymentEventListener() {
@Override
public void onSuccess(TransactionData data) {
Log.d("Payment", "Success: " + data.getTransactionId());
}
@Override
public void onDecline(TransactionData data) {
Log.d("Payment", "Declined: " + data.getTransactionId());
}
});
payments.render("ecommerce-instance-uuid");FellohPayments(ViewGroup container, String publicKey)
FellohPayments(ViewGroup container, String publicKey, PaymentOptions options)| Parameter | Type | Description |
|---|---|---|
container |
ViewGroup |
The view to embed the payment form in |
publicKey |
String |
Your publishable API key from the Felloh Dashboard |
options |
PaymentOptions |
Optional configuration (see below) |
PaymentOptions options = new PaymentOptions()
.setEnvironment(Environment.SANDBOX)
.setMoto(true)
.setDesign(new PaymentDesign(false, true));| Method | Type | Default | Description |
|---|---|---|---|
setEnvironment() |
Environment |
Environment.PRODUCTION |
Payment environment |
setMoto() |
boolean |
false |
Enable Mail Order/Telephone Order |
setDesign() |
PaymentDesign |
PaymentDesign() |
Form appearance options |
| Parameter | Type | Default | Description |
|---|---|---|---|
payButton |
boolean |
true |
Show the built-in pay button |
storeCard |
boolean |
true |
Show card storage option |
Render the payment form for a given ecommerce instance.
payments.render("550e8400-e29b-41d4-a716-446655440000");Throws IllegalArgumentException if the ecommerce ID is not a valid UUID.
Manually trigger payment processing. Use when the built-in pay button is hidden.
payments.pay();Returns the current PaymentStatus: PRELOAD, RENDERED, PROCESSING, SUCCESS, or DECLINED.
Remove the payment form and clean up resources. Call in your Activity/Fragment's onDestroy().
@Override
protected void onDestroy() {
super.onDestroy();
payments.destroy();
}Register a PaymentEventListener to receive payment lifecycle events:
payments.setEventListener(new PaymentEventListener() {
@Override
public void onRender() {
// Payment form is ready
}
@Override
public void onSuccess(TransactionData data) {
// Payment succeeded
}
@Override
public void onDecline(TransactionData data) {
// Payment declined
}
@Override
public void onProcessing(TransactionData data) {
// Payment is being processed
}
});All callbacks receive a TransactionData object with getTransactionId().
| Environment | Description |
|---|---|
Environment.PRODUCTION |
Live payments (default) |
Environment.STAGING |
Staging environment for testing |
Environment.SANDBOX |
Sandbox environment for testing |
- Android API 21+ (Android 5.0 Lollipop)
- Internet permission (added automatically by the SDK)
MIT