You must receive a sample to learn how to use (CowPay SDK), and You can also know in this documentation how to add (CowPay SDK) to your application and how to use it -- you can find the updated sample in link below


Click here to download the latest SDK version.


1- Add (cowpaysdk.aar) file to you libs folder in app folder
2- In Project (build.gradle) you must add Kotlin Extension like:

dependencies {
   classpath ''
   classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41"
   // NOTE: Do not place your application dependencies here; they belong
   // in the individual module build.gradle files

3- in app (build.gradle) you must add those lines to top

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

Then add those dependencies

dependencies {
    //cowpaysdk dependencies must include all
    implementation files('libs/cowpaysdk.aar')
    implementation 'com.squareup.retrofit2:retrofit:2.7.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.2'
    implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
    //rx java,kotlin and android
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
    implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'
    //rx with retrofit
    implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    //LiveData & ViewModel
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
//    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
    implementation("com.squareup.okhttp3:okhttp:3.12.2") {
        force = true
    implementation "com.squareup.okhttp3:logging-interceptor:4.2.2"
    implementation "com.squareup.okhttp3:okhttp-urlconnection:4.4.1"
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation ''

4- in manifest file add those permissions

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">;
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE">;
<uses-permission android:name="android.permission.INTERNET">

5- To set SDK Language you can use:

//set locale language
var locale = CowpayConstantKeys.ENGLISH // or use CowpayConstantKeys. ARABIC
intent.putExtra(CowpayConstantKeys.Language, locale)
CowpayConstantKeys.LanguageCode = locale

6- For proguard-rules you can use:

// In proguard file add this line
-keep class me.cowpay.model.* {;}

7- For using the SDK on testing mode

var paymentEnvironment = CowpayConstantKeys.SandBox

//set environment production or sandBox
//CowpayConstantKeys.Production or CowpayConstantKeys.SandBox
intent.putExtra(CowpayConstantKeys.PaymentEnvironment, paymentEnvironment)

How to use Cowpay SDK features in Code

You must use intent extras to send merchant information, you can find merchant information required in Merchant Dashboard First identify intent to PaymentMethodsActivity

var intent = Intent(this@MainActivity,

//merchant data
intent.putExtra(CowpayConstantKeys().MerchantCode, "GHIu9nk25D5z")

Also, you will need an authorization token to be passed to the SDK required data which you can generate from API settings page in your cowpay dashboard than pass it as follows:

var authorizationToken = "YOUR-Authorization-Token"

intent.putExtra(CowpayConstantKeys.AuthorizationToken, authorizationToken)

And to send user Information, order price and order id

//order id
intent.putExtra(CowpayConstantKeys().MerchantReferenceId, "14")
//order price780
intent.putExtra(CowpayConstantKeys().Amount, "780")
//user data
intent.putExtra(CowpayConstantKeys().CustomerName, "John Smith")
intent.putExtra(CowpayConstantKeys().CustomerMobile, "01234567890")
intent.putExtra(CowpayConstantKeys().CustomerEmail, "")
//user id
intent.putExtra(CowpayConstantKeys().CustomerMerchantProfileId, "15")

Credit Card

If you want pay with Credit card only you must add data

//choose payment method
var PaymentMethod = ArrayList<String>()
intent.putExtra(CowpayConstantKeys().PaymentMethod, PaymentMethod)
// use pay with credit card
intent.putExtra(CowpayConstantKeys().CreditCardMethodType, CowpayConstantKeys().CreditCardMethodPay)

Pay at Fawry

If you want to use Pay with FAWRY

//choose payment method
var PaymentMethod = ArrayList<String>()
intent.putExtra(CowpayConstantKeys().PaymentMethod, PaymentMethod)

Show Both Payment Options

If you want to open available Payment Methods List in COWPAY to user, then he chooses what he wants to use

//choose payment method
var PaymentMethod = ArrayList<String>()
intent.putExtra(CowpayConstantKeys().PaymentMethod, PaymentMethod)

Receiving the payment result

To receive payment result, you can use OnActivityResult

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
   super.onActivityResult(requestCode, resultCode, data)
   if (requestCode == CowpayConstantKeys().PaymentMethodsActivityRequestCode && data != null && resultCode == Activity.RESULT_OK) {
       var responseCode = data.extras.getInt(CowpayConstantKeys().ResponseCode, 0)
       if (responseCode == CowpayConstantKeys().ErrorCode) {
           var responseMSG = data.extras.getString(CowpayConstantKeys().ResponseMessage)
           Toast.makeText(this@MainActivity, responseMSG, Toast.LENGTH_LONG)
       } else if (responseCode == CowpayConstantKeys().SuccessCode) {
           var responseMSG = data.extras.getString(CowpayConstantKeys().ResponseMessage)
           var PaymentGatewayReferenceId = data.extras.getString(CowpayConstantKeys().PaymentGatewayReferenceId)
           Toast.makeText(this@MainActivity," $PaymentGatewayReferenceId"), Toast.LENGTH_LONG)