|
| 1 | +# Rave's Android Drop In UI |
| 2 | + |
| 3 | +Rave's Android Drop-In is a readymade UI that allows you to accept card and bank payments in your Android app. |
| 4 | + |
| 5 | +<img alt="Screenshot of Drop-In" src="https://firebasestorage.googleapis.com/v0/b/saveup-9e594.appspot.com/o/Group.png?alt=media&token=e0c89192-b2a4-47e0-a883-3a78005acd2a" width="600"/> |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | + |
| 10 | +The minimum supported SDK version is 15 |
| 11 | + |
| 12 | +## Adding it to your project |
| 13 | + |
| 14 | + |
| 15 | +**Step 1.** Add it in your root build.gradle at the end of repositories: |
| 16 | + |
| 17 | + allprojects { |
| 18 | + repositories { |
| 19 | + ... |
| 20 | + maven { url 'https://jitpack.io' } |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | +**Step 2.** Add the dependency |
| 25 | + |
| 26 | + dependencies { |
| 27 | + compile 'com.github.Flutterwave:rave-android:1.0.0' |
| 28 | + } |
| 29 | +**Step 3.** Add the required permission |
| 30 | + |
| 31 | +Add the `READ_PHONE_PERMISSION` permission to your android manifest |
| 32 | + |
| 33 | + <uses-permission android:name="android.permission.READ_PHONE_STATE"/> |
| 34 | + |
| 35 | + |
| 36 | +> **REQUIRED PERMISSION** |
| 37 | +> This library requires the **READ_PHONE_PERMISSION** to get the build number for fraud detection and flagging as recommended here https://developer.android.com/training/articles/user-data-ids.html#i_abuse_detection_detecting_high_value_stolen_credentials |
| 38 | +
|
| 39 | +## Usage |
| 40 | + |
| 41 | +### 1. Create a `RavePayManager` instance |
| 42 | +Set the public key, private key and other required parameters. The `RavePayManager` accepts a mandatory instance of the calling `Activity` |
| 43 | + |
| 44 | + new RavePayManager(activity).setAmount(amount) |
| 45 | + .setCountry(country) |
| 46 | + .setCurrency(currency) |
| 47 | + .setEmail(email) |
| 48 | + .setfName(fName) |
| 49 | + .setlName(lName) |
| 50 | + .setNarration(narration) |
| 51 | + .setPublicKey(publicKey) |
| 52 | + .setSecretKey(secretKey) |
| 53 | + .setTxRef(txRef) |
| 54 | + .acceptAccountPayments(boolean) |
| 55 | + .acceptCardPayments(boolean) |
| 56 | + .onStagingEnv(boolean) |
| 57 | + .withTheme(styleId) |
| 58 | + .initialize(); |
| 59 | +* `setAmount()` - This is the amount to be charged from card/account. `double` |
| 60 | +* `setCountry()` - This is the route country for the transaction with respect to the currency. `String` |
| 61 | +* `setCurrency` - This is the specified currency to charge the card in. `String` |
| 62 | +* `setEmail()` - This is the email address of the customer. `String` |
| 63 | +* `setfName()` - This is the first name of the card holder or the customer. `String` |
| 64 | +* `setlName()` - This is the last name of the card holder or the customer. `String` |
| 65 | +* `setNarration()` - This is a custom description added by the merchant. `String` |
| 66 | +* `setPublicKey()` - Merchant's public key `String` |
| 67 | +* `setSecretKey()` - Merchant's secret key `String` |
| 68 | +* `setTxRef()` - This is the unique reference, unique to the particular transaction being carried out. It is generated by the merchant for every transaction `String` |
| 69 | +* `acceptAccountPayments()` - Set to true if you want to accept payments via bank accounts, else set to false. `boolean`. Defaults to `true` |
| 70 | +* `acceptCardPayments()` - Set to true if you want to accept payments via cards, else set to false. `boolean`. Defaults to `true` |
| 71 | +* `withTheme()` - Sets the theme of the UI. `int` |
| 72 | +*`initialize` - Launch the Rave Payment UI |
| 73 | + |
| 74 | +> **SECURITY ALERT** |
| 75 | +> You should never store your **SECRET KEY** on the user's device |
| 76 | +
|
| 77 | +### 2. Handle the response |
| 78 | +In the calling activity, override the `onActivityResult` method to receive the payment response as shown below |
| 79 | + |
| 80 | + @Override |
| 81 | + protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 82 | + if (requestCode == RaveConstants.RAVE_REQUEST_CODE && data != null) { |
| 83 | + String message = data.getStringExtra("response"); |
| 84 | + if (resultCode == RavePayActivity.RESULT_SUCCESS) { |
| 85 | + Toast.makeText(this, "SUCCESS " + message, Toast.LENGTH_SHORT).show(); |
| 86 | + } |
| 87 | + else if (resultCode == RavePayActivity.RESULT_ERROR) { |
| 88 | + Toast.makeText(this, "ERROR " + message, Toast.LENGTH_SHORT).show(); |
| 89 | + } |
| 90 | + else if (resultCode == RavePayActivity.RESULT_CANCELLED) { |
| 91 | + Toast.makeText(this, "CANCELLED " + message, Toast.LENGTH_SHORT).show(); |
| 92 | + } |
| 93 | + } |
| 94 | + else { |
| 95 | + super.onActivityResult(requestCode, resultCode, data); |
| 96 | + } |
| 97 | + } |
| 98 | +The intent's `message` object contains the raw JSON response from the Rave API. This can be parsed to retrieve any additional payment information needed. |
| 99 | + |
| 100 | +### 3. Customize the look |
| 101 | +You can apply a new look by changing the color of certain parts of the UI to highlight your brand colors |
| 102 | + |
| 103 | + <style name="DefaultTheme" parent="AppTheme.NoActionBar"> |
| 104 | + <item name="colorPrimary">@color/colorPrimary</item> |
| 105 | + <item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
| 106 | + <item name="colorAccent">@color/colorAccent</item> |
| 107 | + <item name="OTPButtonStyle">@style/otpBtnStyle</item> |
| 108 | + <item name="PayButtonStyle">@style/payBtnStyle</item> |
| 109 | + <item name="PinButtonStyle">@style/pinButtonStyle</item> |
| 110 | + <item name="OTPHeaderStyle">@style/otpHeaderStyle</item> |
| 111 | + <item name="TabLayoutStyle">@style/tabLayoutStyle</item> |
| 112 | + <item name="PinHeaderStyle">@style/pinHeaderStyle</item> |
| 113 | + <item name="SavedCardButtonStyle">@style/svdCardsBtnStyle</item> |
| 114 | + </style> |
| 115 | + |
| 116 | +## Help |
| 117 | +* Find a bug? [Open an issue](https://github.com/Flutterwave/rave-android/issues) |
| 118 | +* Want to contribute? [Check out contributing guidelines]() and [submit a pull request](https://help.github.com/articles/creating-a-pull-request). |
| 119 | + |
| 120 | +## Want to contribute? |
| 121 | + |
| 122 | +Feel free to create issues and pull requests. The more concise the pull requests the better :) |
| 123 | + |
| 124 | + |
| 125 | +## License |
| 126 | + |
| 127 | +``` |
| 128 | +Rave's Android DropIn UI |
| 129 | +MIT License |
| 130 | +
|
| 131 | +Copyright (c) 2017 |
| 132 | +
|
| 133 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 134 | +of this software and associated documentation files (the "Software"), to deal |
| 135 | +in the Software without restriction, including without limitation the rights |
| 136 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 137 | +copies of the Software, and to permit persons to whom the Software is |
| 138 | +furnished to do so, subject to the following conditions: |
| 139 | +
|
| 140 | +The above copyright notice and this permission notice shall be included in all |
| 141 | +copies or substantial portions of the Software. |
| 142 | +
|
| 143 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 144 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 145 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 146 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 147 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 148 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 149 | +SOFTWARE. |
| 150 | +``` |
0 commit comments