Paypal "_cart"实现与 django-paypal

标签 paypal django-forms django-paypal

我正在使用 django-paypal ipn.standard 并试图让它与 paypal 的“_cart”选项一起工作。但是,我无法使其工作。

我使用这个字典来初始化表单:

cart {
  'amount_1': '0.99',
  'amount_2': '0.99',
  'business': 'seller_436_biz@foo.com',
  'cancel_return': 'http://www.foo.com/ccled/',
  'cmd': '_cart',
  'invoice': '1',
  'item_name_1': 'Item 1',
  'item_name_2': 'Item 2',
  'notify_url': 'http://www.foo.com/ntfy/',
  'return_url': 'http://www.doo.com/done/'
}

form = PayPalPaymentForm(initial=cart)

我也试过在上面的字典中添加 "CMD_CHOICES":"_cart",但没有什么区别

但是,在使用 {{ form.render }} 时,我得到了带有以下 html 的“立即购买”按钮:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  <input type="hidden" name="business" value="seller_436_biz@foo.com" id="id_business" />
  <input type="hidden" name="notify_url" value="'http://www.foo.com/ntfy//" id="id_notify_url" />
  <input type="hidden" name="cancel_return" value="http://www.foo.com/ccled/" id="id_cancel_return" />
  <input type="hidden" name="return" value="http://www.foo.com/done/" id="id_return_url" />
  <input type="hidden" name="invoice" value="1" id="id_invoice" />
  <input type="hidden" name="cmd" value="_cart" id="id_cmd" />
  <input type="hidden" name="charset" value="utf-8" id="id_charset" />
  <input type="hidden" name="currency_code" value="USD" id="id_currency_code" />
  <input type="hidden" name="no_shipping" value="1" id="id_no_shipping" />
  <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="Buy it Now" />
</form>

没有显示任何购物车项目。

我正在查看其他几个线程,例如 Multiple Items in django-paypal .为了进行尝试,我从该示例中剪切粘贴了“item”字典,并将其传递到我的 PayPalPaymentForm。但是,同样,在表格中,我没有看到正在出售的商品。

请问我错过了什么?

最佳答案

我想出了我错过了什么。表单应使用“购物车”选项创建:

form = PayPalPaymentForm(initial=cart, button_type="cart")

关于Paypal "_cart"实现与 django-paypal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10926454/

相关文章:

Django ModelChoiceField 下拉框自定义填充

python - 如何在 Django 中调试 PayPal IPN?

Django-paypal:带有无效回传的 IPN 请求

paypal - 将参数添加到 Paypal Express Checkout Button 以进行订阅付款

php - Paypal Sandbox 定期付款,初始金额待定

php - 用于提交按钮的 HTML 不会将数据插入数据库并一起重定向到 URL

django 表单 dateField 验证失败

paypal - 我如何确保 PayPal 付款退回我的网站以立即记入用户?

python - Django 表单自定义 : change field on other field change

django - Paypal 账户创建 : No redirection to PayPal