Safepay logo
Docs
Safepay logo
Launch Safepay

Python SDK

Learn how to integrate Safepay into your Python backend application


A set of components allowing easy integration of Safepay Button and Safepay Checkout into your website, powered by zoid

1. Install through Pip

In your project root you can run the command below

Pip

Using Pip:

$ pip install safepay-python

2. Import

Import Safepay class from safepay library

3. Create a Safepay client by passing your config

You can now create payments and checkout links.

4. Set currency and amount

Since we're huge fans of React at Safepay, we've integrated this library into our products like Quick Links through the following React integration that ships out of the box with this library

5. Create checkout link

Pass the token received in payment response along with other parameters to generate checkout link. Redirect user to the checkout link.

6. Verify signature

Since we're huge fans of React at Safepay, we've integrated this library into our.

7. Verify webhook

Since we're huge fans of React at Safepay, we've integrated this library into our.

Ending Step

Since we're huge fans of React at Safepay, we've integrated this library into our products like Quick Links through the following React integration that ships out of the box with this library

Ending Step

Since we're huge fans of React at Safepay, we've integrated this library into our products like Quick Links through the following React integration that ships out of the box with this library

Feedback

What do you think of our integration document? Let us know here support@getsafepay.com

from "python_sdk" import safepay;
env = safepay.Safepay(
{
"environment": "sandbox",
"apiKey": "sec_asd12-2342s-1231s",
"v1Secret": "bar",
"webhookSecret": "foo",
}
)
payment_response = env.set_payment_details(
{
"currency": "PKR",
"amount": 1000
}
)
token = payment_response["data"]["token"]
# Pass 'token' to create checkout link
checkout_url = env.get_checkout_url(
{
"beacon": token,
"cancelUrl": "http://example.com/cancel",
"orderId": "T800",
"redirectUrl": "http://example.com/success",
"source": "custom",
"webhooks": True,
}
)
# set webhooks = True if want to subscribe to webhooks
# redirect user to 'url'
Previous
Javascript SDK
Next
React Native SDK