A python SDK for Rasedi payment services.
You can install it using pip install rasedi-payment-sdk
First of all you will need PRIVATE_KEY and SECRET_KEY. These credentials are provided inside of your panel.
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.
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.
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 : strwhich will declare the amount of the payment.It should be a stringified number. -
title : strwhich 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 : strwhich is the description of your payment link. customers will see the description once paying. -
gateways : list[GATEWAY]which it the selection of theGATEWAYs you want your customers use to pay. You can useGATEWAYenum provided in the sdk and use the gateways you desire.from RasediPaymentSDK import GATEWAY -
collectFeeFromCustomer : boolwith this set asTrueall service fees will be collected from your customer paying the payment link. This means service fees will be added to theamountyou provided once paying. -
collectCustomerEmail : boolwith this set asTrueyour customers should enter their email address once paying the payment link. -
collectCustomerPhoneNumber: boolwith this set asTrueyour customers should enter their phone number once paying the payment link. -
redirectUrl : strThe url you want your customer to be returned after payment beingPAIDorFAILED. -
callbackUrl : strYour 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.
statusCode : intWhich is the http status codeheaders : dict[str, str]Which is the headersbodyThe 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 : strwhich 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 : strthe amount of payment with fees included (or excluded) based on thecollectFeeFromCustomerfield. -
status : PAYMENT_STATUSThePAYMENT_STATUSis 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 isPAID -
paidAt : Optional[str]The date of payment being paid if it isPAID -
redirectUrl :strThe redirect url you set it yourself on creation of payment -
payoutAmount : Optional[str]Which is the amount you will recieve after the payment beingPAIDand fees excluded.
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 : strwhich is a unique id for your payment. -
amount : strthe amount of payment with fees included (or excluded) based on thecollectFeeFromCustomerfield. -
status : PAYMENT_STATUSThePAYMENT_STATUSis 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 isPAID -
paidAt : Optional[str]The date of payment being paid if it isPAID -
redirectUrl :strThe redirect url you set it yourself on creation of payment -
payoutAmount : Optional[str]Which is the amount you will recieve after the payment beingPAIDand fees excluded.
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 : strwhich is a unique id for your payment. -
amount : strthe amount of payment with fees included (or excluded) based on thecollectFeeFromCustomerfield. -
status : PAYMENT_STATUSThePAYMENT_STATUSis 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 isPAID -
paidAt : Optional[str]The date of payment being paid if it isPAID -
redirectUrl :strThe redirect url you set it yourself on creation of payment -
payoutAmount : Optional[str]Which is the amount you will recieve after the payment beingPAIDand fees excluded.