MedaPay Android SDK
MedaPay SDK can be used in your App to simplify payment for your customers. Your customers can choose to pay from Amole/Dashen Bank, CBE Birr/CBE, HelloCash/LionBank and mBirr/Multiple Microfinances.
Installation
Add this to your project's gradle file
Add this in your app's build.gradle file
Add the following permission if not already
Configuration
We recommend to initialize MedaPay configurations at app startup unless you have dynamic configurations.
Kotlin
or since MerchantInfo
is optional you can configure without MerchantInfo
Java
or
The api key can be found in MedaPay developer portal.
Creating Payment Object
Pay object have Builder structure to initialize payment parameters
Kotlin
Java
It is possible to add other payment properties in the builder like paymentOptions and callbackUrl
Start Payment
Payment can be started from Activity or Fragment, You need the Pay object as parameter which we see in the above example
Kotlin
Java
this
refers and Activity or Fragment
java onReferenceNumberGenerated(referenceNumber: String)
method will be invoked when a reference number is generated. You have to implement your own way to store the reference number so you can ask MedaPay the status of payment if the payment doesn't end in the screen. (Remember there are many ways to complete payment so you might not get the result from the screen)
Getting Result
onActivityResult
should be implemented in the calling activity or fragment to listen the results. There are three different resultCodes RESULT_SUCCESS
, RESULT_ERROR
and RESULT_CLOSED
RESULT_SCUCCESS
will be returned if the payment is successful on payment screenRESULT_ERROR
will be returned if there is an error while opening the payment screenRESULT_CLOSED
will be returned if the user closed the payment screen. If this result is returned after reference number generated means the user might finish the payment someway so you have to track this payment by the reference number
Mostly there are be two values returned in bundle. result and response. The result value is one of SUCCESS, CLOSED or ERROR and the response is JSON string which will differ based on the result.
Getting Payment Status
Here are scenarios of getting payment status
- Some payments options request pin on payment screen so the result can be fetched automatically from payment screen in this case you will get notified by
onActivityResult
- User close the payment screen and pay the bill another time or from another place using USSD you should track bill status your own
MedaPay provides a way to check payment status