使用 django-paypal 实现经常性付款时出现错误请求错误

时间:2021-02-16 04:38:55

标签: django paypal-ipn paypal-subscriptions django-paypal

def process_payment(request):
    price = request.session.get('price')
    host = request.get_host()
    
    paypal_dict = {
        "cmd": "_xclick-subscriptions",
        "business": 'receiver_email@example.com',
        "a3": "9.99",                      # monthly price
        "p3": 1,                           # duration of each unit (depends on unit)
        "t3": "M",                         # duration unit ("M for Month")
        "src": "1",                        # make payments recur
        "sra": "1",                        # reattempt payment on payment error
        "no_note": "1",                    # remove extra notes (optional)
        "item_name": "my cool subscription",
        'currency_code': 'USD',
        'notify_url': 'http://{}{}'.format(host, reverse('paypal-ipn')),
        'return_url': 'http://{}{}'.format(host, reverse('source:payment_done')),
        'cancel_return': 'http://{}{}'.format(host, reverse('source:payment_cancelled')),
    }

    form = PayPalPaymentsForm(initial=paypal_dict)

    # Output the button.
    form.render()
    return render(request, 'Prayer/process_payment.html', {'form': form})

0 个答案:

没有答案
相关问题