Collect Android Widget enables you to embed Collect's checkout into your Android Mobile applications, allowing your users to choose their preferred payment method and be redirected to its authorization process without needing to go into Collect's hosted checkout.
- Retrieve your Client Public API Keys from here.
- Create a sandbox customer, so you can get connecting immediately.
- Android Studio 3.5.X and above
Add the following lines to your project level build.gradle
:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the following lines to your app level build.gradle
:
dependencies {
implementation 'com.github.Collect-Africa:collect-widget-android:v1.0'
}
Head over to your project AndroidManifest.xml and add the uses-permission
line below
<uses-permission android:name="android.permission.INTERNET" />
Initialize the SDK:
new CollectWidget().CollectCheckout(
"[email protected]", //customer email | required
"John", //customer first name | required
"Doe", //customer last email | required
generateRef(), // your payment reference | required
10000, // Amount in Kobo | required
"NGN", // Currency
"", // itemImage | optional
Enviroment
.SANDBOX, // [ Enviroment.SANDBOX,Enviroment.LIVE ] | required
"your_collect_africa_public_key" // your collect Africa publickey )
.build(Activity, new OnClose() {
@Override
public void OnClose() {
//Widget Closed
}
},
new OnFailed() {
@Override
public void OnFailed(
String msg) {
//payment failed
Toast.makeText(activity,
msg,
Toast
.LENGTH_LONG
)
.show();
}
},
new OnSuccess() {
@Override
public void OnSuccess(
String reference,
int amount) {
// payment successful!
Toast.makeText(activity,
msg,
Toast
.LENGTH_LONG
)
.show();
}
});
For enquires and questions, contact @Astrocodr