Saleor payment gateways are Python plugins implementing the GatewayPlugin interface. Build a PaystackGatewayPlugin class with process_payment() (calls POST /transaction/initialize and returns ClientToken with the authorization_url), confirm_payment() (calls GET /transaction/verify), and optionally refund() (calls POST /refund). Register the plugin in PLUGINS setting in saleor/settings.py.
# saleor/payment/gateways/paystack/__init__.py
import requests, hmac, hashlib
from saleor.payment.interface import GatewayConfig, GatewayResponse, PaymentData
PAYSTACK_API = 'https://api.paystack.co'
def process_payment(payment_information: PaymentData, config: GatewayConfig) -> GatewayResponse:
secret_key = config.connection_params['secret_key']
resp = requests.post(
PAYSTACK_API + '/transaction/initialize',
json={
'email': payment_information.customer_email,
'amount': int(payment_information.amount * 100), # to minor unit
'reference': payment_information.token,
'currency': 'NGN', # or from config
'callback_url': config.connection_params['callback_url'],
},
headers={'Authorization': 'Bearer ' + secret_key},
)
data = resp.json()
return GatewayResponse(
is_success=data['status'],
client_token=data['data']['authorization_url'], # storefront redirects here
transaction_id=data['data']['reference'],
amount=payment_information.amount,
currency=payment_information.currency,
error=data.get('message') if not data['status'] else None,
)
def confirm_payment(payment_information: PaymentData, config: GatewayConfig) -> GatewayResponse:
secret_key = config.connection_params['secret_key']
resp = requests.get(
PAYSTACK_API + '/transaction/verify/' + payment_information.token,
headers={'Authorization': 'Bearer ' + secret_key},
)
data = resp.json()
success = data['data']['status'] == 'success'
return GatewayResponse(
is_success=success,
transaction_id=payment_information.token,
amount=data['data']['amount'] / 100,
currency=data['data']['currency'],
error=None if success else data['data'].get('gateway_response'),
)
# saleor/settings.py
PLUGINS = [
# ... other plugins
'saleor.payment.gateways.paystack.PaystackGatewayPlugin',
]
# In your PaystackGatewayPlugin class:
class PaystackGatewayPlugin(BasePlugin):
PLUGIN_NAME = 'Paystack'
PLUGIN_ID = 'paystack'
CONFIG_STRUCTURE = {
'secret_key': {'label': 'Secret Key', 'type': 'secret'},
'callback_url': {'label': 'Callback URL', 'type': 'string'},
}
DEFAULT_ACTIVE = False
After registering, go to Saleor Dashboard → Plugins → Paystack to enter your secret key and callback URL. Activate the plugin and assign it to your channels.
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
See the Paystack integrations overview for all platform options.
KES 2,999
The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.
Start Paystack Course