Skip to main content

Official Python SDK for the Rasedi API

Project description

rasedi_python_sdk

A python SDK for Rasedi payment services.

Installation

You can install it using pip install rasedi-payment-sdk

How to use

First of all you will need PRIVATE_KEY and SECRET_KEY. These credentials are provided inside of your panel.

Note

If your key starts with live_... it means you are using live mode and if it starts with test_... it means you are using sand-box mode.

Create payment client

Once you provided the PRIVATE_KEY and SECRET_KEY now you can create your payment client simply using PaymentClient class provided in the sdk.

Also there it a third parameter called base_url which is optional but recommended to set. It is our API end point's base url.

For example: from RasediPaymentSDK import PaymentClient

client = PaymentClient(private_key="YOUR_KEY", secret_key="YOUR_SECRET", base_url="https://api.rasedi.com")

Now you are all set to use our payment system.

Create payment

Now that you have created the PaymentClient you can use it to create payment links.

You can use ICreatePayment provided to create a payment link. It includes the fields bellow:

  • amount : str which will declare the amount of the payment.It should be a stringified number.

  • title : str which is the title of your payment link so you can keep track of it in your panel and customers will see the title once paying.

  • description : str which is the description of your payment link. customers will see the description once paying.

  • gateways : list[GATEWAY] which it the selection of the GATEWAYs you want your customers use to pay. You can use GATEWAY enum provided in the sdk and use the gateways you desire.from RasediPaymentSDK import GATEWAY

  • collectFeeFromCustomer : bool with this set as True all service fees will be collected from your customer paying the payment link. This means service fees will be added to the amount you provided once paying.

  • collectCustomerEmail : bool with this set as True your customers should enter their email address once paying the payment link.

  • collectCustomerPhoneNumber: bool with this set as True your customers should enter their phone number once paying the payment link.

  • redirectUrl : str The url you want your customer to be returned after payment being PAID or FAILED.

  • callbackUrl : str Your webhook's endpoint for our system to call when payment status

Now with every parameter explianed, here is an example of create payment link:

response = await client.create_payment(

payload=ICreatePayment(
        amount="10200",
        title="Test Payment",
        description="This is a test payment",
        gateways=[GATEWAY.FIB,GATEWAY.ZAIN],
        redirectUrl="https://your-redirect-url.com",
        callbackUrl="https://your-webhook-url.com",
        collectFeeFromCustomer=True,
        collectCustomerEmail=True,
        collectCustomerPhoneNumber=False
        )

)

After this request you will get the response as an instance of ICreatePaymentResponse.

All responses from our end includes:

  • statusCode : int Which is the http status code
  • headers : dict[str, str] Which is the headers
  • body The type of body is differ based on the method you are using.

Now with that being said lets explian the response body of create payment link: It with be an instance of ICreatePaymentResponseBody:

  • referenceCode : str which is a unique id for your payment link, you can use this to check the your payment which will be explained in next step.

  • amount : str the amount of payment with fees included (or excluded) based on the collectFeeFromCustomer field.

  • status : PAYMENT_STATUS The PAYMENT_STATUS is an enum which is provided in the library. from RasediPaymentSDK import PAYMENT_STATUS.

  • paidVia : Optional[str] The gateway used to be paid if the payment is PAID

  • paidAt : Optional[str] The date of payment being paid if it is PAID

  • redirectUrl :str The redirect url you set it yourself on creation of payment

  • payoutAmount : Optional[str] Which is the amount you will recieve after the payment being PAID and fees excluded.

Get payment

get_payment_by_reference_code method will get the payment you have created. For using this method all you need is the referenceCode provided in the response of your create_payment method.

For example:

response = await client.get_payment_by_reference_code(reference_code="REFERENCE_CODE")

The body inside the response will be an instance of IPaymentDetailsResponseBody which contains these fields:

  • referenceCode : str which is a unique id for your payment.

  • amount : str the amount of payment with fees included (or excluded) based on the collectFeeFromCustomer field.

  • status : PAYMENT_STATUS The PAYMENT_STATUS is an enum which is provided in the library. from RasediPaymentSDK import PAYMENT_STATUS.

  • paidVia : Optional[str] The gateway used to be paid if the payment is PAID

  • paidAt : Optional[str] The date of payment being paid if it is PAID

  • redirectUrl :str The redirect url you set it yourself on creation of payment

  • payoutAmount : Optional[str] Which is the amount you will recieve after the payment being PAID and fees excluded.

Cancel payment

cancel_payment method will cancel the payment you have created. For using this method all you need is the referenceCode provided in the response of your create_payment method.

For example:

response = await client.cancel_payment(reference_code="REFERENCE_CODE")

The body inside the response will be an instance of ICancelPaymentResponseBody which contains these fields:

  • referenceCode : str which is a unique id for your payment.

  • amount : str the amount of payment with fees included (or excluded) based on the collectFeeFromCustomer field.

  • status : PAYMENT_STATUS The PAYMENT_STATUS is an enum which is provided in the library. from RasediPaymentSDK import PAYMENT_STATUS.

  • paidVia : Optional[str] The gateway used to be paid if the payment is PAID

  • paidAt : Optional[str] The date of payment being paid if it is PAID

  • redirectUrl :str The redirect url you set it yourself on creation of payment

  • payoutAmount : Optional[str] Which is the amount you will recieve after the payment being PAID and fees excluded.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rasedi_payment_sdk-1.0.6.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rasedi_payment_sdk-1.0.6-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file rasedi_payment_sdk-1.0.6.tar.gz.

File metadata

  • Download URL: rasedi_payment_sdk-1.0.6.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for rasedi_payment_sdk-1.0.6.tar.gz
Algorithm Hash digest
SHA256 2fad1a700f03024747b4fe966807420775dae0478858a28e2f7ec530b9f5f1e5
MD5 b790762b4c4c18bd6a9d706aea4f7214
BLAKE2b-256 808c01177f77a084fdf6c9731b76a6c7b7063646bd82eec6a9b57382c707ae5d

See more details on using hashes here.

File details

Details for the file rasedi_payment_sdk-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for rasedi_payment_sdk-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bbfb4525af8f8418171d1ce15462676c26f86cc715f17bb007c4b2f069dc4de0
MD5 c6cb67e709adacb1dacc8b105385a6be
BLAKE2b-256 cda3858e454a63081b2c365d9c70da387dba73a8956171372d235b7338aebdce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page