Skip to content

Commit

Permalink
Add readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
weylar committed Jun 28, 2020
1 parent fd95650 commit 0ef8a7b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 30 deletions.
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
```
Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

}
26 changes: 15 additions & 11 deletions app/src/main/java/com/weylar/paystackui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?) {
Expand All @@ -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)
Expand All @@ -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) {
Expand All @@ -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")
}

}
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"-->

Expand Down

0 comments on commit 0ef8a7b

Please sign in to comment.