Info !!! To get started, you need to download the latest version of our JAVA package. Download
Warning !!!
For your tests, connect to the test platform instead. Connection to the test platform
By registering on the test platform, your test account will be credited with100.000 Fcfa. This will allow you to easily complete the integration tests before going into production.
By registering on the test platform, your test account will be credited with100.000 Fcfa. This will allow you to easily complete the integration tests before going into production.
Once done, follow these steps :
- Decompress the file
.zip
- Copy the file
pay-android-gateway-release.aar
in the folderlibs
of your application - Open the file
build.gradle
of your application and modify the lineimplementation fileTree(dir: 'libs', include: ['*.jar'])
to haveimplementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
- Still in the file
build.gradle
, add in the blockdependencies
the lines below :implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
implementation 'com.squareup.okio:okio:2.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
- Perform a
gradle build
to update your application
Info !!! At this point, your application is ready to use our plugin
Now open the activity or fragment where the payment will take place.
Once done, follow these steps:
-
- Declare the
request code
and plugin configuration variables by copying and pastingprivate static final int PLUS_PAYMENT_ACTIVITY_RESULT = 1102; // The plugin request code (do not change its value)
private Pay_Setup RequestSetup, ResponseSetup;
- Declare the
-
- Initialize the plugin by copying and pasting
String appName = "name of your mobile app";
RequestSetup = new Pay_Setup(); // initialization of the setup variable for sending
ResponseSetup = new Pay_Setup(); // initialization of the setup variable for the response
RequestSetup.setApi_public_key("Master key generated during the creation of your application");
RequestSetup.setApi_token("Token generated during the creation of your application");
// Definition of the mode of use. Either 'test' or 'live', example : RequestSetup.setMode("live") ou RequestSetup.setMode("test")
RequestSetup.setMode(" How your application works");
- Initialize the plugin by copying and pasting
RequestSetup.setMethod(0);
-
- Suppose your customer has purchased two items. To add these two articles to the
setup
, do like this :RequestSetup.addInvoiceitem(new Pay_InvoiceItem("Jean Gucci", 3, 150, 450, "Jean bleu, de marque Gucci"));
RequestSetup.addInvoiceitem(new Pay_InvoiceItem("Jean Prada", 2, 100, 200, "Jean noir, de marque Prada"));
- Suppose your customer has purchased two items. To add these two articles to the
Class prototype
Pay_InvoiceItem(String name, double quantity, double unit_price, double total_price, String description) où :
name : Item name
quantity : item quantity
unit_price : unit price of the item
total_price : total price of the item
description : description of the item purchased or other item details
Pay_InvoiceItem
Pay_InvoiceItem(String name, double quantity, double unit_price, double total_price, String description) où :
name : Item name
quantity : item quantity
unit_price : unit price of the item
total_price : total price of the item
description : description of the item purchased or other item details
-
- To add the total and the description of the invoice, do like this :
RequestSetup.setDescription("Purchase of "+ RequestSetup.getInvoiceItems().size()+" item(s) for "+RequestSetup.getTotal_amount()+" franc(s) in "+appName );
RequestSetup.setTotal_amount(650); // allows to indicate the total amount of the invoice. this amount will be deducted from the customer
- To add the total and the description of the invoice, do like this :
-
- To start the payment process, do like this :
Intent PaymentActivity = new Intent(getApplicationContext(), pay_payment_activity.class);
Bundle PaymentActivitySetup = new Bundle();
PaymentActivitySetup.putParcelable("setup",RequestSetup);
PaymentActivity.putExtras(PaymentActivitySetup);
startActivityForResult(PaymentActivity, PAY_PAYMENT_ACTIVITY_RESULT);
- To start the payment process, do like this :
- To recover the result of the payment process, do like this :
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PAY_PAYMENT_ACTIVITY_RESULT && resultCode == RESULT_OK) {
Bundle PaymentActivitySetup = data.getExtras();
Pay_GetReport report = PaymentActivitySetup.getParcelable("report");
ResponseSetup = PaymentActivitySetup.getParcelable("setup");
switch (report.getResponse_code()){
case "00":
if(report.getStatus() == "completed"){
// write your successful payment code here
Toast.makeText(getApplicationContext(),"Succes", Toast.LENGTH_SHORT).show();
}else{
//write your failed payment code here
Toast.makeText(getApplicationContext(),"Echec", Toast.LENGTH_SHORT).show();
}
// to recover the token of this transaction, do ResponseSetup.getInvoiceToken();
break;
default:
//write your failed payment code here
Toast.makeText(getApplicationContext(),"Echec", Toast.LENGTH_SHORT).show();
// failure pattern display
Toast.makeText(getApplicationContext(),""+report.getResponse_text(),Toast.LENGTH_SHORT).show();
// to recover the token of this transaction, do ResponseSetup.getInvoiceToken();
break;
}
}
}