Introduction
The official Android SDK for integrating the payment gateway into your native Android application. This SDK provides a seamless in-app checkout experience by handling API communication and rendering the checkout page securely.
Installation
Add the SDK to your project using Gradle and JitPack.
Step 1: Add JitPack Repository
Add the JitPack repository to your project's root settings.gradle.kts file.
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
// Add JitPack repository
maven { url = uri("https://jitpack.io") }
}
}
Step 2: Add the SDK Dependency
Add the following line to your `app/build.gradle.kts` file. Make sure to use the latest version available.
// app/build.gradle.kts
dependencies {
// ... other dependencies
// Secure Soft Pay SDK (Use the latest version tag from GitHub)
implementation("com.github.SecureSoftPay:SecureSoftPay-Official-AndroidSDK:1.3.0")
}
Usage Guide (Java)
The developer is responsible for creating the UI to collect payment information. The SDK's role is to take that information and handle the payment process securely.
Step 1: Initialize the SDK
Initialize the SDK once when your application starts (e.g., in your Application class). You must provide your API Key, Base URL, and the full Endpoint URLs from your "API Settings" page.
// In MyApp.java (Your Application class)
import android.app.Application;
import com.securesoft.pay.SecureSoftPay;
import com.securesoft.pay.SecureSoftPayConfig;
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
String apiKey = "YOUR_SECRET_API_KEY_FROM_DASHBOARD";
String baseUrl = "https://your-domain.com/api"; // Base URL from API Settings
String checkoutUrl = "https://your-domain.com/api/v1/checkout"; // Payment Initiation Endpoint
String verifyUrl = "https://your-domain.com/api/v1/verify"; // Verify Payment Endpoint
SecureSoftPayConfig config = new SecureSoftPayConfig(
apiKey,
baseUrl,
checkoutUrl,
verifyUrl
);
SecureSoftPay.initialize(config);
}
}
Step 2: Start a Payment
From your UI (e.g., an Activity), collect the payment details, create a PaymentRequest object, and call startPayment.
// In your Activity (e.g., on a "Pay Now" button click)
import com.securesoft.pay.PaymentRequest;
import com.securesoft.pay.PaymentResultListener;
import com.securesoft.pay.SecureSoftPay;
// Assume you have EditTexts for amount, name, and email
// double amount = Double.parseDouble(amountEditText.getText().toString());
// String name = nameEditText.getText().toString();
// String email = emailEditText.getText().toString();
PaymentRequest request = new PaymentRequest(
amount,
name,
email
);
SecureSoftPay.startPayment(this, request, new PaymentResultListener() {
@Override
public void onSuccess(String transactionId) {
// Payment was successful!
// Update your UI and verify the order on your own server.
Toast.makeText(YourActivity.this, "Success! TrxID: " + transactionId, Toast.LENGTH_LONG).show();
}
@Override
public void onFailure(String errorMessage) {
// Payment failed or was cancelled.
Toast.makeText(YourActivity.this, "Failure: " + errorMessage, Toast.LENGTH_LONG).show();
}
});