Hello Java Developers,
Here at Intuit we constantly strive to make it easier for you to use our APIs and onboard to our platform quickly. One feedback we have received in the past is to add support for Payments API in the Intuit SDK. We are pleased to announce that we now have support for Payments API in the latest version of Java SDK (version 5.0.0 or upwards).
Here is a quick guide on how to get started and use the library-
Including the SDK to your project:
To include the library to a java maven project, add the following dependencies to the pom.xml.
<dependency> <groupId>com.intuit.quickbooks-online</groupId> <artifactId>payments-api</artifactId> <version>5.0.0</version> </dependency>
To include the library to a java gradle project, add the following dependencies to the build.gradle file.
Make sure to use the latest version of the SDK found here.
Using the SDK to call Payments API:
Create the RequestContext object as shown below. Pass in the accessToken and Environment.
RequestContext requestContext = new RequestContext.Builder(accessToken, Environment.SANDBOX).build();
You can also set Proxy parameters or a new requestId in the same way.
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.
TokenService tokenService = new TokenService(requestContext);
Prepare Token request to create token for a credit card
Address address = new Address.Builder().region("CA").postalCode("94086") .streetAddress("1130 Kifer Rd").city("Sunnyvale") .country("US").build(); Card card = new Card.Builder().expYear("2020").expMonth("02").address(address) .name("emulate=0").cvc("123") .number("4111111111111111").build(); Token tokenRequest = new Token.Builder().card(card).build();
Call the TokenService to create token
Token token = tokenService.createToken(tokenRequest);
Retrieve token value
Logging important attributes:
Using the SDK, we have made it easier for you to log important attributes for faster debugging.
To log intuit_tid, use the following method
To log requestId, use the following method
Have more questions or suggestions for improvement? Reach out to us on our developer forums.