姜戈与贝宝集成

发布于 2024-08-29 22:54:19 字数 114 浏览 2 评论 0原文

我正在用 Python(使用 Django)设计一个网站,我需要通过它来销售东西。

有人可以帮助我使用源代码来集成 paypal-pro(直接付款)或 paypal-standard(快速结账)吗?

I am designing a website in Python (using Django), and I need to sell things through it.

Can somebody help me with the source code to integrate the paypal-pro (do-direct payment) or else paypal-standard (express checkout)?

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

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

发布评论

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

评论(5

舟遥客 2024-09-05 22:54:19

您可能想尝试 django-paypal,甚至还有一个 教程就在首页上。

You might want to try django-paypal, there's even a tutorial right there on the front page.

筱武穆 2024-09-05 22:54:19

paypal.standard.ipn

PayPal API 生成一个按钮,该按钮将通过 paypal.standard.ipn

对于 API 集成,您必须遵循以下给定步骤:

安装 django-paypal

pip install django-paypal

更新 settings.py 文件:

INSTALLED_APPS = [
    'paypal.standard.ipn',
]

PAYPAL_RECEIVER_EMAIL = 'XXXXX'
PAYPAL_TEST = True

写入接收者的电子邮件地址。 PAYPAL_TEST = True 表示您想要测试 API 付款。原始支付API可以写“False”。

运行命令:

python manage.py migrate 

urls.py中:

url(r'^paypal/', include('paypal.standard.ipn.urls')),
url(r'^payment_process/

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})

按照参考中给出的 django 代码视频教程进行操作。

payment_process.html 中:

{{ form.render }}

要调用 API,您需要请求 / payment_process/.它将在 HTML 上生成一个按钮,调用 PayPal API 进行交易。进一步的处理将在 PayPal 端、登录或卡支付上完成。

, api_views.payment_process, name='payment_process' ), url(r'^payment_done/

views.py中:


按照参考中给出的 django 代码视频教程进行操作。

payment_process.html 中:


要调用 API,您需要请求 / payment_process/.它将在 HTML 上生成一个按钮,调用 PayPal API 进行交易。进一步的处理将在 PayPal 端、登录或卡支付上完成。

, TemplateView.as_view(template_name= "pets/payment_done.html"), name='payment_done'), url(r'^payment_canceled/

views.py中:


按照参考中给出的 django 代码视频教程进行操作。

payment_process.html 中:


要调用 API,您需要请求 / payment_process/.它将在 HTML 上生成一个按钮,调用 PayPal API 进行交易。进一步的处理将在 PayPal 端、登录或卡支付上完成。

, TemplateView.as_view(template_name= "pets/payment_canceled.html"), name='payment_canceled'),*

views.py中:

按照参考中给出的 django 代码视频教程进行操作。

payment_process.html 中:

要调用 API,您需要请求 / payment_process/.它将在 HTML 上生成一个按钮,调用 PayPal API 进行交易。进一步的处理将在 PayPal 端、登录或卡支付上完成。

paypal.standard.ipn

PayPal API Generates a Button which will call its API through paypal.standard.ipn.

For API Integration you have to follow below given steps:

Install django-paypal:

pip install django-paypal

Update settings.py file:

INSTALLED_APPS = [
    'paypal.standard.ipn',
]

PAYPAL_RECEIVER_EMAIL = 'XXXXX'
PAYPAL_TEST = True

Write Email address of Receiver. PAYPAL_TEST = True means you want a Test API payment. You can write "False" for Original payment API.

Run command:

python manage.py migrate 

In urls.py:

url(r'^paypal/', include('paypal.standard.ipn.urls')),
url(r'^payment_process/

In 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.

In payment_process.html:

{{ form.render }}

For calling API you have request for /payment_process/. It will generate a button on HTML which calls PayPal API for transaction. Further process will be done on PayPal end, Login or Card Payment.

, api_views.payment_process, name='payment_process' ), url(r'^payment_done/

In views.py:


Follow video tutorial for django-code given in reference.

In payment_process.html:


For calling API you have request for /payment_process/. It will generate a button on HTML which calls PayPal API for transaction. Further process will be done on PayPal end, Login or Card Payment.

, TemplateView.as_view(template_name= "pets/payment_done.html"), name='payment_done'), url(r'^payment_canceled/

In views.py:


Follow video tutorial for django-code given in reference.

In payment_process.html:


For calling API you have request for /payment_process/. It will generate a button on HTML which calls PayPal API for transaction. Further process will be done on PayPal end, Login or Card Payment.

, TemplateView.as_view(template_name= "pets/payment_canceled.html"), name='payment_canceled'),*

In views.py:

Follow video tutorial for django-code given in reference.

In payment_process.html:

For calling API you have request for /payment_process/. It will generate a button on HTML which calls PayPal API for transaction. Further process will be done on PayPal end, Login or Card Payment.

羁拥 2024-09-05 22:54:19

您查看过 pypaypal 吗?您可以创建一个连接到 PayPal 的视图并提交您的付款命令。

Did you look at pypaypal? You could create a view that connects to PayPal and submit your payment commands.

叶落知秋 2024-09-05 22:54:19

更好的是使用所有者的“本机”文档:docs paypal

Better will be to use "native" docs from owner: docs paypal

只是一片海 2024-09-05 22:54:19

教程指导如何接受Paypal 应用程序通过沙箱 ClientId 进行支付SecretKey 无需任何第三方库。

您还可以将付款跟踪 ID 作为 purchase_units 列表的字典对象中的 custom_id 发送到 create_order.request_body 函数。
如下图:

create_order.request_body (
        {
            "intent": "CAPTURE",
            "purchase_units": [
                {
                    "custom_id": "YOUR_TRACKING_ID",
                    "amount": {
                        "currency_code": "USD",
                        "value": course.price,
                        "breakdown": {
                            "item_total": {
                                "currency_code": "USD",
                                "value": course.price
                            }
                            },
                        },                               


                }
            ]
        }
    )

This tutorial guides how to accept Paypal apps payment via sandbox ClientId & SecretKey without any third party library.

You can also send payment tracking id as custom_id in purchase_units list's dictionary object to create_order.request_body function.
As shown below:

create_order.request_body (
        {
            "intent": "CAPTURE",
            "purchase_units": [
                {
                    "custom_id": "YOUR_TRACKING_ID",
                    "amount": {
                        "currency_code": "USD",
                        "value": course.price,
                        "breakdown": {
                            "item_total": {
                                "currency_code": "USD",
                                "value": course.price
                            }
                            },
                        },                               


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