![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
zw.co.paynow:java-sdk
Advanced tools
This project contains libraries to interface with Zimbabwe's Leading Payments Gateway Paynow
Before you can start making requests to Paynow's API, you need to get an integration ID and integration Key from Paynow. Details about how you can retrieve the ID and key are explained in detail on this page
In order to make use of this project, the following prerequisites must be met for it to work.
To use the Java Paynow SDK, you need to add the latest release as a dependency to your project. The latest release will be in the Maven Central Repository.
repositories {
mavenCentral()
}
dependencies {
implementation 'zw.co.paynow:java-sdk:1.1.2'
}
<dependency>
<groupId>zw.co.paynow</groupId>
<artifactId>java-sdk</artifactId>
<version>1.1.2</version>
</dependency>
Create an instance of Paynow
associated with your integration ID and integration key as supplied by Paynow.
Paynow paynow = new Paynow("INTEGRATION_ID", "INTEGRATION_KEY");
A web based transaction is made over the web, via the Paynow website.
You can optionally set the result and return URLs.
paynow.setResultUrl("http://example.com/gateways/paynow/update");
paynow.setReturnUrl("http://example.com/return?gateway=paynow&merchantReference=1234");
Create a new payment using any of the createPayment(...)
methods, ensuring you pass your own unique reference for that payment (e.g invoice id). If you also pass in the email address, Paynow will attempt to auto login the customer at the Paynow website using this email address if it is associated with a registered account.
Payment payment = paynow.createPayment("Invoice 35");
You can then start adding items to the payment cart.
// Passing in the name of the item and the price of the item
payment.add("Bananas", 2.5);
payment.add("Apples", 1.0);
When you are ready to submit the payment request, initiate the transaction by calling the send(...)
method. You can optionally set the description of the cart which will be shown to the user at the Paynow website, otherwise a default description will be generated.
payment.setCartDescription("Some custom description");//this is optional
// Save the response from paynow in a variable
WebInitResponse response = paynow.send(payment);
The WebInitResponse
response from Paynow will contain various information including:
If the request was successful, you should consider saving the poll URL sent from Paynow in your database so that you can use it later to check if the transaction has been paid.
if (response.success()) {
// Get the url to redirect the user to so they can make payment
String redirectUrl = response.redirectURL();
// Get the poll URL of the transaction
String pollUrl = response.pollUrl();
} else {
// Ahhhhhhhhhhhhhhh
// *freak out*
}
A mobile transaction is a transaction made using mobile money e.g. using Ecocash or OneMoney
Note: Mobile based transactions currently only work for Ecocash and OneMoney
Create a new payment using the createPayment(...)
method that requires a unique merchant reference and the email address of the user making the payment.
Payment payment = paynow.createPayment("Invoice 32", "user@example.com");
Adding items to the cart is the same as in web based transactions.
// Passing in the name of the item and the price of the item
payment.add("Bananas", 2.5);
payment.add("Apples", 1.0);
When you are ready to submit the payment request, initiate the transaction by calling the sendMobile(...)
method.
MobileInitResponse response = paynow.sendMobile(payment, "0771234567", MobileMoneyMethod.ECOCASH);
The MobileInitResponse
response from Paynow will contain various information including:
If the request was successful, you should consider saving the poll URL sent from Paynow in your database so that you can use it later to check if the transaction has been paid.
if (response.success()) {
// Get the instructions to show to the user
String instructions = response.instructions();
// Get the poll URL of the transaction
String pollUrl = response.pollUrl();
} else {
// Ahhhhhhhhhhhhhhh
// *freak out*
}
It is possible to check the status of a transaction i.e. if the payment has been paid. To do this, make sure after initiating the transaction, you take note of the poll URL in the response. With this URL, call the pollTransaction(...)
method of the Paynow
object you created as follows. Note that checking transaction status is the same for web and mobile based transasctions.
// Check the status of the transaction with the specified pollUrl
StatusResponse status = paynow.pollTransaction(pollUrl);
if (status.isPaid()) {
// Yay! Transaction was paid for
} else {
System.out.println("Why you no pay?");
}
The following is a full usage example for web based transactions.
// MakingFirstPayment.java
import zw.co.paynow.core.*;
import zw.co.paynow.core.Paynow;
import zw.co.paynow.core.Payment;
public class MakingFirstPayment {
public static void main(String[] args) {
Paynow paynow = new Paynow("INTEGRATION_ID", "INTEGRATION_KEY");
Payment payment = paynow.createPayment("Invoice 35");
// Passing in the name of the item and the price of the item
payment.add("Bananas", 2.5);
payment.add("Apples", 3.4);
//Initiating the transaction
WebInitResponse response = paynow.send(payment);
//If a mobile transaction,
//MobileInitResponse response = paynow.sendMobile(payment, "0771234567", MobileMoneyMethod.ECOCASH);
if (response.isRequestSuccess()) {
// Get the url to redirect the user to so they can make payment
String redirectURL = response.redirectURL();
// Get the poll url of the transaction
String pollUrl = response.pollUrl();
//checking if the payment has been paid
StatusResponse status = paynow.pollTransaction(pollUrl);
if (status.paid()) {
// Yay! Transaction was paid for
} else {
System.out.println("Why you no pay?");
}
} else {
// Something went wrong
System.out.println(response.errors());
}
}
}
FAQs
This project contains libraries to interface with Zimbabwe's Leading Payments Gateway Paynow
We found that zw.co.paynow:java-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.