Skip to content

CHIPAsia/chip-java-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chip Java library

Requirements

Java 8 or later.

Building

Gradle

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')
}

Getting Started

Simple usage looks like:

public class App {
    public static void main(String[] args) throws IOException {
        PaymentApi api = new PaymentApi("BRAND_ID",
                "API_KEY",
                "https://gate.chip-in.asia/api/v1/");
        ClientDetails clientDetails = new ClientDetails("test@test.com");
        List<Product> productList = new ArrayList<>();
        productList.add(new Product("Test", 100));
        PurchaseDetails purchaseDetails = new PurchaseDetails(productList);
        Purchase purchase = new Purchase(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(new Callback<Purchase>() {
            @Override
            public void onResponse(Call<Purchase> call, Response<Purchase> response) {
                if (response.isSuccessful()) {
                    System.out.println(response.body().getCheckoutUrl());
                } else {
                    System.out.println(api.errors(response));
                }
            }
        
            @Override
            public void onFailure(Call<Purchase> call, Throwable t) {
        
            }
        });
    }
}

Testing

./gradlew test

Example

Check our examples here.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages