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.
Add this to your project's gradle file
Add this in your app's build.gradle file
Add the following permission if not already
We recommend to initialize MedaPay configurations at app startup unless you have dynamic configurations.
MerchantInfo is optional you can configure without
The api key can be found in MedaPay developer portal.
Creating Payment Object
Pay object have Builder structure to initialize payment parameters
It is possible to add other payment properties in the builder like paymentOptions and callbackUrl
Payment can be started from Activity or Fragment, You need the Pay object as parameter which we see in the above example
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)
onActivityResult should be implemented in the calling activity or fragment to listen the results. There are three different resultCodes
RESULT_SCUCCESSwill be returned if the payment is successful on payment screen
RESULT_ERRORwill be returned if there is an error while opening the payment screen
RESULT_CLOSEDwill 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
- 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