Universal Rasedi Payment Gateway SDK for Nodejs, React, Vue, Angular and React Native
Check the Github Repository for full implementations:
npm install rasedi-sdkInitialize the client with your credentials. Obtain your keys from the Rasedi Dashboard.
import { RasediClient, Gateway, PaymentStatus } from 'rasedi-sdk';
const client = new RasediClient('YOUR_PRIVATE_KEY', 'YOUR_SECRET_KEY');Initiate a new payment request. You can specify multiple gateways and various options.
const paymentResponse = await client.createPayment({
amount: "1050", // Amount in smallest currency unit (e.g., cents or local equivalent)
title: "Order #12345",
description: "Premium Subscription Plan",
gateways: [Gateway.CREDIT_CARD, Gateway.ZAIN], // Specify allowed payment methods
redirectUrl: "https://your-domain.com/payment/success",
callbackUrl: "https://your-domain.com/api/webhooks/payment", // For server-to-server notifications
collectFeeFromCustomer: false,
collectCustomerEmail: true,
collectCustomerPhoneNumber: true
});
console.log(`Payment Initiated: ${paymentResponse.body.referenceCode}`);
console.log(`Redirect URL: ${paymentResponse.body.redirectUrl}`);Retrieve the current status of a payment using its unique referenceCode. This is useful for polling or verifying payment completion.
const statusResponse = await client.getPaymentByReference(paymentResponse.body.referenceCode);
if (statusResponse.body.status === PaymentStatus.PAID) {
console.log("Payment successful!");
} else {
console.log(`Current Status: ${statusResponse.body.status}`);
}Cancel a pending payment. This operation is only valid for payments that are still in a PENDING state.
const cancelResponse = await client.cancelPayment(paymentResponse.body.referenceCode);
if (cancelResponse.body.status === PaymentStatus.CANCELED) {
console.log("Payment successfully canceled.");
}Supported payment gateways:
| Enum Value | Description |
|---|---|
Gateway.FIB |
First Iraqi Bank |
Gateway.ZAIN |
ZainCash |
Gateway.ASIA_PAY |
AsiaPay |
Gateway.FAST_PAY |
FastPay |
Gateway.NASS_WALLET |
NassWallet |
Gateway.CREDIT_CARD |
Credit Card (Visa/Mastercard) |
Possible states of a payment:
| Enum Value | Description |
|---|---|
PaymentStatus.PENDING |
Payment created and awaiting user action |
PaymentStatus.PAID |
Payment successfully completed |
PaymentStatus.FAILED |
Payment failed or was declined |
PaymentStatus.CANCELED |
Payment was manually canceled |
PaymentStatus.TIMED_OUT |
Payment session expired |
Check the repository for full implementations:
MIT