All Projects → knightbenax → Pentecost

knightbenax / Pentecost

Licence: MIT License
Payment Android UI Library for PayStack

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Pentecost

cashier-paystack
Cashier provides an expressive, fluent interface to Paystack's subscription billing services.
Stars: ✭ 44 (+100%)
Mutual labels:  payment, paystack
angular4-paystack
💵 An angular2+ module for paystack transactions
Stars: ✭ 51 (+131.82%)
Mutual labels:  payment, paystack
flutter paystack
💳 A robust Flutter plugin for making payments via Paystack Payment Gateway. Completely supports Android and iOS
Stars: ✭ 146 (+563.64%)
Mutual labels:  payment, paystack
EPAYMENT
EPayment - Multi Payment Provider for .Net Core
Stars: ✭ 43 (+95.45%)
Mutual labels:  payment
paymentgateway
Dokumentace ČSOB platební brány a jejího eAPI pro platby platebními kartami, Apple Pay, mallpay a platebními tlačítky ČSOB.
Stars: ✭ 104 (+372.73%)
Mutual labels:  payment
FinanceKit
FinanceKit is a Framework for iOS and Mac to build apps working with financial data, like money, currencies, stocks, portfolio, transactions and other concepts.
Stars: ✭ 15 (-31.82%)
Mutual labels:  payment
spring-boot-payment-starter
google play 和 appstore 服务端支付校验
Stars: ✭ 21 (-4.55%)
Mutual labels:  payment
PayumYiiExtension
Rich payment solutions for Yii framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
Stars: ✭ 13 (-40.91%)
Mutual labels:  payment
AndroidSDK
Paycom Android SDK
Stars: ✭ 22 (+0%)
Mutual labels:  payment
wechat-payment
微信支付Node.js基础工具库
Stars: ✭ 26 (+18.18%)
Mutual labels:  payment
pagarme-go
Pagar.me library in Go
Stars: ✭ 13 (-40.91%)
Mutual labels:  payment
stripe-update-card
💳 Expose a page that let your customers update their payment information on Stripe.
Stars: ✭ 16 (-27.27%)
Mutual labels:  payment
stencil-payment
Payment request API implementation in Stenciljs
Stars: ✭ 28 (+27.27%)
Mutual labels:  payment
adyen-dotnet-api-library
Adyen API Library for .NET
Stars: ✭ 69 (+213.64%)
Mutual labels:  payment
zarinpal-laravel
Zarinpal payment for Laravel Framework
Stars: ✭ 31 (+40.91%)
Mutual labels:  payment
paydash
Worker payments dashboard for MGNREGA
Stars: ✭ 44 (+100%)
Mutual labels:  payment
laravel-multi-payment
Laravel online gateway payment package with multi driver support
Stars: ✭ 22 (+0%)
Mutual labels:  payment
awesome-payment
A curated list of payment services
Stars: ✭ 22 (+0%)
Mutual labels:  payment
awesome-ecommerce
Collect and develop Open Source or Free Projects for building ecommerce platform easy and fast and free
Stars: ✭ 39 (+77.27%)
Mutual labels:  payment
woocommerce-otpbank-payment-gateway
WooCommerce Payment Gateway for OTP Bank (Hungary)
Stars: ✭ 20 (-9.09%)
Mutual labels:  payment

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.

Screenshot

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.

Installation

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

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
        ...
    }
}

Maven

<dependency> 
    <groupId>com.github.knightbenax</groupId>
    <artifactId>pentecost</artifactId> 
    <version>1.1.15</version> 
</dependency>

Gradle

implementation 'com.github.knightbenax:Pentecost:1.1.15'

Setup

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 - https://api.paystack.co/bank?gateway=emandate&pay_with_bank=true

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;
        }

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

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

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


            return otpSingleton.getOtp();
        }

        @Override
        protected void onPostExecute(String otp) {
            super.onPostExecute(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

<app.ephod.pentecost.library.paystack.PaymentView
                android:layout_width="match_parent"
                android:id="@+id/paymentView"
                android:layout_height="match_parent"/>

Set Theme

    app:pentecostTheme="black|white"

Set Background Drawable

    app:pentecostBackground=""

Set Background Color

    app:pentecostBackgroundColor=""

Set Header Image Src

    app:pentecostHeaderSrc=""

Usage - Code Behind

Set Theme

    paymentView.setPentecostTheme("black|white");

Set Background Drawable

    paymentView.setPentecostBackground(drawable);

Set Background Color

    paymentView.setPentecostBackgroundColor(color);

Set Billable Header

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

    paymentView.setBillHeader('')

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

    paymentView.setBillContent('')

Set Card Number

    paymentView.setCardNumber('')

Set CardCVV

    paymentView.setCardCVV('')

Set Card Expiry Date

    paymentView.setCardExpDate('')

Get Card Number

    paymentView.getCardNumber()

Get CardCVV

    paymentView.getCardCVV()

Get Card Expiry Date

    paymentView.getCardExpDate()

Get Selected Bank

    paymentView.getBankName()

Get entered Account Number

    paymentView.getAccountNumber()

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

    paymentView.getAccountHolderBirthday()

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

    paymentView.showLoader();

Remove PaymentView from loading mode

    paymentView.hideLoader();

Get PaymentView Pay Button

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

    paymentView.getPayButton()

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() {
            @Override
            public void onChargeCard() {
                //Use Paystack's SDK chargeCard or whatever you want really.
            }


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

            @Override
            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.

@knightbenax

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].