Payment Android UI Library for PayStack
Switch branches/tags
Nothing to show
Clone or download
Latest commit c0344b6 Nov 17, 2018

Pentecost - Payment Android UI Library for PayStack

Knightbenax Approved Platform Android Arsenal

Pentecost gives you a quick customizable PaymentView to use with PayStack. Simply show and hide as needed. Now supports Paystack payment with banks.


Why PayStack?

Why not PayStack? PayStack is currently one of the easiest and fastest way to receive payments. Their Android SDK gets you set up in a few minutes.


Add to your root build.gradle at the end of repositories

allprojects {
    repositories {
        maven { url '' }




implementation 'app.ephod.pentecost:pentecost:1.1.12'


For card payments, you are set from the go. Only payment with banks gets a little tricky. First you have to get the list of Paystack's supported banks to populate the banks spinner from here -

Populate the spinner

paymentView.setBanksSpinner(String[] arrayOfBanks)

Then you are all set. Pentecost handles the birthday field by showing a datepicker dialog when the user taps.

Handling OTP and Phone Token

Paystack's pay with bank is a three step process where the user is asked to input his/her OTP sent from the bank and then the token sent to the registered phone number with the paying account. Ideally you can show your own OTP and Phone Token views but since you already have the Paystack SDK added, we can just borrow views from there to use.

  1. Send bank details and birthday to server which then sends to Paystack.
  2. Save the reference gotten from the response and show the OTP view. Send response to your server. Your server hits Paystack
  3. You can save the reference again from the response or if you are hard guy, you can fetch the previously saved one. Show the Phone Token view. Send response to your server. Your server hits Paystack.

Paystack's OTP views makes use of sync locks to wait for user input, so you have to run in an asynctask.

private class BankOtpAsyncTask extends AsyncTask<Void, Void, String>{

        String reference, message;

        public BankOtpAsyncTask(String reference, String message){
            this.reference = reference;
            this.message = message;

        protected String doInBackground(Void... voids) {
            //this sets the message to show the user when the OTP view pops

            Intent intent = new Intent(Activity.this, OtpActivity.class);

            synchronized (otpSingleton){
                try {
                } catch (InterruptedException e) {
                    //showUniversalError("OTP Interrupted");

            return otpSingleton.getOtp();

        protected void onPostExecute(String otp) {
            if (otp != null) {
                //tell server. This is where we process the OTP/Phone Token entered
                sendBankOtpOrPhoneToken(reference, otp);
            } else {
                //showUniversalError("You did not provide an OTP");
                //showUniversalError("You did not provide a token");

and then

new BankOtpAsyncTask(reference,"Enter Bank Otp").execute();

The same can be done for the Phone Token.

Usage - XML

Define in XML


Set Theme


Set Background Drawable


Set Background Color


Set Header Image Src


Usage - Code Behind

Set Theme


Set Background Drawable


Set Background Color


Set Billable Header

This is line that describes the payment to the user. Can leave blank


Set Billable Amount

This shows the amount the user is paying, including the currency. This would be different from the value you would be sending to PayStack, which is in kobo


Set Card Number


Set CardCVV


Set Card Expiry Date


Get Card Number


Get CardCVV


Get Card Expiry Date


Get Selected Bank


Get entered Account Number


Get entered birthday (Paystack needs this for payments using banks)


Put PaymentView in loading mode

This can be used when the transaction is being made to PayStack or to indicate an initiated action is in progress


Remove PaymentView from loading mode


Get PaymentView Pay Button

This returns a Button. You can add a click listener to it and process events.


Set Pay Button listener

This sets the event that should fire when the user clicks the pay button either paying with card or bank. Pentecost already checks for empty views, so don't worry your action won't fire if user leaves the fields empty.

    paymentView.setChargeListener(new PaymentView.ChargeListener() {
            public void onChargeCard() {
                //Use Paystack's SDK chargeCard or whatever you want really.

            public void onChargeBank() {
                //send the bank details to your server
                //which then sends to Paystack's pay_with_bank api

            public void onSuccess() {

Using this library?

If you are using this library, you can give me a quick shoutout on Twitter with a link to your app and I would showcase here.