Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Card Payment
  2. Bank Transfer (this is what is special:)


1. Add the dependency for the Monnify SDK

...

Code Block
languageactionscript3
themeMidnight
dependencies {
    // ...
    implementation 'com.teamapt.monnify.sdk:monnify-android-sdk:1.0.1819'
}

Remember to add Internet permission to application manifest:

actionscript3
Code Block
language
themeMidnight
<uses-permission android:name="android.permission.INTERNET" />

2. Create an instance of the Monnify SDK

...

Code Block
languageactionscript3
themeMidnight
val transaction = TransactionDetails.Builder()
            .amount(BigDecimal("2000"))
            .currencyCode("NGN")
            .customerName("Customer Name")
            .customerEmail("mail.cus@tome.er")
            .paymentReference("PAYMENT_REF")
            .paymentDescription("Description of payment")
            .incomeSplitConfig(arrayListOf<SubAccountDetails>())
            .build()
            
monnify.initializePayment(
            this@MainActivity,
            transaction,
            INITIATE_PAYMENT_REQUEST_CODE,
            KEY_RESULT)

...

Code Block
languageactionscript3
themeMidnight
TransactionDetails transaction = new TransactionDetails.Builder()
            .amount(new BigDecimal("2000"))
            .currencyCode("NGN")
            .customerName("Customer Name")
            .customerEmail("mail.cus@tome.er")
            .paymentReference("PAYMENT_REF")
            .paymentDescription("Description of payment")
            .build();

monnify.initializePayment(
        MainActivity.this,
                transaction,
                INITIATE_PAYMENT_REQUEST_CODE,
                KEY_RESULT);


5. Get the outcome of the payment attempt so that you can update application UI after payment gateway is closed.

This is done in the onActivityResult() method of your activity. Use the request code and data key passed in the initializePayment() method to get data returned by the SDK

...

TypeMeaning
PENDINGTransaction not paid for.
PAIDThe customer paid exact amount
OVERPAIDThe customer paid more than the expected amount.
PARTIALLY_PAIDThe customer paid less than the expected amount.
FAILEDTransaction completed unsuccessfully. This means no payment came in for Account Transfer method or attempt to charge card failed.
PAYMENT_GATEWAY_ERRORPayment tried but an error occurred on Monnify gateway

...


You can add sub-accounts to receive settlements for a particular transaction when initializing the transaction as shown below:

...

languageactionscript3
themeMidnight

...

Additional initializePayment parameters

Payment Methods specify transaction-level payment methods. Sub-Accounts are accounts that will receive settlement for the particular transaction being initialized. MetaData is map with single depth for any extra information you want to pass along with the transaction. See a sample below:


Kotlin

transaction = TransactionDetails.Builder()
            //...
            .incomeSplitConfig(arrayListOf<SubAccountDetails>(
                SubAccountDetails("MFY_SUB_319452883968", 10.

...

5f, BigDecimal("500"), true),
          

...

    

...

 

...

 SubAccountDetails("MFY_SUB_259811283666", 10.

...

5f, BigDecimal("1000"), false)
            ))
      

...

     

...

 

...

.metaData(hashMapOf(
                Pair("deviceType", "mobile_android"),
            

...

    Pair("ip", "127.168.22.98")
                // any other info
   

...

         ))
            .paymentMethods(arrayListOf<PaymentMethod>(
                add(PaymentMethod.CARD),
                add(PaymentMethod.ACCOUNT_TRANSFER)
            ))
            .build()

...

languageactionscript3
themeMidnight

...

 
TransactionDetails transaction = new TransactionDetails.Builder()
            //...
            .incomeSplitConfig(new ArrayList<SubAccountDetails>() {{ 
                add(new SubAccountDetails("MFY_SUB_319452883968", 10.

...

5f, new BigDecimal("500"), true)); 

...

 

...

 

...

 

...

             

...

add(new SubAccountDetails("MFY_SUB_259811283666", 10.

...

5f, new BigDecimal("1000"), false)); 
            }})
     

...

     

...

 

...

 

...

.metaData(new HashMap<String, String>() {{
                put("deviceType", "mobile_android");
                

...

put("ip", "127.168.22.98");
                // any other 

...

info
            }})
            .paymentMethods(new ArrayList<PaymentMethod>() {{
                add(PaymentMethod.CARD);
                add(PaymentMethod.ACCOUNT_TRANSFER);
            }})
            .build();

JAVA

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
cqllabel = "dynamic-accounts"

...