This small application demonstrates how you might set up a web server using Java and Spark with RESTful routes to accept your Recurly.js form submissions and use the tokens to create and update customer billing information without having to handle credit card data.
This example makes use of the un-official Recurly Java client library for API v2.
Note that it is not necessary to use the Spark framework. In this example it is used to organize various API actions into distinct application routes, but one could just as easily implement these API actions in separate Java classes or within another application framework altogether.
-
If you haven't already, install docker.
-
Update the values in docker.env at the (root of the repo)[https://github.com/recurly/recurly-integration-examples/blob/main/docker.env]
-
Run
docker-compose up --build
- Install dependencies
The Recurly Java library is distributed via Maven Central:
<dependency>
<groupId>com.ning.billing</groupId>
<artifactId>recurly-java-library</artifactId>
<version>0.29.0</version>
</dependency>
The Spark Web Framework is distributed via Maven Central
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.9.1</version>
</dependency>
- Start the server
$ mvn clean compile && mvn exec:java -Dexec.mainClass="com.recurly.examples.App"