A Java based API wrapper for the Paystack API
A Java API wrapper for the facilitation of quick and easy development and integration of Java based applications with the the Paystack API.
PaystackJava removes the grunt involved in consuming the Paystack API and implements a diverse array of helper methods to enable rapid prototyping and testing.
- Unirest (Installation procedures here: https://github.com/Mashape/unirest-java#installing)
- Download PaystackJava
- Add jar file as a Module to your Java project:
- On Intellij IDEA: File -> Project Structure -> Modules -> Dependencies Tab -> Add -> JARs or Directories -> Attach jar
- On Netbeans: Project properties -> Libraries -> Compile -> ADD JAR/folder -> Add Jar
To create a new Paystack customer:
Customers customers = new Customers();
customers.createCustomer("[email]","[first_name]","[last_name]","[phone]","[metadata]");To fetch a customer
Customers customers = new Customers();
customers.fetchCustomer("[id_or_customer_code]");But what if you want to get the server JSON respone?
Customers customers = new Customers();
JSONObject jsonObject = new JSONObject(customers.fetchCustomer("[id_or_customer_code]"));Want to initialize a Paystack transaction?
Transactions transactions = new Transactions();
transactions.initializeTransaction("[reference]","[amount]","[email]","[plan]","[callback_url]");Don't like using strings to make your API requests?
ApiQuery apiQuery = new ApiQuery();
apiQuery.putParams("name","Offering collections");
new Pages().createPage(apiQuery);Or maybe you just love using HashMaps
HashMap<String,Object> query = new HashMap();
query.put("name","Offering collections");
new Pages().createPage(query);Remember to always shut down the API connection once you are done making requests
PaystackJava utilizes a background event loop and your Java application won't be able to exit until you manually shutdown all the threads by invoking:
ApiConnection.shutDown();PaystackJava utilizes a Keys.json file for the management of api key resources. This file must be placed in your root project directory and has the following structure:
{
"API_KEYS":{
"KEY_IN_USE": "sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"TEST_SECRET_KEY": "sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"TEST_PUBLIC_KEY": "pk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"LIVE_SECRET_KEY": "sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"LIVE_PUBLIC_KEY": "pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}- connectAndQuery [JSONObject]
- connectAndQueryWithGet [JSONObject]
- connectAndQueryWithPut [JSONObject]
- shutDown [void]
- newQuery [void]
- putParams [JSONObject]
- paystackStandard [JSONObject]
- verifyTransactions [JSONObject]
- chargeReturningCustomer [JSONObject]
- updateCustomer [JSONObject]
- createCustomer [JSONObject]
- listCustomers [JSONObject]
- fetchCustomer [JSONObject]
- updateCustomer [JSONObject]
- createCustomer [JSONObject]
- listCustomers [JSONObject]
- fetchCustomer [JSONObject]
- updateCustomer [JSONObject]
- initializeTransaction [JSONObject]
- verifyTransaction [JSONObject]
- listTransactions [JSONObject]
- fetchTransaction [JSONObject]
- chargeAuthorization [JSONObject]
- chargeToken [JSONObject]
- exportTransactions [JSONObject]
- listPlans [JSONObject]
- fetchPlan [JSONObject]
- updatePlan [JSONObject]
- updateCustomer [JSONObject]
- createPage [JSONObject]
- listPages [JSONObject]
- fetchPage [JSONObject]
- updatePage [JSONObject]
MIT License