我有一个在线商店,用户可以互相付款购买东西,我一直在使用沙箱帐户对其进行测试,但我认为它不起作用。我实在不明白问题出在哪里
这是我的观点.py:
def payment_process(request, trade_id):
trade = get_object_or_404(Trade, id=trade_id)
host = request.get_host()
paypal_dict = {
'business': trade.seller.email,
'amount': Decimal(trade.price),
'item_name': trade.filename,
'invoice': str(trade.id),
'currency_code': 'USD',
'notify_url': 'https://{}{}'.format(host,
reverse('paypal-ipn')),
'return_url': 'https://{}{}/{}'.format(host,
*reverse('payment_done', kwargs={'trade_id': trade.id})),
'cancel_return': 'https://{}{}'.format(host,
reverse('home')),
}
form = PayPalPaymentsForm(initial=paypal_dict)
return render(request, 'payment/payment_process.html', {'trade': trade, 'form': form})
@csrf_exempt
def payment_done(request, trade_id):
# Do some very important stuff after paying ...
# It would be really nice if someone can help me with a checker
messages.success(request, 'Your product is in your inbox now')
return redirect('trade:inbox')
我的网址.py:
urlpatterns = [
path('admin/', admin.site.urls),
...
# Prodbox Payment
path('payment/process/<int:trade_id>/', payment_views.payment_process, name="payment_process"),
path('payment/done/<int:trade_id>/', payment_views.payment_done, name="payment_done"),
# Prodbox packages
path('paypal/', include('paypal.standard.ipn.urls')),
]
完成付款后将用户重定向到 payment_done 视图非常重要(如果我有一个检查器在运行完成功能之前检查付款是否完成,那就太好了)
另请注意,我强调用户使用他们的 PayPal 电子邮件帐户
那么为什么它不起作用?
千巷猫影
相关分类