An open API service indexing awesome lists of open source software.

https://github.com/mirotechteam/rasedi-c-sharp-sdk

Build desktop, web, or backend integrations for Rasedi using C#. Ideal for Windows-based solutions and enterprise-level systems.
https://github.com/mirotechteam/rasedi-c-sharp-sdk

csharp iraq kurdistan netcore payment-gateway payment-integration paymetn rasedi sdk

Last synced: about 2 months ago
JSON representation

Build desktop, web, or backend integrations for Rasedi using C#. Ideal for Windows-based solutions and enterprise-level systems.

Awesome Lists containing this project

README

          

๏ปฟ# C#.NET SDK

A lightweight SDK for interacting with the Rasedi Payment API, built on top of [HttpClient in System.Net.Http and System.Net.Http.Headers] for fast, native HTTP calls and private key-based request signing.

---

## ๐Ÿ“ฆ Installation

```bash
dotnet add package RasediSDK --version x.x.x
```

---

## ๐Ÿš€ Usage

```C#
using RasediSDK.Rest;
using RasediSDK.Rest.Enums;
using RasediSDK.Rest.Interfaces;
using RasediSDK.Exceptions;

var client = new PaymentRestClient(privateKey, secretKey);
```

> **Note:**
> Switching between sandbox and production mode will be automatically based on (test) and (live) keyword inside secretKey `(test = sandbox mode, live = production mode)`.

---

## ๐Ÿ” Authentication

The SDK uses a private key and a secret to sign every request with HMAC. Signature logic is handled internally.

---

## ๐Ÿงช Example

```C#
string privateKey = `-----BEGIN ENCRYPTED PRIVATE KEY-----
...
-----END ENCRYPTED PRIVATE KEY-----`;

string secretKey = "live_xxx..."; // or "test_xxx..."

var client = new PaymentRestClient(privateKey, secretKey);
```

---

## ๐Ÿ“˜ API Reference

#### `new PaymentRestClient(string privateKey, string secretKey)`

Creates a new client instance.

---

#### `async Task CreatePaymentAsync(ICreatePayment payload)`

Creates a new payment session.

**Hint:** The `amount` parameter cannot be a decimal value.

**Parameters:**

```C#
new CreatePayment
{
string amount; // e.g. "1000"
GateWays[] gateways; // e.g. [GateWays.ZAIN, GateWays.FIB]
string title;
string description;
string redirectUrl;
string callbackUrl;
bool collectFeeFromCustomer;
bool collectCustomerEmail;
bool collectCustomerPhoneNumber;
}
```

**Returns:**

```C#
new CreatePaymentResponse
{
StatusCode = response.StatusCode,
Body = response.Body,
Headers = response.Headers
};
```

**Example:**

```C#
await client.CreatePaymentAsync( new CreatePayment {
amount: "1000",
gateways: [GateWays.FIB],
title: "Test",
description: "Desc",
redirectUrl: "https://google.com",
callbackUrl: "https://google.com",
collectFeeFromCustomer: false,
collectCustomerEmail: false,
collectCustomerPhoneNumber: false,
});
```

---

#### `async Task GetPaymentByIdAsync(string referenceCode)`

Gets the details of a payment.

**Returns:**

```C#
new PaymentDetailsResponse
{
StatusCode = response.StatusCode,
Body = response.Body,
Headers = response.Headers
};
```

**Example:**

```C#
var status = await client.GetPaymentByIdAsync("your-reference-code");
Console.WriteLine(status.body.status);
```

---

#### `async Task CancelPaymentAsync(string referenceCode)`

Cancels an existing payment.

**Example:**

```C#
await client.CancelPaymentAsync("your-reference-code");
```

**Returns:**

```C#
new CancelPaymentResponse
{
StatusCode = response.StatusCode,
Body = response.Body,
Headers = response.Headers
};
```

---
#### `Using RasediSDK.Exception to catch different type of exception`

The exceptions help you to catch more specific and error-related issues.

**Example:**

```C#
try
{
// 1. Try to get a public key by ID
...................................

// 2. Validate payload content
...................................

// 3. More SDK calls...............
}
catch (PublicKeyNotFoundException ex)
{
Console.WriteLine("Handle missing key specifically: " + ex.Message);
}
catch (InvalidPayloadException ex)
{
Console.WriteLine("Handle invalid payload specifically: " + ex.Message);
}
catch (JwtValidationException ex)
{
Console.WriteLine("Handle JWT validation errors: " + ex.Message);
}
catch (PayloadDeserializationException ex)
{
Console.WriteLine("Handle deserialization errors: " + ex.Message);
}
catch (PemFormatException ex)
{
Console.WriteLine("Handle PEM format errors: " + ex.Message);
}
catch (RasediException ex)
{
// Catch any other SDK-related errors not explicitly caught above
Console.WriteLine("General Rasedi SDK error: " + ex.Message);
}
catch (Exception ex)
{
// Catch unexpected errors not related to SDK
Console.WriteLine("Unexpected error: " + ex.Message);
}
```

---

## ๐Ÿท๏ธ Types

```C#
public enum GateWays
{
[EnumMember(Value = "FIB")]
FIB,

[EnumMember(Value = "ZAIN")]
ZAIN,

[EnumMember(Value = "ASIA_PAY")]
ASIA_PAY,

[EnumMember(Value = "FAST_PAY")]
FAST_PAY,

[EnumMember(Value = "NASS_WALLET")]
NASS_WALLET,

[EnumMember(Value = "CREDIT_CARD")]
CREDIT_CARD
}
```
```
public enum PaymentStatuses
{
[EnumMember(Value = "TIMED_OUT")]
TIMED_OUT,

[EnumMember(Value = "PENDING")]
PENDING,

[EnumMember(Value = "PAID")]
PAID,

[EnumMember(Value = "CANCELED")]
CANCELED,

[EnumMember(Value = "FAILED")]
FAILED,

[EnumMember(Value = "SETTLED")]
SETTLED
}
```

---

## ๐Ÿ’ฌ Need Help?

Contact the payment provider or open an issue on the internal GitHub repo.

---
## ๐ŸŽฏ Testing SDK

You can test the SDK [ โžก๏ธ here](https://github.com/MirotechTeam/rasedi-c-sharp-sdk/blob/master/Test/TestSdk.cs).

---