我正在设计一个用Python (使用Django)的网站,我需要通过它来销售东西。
谁能帮助我的源代码,以集成贝宝-pro(做直接付款)或其他贝宝标准(快速结账)?
发布于 2010-04-26 22:56:14
你可能想试试django-paypal,在首页上甚至有一个tutorial。
发布于 2017-12-19 00:01:19
Button会生成一个通过paypal.standard.ipn调用其PayPal接口的按钮。
对于API集成,您必须遵循以下给定步骤:
安装django-paypal
pip install django-paypal更新settings.py文件:
INSTALLED_APPS = [
'paypal.standard.ipn',
]
PAYPAL_RECEIVER_EMAIL = 'XXXXX'
PAYPAL_TEST = True写下收件人的电子邮件地址。PAYPAL_TEST = True意味着你想要测试应用程序接口付款。原始支付接口可以写False。
运行命令:
python manage.py migrate 在urls.py中
url(r'^paypal/', include('paypal.standard.ipn.urls')),
url(r'^payment_process/$', api_views.payment_process, name='payment_process' ),
url(r'^payment_done/$', TemplateView.as_view(template_name= "pets/payment_done.html"), name='payment_done'),
url(r'^payment_canceled/$', TemplateView.as_view(template_name= "pets/payment_canceled.html"), name='payment_canceled'),*在views.py中
from django.conf import settings
from django.urls import reverse
from django.shortcuts import render, get_object_or_404
from paypal.standard.forms import PayPalPaymentsForm
def payment_process(request):
host = request.get_host()
paypal_dict = {
'business': settings.PAYPAL_RECEIVER_EMAIL,
'amount': '100',
'item_name': 'Item_Name_xyz',
'invoice': 'Test Payment Invoice',
'currency_code': 'USD',
'notify_url': 'http://{}{}'.format(host, reverse('paypal-ipn')),
'return_url': 'http://{}{}'.format(host, reverse('payment_done')),
'cancel_return': 'http://{}{}'.format(host, reverse('payment_canceled')),
}
form = PayPalPaymentsForm(initial=paypal_dict)
return render(request, 'pets/payment_process.html', {'form': form})Follow video tutorial for django-code given in reference.
在payment_process.html:中
{{ form.render }}对于调用接口,您有/payment_process/请求。它将在HTML上生成一个按钮,该按钮调用PayPal应用程序接口进行交易。进一步的过程将完成在PayPal端,登录或卡支付。
发布于 2010-04-26 22:43:41
你看过pypaypal吗?您可以创建一个连接到PayPal的视图并提交您的支付命令。
https://stackoverflow.com/questions/2714284
复制相似问题