django-paypal 中的多个项目

发布于 2024-09-28 13:46:54 字数 193 浏览 1 评论 0原文

我正在使用 dcramer 版本的 django-paypal(但我认为它是 dcramer 还是 johnboxall 的并不重要)。

1) 我如何在我的 paypal_dict 中指定多个项目(在 PayPalPaymentsForm 中使用)? 2) 另外,我需要在 Paypal 屏幕上显示的摘要中适当指定运费和单个数量 - 我该如何执行此操作?

I am using dcramer's version of django-paypal(but i think it shouldnt matter whether it is dcramer or johnboxall's).

1) How can i specify multiple items in my paypal_dict(to be used in PayPalPaymentsForm)?
2) Also, i need to suitably specify the shipping cost and the individual quantities in the Summary that appears in the Paypal screen - how do i do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

铁轨上的流浪者 2024-10-05 13:46:54

我不喜欢 django-paypal。只需阅读 PayPal api: https://www.paypal .com/cgi-bin/webscr?cmd=p/pdn/howto_checkout-outside

要将购物车中的所有商品推送至 PayPal:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="upload" value="1">
        <input type="hidden" name="business" value="[email protected]">
        <input type="hidden" name="currency_code" value="EUR">

        <!-- Run a for loop -->
        {% for item in cart %}
        <input type="hidden" name="item_name_1" value="Item Name 1">
        <input type="hidden" name="amount_1" value="10.00">
        <input type="hidden" name="item_name_2" value="Item Name 2">
        <input type="hidden" name="amount_2" value="20.00">
        .
        .
        .
        <input type="hidden" name="item_name_N" value="Item Name N">
        <input type="hidden" name="amount_N" value="30.00">
        {% endfor %}

        <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>

I'm not fond of django-paypal. Just read the PayPal api: https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/howto_checkout-outside.

To push all the items in your cart to PayPal:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="upload" value="1">
        <input type="hidden" name="business" value="[email protected]">
        <input type="hidden" name="currency_code" value="EUR">

        <!-- Run a for loop -->
        {% for item in cart %}
        <input type="hidden" name="item_name_1" value="Item Name 1">
        <input type="hidden" name="amount_1" value="10.00">
        <input type="hidden" name="item_name_2" value="Item Name 2">
        <input type="hidden" name="amount_2" value="20.00">
        .
        .
        .
        <input type="hidden" name="item_name_N" value="Item Name N">
        <input type="hidden" name="amount_N" value="30.00">
        {% endfor %}

        <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
天邊彩虹 2024-10-05 13:46:54

我最终在视图中构建了这样的项目字典:

item = {
    'cancelurl':     'http://%s%s' % DYNAMIC_URL, reverse('pay_cancel')), # Express checkout cancel url
    'returnurl':     'http://%s%s' % (DYNAMIC_URL, reverse('pay_now')), # Express checkout return url

    'l_name0':       'Your product name',
    'l_number0':     1234,
    'l_desc0':       'longer description',
    'l_amt0':        100.00,
    'l_qty0':        1,

    'l_name1':       'Your product name',
    'l_number1':     1234,
    'l_desc1':       'longer description',
    'l_amt1':        200.00
    'l_qty1':        2,

    'itemamt':       500.00,
    'taxamt':        0.00,
    'shippingamt':   0.00,
    'handlingamt':   0.00,
    'shipdiscamt':   0.00,
    'insuranceamt':  0.00,
    'amt':           500.00, # Amount to charge for basket
}

然后这个字典像这样捆绑在一起:

kw = {
    'item': item,
    'payment_template': 'cms/register.html', # Template name for payment
    'confirm_template': 'cms/paypal-confirmation.html', # Template name for confirmation
    'success_url':      reverse('pay_success'), # Ultimate return URL
}

ppp = PayPalPro(**kw)
return ppp(request)

这是你的意思吗?

I end up building item dictionaries like this in the view:

item = {
    'cancelurl':     'http://%s%s' % DYNAMIC_URL, reverse('pay_cancel')), # Express checkout cancel url
    'returnurl':     'http://%s%s' % (DYNAMIC_URL, reverse('pay_now')), # Express checkout return url

    'l_name0':       'Your product name',
    'l_number0':     1234,
    'l_desc0':       'longer description',
    'l_amt0':        100.00,
    'l_qty0':        1,

    'l_name1':       'Your product name',
    'l_number1':     1234,
    'l_desc1':       'longer description',
    'l_amt1':        200.00
    'l_qty1':        2,

    'itemamt':       500.00,
    'taxamt':        0.00,
    'shippingamt':   0.00,
    'handlingamt':   0.00,
    'shipdiscamt':   0.00,
    'insuranceamt':  0.00,
    'amt':           500.00, # Amount to charge for basket
}

This dict then gets bundled up like this:

kw = {
    'item': item,
    'payment_template': 'cms/register.html', # Template name for payment
    'confirm_template': 'cms/paypal-confirmation.html', # Template name for confirmation
    'success_url':      reverse('pay_success'), # Ultimate return URL
}

ppp = PayPalPro(**kw)
return ppp(request)

Is that what you mean?

长梦不多时 2024-10-05 13:46:54

假设您想让贝宝与您的购物车一起使用。
对购物车中的商品使用 for 循环。
为了获得每个项目的编号以便贝宝识别它们,我使用
商品编号

{% extends 'base.html' %}
{% block content %}

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="currency_code" value="USD">
{% for item in cart %}

<input type="hidden" name="item_name_{{item.id}}" value="  
{{item.name}}">
<input type="hidden" name="amount_{{item.id}}" value="{{item.price}}">
{% endfor %}

<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" 
name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>


{% endblock %}

Assuming you want to to make paypal work with your cart.
Use a for loop for items in the cart.
In order to get a number for each item for paypal to recognize them i use
item.id

{% extends 'base.html' %}
{% block content %}

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="currency_code" value="USD">
{% for item in cart %}

<input type="hidden" name="item_name_{{item.id}}" value="  
{{item.name}}">
<input type="hidden" name="amount_{{item.id}}" value="{{item.price}}">
{% endfor %}

<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" 
name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>


{% endblock %}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文