Skip to content

Commit 6cc31db

Browse files
Merge pull request #1 from thepeerstack/setup/thepeer-android-init
Setup/thepeer android init
2 parents 2b22e4b + 965bd2e commit 6cc31db

File tree

95 files changed

+2792
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2792
-1
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties
16+
/.idea/*

README.md

Lines changed: 224 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,224 @@
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+

build.gradle

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
buildscript {
3+
ext.kotlin_version = '1.6.10'
4+
repositories {
5+
google()
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath "com.android.tools.build:gradle:7.0.4"
10+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11+
// NOTE: Do not place your application dependencies here; they belong
12+
// in the individual module build.gradle files
13+
}
14+
}
15+
16+
task clean(type: Delete) {
17+
delete rootProject.buildDir
18+
}
19+
20+
ext {
21+
// Compose
22+
composeVersion = '1.1.1'
23+
constraintLayoutComposeVersion = '1.0.0-rc01'
24+
activityComposeVersion = '1.4.0'
25+
accompanistPagerVersion = '0.20.0'
26+
composeNavigationVersion = '2.3.0'
27+
composeViewModelVersion = '2.4.0'
28+
29+
// Coroutine
30+
coroutineVersion = '1.5.2'
31+
coroutineTestVersion = '1.5.2'
32+
33+
// OkHTTP
34+
okHttpVersion = '4.9.2'
35+
36+
// Moshi
37+
moshiVersion = '1.12.0'
38+
moshiAdaptersVersion = '1.12.0'
39+
moshiKotlinVersion = '1.12.0'
40+
41+
// Retrofit
42+
retrofitVersion = '2.9.0'
43+
retrofitMoshiConverterVersion = '2.9.0'
44+
loggingInterceptorVersion = '4.9.2'
45+
46+
// Mockk
47+
mockkVersion = '1.12.0'
48+
49+
// Junit
50+
junitVersion = '4.13.2'
51+
52+
//Navigation graph
53+
navGraph = '2.4.1'
54+
55+
//lifecycle
56+
lifecycleVersion = '2.5.0-alpha03'
57+
58+
// Robolectric
59+
robolectricVersion = '4.7.2'
60+
}

demo-app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

demo-app/build.gradle

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
id 'kotlin-kapt'
5+
6+
}
7+
8+
9+
android {
10+
compileSdk 31
11+
12+
13+
defaultConfig {
14+
applicationId "co.thepeer"
15+
minSdk 21
16+
targetSdk 31
17+
versionCode 1
18+
versionName "1.0"
19+
20+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
21+
}
22+
23+
buildFeatures {
24+
viewBinding true
25+
}
26+
27+
buildTypes {
28+
release {
29+
minifyEnabled false
30+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
31+
}
32+
}
33+
compileOptions {
34+
sourceCompatibility JavaVersion.VERSION_1_8
35+
targetCompatibility JavaVersion.VERSION_1_8
36+
}
37+
kotlinOptions {
38+
jvmTarget = '1.8'
39+
}
40+
}
41+
42+
dependencies {
43+
44+
implementation project(':thepeer-android')
45+
implementation 'androidx.core:core-ktx:1.7.0'
46+
implementation 'androidx.appcompat:appcompat:1.4.1'
47+
implementation 'com.google.android.material:material:1.5.0'
48+
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
49+
testImplementation 'junit:junit:4.+'
50+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
51+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
52+
}

demo-app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

0 commit comments

Comments
 (0)