Mobile SDKs

WayaQuick — Android SDK

Android library with blocking and async calls for payments and payouts.

  • Android · Java
Installinclude ':wayapay'

The official Android SDK for WayaQuick. Accept payments, send payouts and verify accounts — built natively with Java, OkHttp and Gson.

#Requirements

  • Android minSdk 21+
  • Java 8+

#Installation

The SDK is a standard Android library module you can use locally without publishing. Add the wayapay module to settings.gradle:

Gradle
include ':wayapay'

Then add the dependency to your app module build.gradle:

Gradle
dependencies {
    implementation project(':wayapay')
}

#Setup

Java
import ng.wayapay.sdk.*;

WayaPayClient client = new WayaPayClient(
        "YOUR_MERCHANT_ID",
        "YOUR_API_SECRET_KEY",
        WayaPayEnvironment.DEVELOPMENT
);

You can also pass the environment as a string:

Java
WayaPayClient client = new WayaPayClient(
        "YOUR_MERCHANT_ID",
        "YOUR_API_SECRET_KEY",
        "production"
);

#Threading

Every method comes in a blocking and an asynchronous version:

  • Blocking methods return a WayaPayResult and must run off the main thread.
  • Async methods run on a background executor and return the result through a callback.
  • Switch back to the UI thread before updating views.

#Initialize payment

Starts a payment and returns a transaction ID and payment link.

Java
InitializePaymentRequest request =
        InitializePaymentRequest.builder()
        .currency("NGN")
        .amount(5000)
        .callBackUrl("https://yourapp.com/callback")
        .idempotencyKey("unique-key-123")
        .paymentRef("order-001")
        .metadata(
                PaymentMetadata.builder()
                .firstName("Ada")
                .lastName("Lovelace")
                .phoneNumber("08000000000")
                .emailAddress("ada@example.ng")
                .cancelUrl("https://yourapp.com/cancel")
                .build()
        )
        .build();

client.initializePaymentAsync(request, result -> {
    if (result.isSuccess()) {
        String txnId =
                result.getData()
                .get("transactionId")
                .getAsString();

        String link = client.paymentLinkFor(txnId);

        runOnUiThread(() -> openCheckout(link));
    } else {
        Log.e("WayaPay", result.getMessage());
    }
});

#Verify account & initiate payout

Always verify the destination account before sending a payout.

Java
VerifyAccountRequest verify =
        VerifyAccountRequest.builder()
        .accountNumber("0123456789")
        .bankCode("058")
        .build();

client.verifyAccountAsync(verify, vRes -> {
    if (!vRes.isSuccess()) return;

    InitiatePayoutRequest payout =
            InitiatePayoutRequest.builder()
            .currency("NGN")
            .amount(2500)
            .idempotencyKey("payout-key-456")
            .bankCode("058")
            .accountNumber("0123456789")
            .build();

    client.initiatePayoutAsync(payout, pRes -> {
        // handle payout result
    });
});

#Verify transaction

Gets the current status of a transaction by its reference.

Java
client.verifyTransactionAsync("TXN_REF", res -> {
    // handle response
});

#Fetch bank list

Returns every supported bank and its code.

Java
client.fetchBankListAsync(res -> {
    // handle response
});

#Handling responses

Every method returns a WayaPayResult<JsonObject> with the status, data, message, code and raw response.

Java
client.verifyTransactionAsync("TXN_REF", result -> {
    if (result.isSuccess()) {
        System.out.println(result.getData());
    } else {
        System.out.println(result.getMessage());
    }
});

#Environments

ValueDescription
developmentTest environment
devTest environment
productionLive environment
prodLive environment

#Project structure

Java
wayapay-android/
├── settings.gradle
├── build.gradle
├── gradle.properties
└── wayapay/
    ├── build.gradle
    ├── consumer-rules.pro
    ├── proguard-rules.pro
    └── src/
        ├── main/
        │   ├── AndroidManifest.xml
        │   └── java/ng/wayapay/sdk/
        │       ├── WayaPayClient.java
        │       ├── WayaPayEnvironment.java
        │       ├── WayaPayResult.java
        │       ├── WayaPayCallback.java
        │       ├── PaymentMetadata.java
        │       ├── InitializePaymentRequest.java
        │       ├── InitiatePayoutRequest.java
        │       └── VerifyAccountRequest.java
        └── test/java/ng/wayapay/sdk/
            ├── WayaPayClientTest.java
            └── TestClient.java

#Cleanup

Call close() when you're done with the SDK, for example in onDestroy(), to shut down its background executor.

Java
@Override
protected void onDestroy() {
    client.close();
    super.onDestroy();
}