0

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

1) 如何在我的 paypal_dict 中指定多个项目(用于 PayPalPaymentsForm)?2) 另外,我需要在 Paypal 屏幕上显示的摘要中适当地指定运费和单个数量 - 我该怎么做?

4

3 回答 3

1

我不喜欢 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="you@youremail.com">
        <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>
于 2013-11-04T05:32:43.270 回答
0

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

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
}

然后这个 dict 像这样捆绑起来:

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)

你是这个意思吗?

于 2011-01-16T16:23:42.740 回答
0

假设您想让贝宝与您的购物车一起工作。对购物车中的物品使用 for 循环。为了获得每个项目的数字以便贝宝识别它们,我使用 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="account@mail.com">
<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 %}
于 2018-11-30T22:16:05.550 回答