用于集成webtopay支付的可插入django应用程序
django-webtopa的Python项目详细描述
灵感来自Django PayPal
如何使用
安装django webtopay
将WEBTOPAY_PASSWORD='pass'添加到设置文件中
添加回调URL:: url(r'^wtp/',include('webtopay.urls.makro')) (这应该比较难猜测)
创建提交表单:
form = WebToPaymentForm( dict(projectid = 123123, orderid = '3c3662bcb661d6de679c636744c66b62', accepturl = request.build_absolute_uri(), cancelurl = request.build_absolute_uri(), callbackurl = reverse('webtopay-makro'), paytext = "Payment for services", p_firstname = "Vardenis", p_lastname = "Pavardenis", p_email = "vardenis@pavardenis.lt", amount = 989, # 9 Lt 89 ct test = 1 ), button_html="<input type='submit' value='Pay!'/>", )
付款完成时捕获django信号:
from webtopay.signals import payment_was_successful def process_payment(**kargs): trans = kargs['sender'] if price_i_expect * 100 != trans.amount: log.error("Received wrong amount. Expected: %d, got: %d",\ price_i_expect*100, trans.amount) return paid = True # from this point we assume customer paid #... payment_was_successful.connect(process_payment)
如果你想知道什么时候 出错:
from webtopay.signals import payment_was_flagged def investigate_payment(**kargs): # kargs['sender'] is an instance of WebToPayResponse. # All fields are documented in webtopay/models.py log.warn("Payment went wrong for %s, please investigate", kargs['sender'].orderid) payment_was_flagged.connect(investigate_payment)
如果您有任何问题,请使用issues页面。