我正在使用 django-paypal,但无法访问 paypal 付款流程。
我对贝宝表格有我的看法,但在点击贝宝上的购买按钮后没有任何反应。
这是我的代码:(查看)
def paypal(request):
amount = 0
cart_item = get_cart_items(request)
all_product_in_cart = CartItem.objects.filter(cart_id=_cart_id(request))
for cart in all_product_in_cart:
amount += cart.product.price * cart.quantity
# What you want the button to do.
paypal_dict = {
"business": "xxx@xxx.com",
"amount": amount,
'currencycode': 'EUR',
"item_name": cart.product.name,
"invoice": "unique-invoice-id",
"notify_url": "/ipn/",
"return_url": request.build_absolute_uri(reverse("boutiquecar.views.success_payment")),
"cancel_return": request.build_absolute_uri(reverse("boutiquecar.views.cancel_payment")),
}
# Create the instance.
form = PayPalPaymentsForm(initial=paypal_dict, button_type="cart")
return render(request, "shop_paypal/payment.html", {
"form": form,
'amount': amount,
})
和模板:
<h1>You are about to buy for {{ amount }} €</h1>
<form method="post" action="{{ paypal_url }}">
{% csrf_token %}
<table>
<tbody>
{% if errors %}<tr><td colspan="2" align="center">{{ errors }}</td></tr>{% endif %}
{{ form.render }}
<tr><td colspan="2" align="right"><input type="submit" /></td></tr>
</tbody>
</table>
</form>
通常正如我在其他帖子中看到的那样,它会起作用,但我不知道如何解决它!
如果你能帮忙,那就太好了!:) 提前致谢