Universal Rasedi Payment Gateway SDK for iOS, macOS, and Swift server-side applications. Fully powered by Apple's native CryptoKit and Security frameworks to ensure zero external dependencies and maximum security for cryptographic signatures.
Check the Github Repository for full implementations.
The preferred way to install the Rasedi SDK is through the Swift Package Manager.
In Xcode:
- Go to
File>Add Packages... - Enter the repository URL:
https://github.com/MirotechTeam/rasedi-swift-sdk.git - Click "Add Package" and select the
Rasedilibrary for your target.
In Package.swift:
Add the dependency to your project's Package.swift file:
dependencies: [
.package(url: "https://github.com/MirotechTeam/rasedi-swift-sdk.git", from: "1.0.0")
]Initialize the RasediClient with your cryptographic credentials. Obtain your raw PEM format keys from the Rasedi Dashboard.
import Rasedi
let privateKey = """
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEICJ+........................................
-----END PRIVATE KEY-----
"""
let secretKey = "test_your_secret_key_here"
let client = RasediClient(privateKey: privateKey, secretKey: secretKey)Note: Test vs. Live environment URL routing is automatically deduced based on whether your
secretKeystring contains"test".
Initiate a new payment request. Specify the supported Gateway endpoints and callback destinations.
let payload = CreatePaymentPayload(
amount: "1050", // Amount in smallest currency unit
title: "Order #12345",
description: "Premium Subscription Plan",
gateways: [.creditCard, .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
)
Task {
do {
let paymentResponse = try await client.createPayment(payload: payload)
print("Payment Initiated: \(paymentResponse.body.referenceCode)")
print("Redirect URL: \(paymentResponse.body.redirectUrl)")
} catch {
print("Payment error: \(error.localizedDescription)")
}
}Retrieve the current deterministic status of a payment using its unique referenceCode. Useful for polling verification without waiting for standard webhook callbacks.
Task {
do {
let statusResponse = try await client.getPaymentByReference(referenceCode: "YOUR_REFERENCE_CODE")
if statusResponse.body.status == .paid {
print("Payment successful!")
} else {
print("Current Status: \(statusResponse.body.status.rawValue)")
}
} catch {
print("Status check failed: \(error)")
}
}Cancel a pending payment session programmatically. This operation is strictly only permissible when the payment is currently listed in a .pending state prior to execution.
Task {
do {
let cancelResponse = try await client.cancelPayment(referenceCode: "YOUR_REFERENCE_CODE")
if cancelResponse.body.status == .canceled {
print("Payment successfully canceled.")
}
} catch {
print("Cancellation error: \(error)")
}
}Supported payment gateways:
| Enum Value | String Raw | Description |
|---|---|---|
.fib |
FIB |
First Iraqi Bank |
.zain |
ZAIN |
ZainCash |
.asiaPay |
ASIA_PAY |
AsiaPay |
.fastPay |
FAST_PAY |
FastPay |
.nassWallet |
NASS_WALLET |
NassWallet |
.creditCard |
CREDIT_CARD |
Credit Card (Visa/Mastercard) |
Possible determinative states surrounding a specific payment context:
| Enum Value | String Raw | Description |
|---|---|---|
.pending |
PENDING |
Payment created and awaiting user action |
.paid |
PAID |
Payment successfully completed |
.failed |
FAILED |
Payment failed or was declined |
.canceled |
CANCELED |
Payment was manually canceled |
.timedOut |
TIMED_OUT |
Payment session expired over inactivity |
iOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+
(Requires Apple's natively included CryptoKit implementations to drive fast, isolated, standard cryptographic integrations independent of bloated C libraries).
MIT