Add the library into an Android project

1. Put the aar file under /app/libs
2. Add these repositories into build.gradle of app

mavenCentral()
maven { url 'https://jitpack.io' }

3. add these dependencies into build.gradle of project

// Payment API
implementation(name: 'app-release', ext: 'aar')
// Networking
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
// Permission Handler
implementation 'com.github.Redman1037:Android-Permissions:3.8'

Using the library for payment for Android App

1. Create an Payment object with Activity. The apiURL will be provided during account opening.

SpiralPayment payment = new SpiralPayment(activity, apiURL);

2. (Optional, for Octopus only) Call the “isOctopusAppInstalled” method to check whether the smartphone has the Octopus App. If not, ask the user to download it. Otherwise, PaymentStatus “APP_NOT_INSTALLED” will be returned when the “pay” method is called

if (!payment.isOctopusAppInstalled()) {
    ToastUtils.showLong("Please download Octopus App");
    payment.openGooglePlay2DownloadOctopusApp();
    return;
}


3. Call the “pay” method with a session ID and a PaymentResultCallback callback

payment.pay(sessionId, new PaymentResultCallback() {
    @Override
    public void onFinish(PaymentResult paymentResult) {
        // do something
    }

Class Definition

PaymentResult

FieldTypeSample
sessionIdStringMPGSSESSION0002121895830J8251291G62
paymentStatusPaymentStatusAPPROVED

  PaymentStatus

ValueRemark
APPROVED 
CANCELLED 
DECLINED 
NOT_SUPPORTED 
UNCONFIRMEDUnable to determine the result and need to make further query at backend
QUERY_FAILEDCannot get the required transaction information by the session ID.
The transaction is not initialed on the payment APP.
APP_NOT_INSTALLEDFor Octopus, which means the Octopus App is not installed