Apruve Client for Java

Java client for merchant integration with Apruve

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.apruve
ArtifactId

ArtifactId

apruve-java
Last Version

Last Version

0.4.2
Release Date

Release Date

Type

Type

jar
Description

Description

Apruve Client for Java
Java client for merchant integration with Apruve
Project URL

Project URL

http://www.apruve.com
Source Code Management

Source Code Management

https://github.com/apruve/apruve-java

Download apruve-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.apruve/apruve-java/ -->
<dependency>
    <groupId>com.apruve</groupId>
    <artifactId>apruve-java</artifactId>
    <version>0.4.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.apruve/apruve-java/
implementation 'com.apruve:apruve-java:0.4.2'
// https://jarcasting.com/artifacts/com.apruve/apruve-java/
implementation ("com.apruve:apruve-java:0.4.2")
'com.apruve:apruve-java:jar:0.4.2'
<dependency org="com.apruve" name="apruve-java" rev="0.4.2">
  <artifact name="apruve-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.apruve', module='apruve-java', version='0.4.2')
)
libraryDependencies += "com.apruve" % "apruve-java" % "0.4.2"
[com.apruve/apruve-java "0.4.2"]

Dependencies

compile (8)

Group / Artifact Type Version
commons-logging : commons-logging jar 1.1.3
org.apache.httpcomponents : httpclient jar 4.3.1
org.slf4j : slf4j-log4j13 jar 1.0.1
javax.xml.bind : jaxb-api jar 2.1
javax.ws.rs : javax.ws.rs-api jar 2.0
org.glassfish.jersey.core : jersey-client jar 2.7
org.glassfish.jersey.media : jersey-media-moxy jar 2.7
org.apache.commons : commons-lang3 jar 3.3

test (2)

Group / Artifact Type Version
junit : junit jar 4.8
org.easymock : easymock jar 3.1

Project Modules

There are no modules declared in this project.

Apruve

Innovation in the world of B2B Payments

Issues

Please use Github issues to request features or report bugs.

Installation

Maven

Add this dependency to your pom.xml:

<dependency>
    <groupId>com.apruve</groupId>
    <artifactId>apruve-java</artifactId>
    <version>0.4.0</version>
</dependency>

NOTE: the <version>XXX</version> can be out of date in this README.

Usage

Before using the rest of the Apruve Java client, be sure to call the ApruveClient.init() method to configure the client with your API key and the environment you wish to use (TEST or PROD). If you need to use multiple API keys in the same application for some reason, you will need to re-init the client with the appropriate key before each call.
(Using the client in this way is not thread-safe).

ApruveClient.init("myAPIKey", ApruveEnvironment.TEST);

During the checkout process, the PaymentRequest class can be used to generate the JSON and secure hash strings that are needed to initialize apruve.js. Instantiate the class, add line items, subscriptions, or other attributes, and call the toJson() and/or toSecureHash() methods:

PaymentRequest paymentRequest = new PaymentRequest(myMerchantId);
paymentRequest.setAmountCents(5000);
LineItem lineItem = new LineItem();
lineItem.setQuantity(1);
lineItem.setAmountCents(5000);
lineItem.setTitle("A widget");
paymentRequest.addLineItem(lineItem);
json = paymentRequest.toJson();
hash = paymentRequest.toSecureHash();

Each model class defines methods that implement calls to the different RESTful APIs defined for that model. The basic pattern is that actions that require a request body (creates, updates, etc.) are implemented as instance methods and use the state of the object to generate the request body via JAXB. Actions that do not require a request body are implemented as statics. For example, this will retrieve and update a Subscription:

Subscription subscription = Subscription.get("abcd1234");
subscription.setQuantity(5);
subscription.setPriceEachCents(2500);
subscription.setAmountCents(12500);
subscription.update();

API calls (other than get() or getAll()) are wrapped in an ApruveResponse<> object. If the call was successful, call getResponseObject() on this wrapper to get the API-specific respose for that call. If the call failed, the getErrorResponse() method will contain the failure reason.

ApruveResponse<PaymentRequestUpdateResponse> response = PaymentRequest.finalize("aPaymentRequestId");
if (response.success()) {
	System.out.println("The new status is: " + response.getResponseObject.getStatus());
} else {
	System.err.println("The update failed: " + response.getErrorResponse());
}

Testing

$ mvn test

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Write your code and tests
  4. Ensure all tests still pass
  5. Commit your changes (git commit -am 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new pull request
com.apruve

Apruve

B2B Credit Management Solutions

Versions

Version
0.4.2
0.4.1
0.4.0
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1