Skip to content

esiteltd/java-zaincash-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zain Cash Logo

Zain Cash Payment Gateway - Java SDK

GitHub Package GitHub Release Java Version License: MIT


Getting Started

1. Add the Dependency

Add to your build.gradle:

dependencies {
    implementation 'com.esite.zaincash:zaincash-sdk:0.0.1'
}

2. Configure Application Properties

Add to your application.properties or .yml:

zaincash:
msisdn:
secret: 
merchant-id:
environment: 
language: 
  • Environment: PRODUCTION or SANDBOX
  • Language: ENGLISH or ARABIC

Creating a Payment Request

Use the PaymentRequest class:

PaymentRequest paymentRequest = new PaymentRequest(
        your_amount,
        your_service_type,
        your_order_id,
        "https://your-redirect-url.com"
);

Notes:

  • Amount (IQD):

    • Must be in Iraqi Dinar (IQD).
    • If using USD, multiply by the exchange rate (e.g., 10 USD * 1450 = 14500 IQD).
    • Must be greater than 1000 IQD.
  • Service Type:
    Brief description (e.g., "Book Purchase", "Internet Subscription").

  • Order ID:
    Used for internal tracking (e.g., "Order12345").

    • Type: String
    • Max Length: 512 characters
  • Redirect URL:
    Publicly accessible endpoint to handle ZainCash response.


Initiate Payment

Inject ZainCashSDK and use:

private final ZainCashSDK zainCashSDK;

public void initializePayment() {
    PaymentRequest paymentRequest = new PaymentRequest(
            your_amount,
            your_service_type,
            your_order_id,
            "https://your-redirect-url.com"
    );

    try {
        // Redirect user to payment URL
        String paymentResponse = zainCashSDK.initiatePayment(paymentRequest);
    } catch (ZainCashException e) {
        // Handle exception
    }
}

Checking Payment Status

Extract the token from the redirect URL and check status:

private final ZainCashSDK zainCashSDK;

public void checkPaymentStatus(String token) {
    try {
        StatusResponse paymentStatusResponse = zainCashSDK.checkPaymentStatus(token);
    } catch (ZainCashException e) {
        // Handle exception
    }
}

StatusResponse Class

public class StatusResponse {
    private String success;
    private String orderId;
    private String id;
    private Date iat;
    private Date exp;
}

Support

For any issues, feel free to reach out.

Developed with ❤️ by @alsaadii98 at eSITE Information Technology.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages