为Django的MultiSafepay支付网关集成
项目描述
django-multisafepay
MultiSafepay支付网关集成,支持许多国际支付方式。MultiSafepay是一家位于荷兰的大型支付网关。
MultiSafepay提供两种支付方式,请参阅 https://www.multisafepay.com/en/Payment-services/
安装
通过pip安装
pip install django-multisafepay
配置
在MultiSafepay商家 网站设置 中添加新网站。使用这些设置配置应用程序
- MULTISAFEPAY_ACCOUNT_ID
由MultiSafepay提供的账户ID。
- MULTISAFEPAY_SITE_ID
在MultiSafepay网站设置面板中找到的网站ID。
- MULTISAFEPAY_SITE_CODE
在MultiSafepay网站设置面板中找到的网站安全码。
- MULTISAFEPAY_TESTING
是否以测试模式运行。默认为 True。
添加到 urls.py
urlpatterns += patterns('', url(r'^api/multisafepay/', include('django_multisafepay.urls')), )
建议,临时记录此包的所有事件
LOGGING = { # ... 'handlers': { # ... 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', }, }, 'loggers': { # ... 'django_multisafepay': { 'handlers': ['console'], 'level': 'DEBUG', 'propagate': True, }, }, }
用法
创建新的支付交易
from django_multisafepay.client import MultiSafepayClient from django_multisafepay.data import Transaction, Customer from django.shortcuts import redirect def pay(request): client = MultiSafepayClient() reply = client.start_checkout( transaction = Transaction( ), customer = Customer( ) ) return redirect(reply.payment_url)
对于快速结账,请使用 start_checkout() 方法。
对于连接方法,请使用 redirect_transaction() 方法。
这两种方法都返回一个用于重定向用户的URL。
获取状态
client = MultiSafepayClient() statusreply = client.status(self.transaction_id)
待办事项
与 django-merchant 或 django-getpaid 精心集成。
并非所有XML功能都已实现,例如:
结账购物车
自定义字段
运费
ideal发行商请求(简单添加)