Skip to content

Commit 701b44f

Browse files
committed
Hyperwallet Android Core SDK
Initial commit of Hyperwallet Core SDK for Android. This commit has the following functionality: * Create Bank Account and Bank Card for United States (USD) * Retrieve field requirements for bank Accounts and Bank Cards * List Accounts * Deactivate (Remove) Accounts
0 parents  commit 701b44f

File tree

182 files changed

+16115
-0
lines changed

Some content is hidden

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

182 files changed

+16115
-0
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.DS_Store
2+
3+
# Gradle files
4+
.gradle/
5+
build/
6+
7+
# Android Studio
8+
.idea/
9+
*.iml
10+
11+
# Local configuration file
12+
local.properties
13+
14+
# Log Files
15+
*.log

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Changelog
2+
=========
3+
4+
1.0.0-beta01
5+
-------------------
6+
- Initial release
7+
* Create Bank Account and Bank Card for United States (USD)
8+
* Retrieve field requirements for bank Accounts and Bank Cards
9+
* List Accounts
10+
* Deactivate (Remove) Accounts

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Hyperwallet Systems Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Hyperwallet Android Core SDK
2+
3+
Welcome to Hyperwallet's Android Core SDK. This library will help you create transfer methods in your Android app, such as bank account, PayPal account, etc.
4+
5+
Note that this SDK is geared towards those who only require back end data, which means you will have to build your own UI.
6+
7+
We also provide an out-of-the-box [Hyperwallet Android UI SDK](https://github.com/hyperwallet/hyperwallet-android-ui-sdk) for you if you decide not to build your own UI.
8+
9+
## Prerequisites
10+
* A Hyperwallet merchant account
11+
* Set Up your server to manage the user's authentication process on the Hyperwallet platform
12+
* An Android IDE
13+
* Android version >= 21
14+
15+
## Installation
16+
17+
To install Hyperwallet Core SDK, you just need to add the dependency into your build.gradle file in Android Studio (or Gradle). For example:
18+
19+
```bash
20+
api 'com.hyperwallet.android:core-sdk:1.0.0-beta01'
21+
```
22+
23+
## Initialization
24+
25+
After you're done installing the SDK, you need to initialize an instance in order to utilize core SDK functions. Also you need to provide a [HyperwalletAuthenticationTokenProvider](#Authentication) object to retrieve an authentication token.
26+
27+
```java
28+
// initialize core SDK
29+
Hyperwallet.getInstance(hyperwalletAuthenticationTokenProvider)
30+
31+
// use core SDK functions
32+
Hyperwallet.getDefault().createBankAccount(bankAccount, listener);
33+
```
34+
35+
## Authentication
36+
First of all, your server side should be able to send a POST request to Hyperwallet endpoint via Basic Authentication to retrieve an [authentication token](https://jwt.io/). For example:
37+
38+
```
39+
curl -X "POST" "https://api.sandbox.hyperwallet.com/rest/v3/users/{user-token}/authentication-token" \
40+
-u userName:password \
41+
-H "Content-type: application/json" \
42+
-H "Accept: application/json"
43+
```
44+
45+
Then, you need to provide a class (an authentication provider) which implements HyperwalletAuthenticationTokenProvider to retrieve an authentication token from your server.
46+
47+
```java
48+
49+
public class TestAuthenticationProvider implements HyperwalletAuthenticationTokenProvider {
50+
51+
public static final MediaType JSON
52+
= MediaType.get("application/json; charset=utf-8");
53+
private static final String mBaseUrl = "https://your/server/to/retrieve/authenticationToken";
54+
55+
@Override
56+
public void retrieveAuthenticationToken(final HyperwalletAuthenticationTokenListener listener) {
57+
58+
OkHttpClient client = new OkHttpClient();
59+
60+
String payload = "{}";
61+
RequestBody body = RequestBody.create(JSON, payload);
62+
Request request = new Request.Builder()
63+
.url(baseUrl)
64+
.post(body)
65+
.build();
66+
67+
client.newCall(request).enqueue(new Callback() {
68+
@Override
69+
public void onFailure(Call call, IOException e) {
70+
listener.onFailure(UUID.randomUUID(), e.getMessage());
71+
}
72+
73+
@Override
74+
public void onResponse(Call call, Response response) throws IOException {
75+
listener.onSuccess(response.body().string());
76+
}
77+
});
78+
}
79+
}
80+
81+
```
82+
## Usage
83+
The functions in core SDK are available to use once the authentication is done.
84+
85+
### Using ```createBankAccount```
86+
87+
```
88+
final HyperwalletBankAccount bankAccount = new HyperwalletBankAccount.Builder("US",
89+
"USD",
90+
"8017110254")
91+
.branchId("211179539")
92+
.build();
93+
Hyperwallet.getDefault().createBankAccount(bankAccount, listener);
94+
```
95+
96+
### Using ```createBankCard```
97+
98+
```
99+
final HyperwalletBankCard bankCard = new HyperwalletBankCard.Builder("US",
100+
"USD",
101+
"4216701111111114",
102+
"2020-12",
103+
"123")
104+
.cardBrand("Visa")
105+
.build()
106+
107+
Hyperwallet.getDefault().createBankCard(bankCard, listener);
108+
```
109+
110+
### Using ```deactivateBankAccount```
111+
```
112+
Hyperwallet.getDefault()
113+
.deactivateBankAccount("your-bank-account-token", "deactivate bank account", listener);
114+
```
115+
116+
### Using ```deactivateBankCard```
117+
```
118+
Hyperwallet.getDefault()
119+
.deactivateBankAccount("your-bank-card-token", "deactivate bank card", listener);
120+
```
121+
122+
### Using ```updateBankAccount```
123+
```
124+
final HyperwalletBankAccount updatedBankAccount = new HyperwalletBankAccount
125+
.Builder()
126+
.bankAccountId("new bank account Id")
127+
.token("your-bank-account-token")
128+
.build();
129+
Hyperwallet.getDefault().updateBankAccount(updatedBankAccount, listener);
130+
```
131+
132+
### Using ```updateBankCard```
133+
```
134+
final HyperwalletBankCard updatedBankCard = new HyperwalletBankCard.Builder()
135+
.cardBrand("new card brand")
136+
.token("your-bank-card-token")
137+
.build()
138+
139+
Hyperwallet.getDefault().updateBankCard(updatedBankCard, listener);
140+
```
141+
142+
## License
143+
The Hyperwallet Android Core SDK is open source and available under the [MIT](https://github.com/hyperwallet/hyperwallet-android-sdk/blob/master/LICENSE) license.

build.gradle

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
buildscript {
3+
repositories {
4+
google()
5+
jcenter()
6+
mavenLocal()
7+
}
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:3.3.2'
10+
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7"
11+
12+
// NOTE: Do not place your application dependencies here; they belong
13+
// in the individual module build.gradle files
14+
}
15+
}
16+
17+
allprojects {
18+
repositories {
19+
google()
20+
jcenter()
21+
mavenLocal()
22+
}
23+
24+
project.version = "1.0.0-beta01";
25+
}
26+
27+
task clean(type: Delete) {
28+
delete rootProject.buildDir
29+
}
30+
31+

core/.gitignore

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

core/build.gradle

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'maven-publish'
3+
apply plugin: 'signing'
4+
apply plugin: 'org.sonarqube'
5+
apply from: "$projectDir/config/jacoco-settings.gradle"
6+
7+
android {
8+
compileSdkVersion 28
9+
testOptions.unitTests.includeAndroidResources = true
10+
defaultConfig {
11+
minSdkVersion 21
12+
targetSdkVersion 28
13+
versionCode 1
14+
versionName version
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
}
17+
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22+
}
23+
debug {
24+
testCoverageEnabled true
25+
}
26+
}
27+
28+
flavorDimensions "server"
29+
30+
productFlavors {
31+
dev {
32+
33+
}
34+
prod {
35+
36+
}
37+
}
38+
39+
android.variantFilter { variant ->
40+
if (variant.buildType.name.equals('release')
41+
&& variant.getFlavors().get(0).name.equals('debug')) {
42+
variant.setIgnore(true)
43+
}
44+
}
45+
46+
47+
48+
lintOptions {
49+
abortOnError true
50+
warningsAsErrors true
51+
lintConfig file("config/lint.xml")
52+
}
53+
}
54+
55+
56+
dependencies {
57+
58+
implementation "androidx.appcompat:appcompat:1.0.2"
59+
60+
testImplementation "junit:junit:4.12"
61+
testImplementation "org.mockito:mockito-core:2.23.4"
62+
testImplementation "org.robolectric:robolectric:4.1"
63+
testImplementation "com.squareup.okhttp3:mockwebserver:3.11.0"
64+
testImplementation group: 'pl.pragmatists', name: 'JUnitParams', version: "1.1.1"
65+
testImplementation group: 'org.hamcrest', name: 'java-hamcrest', version: "2.0.0.0"
66+
67+
}
68+
69+
70+
task javadocs(type: Javadoc) {
71+
source = android.sourceSets.main.java.srcDirs
72+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
73+
failOnError false
74+
}
75+
76+
task javadocsJar(type: Jar, dependsOn: javadocs) {
77+
classifier = 'javadoc'
78+
from javadocs.destinationDir
79+
}
80+
81+
task sourcesJar(type: Jar) {
82+
classifier = 'sources'
83+
from android.sourceSets.main.java.srcDirs
84+
}
85+
86+
def aarFile = file("$buildDir/outputs/aar/core-$version"+".aar")
87+
def aarArtifact = artifacts.add('archives', aarFile) {
88+
type 'aar'
89+
}
90+
91+
def isReleaseVersion = !version.endsWith('SNAPSHOT')
92+
93+
publishing {
94+
95+
repositories {
96+
maven {
97+
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
98+
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
99+
url = isReleaseVersion ? releasesRepoUrl : snapshotsRepoUrl
100+
credentials {
101+
username sonatypeUsername
102+
password sonatypePassword
103+
}
104+
}
105+
}
106+
107+
publications {
108+
hyperwalletCore(MavenPublication) {
109+
groupId = 'com.hyperwallet.android'
110+
artifactId = 'core-sdk'
111+
version = version
112+
113+
artifact(sourcesJar)
114+
artifact(javadocsJar)
115+
artifact(aarArtifact)
116+
117+
pom {
118+
pom.withXml {
119+
def dependenciesNode = asNode().appendNode('dependencies')
120+
configurations.implementation.allDependencies.each {
121+
def dependencyNode = dependenciesNode.appendNode('dependency')
122+
dependencyNode.appendNode('groupId', it.group)
123+
dependencyNode.appendNode('artifactId', it.name)
124+
dependencyNode.appendNode('version', it.version)
125+
}
126+
}
127+
licenses {
128+
license {
129+
name = 'MIT License'
130+
url = 'http://www.opensource.org/licenses/MIT'
131+
}
132+
}
133+
developers {
134+
developer {
135+
id = 'devs'
136+
name = 'Hyperwallet Developers'
137+
}
138+
}
139+
scm {
140+
connection = 'scm:git:git://github.com/hyperwallet/hyperwallet-android-sdk.git'
141+
developerConnection = 'scm:git:git://github.com/hyperwallet/hyperwallet-android-sdk.git'
142+
url = 'https://github.com/hyperwallet/hyperwallet-android-sdk'
143+
}
144+
}
145+
}
146+
}
147+
}
148+
149+
tasks.withType(Sign) {
150+
onlyIf {
151+
isReleaseVersion
152+
}
153+
}
154+
155+
signing {
156+
sign publishing.publications.hyperwalletCore
157+
}
158+
159+
sonarqube {
160+
properties {
161+
def libraries = project.android.sdkDirectory.getPath() + "/platforms/android-28/android.jar"
162+
property "sonar.sources", "src/main/java"
163+
property "sonar.binaries", "build/intermediates/javac/prodRelease/compileProdReleaseJavaWithJavac/classes/com/hyperwallet/android"
164+
property "sonar.libraries", libraries
165+
!version.endsWith('SNAPSHOT')
166+
}
167+
}

0 commit comments

Comments
 (0)