diff --git a/README.md b/README.md index f78b067..56352f0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ ![Bank payment](screenshots/bank_page.PNG) ![Card payment](screenshots/card_page.PNG) ![Saved cards](screenshots/saved_cards.PNG) -![Scan page](screenshots/scan_page.PNG) ### What is Bunny ? Bunny is a beautiful, easy-to-use, and highly customisable Paystack UI library for Android. It helps with quick integration into your PayStack Android project. @@ -22,15 +21,18 @@ To use PayStack in your project, kindly follow this link [https://github.com/Pay ## Installation Add this to your root `build.gradle` of your project ``` -Code goes here +allprojects { + repositories { + ... + jcenter() + maven { url 'https://jitpack.io' } + ... + } +} ``` ### Gradle ``` -Code goes here -``` -### Maven -``` -Code goes here + implementation 'com.github.weylar:bunny:1.0.0' ``` ## Usage Once imported in your project, a basic usage will be to add this in your layout file: @@ -92,29 +94,30 @@ payView.onPayClickListener(object : PayView.OnPayListener { ### Usage - Kotlin | Java + #### Setters -- `enableCardScan(Activity, Boolean)` - This enables or disables card scan option. Default value is false. - `setBunnyTheme(Color)` - This determines the entire view theme. Automatically adjust the view colors to match with the specified in color. Note that if this is set, it overrides any color property set from xml on any view item. - -- `setBanks(List)` - This is a compulsory field. It is used to attach list of bank names on spinner used during bank payment. - - `setAmount(Float)` - Amount to be displayed on the payment page. - `setAmountColor(Color)` - Defines the amount text color. - `setPayButtonBackground(Drawable|Color)` - This defines the background property of the pay button. Can either be a custom drawable background or solid color. - `setPayButtonTextColor(Color)` - Defines the pay button text color property. - `setPayButtonText(String)` - Defines text to show on pay button. +- `enableDetailSave(Boolean)` - Determines whether to show save card or bank details option. Default value is true. + +##### Card Payment +- `enableCardScan(Activity, Boolean)` - This enables or disables card scan option. Default value is false. +- `setBanks(List)` - This is a compulsory field. It is used to attach list of bank names on spinner used during bank payment. - `setCardBackground(Drawable|Color)` - Defines the credit card view background. This can either be a solid color or a custom drawable background. - `setCardContentColor(Color)` - Defines the color of the view contents in the credit card view. -- `enableDetailSave(Boolean)` - Determines whether to show save card or bank details option. Default value is true. - `setCardNumber(String)` - Sets card number value on card number edit text view. -- `setBankAccountNumber(String)` - Sets account number value on edit text view. -- `setDob(String)` - Sets date of birth value on edit text view. - `setCardExpiryDate(String)` - Sets expiry date value on edit text view. - `setCardCVV(String)` - Sets card value cvv on edit text view. - `setCardHolderName(String)` - Sets card holder name value on edit text view. - +##### Bank Payment +- `setBankAccountNumber(String)` - Sets account number value on edit text view. +- `setDob(String)` - Sets date of birth value on edit text view. #### Getters @@ -189,6 +192,9 @@ enableDetailSave(Boolean) ``` Passing in `false`, `true` will otherwise enable it. +### What Next? +Check out this repo, App module for a complete integration with PayStack usage. + ## Important Stuff To Note - When you set `bunnyTheme` , note that this will override any other color or background configuration in `XML`. To avoid this, you need to apply other changes through your code. Example: ``` diff --git a/app/build.gradle b/app/build.gradle index 7bf9704..4e3a4db 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,6 +37,7 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation 'co.paystack.android:paystack:3.0.18' - implementation project(':bunny') + // implementation project(':bunny') + implementation 'com.github.weylar:bunny:1.0.0' } \ No newline at end of file diff --git a/app/src/main/java/com/weylar/paystackui/MainActivity.kt b/app/src/main/java/com/weylar/paystackui/MainActivity.kt index c7608ab..7b750c1 100644 --- a/app/src/main/java/com/weylar/paystackui/MainActivity.kt +++ b/app/src/main/java/com/weylar/paystackui/MainActivity.kt @@ -2,6 +2,7 @@ package com.weylar.paystackui import android.app.Activity import android.content.Intent +import android.graphics.Color import android.os.Bundle import android.util.Log import androidx.appcompat.app.AppCompatActivity @@ -18,6 +19,7 @@ import com.weylar.bunny.data.BankPayViewData import com.weylar.bunny.data.CardPayViewData class MainActivity : AppCompatActivity() { + private val LOG: String = "MainActivity" private lateinit var payView: PayView override fun onCreate(savedInstanceState: Bundle?) { @@ -26,9 +28,11 @@ class MainActivity : AppCompatActivity() { payView = findViewById(R.id.pay_view) payView.enableCardScan(this, true) - // payView.setBunnyTheme(Color.BLACK) - // payView.setBanks(listOf("Access", "Uba")) - // payView.setAmount(100.0f) + payView.setBunnyTheme(Color.BLACK) + payView.setBanks(listOf("Access", "Uba")) + payView.setAmount(100.0f) + + // These are complete list of invocable method calls. // payView.setAmountColor(R.color.black) // payView.setPayButtonBackground(ActivityCompat.getDrawable(this, R.drawable.button_bg)) // payView.setPayButtonTextColor(Color.YELLOW) @@ -40,9 +44,9 @@ class MainActivity : AppCompatActivity() { payView.onPayClickListener(object : PayView.OnPayListener { override fun onBankPayListener(bankPayViewData: BankPayViewData) { - Log.i("Aminu", bankPayViewData.accountNumber) - Log.i("Aminu", bankPayViewData.bankName) - Log.i("Aminu", bankPayViewData.dateOfBirth) + Log.i(LOG, bankPayViewData.accountNumber) + Log.i(LOG, bankPayViewData.bankName) + Log.i(LOG, bankPayViewData.dateOfBirth) } override fun onCardPayListener(cardPayDataView: CardPayViewData) { @@ -55,29 +59,29 @@ class MainActivity : AppCompatActivity() { val charge = Charge() charge.card = card charge.amount = 200 - charge.email = "idrisaminu861@gmail.com" + charge.email = "sample@hey.com" PaystackSdk.chargeCard( this@MainActivity, charge, object : Paystack.TransactionCallback { override fun onSuccess(transaction: Transaction?) { - Log.i("Aminu", "Successful transaction") + Log.i(LOG, "Successful transaction") payView.hideLoadingSpinner() } override fun beforeValidate(transaction: Transaction?) { - Log.i("Aminu", "Before validate is called") + Log.i(LOG, "Before validate is called") } override fun onError(error: Throwable?, transaction: Transaction?) { - Log.i("Aminu", "Error: " + error?.localizedMessage) + Log.i(LOG, "Error: " + error?.localizedMessage) payView.hideLoadingSpinner() } }) } else { - Log.i("Aminu", "It's not valid") + Log.i(LOG, "It's not valid") } } diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml index e147b6a..8b3b722 100644 --- a/app/src/main/res/layout/main.xml +++ b/app/src/main/res/layout/main.xml @@ -17,9 +17,8 @@ app:cardBackground="@drawable/card_bg" app:cardContentColor="@color/white" app:payButtonBackground="@color/black" - app:payButtonText="Yahaha" - - app:enableDetailSave="false" + app:payButtonText="Pay" + app:enableDetailSave="false" app:bunnyTheme="#000000" app:payButtonTextColor="@color/white"-->