The java library for integrating with Chargebee Recurring Billing and Subscription Management solution.
Chargebee now supports two API versions - V1 and V2, of which V2 is the latest release and all future developments will happen in V2.
This library is for our API version V2. The library for V1 can be found in chargebee-v1 branch.
Add the below dependency to your pom.xml
:
<dependency>
<groupId>com.chargebee</groupId>
<artifactId>chargebee-java</artifactId>
<version>[latest-2.x.x-release-version]</version>
</dependency>
ChargeBee java jar is distributed as part of the release under the dist
directory. Just checkout the latest version for 2.x.x by git checkout [latest 2.x.x release tag]
or
Build the jar by running maven as follows in latest release tag for 2.x.x:
git checkout [latest 2.x.x release tag]
mvn clean package
You can also copy the below code snippet from our API Reference documentation. We have provided downloadable code for each API operation.
import java.io.IOException;
import com.chargebee.*;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
public class Sample{
public static void main(String args[]) throws IOException{
Environment.configure("{site}","{site_api_key}");
Result result = Subscription.create()
.id("HwxfyiHNUFzaiWO")
.planId("starter")
.customerEmail("john@user.com")
.customerFirstName("John")
.customerLastName("Wayne").request();
Subscription subscription = result.subscription();
Customer customer = result.customer();
Card card = result.card();
System.out.println(result);
}
}
See the LICENSE file.