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]
The MIT License (MIT)
Copyright (c) 2016 Iyanu Adelekan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.