Skip to content

Commit 964a7b2

Browse files
committed
initial commit
0 parents  commit 964a7b2

Some content is hidden

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

51 files changed

+4089
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build
6+
7+
.DS_Store

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Chip Java library
2+
3+
## Requirements
4+
5+
Java 8 or later.
6+
7+
## Building
8+
9+
## Gradle
10+
11+
Copy library to your project
12+
13+
Include library in `settings.gradle`
14+
15+
```groovy
16+
include ':chip-sdk'
17+
```
18+
19+
if there is an error resolving the project, you might need to define the location of the project. i.e:
20+
21+
```groovy
22+
project(':chip-sdk').projectDir = file("../../chip-java-sdk")
23+
```
24+
25+
Add dependency to `build.gradle`
26+
27+
```groovy
28+
dependencies {
29+
...
30+
implementation project(':chip-sdk')
31+
}
32+
```
33+
34+
## Getting Started
35+
36+
Simple usage looks like:
37+
38+
39+
```java
40+
public class App {
41+
public static void main(String[] args) throws IOException {
42+
PaymentApi api = new PaymentApi("BRAND_ID",
43+
"API_KEY",
44+
"https://gate.chip-in.asia/api/v1/");
45+
ClientDetails clientDetails = new ClientDetails("test@test.com");
46+
List<Product> productList = new ArrayList<>();
47+
productList.add(new Product("Test", 100));
48+
PurchaseDetails purchaseDetails = new PurchaseDetails(productList);
49+
Purchase purchase = new Purchase(api.getBrandId(), clientDetails, purchaseDetails);
50+
purchase.setSuccessRedirect("https://yoursystem.com/?success=1");
51+
purchase.setFailureRedirect("https://yoursystem.com/?success=0");
52+
Call<Purchase> purchaseCall = api.getService().createPurchase(purchase);
53+
purchaseCall.enqueue(new Callback<Purchase>() {
54+
@Override
55+
public void onResponse(Call<Purchase> call, Response<Purchase> response) {
56+
if (response.isSuccessful()) {
57+
System.out.println(response.body().getCheckoutUrl());
58+
} else {
59+
System.out.println(api.errors(response));
60+
}
61+
}
62+
63+
@Override
64+
public void onFailure(Call<Purchase> call, Throwable t) {
65+
66+
}
67+
});
68+
}
69+
}
70+
```
71+
72+
## Testing
73+
74+
```bash
75+
./gradlew test
76+
```
77+
78+
## Example
79+
Check our examples [here](./examples).

build.gradle

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
plugins {
2+
id 'java-library'
3+
id 'maven-publish'
4+
}
5+
6+
group 'org.example'
7+
version '1.0-SNAPSHOT'
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
dependencies {
14+
api 'com.squareup.retrofit2:retrofit:2.9.0'
15+
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
16+
implementation 'com.google.code.gson:gson:2.8.6'
17+
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.1'
18+
testImplementation group: 'junit', name: 'junit', version: '4.12'
19+
testImplementation "com.squareup.okhttp3:mockwebserver:4.2.1"
20+
}

examples/.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+

examples/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build

examples/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/.idea/gradle.xml

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/.idea/jarRepositories.xml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/.idea/misc.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)