Android SDK

Before using SDK, these setup must be completed

Process to integrate NeoX Payment Gateway

Implement permissions in AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        ...
        android:requestLegacyExternalStorage="true"
        >
        ...
    </application>

</manifest>

Implement NeoX SDK library in app/build.gradle

Download package here

dependencies {
    implementation(files("libs/neox-release.aar"))
    ...
}

Method to initialize payment request

import com.android.neox.*
...

class YOUR_ACTIVITY: AppCompatActivity() {
   private lateinit var yourPaymentBtn: Button
   
   override fun onCreate(savedInstanceState: Bundle?) {
      ...
      
      yourPaymentBtn.setOnClickListener {
         val paymentRequest = NeoXPaymentRequest(
             neo_ENV = "development environment" // Default is production. Supported sandbox|production. Ex: NeoXEnvironment.SANDBOX.env
             neo_MerchantCode = "merchant code",
             neo_SecureHash = "secret key",
             neo_Amount = "payment amount", // 10000
             neo_PaymentMethod = arrayOf("payment channel"), // Default is all channel. Payment methods WALLET|ATM|CC|QC
             neo_MerchantTxnID = "your transaction id", // size <= 36.
             neo_OrderID = "order_id || order_code",
             neo_OrderInfo = "order description", // size <= 256
             neo_Command = "command", // Supported commands are PAY, QUERY. Default is PAY. 
             neo_Currency = "payment currency", // Supported currencies are VND, USD. Default is VND.
             neo_Locale = "locale", // Supported locales are vi, en. Default is vi,
             neo_Version = "version", // Default is 1.
             neo_ReturnURL = "url address" // URL to return payment result.
         )
         NeoXPaymentHandler.paymentInitialize(this, paymentRequest)
      }
   }

  ...
 
}

Method to listen payment event

import com.android.neox.*
...

class YOUR_ACTIVITY: AppCompatActivity() {
   ...
   override fun onCreate(savedInstanceState: Bundle?) {
       ...
      
       NeoXPaymentHandler.setNeoXPaymentListener(object: NeoXPaymentListener {
            override fun onPaymentClose() {
                    // Your implementation
            }
            override fun onPaymentError(result: NeoXPaymentResult) {
                    // Your implementation
            }
            override fun onPaymentSuccess(result: NeoXPaymentResult) {
                    // Your implementation
            }
        })
   }

  ...
 
}

Method to custom Payment Gateway UI

import com.android.neox.*
...

class YOUR_ACTIVITY: AppCompatActivity() {
   ...
   override fun onCreate(savedInstanceState: Bundle?) {
      ...
      
      with(NeoXPaymentUtils) {
            useNeoXToolbar = false
            finishActivityOnComplete = true
            overridePaymentButton(NeoXPaymentButton(
                label = "Pay now",
                backgroundColor = "#fed07f",
                textColor = "#000",
                fontSize = 16,
                borderRadius = 24
            ))
            overridePaymentViewTitles(NeoXTitles(
                paymentGatewayTitle = "NeoX Payment Gateway",
                bankPaymentTitle = "Bank transfer",
                cardPaymentTitle = "ATM/Card payment",
                resultTitle = "Payment result"
            ))
        }
     }

  ...
 
}

Last updated