|
| 1 | +JAVA-PAYMENTS-SDK |
| 2 | +================== |
| 3 | + |
| 4 | +**Help:** [Support](https://developer.intuit.com/help), [Samples](https://developer.intuit.com/docs/0100_quickbooks_online/0400_tools/0005_sdks/0200_java/0004_sample_code_and_sample_apps) <br/> |
| 5 | +**Documentation:** [User Guide](https://developer.intuit.com/app/developer/qbpayments/docs/develop/using-an-sdk-to-integrate-with-the-payments-api#java) <br/> |
| 6 | +**Continuous Integration:** [](https://travis-ci.org/intuit/QuickBooks-V3-Java-SDK) <br/> |
| 7 | +**Maven:** [](https://maven-badges.herokuapp.com/maven-central/com.intuit.quickbooks-online/payments-api) <br/> |
| 8 | +**License:** [](http://www.apache.org/licenses/LICENSE-2.0) <br/> |
| 9 | + |
| 10 | + |
| 11 | +## Overview |
| 12 | +This Payments SDK provides a Java library that make it easier to call QuickBooks Online Payments API. This library supports the following APIs: |
| 13 | + |
| 14 | +* Token creation for card and bankAccount. |
| 15 | +* BankAccount functions like create, delete, retrieve. |
| 16 | +* Card functions like create, delete, retrieve. |
| 17 | +* Charge functions like create, capture, retrieve, refund. |
| 18 | +* ECheck functions like create retrieve, refund. |
| 19 | + |
| 20 | +In addition to the above, the library also supports, logging, error handling, serialization/deserialization and capturing intuit_tid for easier debugging. |
| 21 | +Note: This library works only for OAuth2 apps. |
| 22 | + |
| 23 | +## System Requirements |
| 24 | +The SDK works on JDK 1.6 and above. |
| 25 | + |
| 26 | +## Install |
| 27 | +The SDK can be installed using one of the ways below- |
| 28 | +1. Download the latest version of the jar from [maven](https://search.maven.org/search?q=quickbooks) and add it to your projects classpath |
| 29 | + ```sh |
| 30 | + payment-api.jar |
| 31 | + ``` |
| 32 | + |
| 33 | +2. Add the following dependency to the build.gradle file. Make sure to use the latest version of the SDK found [here](https://search.maven.org/search?q=quickbooks) |
| 34 | + ```sh |
| 35 | + compile("com.intuit.quickbooks-online:payments-api:5.0.0") |
| 36 | + ``` |
| 37 | + |
| 38 | +3. Add the following dependency to the pom.xml file. Make sure to use the latest version of the SDK found [here](https://search.maven.org/search?q=quickbooks) |
| 39 | + ```sh |
| 40 | + <dependency> |
| 41 | + <groupId>com.intuit.quickbooks-online</groupId> |
| 42 | + <artifactId>payments-api</artifactId> |
| 43 | + <version>5.0.0</version> |
| 44 | + </dependency> |
| 45 | + ``` |
| 46 | + |
| 47 | +## Usage |
| 48 | +1. Create the RequestContext object as shown below. Pass in the accessToken and Environment. |
| 49 | +```java |
| 50 | +RequestContext requestContext = new RequestContext.Builder(accessToken, Environment.SANDBOX).build(); |
| 51 | +``` |
| 52 | +The above code automatically sets a unique requestid as well. To provide your custom requestid use the below code- |
| 53 | +```java |
| 54 | +RequestContext requestContext = new RequestContext.Builder(accessToken, Environment.SANDBOX) |
| 55 | + .requestId(requestId).build(); |
| 56 | +``` |
| 57 | +You can also set Proxy parameters in the same way. |
| 58 | +
|
| 59 | +2. Create the Service object. The sample below shows how to create a TokenService, you can create other service objects - Echeck, Charge, Card, BankAccount in the same way. |
| 60 | +```java |
| 61 | +TokenService tokenService = new TokenService(requestContext); |
| 62 | +``` |
| 63 | +
|
| 64 | +3. Prepare Token request create token for a credit card |
| 65 | +```java |
| 66 | +Address address = new Address.Builder().region("CA").postalCode("94086") |
| 67 | + .streetAddress("1130 Kifer Rd").city("Sunnyvale") |
| 68 | + .country("US").build(); |
| 69 | +``` |
| 70 | +
|
| 71 | +```java |
| 72 | +Card card = new Card.Builder().expYear("2020").expMonth("02").address(address) |
| 73 | + .name("emulate=0").cvc("123") |
| 74 | + .number("4111111111111111").build(); |
| 75 | +``` |
| 76 | +
|
| 77 | +```java |
| 78 | +Token tokenRequest = new Token.Builder().card(card).build(); |
| 79 | +``` |
| 80 | +
|
| 81 | +4. Call the TokenService to create token |
| 82 | +```java |
| 83 | +Token token = tokenService.createToken(tokenRequest); |
| 84 | +``` |
| 85 | +
|
| 86 | +5. Retrieve token value |
| 87 | +```java |
| 88 | +token.getValue(); |
| 89 | +``` |
| 90 | +
|
| 91 | +## Logging important attributes |
| 92 | +Makes sure to log intuit_tid and requestId for each of your request for easier debugging |
| 93 | +
|
| 94 | +For logging intuit_tid, use the following method |
| 95 | +```java |
| 96 | +token.getIntuit_tid(); |
| 97 | +``` |
| 98 | +
|
| 99 | +For logging requestId, use the following method |
| 100 | +```java |
| 101 | +token.getRequestId(); |
| 102 | +``` |
| 103 | +
|
| 104 | +## Sample |
| 105 | +For more samples on how to create other entities and operation, take a look at the sample application below : |
| 106 | +[sample](https://github.com/IntuitDeveloper/SampleApp-Payments-Java) |
| 107 | +
|
| 108 | +
|
0 commit comments