Finpay   2.0.0

Publisher:
master@mainapi.net

API Documentation


Payment method yang disediakan oleh PT Finnet Indonesia meliputi pembayaran melalui transfer ATM dengan mekanisme payment code, dan pembayaran dengan menggunakan kartu kredit. Pengguna API ini harus terdaftar sebagai merchant PT Finnet.

To make a call to Finpay API, send HTTP request using the following details:

Base URL https://api.mainapi.net/finpay/2.0.0
Endpoint /messages
Header
  • (Optional) X-MainAPI-Username: <given username>
  • (Optional) X-MainAPI-Password: <given password>
  • (Optional) X-MainAPI-Senderid: <registered masking>
  • Accept: application/json
  • Content-Type: application/x-www-form-urlencoded
  • Authorization: Bearer <access token>
Body
  • msisdn=<phone number>
  • content=<message to send>
  Please login to try this API.

Finpay SDK

Finpay

Finpay is a payment methods provided by PT Finnet Indonesia including payment by ATM transfer with payment code mechanism, and payment by credit card. The user of this API must be registered as a PT Finnet merchant.

Getting started

Configure Repository Gradle

Configure repository gradle by following this:

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://dl.bintray.com/mainapi/SDK"
        }
    }
}

Dependency

Include the dependency in module gradle :

dependencies {
    implementation 'net.mainapi.sdk:core:1.0.0@aar'
    implementation 'net.mainapi.sdk:finpay:2.0.0@aar'
}

Installation

Define base URL, Key, and Secret using MainApiConfig, in your Application class in the onCreate() method.

@Override
public void onCreate() {
    super.onCreate();
    MainApiConfig.initDefault(new MainApiConfig
        .Builder()
        .with(getApplicationContext())
        .setBaseUrl("https://api.mainapi.net/")
        .setKeyAndSecret("YOUR_KEY", "YOUR_SECRET")
        .build());
}

Note: Key and Secret are obtained from MainAPI website in user account information on individual application page .

Usage

Post Finpay Transaction

To post finpay transaction you need to set required parameter as follows:

  • Amount: Transaction amount. In major units, for example 9 dollars 50 cents must be sent as 9.50 not 950
  • AuthKey: Registered Finnet merchant authentication key.
  • CartId: Transaction cart ID.
  • Currency: Currrency being used, for example IDR.
  • Description: Transaction description.
  • Method: The request method being used. Set as create to generate a new transaction or set as check to check a transaction status.
  • StoreId: Registered Finnet merchant store ID.
  • TestMode: Test mode indicator. 0 = Live, 1 = Test
  • UrlAuth: Callback URl for authorized transactions.
  • UrlCancel: Callback URL for cancelled transactions.
  • UrlDecline: Callback URl for declined transactions.
  • UrlUpdate: Callback URL for API call results.

See request example below:

Finpay finpay = new Finpay(MainActivity.this);
Request.Transaction transaction = new Request().new Transaction();
transaction.setAmount("1000");
transaction.setAuthKey("Q6ZLS~KHks^rwSX7");
transaction.setCartId(cartId); /*ex. XXI01234567*/
transaction.setCurrency("idr");
transaction.setDescription("Test Finpay");
transaction.setMethod("create");
transaction.setStoreId("19508");
transaction.setTestMode("0");
transaction.setUrlAuth("https://apidev.mainapi.net/finpay/auth.php");
transaction.setUrlCancel("https://apidev.mainapi.net/finpay/cancel.php");
transaction.setUrlDecline("https://apidev.mainapi.net/finpay/decline.php");
transaction.setUrlUpdate("https://apidev.mainapi.net/finpay/callback_ivp_update_url.php");

finpay.postFinpayTransaction(transaction, new FinpayTransactionCallbacks() {
    @Override
    public void onSuccess(@NonNull FinpayTransaction result) {
        Log.d("Success", "Ref no. " +  result.getOrder().getRef());
        webView.loadUrl(result.getOrder().getUrl());
    }

    @Override
    public void onFailure(@NonNull Throwable t) {
    }

    @Override
    public void onError(@NonNull JSONObject jsonError) {
    }
});

Note: This method will give you an Order Reference Number, this number can be used to check the transaction status.

Check Finpay Transaction

Check finpay transaction using Order Reference Number acquired after posting a transaction.
See request example below:

Finpay finpay = new Finpay(MainActivity.this);
Request.CheckTransaction checkTransaction = new Request().new CheckTransaction();
checkTransaction.setAuthKey("Q6ZLS~KHks^rwSX7");
checkTransaction.setMethod("check");
checkTransaction.setStoreId("19508");
checkTransaction.setOrderRef(orderRef);

finpay.checkFinpayTransaction(checkTransaction, new FinpayCheckTransactionCallbacks() {
    @Override
    public void onSuccess(@NonNull FinpayCheckTransaction result) {
        Log.d("Success", result.getOrder().getStatus().getText());
    }

    @Override
    public void onFailure(@NonNull Throwable t) {

    }

    @Override
    public void onError(@NonNull JSONObject jsonError) {

    }
});

  Please login to use this API.

Unlimited