This repository has been archived by the owner on Jun 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aayush Malhotra
committed
Jan 19, 2021
0 parents
commit a1fe846
Showing
22 changed files
with
1,069 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.idea | ||
build | ||
.gradle | ||
.classpath | ||
.project | ||
.settings | ||
settings.gradle | ||
bin | ||
env.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 BrokenTusk Technologies Private Ltd | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# Setu Java SDK | ||
|
||
SDK to help Java developers integrate with Setu APIs. | ||
|
||
Currently the following APIs are supported : | ||
- UPI Deeplinks | ||
|
||
The package is under development so stay tuned for changes. | ||
|
||
## Installation | ||
|
||
## Usage | ||
|
||
### UPI Deeplinks | ||
The following actions are currenly supported : | ||
- Generate new payment link | ||
- Check status of payment | ||
|
||
#### Generate new payment link | ||
Create an instance of SetuRequestHelper and add the required parameters to it as shown. | ||
``` java | ||
final SetuRequestHelper helper = new SetuRequestHelper( | ||
schemeId, // unique id | ||
secret, // unique key | ||
productInstance, // unique product instance | ||
isProduction // determines sandbox or prod environment | ||
); | ||
``` | ||
To generate the link, call the method `generateLink()` on the above created object. The method returns an object of type `GenerateLinkResponse`, | ||
to get relevant data from the request use the getters defined in the class as follows. The method contains the following arguments in order: | ||
- `Integer` amount -> Bill amount in paisa | ||
- `Integer` expiresInDays -> Teh deeplink is created on the time of request and we can monitor its validity in the given time frame // optional | ||
- `String` payeeName -> Details of the customer // optional | ||
- `String` refId -> Biller's bill ID | ||
- `String` exactness -> Amount exactness, can be EXACT, EXACT_UP or EXACT_DOWN | ||
``` java | ||
final GenerateLinkResponse res = helper.generateLink(10000, 20, "Test Name", "billerID1234", "EXACT") | ||
``` | ||
The following success JSON is converted to the GenerateLinkResponse object. | ||
``` JSON | ||
{ | ||
"status" : "", | ||
"success" : true, | ||
"data":{ | ||
"name" : "", | ||
"platformBillID" : "", | ||
"paymentLink" : { | ||
"shortURL" : "", | ||
"upiID" : "", | ||
"upiLink" : "" | ||
} | ||
} | ||
} | ||
``` | ||
The following getters can be used on the object to get relevant data. | ||
``` java | ||
getStatus() // -> String | ||
getSuccess() // -> Boolean | ||
getName() // -> String | ||
getUpiId() // -> String | ||
getPlatformBillId() // -> String | ||
getError() // -> DeeplinkError | ||
``` | ||
#### Check Status | ||
|
||
The deeplink generated can be checked with this method, it gives information about the status of the payment. From the `helper` call the method `checkStatus()`. | ||
It takes the parameter of `platformBillID` which is returned when link is generated for the first time. | ||
The success response is in the given JSON format | ||
|
||
``` JSON | ||
{ | ||
"status" : "", | ||
"success" : true, | ||
"data":{ | ||
"name" : "", | ||
"createdAt" : "", | ||
"expiresAt" : "", | ||
"platformBillID" : "", | ||
"status" : "", | ||
"paymentLink" : { | ||
"shortURL" : "", | ||
"upiID" : "", | ||
"upiLink" : "" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
The above JSON is converted to the object of type `CheckStatusResponse` and we can get relevant data from the following getters | ||
``` java | ||
getRequestStatus() // -> String | ||
getSuccess() // -> Boolean | ||
getCreatedAt() // -> String | ||
getExpiresAt() // -> String | ||
getName() // -> String | ||
getUpiId() // -> String | ||
getUpiLink() // -> String | ||
getPlatformBillID() // -> String | ||
getError() // -> DeeplinkError | ||
``` | ||
|
||
#### Mock Payment (only in sandbox mode) | ||
|
||
Mock payment allows us to test the system in sandbox environment. On the `helper` call the method `mockPayment()`. It takes 2 arguments : | ||
- `Integer` amount - Amount in paisa | ||
- `String` UpiId of the biller (this is received in the status response) | ||
|
||
The response returns nothing so we use the status code and provide a String to give feedback to the user. On a successful mock payment we get | ||
`Mock Success` string in the console else RequestException is thrown with status code from the server. | ||
|
||
#### DeeplinkError Object | ||
|
||
`DeeplinkError` object has the following members : | ||
``` java | ||
private final String code; | ||
private final String detail; | ||
private final String docURL; | ||
private final String title; | ||
private final List<String> errors; | ||
private final String traceId; | ||
``` | ||
This object is not accessible outside the package so to get info related to the error use the getters available withing the response objects. | ||
|
||
## License | ||
|
||
MIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+' | ||
} | ||
} | ||
|
||
plugins { | ||
id 'java-library' | ||
id 'maven-publish' | ||
// id "com.jfrog.bintray" version "1.+" | ||
} | ||
apply plugin: 'com.jfrog.bintray' | ||
|
||
group 'org.setu' | ||
version '0.0.1' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
publishing { | ||
publications { | ||
MyPublication(MavenPublication) { | ||
from components.java | ||
groupId "org.setu.java_sdk" | ||
artifactId 'gradle-project' | ||
version '0.0.1' | ||
} | ||
} | ||
} | ||
|
||
bintray { | ||
user = System.getProperty('USER') | ||
key = System.getProperty('KEY') | ||
pkg { | ||
repo = 'setu-java-sdk' | ||
name = 'org.setu.java_sdk' | ||
licenses = ['MIT'] | ||
vcsUrl = 'https://github.com/AadumKhor/setu-java-sdk.git' | ||
} | ||
publications = ['MyPublication'] | ||
} | ||
|
||
|
||
|
||
dependencies { | ||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0' | ||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' | ||
|
||
// JWT | ||
implementation 'com.auth0:java-jwt:3.12.0' | ||
//GSON | ||
implementation 'com.google.code.gson:gson:2.8.6' | ||
// OkHttp | ||
implementation 'com.squareup.okhttp3:okhttp:3.2.0' | ||
|
||
testCompile group: 'junit', name: 'junit', version: '4.12' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.