The Veem Java SDK provides an interface to make it easier to call Veem Global Payments APIs for server side Java backend service. Some of the features included in the SDK are:
- The SDK works on JDK 8 and above.
- A developer account
- An application with a customer account and the associated client id and secret (Authorization flow / Client Credentials flow)
- Clone the GitHub repo to your computer.
- Import it to the IDE of your choice.
To test the code locally, follow the steps below:
- cd to the project directory
- Client can either integrate with Authorization flow or Client Credential Flow;
- For Authorization flow, fill in the
testConfigAuth.json
file values with client id ,client secret and redirect url (optional). - For Client Credentials flow, fill in the
testConfigClientCreds.json
file values with client id and client secret. - To exercise all Veem Global Payment APIs, fill access_token received from either step 3 or 4 to
testConfig.json
. - Run the command:
./gradlew build
- this will run the unit test and build the sdk jar.
In order to get the access tokens from the Developer Portal;
Sign In with Veem - Sign into developer Portal .
Create an Application- Create a new application by providing the Name
, OAuth2 Redirection URLs
and Payment Status Webhooks
.
Create a Customer- Create a new customer by providing Business Name
, Country
and Primary Email
Get Credentials- Go the Application and select the Customer
and copy the Access Token
.
In order to get the access token
programmatically, get the client id, client secrets (Optional redirect url for Authorization flow).
val veemContext = new VeemContext.VeemContextBuilder()
.environment(SANDBOX) //SANDBOX or PRODUCTION environment
.clientId(clientId)
.clientSecret(clientSecret)
.build()
val authenticationClient = veemContext.getAuthenticationClient()
val tokenResponse = authenticationClient.getTokenFromClientCredentials(Arrays.asList(Scope.ALL))
The following example is to send invoice using Invoice Client
VeemContext veemContext = new VeemContext.VeemContextBuilder()
.environment(SANDBOX)
.build()
Invoice invoice = Invoice.builder()
.amount(new Amount(BigDecimal.valueOf(100), USD))
.payer(Account.builder()
.email("test-${-> randomUUID()}@mailinator.com")
.firstName("Test")
.lastName("Veem API")
.countryCode(US)
.phone("2102102100")
.type(INCOMPLETE)
.build())
.build()
Invoice sentInvoice = veemClient.invoices().send(invoice)