|
1 | | -# Thepeer Android SDK |
| 1 | +# ThePeer Android SDK |
| 2 | + |
| 3 | +ThePeer Android SDK gives one integration access to all fintech businesses on your Android App |
| 4 | + |
| 5 | + |
| 6 | +1. Send |
| 7 | +3. Checkout |
| 8 | +4. Direct Charge |
| 9 | + |
| 10 | +## Demo |
| 11 | + |
| 12 | +https://user-images.githubusercontent.com/16048595/167891393-6f198712-7648-4f45-959a-a289fab42006.mo |
| 13 | + |
| 14 | +https://user-images.githubusercontent.com/16048595/167891381-2ad76193-3cf1-4abe-870b-0924fee498fb.mov |
| 15 | + |
| 16 | +https://user-images.githubusercontent.com/16048595/167891309-d6608bba-20dc-4840-be60-96c6ef390ea3.mov |
| 17 | + |
| 18 | + |
| 19 | +## Setup Implementation |
| 20 | + |
| 21 | +#### Step 1: Add Dependency |
| 22 | + |
| 23 | +To your root build.gradle file add: |
| 24 | + |
| 25 | +``` |
| 26 | +allprojects { |
| 27 | + repositories { |
| 28 | + google() |
| 29 | + mavenCentral() |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +To your app-level build.gradle file add: |
| 35 | + |
| 36 | +```groovy |
| 37 | +dependencies { |
| 38 | + // ... |
| 39 | + implementation "co.thepeer.android-sdk:android:sdk:[coming soon]" |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +#### Step 2: Add Public Key to Manifest |
| 44 | + |
| 45 | +``` |
| 46 | + <meta-data |
| 47 | + android:name="co.thepeer.PublicKey" |
| 48 | + android:value="YOUR_PUBLC_KEY" /> |
| 49 | + ``` |
| 50 | + |
| 51 | +#### Step 3: Initialization |
| 52 | + |
| 53 | +KOTLIN |
| 54 | + |
| 55 | +```kotlin |
| 56 | + |
| 57 | +//initialize ThePeer SDK |
| 58 | +override fun onCreate(savedInstanceState: Bundle?) { |
| 59 | + super.onCreate(savedInstanceState) |
| 60 | + |
| 61 | + |
| 62 | + //initialize ThePeer SDK |
| 63 | + val thePeer = ThePeer.Builder( |
| 64 | + activity = this, |
| 65 | + amount = BigDecimal(10000.00), |
| 66 | + currency = "NGN", |
| 67 | + userReference = getString(R.string.user_reference), |
| 68 | + resultListener = resultListener |
| 69 | + ).setMeta(mapOf("remark" to "Enjoy")).build() |
| 70 | + |
| 71 | + } |
| 72 | + |
| 73 | +``` |
| 74 | + |
| 75 | +JAVA |
| 76 | + |
| 77 | +```java |
| 78 | + |
| 79 | +//initialize ThePeer SDK |
| 80 | + @Override |
| 81 | + protected void onCreate(Bundle savedInstanceState) { |
| 82 | + super.onCreate(savedInstanceState); |
| 83 | + setContentView(R.layout.activity_main); |
| 84 | + |
| 85 | + //initialize ThePeer SDK |
| 86 | + ThePeer thePeer =new ThePeer.Builder( |
| 87 | + this, |
| 88 | + new BigDecimal("1000.00"), |
| 89 | + "NGN", |
| 90 | + getResources().getString(R.string.user_reference), |
| 91 | + new ThePeerResultListener()) |
| 92 | + |
| 93 | + } |
| 94 | +``` |
| 95 | + |
| 96 | +| Paramater name | Description | Required | |
| 97 | +|------------------------ | --------------------------------------|--------------------------------------| |
| 98 | +| `amount` | The amount you intend to send and must be pass as an integer in kobo |`true`| |
| 99 | +| `currency ` | Currency which can be `"NGN"` or `"USD"` |`true`| |
| 100 | +| `userReference` | The user reference returned by Thepeer API when a user has been indexed |`true`| |
| 101 | +| `meta` | This object should contain additional/optional attributes you would like to have on your transaction response |`false`| |
| 102 | + |
| 103 | +## Send |
| 104 | + |
| 105 | +Initiate the send request by calling the below function |
| 106 | + |
| 107 | +KOTLIN |
| 108 | + |
| 109 | +```kotlin |
| 110 | + |
| 111 | +thePeer.send() |
| 112 | + |
| 113 | +``` |
| 114 | + |
| 115 | +JAVA |
| 116 | + |
| 117 | +```java |
| 118 | + |
| 119 | +thePeer.send(); |
| 120 | + |
| 121 | +``` |
| 122 | + |
| 123 | +## Checkout |
| 124 | + |
| 125 | +Initiate the checkout request by calling the below function |
| 126 | + |
| 127 | +KOTLIN |
| 128 | + |
| 129 | +```kotlin |
| 130 | + |
| 131 | +thePeer.checkout(email: String) |
| 132 | + |
| 133 | +``` |
| 134 | + |
| 135 | +JAVA |
| 136 | + |
| 137 | +```java |
| 138 | + |
| 139 | +thePeer.checkout(String email); |
| 140 | + |
| 141 | +``` |
| 142 | + |
| 143 | +## Direct Charge |
| 144 | + |
| 145 | +Initiate the Direct Charge request by calling the below function |
| 146 | + |
| 147 | +KOTLIN |
| 148 | + |
| 149 | +```kotlin |
| 150 | + |
| 151 | +thePeer.directCharge() |
| 152 | + |
| 153 | +``` |
| 154 | + |
| 155 | +JAVA |
| 156 | + |
| 157 | +```java |
| 158 | + |
| 159 | +thePeer.directCharge(); |
| 160 | + |
| 161 | +``` |
| 162 | + |
| 163 | +## Listener |
| 164 | + |
| 165 | +Once the request is initiated the SDK will wait from response from the service and notify the App |
| 166 | +via `ThePeerResultListener` |
| 167 | +KOTLIN |
| 168 | + |
| 169 | +```Kotlin |
| 170 | +private val resultListener = object : ThePeerResultListener { |
| 171 | + override fun onSuccess(transaction: ThePeerTransaction) { |
| 172 | + //Transaction Successful |
| 173 | + Log.v(TAG, transaction.toString()) |
| 174 | + |
| 175 | + } |
| 176 | + |
| 177 | + override fun onError(error: Throwable) { |
| 178 | + //Transaction Error occured |
| 179 | + Log.e(TAG, error.message) |
| 180 | + } |
| 181 | + |
| 182 | + override fun onCancelled() { |
| 183 | + //Transaction was cancelled |
| 184 | + Log.e(TAG, " Cancelled") |
| 185 | + } |
| 186 | + |
| 187 | +} |
| 188 | + |
| 189 | +``` |
| 190 | + |
| 191 | +JAVA |
| 192 | + |
| 193 | +```java |
| 194 | + |
| 195 | + new ThePeerResultListener() { |
| 196 | + |
| 197 | + @Override |
| 198 | + public void onSuccess(@NonNull ThePeerTransaction transaction) { |
| 199 | + ((TextView) findViewById(R.id.resultText)).setText(transaction.toString()); |
| 200 | + } |
| 201 | + |
| 202 | + @Override |
| 203 | + public void onCancelled() { |
| 204 | + |
| 205 | + } |
| 206 | + |
| 207 | + @Override |
| 208 | + public void onError(@NonNull Throwable error) { |
| 209 | + |
| 210 | + } |
| 211 | + |
| 212 | + } |
| 213 | + |
| 214 | + |
| 215 | +``` |
| 216 | +## Support |
| 217 | + |
| 218 | +If you're having trouble with Thepeer React or your integration, please reach out to us at <[email protected]>. We're more than happy to help you out. |
| 219 | + |
| 220 | +## Thepeer API References |
| 221 | + |
| 222 | +- [Thepeer API Docs](https://docs.thepeer.co) |
| 223 | +- [Thepeer Dashboard](https://dashboard.thepeer.co) |
| 224 | + |
0 commit comments