Updated 31 December 2021
In this blog, we are going to learn about Paymob payment gateway integration in android with SDK approach.
Before starting integration first, we need to know what a payment gateway is.
A payment gateway is a merchant service provided by an e-commerce application service provider. Which authorizes card or direct payment processing.
Paymob payment gateway provides quick and secure online transactions. Paymob plays a vital role in the digital financial transformation initiatives sponsored by the Central Bank of Egypt which is set to transform Egypt’s financial inclusion landscape in the foreseeable future.
If you are interested in Paymob payment and want Paymob payment gateway integration in android with SDK then this blog will help you to do so.
Paymob payment gateway work on the below steps:
Download the SDK from the link.
Add the .aar files in the lib folder.
SDK PaymentForm provides the UI interface for payment. So you have to create or initialize the view.
We are using the Paymob PayActivity
that will contain the UI for payment. So we have to start the Activity for result like:
1 2 3 4 5 6 7 8 9 10 11 |
val pay_intent = Intent(mFragmentContext.context, PayActivity::class.java) pay_intent.putExtra(PayActivityIntentKeys.PAYMENT_KEY, "Payment key") pay_intent.putExtra(PayActivityIntentKeys.THREE_D_SECURE_ACTIVITY_TITLE, "Verification") pay_intent.putExtra(PayActivityIntentKeys.SAVE_CARD_DEFAULT, false) pay_intent.putExtra(PayActivityIntentKeys.SHOW_SAVE_CARD, false) pay_intent.putExtra(PayActivityIntentKeys.THEME_COLOR, mFragmentContext.requireContext().getResources().getColor(R.color.colorPrimary)) pay_intent.putExtra("ActionBar", true) pay_intent.putExtra("language", "en") mFragmentContext.startActivityForResult(pay_intent, RC_PAYMOB_REQUEST) val secure_intent = Intent(mFragmentContext.context, ThreeDSecureWebViewActivty::class.java) secure_intent.putExtra("ActionBar", true) |
Payment key is the the token generated from the server end. For more details please follow the link.
It’s time to handle the payment callback. ThreeDSecureWebViewActivty()
of payment, SDK is responsible for return callback to your app. Now, you have to get the data from the intent like :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == ConstantsHelper.RC_PAYMOB_REQUEST) { if (resultCode == IntentConstants.USER_CANCELED) { //User canceled } else if (resultCode == IntentConstants.MISSING_ARGUMENT) { //Missing the key arguments } else if (resultCode == IntentConstants.TRANSACTION_ERROR) { //Tansaction error } else if (resultCode == IntentConstants.TRANSACTION_REJECTED) { //Transaction rejected } else if (resultCode == IntentConstants.TRANSACTION_SUCCESSFUL) { //Payment success perform the next action } } } |
In this blog, you have learned about the Paymob payment gateway integration in android with SDK.
For more information regarding the Paymob payment gateway follow the link.
Thanks for reading this blog. You can also check other blogs from here.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.