Java 8 or later.
Copy library to your project
Include library in settings.gradle
include ':chip-sdk'if there is an error resolving the project, you might need to define the location of the project. i.e:
project(':chip-sdk').projectDir = file("../../chip-java-sdk")Add dependency to build.gradle
dependencies {
...
implementation project(':chip-sdk')
}Simple usage looks like:
publicclassApp {
publicstaticvoidmain(String[] args) throwsIOException {
PaymentApiapi = newPaymentApi("BRAND_ID",
"API_KEY",
"https://gate.chip-in.asia/api/v1/");
ClientDetailsclientDetails = newClientDetails("test@test.com");
List<Product> productList = newArrayList<>();
productList.add(newProduct("Test", 100));
PurchaseDetailspurchaseDetails = newPurchaseDetails(productList);
Purchasepurchase = newPurchase(api.getBrandId(), clientDetails, purchaseDetails);
purchase.setSuccessRedirect("https://yoursystem.com/?success=1");
purchase.setFailureRedirect("https://yoursystem.com/?success=0");
Call<Purchase> purchaseCall = api.getService().createPurchase(purchase);
purchaseCall.enqueue(newCallback<Purchase>() {
@OverridepublicvoidonResponse(Call<Purchase> call, Response<Purchase> response) {
if (response.isSuccessful()) {
System.out.println(response.body().getCheckoutUrl());
} else {
System.out.println(api.errors(response));
}
}
@OverridepublicvoidonFailure(Call<Purchase> call, Throwablet) {
}
});
}
}./gradlew testCheck our examples here.