Today mobile payments are being adopted all over the world in many different ways .If we’re building a mobile app for business, we’ll have to somehow accept payments in our application. For payment process various mobile payment gateways are generally being used. Now, there are a large number of payment gateways available in the market which can allow you to process credit card transaction data through their APIs. Paytab is one of the widely used payment gateway .
PayTabs providing the most secure, reliable and user-friendly payment process it is used in many businesses for the payment purpose. We can easily implement it in mobile application by using the Paytab android SDK provided by the Paytab . There are some simple step which we need to follow for integration –
1.Download the PayTabs android SDK
http://developers.paytabs.com/docs-apis/#android-sdk In this link you can find the android SDk and documentation for the same.
2.Add paytab SDK in your project as a module and add the Module dependency in your project. Extract the PayTabs Android SDK.zip and add the Paytabs_SDK.aar file to your project as a new module.For adding the dependency follow the step-
. Right click on your App and choose Open Module Settings.
. Go to Dependency and click on Module Dependency
. Choose the :PayTabs_SDK module to be included
3.Also add this dependency inside the build.gradle file-
compile ‘io.card:android-sdk:5.3.0’ .
Now we will launch the PayTabActivity activity from our payment activity, we do not need to declare PayTabActivity it already declared in PayTab SDk .We have to pass some data through intent which is required for the payment . There are lots of data which we need to send inPayTabActivity some of them are required and some are optional .
Here is the list of required data –
pt_merchant_email – Merchant email that you use to sign up and/or login into PayTabs Merchant Dashboard
pt_secret_key – SECRET Key generated by merchant dashboard this can be found by logging in to your Merchant Dashboard > Mobile Payments > Secret Key
pt_transaction_title – This is the customer name that will be displayed in the To field in your transaction details
pt_amount – The amount of the transaction
pt_currency_code – Currency of the amount stated.3 character ISO currency code
pt_shared_prefs_name – Provide the name of the shared folder between your App and PayTabs SDK
pt_customer_email – – Email of the customer
pt_customer_phone_number – Phone Number of the Customer
pt_order_id – The order id from your App to be able to map your order’s to PayTabs transactions
pt_product_name – Comma separated product names involved in the transactions
// Add customer Billing address Details //
pt_postal_code_billing – Billing Postal code provided by the customer. In case the country doesn’t have a valid postal code, you can pass the country international dialing code (00973)
// Add customer Shipping address Details //
pt_postal_code_shipping – Shipping Postal code provided by the customer. In case the country doesn’t have a valid postal code, you can pass the country international dialing code (00973)
Except these data the other are not required it is upto you that you want to send it or not.
For your reference i have added some code to pass the data in PayTabActivity .
Intent in = new Intent(MainActivity.this, PayTabActivity.class);
in.putExtra("pt_merchant_email", "[email protected]"); //this a demo account for
testing the sdk
MMImeN22kx6C9zZ");//Add your Secret Key Here
in.putExtra("pt_transaction_title", "Mr. John Doe");
in.putExtra("pt_currency_code", "USD"); //Use Standard 3 character ISO
in.putExtra("pt_shared_prefs_name", "myapp_shared"); // write a name of the shared folder between your App and PayTabs SDK
in.putExtra("pt_customer_email", "[email protected]");
in.putExtra("pt_product_name", "Samsung Galaxy S6");
in.putExtra("pt_timeout_in_seconds", "300"); //Optional
in.putExtra("pt_address_billing", "Flat 1,Building 123, Road 2345");
in.putExtra("pt_postal_code_billing", "00973"); //Put Country Phone code if Postal code not available '00973'//
in.putExtra("pt_address_shipping", "Flat 1,Building 123, Road 2345");
in.putExtra("pt_postal_code_shipping", "00973"); //Put Country Phone code if Postal
code not available '00973'
int requestCode = 0;
SDK returns two values in the response –
PayTabs Transaction ID (pt_transaction_id)
PayTabs Response Code (pt_response_code)
In the case of successful payment response code is 100 and if we are getting any other response code it means that the transaction has been rejected or payment is unsuccessful.
The Complete list of response codes and their description can be found in Merchant Dashboard > Help > Reason Codes.
To handle the response from SDK we you need to override Activity’s onActivityResult and Inside the onActivityResult function add the following code-
super.onActivityResult(requestCode, resultCode, data);
SharedPreferences shared_prefs = getSharedPreferences("myapp_shared", MODE_PRIVATE);
String pt_response_code = shared_prefs.getString("pt_response_code", "");
String pt_transaction_id = shared_prefs.getString("pt_transaction_id", "");
Toast.makeText(MainActivity.this, "PayTabs Response Code : " + pt_response_code,
Toast.makeText(MainActivity.this, "Paytabs transaction ID after payment : " +
For test the payment gatwatway –
PayTabs does not provide an explicit Sandbox / Testing environment. we can test all the functionalities by using a demo account . In the paytab website we can easily create a demo account and test the application in TEST Environment . Once you have completed the testing you will need to activate your LIVE MERCHANT ACCOUNT by clicking on GO LIVE through your PayTabs Merchant Account. If you activate your account as LIVE MERCHANT ACCOUNT you can not be able to put it as TEST ACCOUNT for this you need to contact with the support team of Paytab .
the link of paytab website for creating account is mentioned below –
To test your payment process, you can typically use any valid credit card number or you can use the ones listed below.
you can also refer their integration guide – https://www.paytabs.com/PayTabs_Android_SDK_V2.1.pdf
Thanks for reading .
Be the first to comment.