我使用django-paypal进行有效的付款方式,但是,如何在完成付款后重定向用户后如何检查付款是否实际完成? 这是我基于process_payment函数的视图:
def payment_process(request, trade_id):
trade = get_object_or_404(Trade, id=trade_id)
host = request.get_host()
paypal_dict = {
...
'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})
我的payment_done视图(付款后用户重定向到该视图:
# if paymenis done ????????:
messages.success(request, 'Your product is in your inbox now')
return redirect('trade:inbox')
# else (the payment was not completed
messages.error(request, 'You didnt complete the payment, if you are sure you did contact us at someemail@gmail.com and provide us with some evidence')
return redirect('home')