paypal序列django python需要解释 - 进程执行

时间:2018-04-21 04:11:00

标签: python django rest paypal

我想在我的django app上引用paypalrestsdk,但不确定授权和执行之间的顺序 https://github.com/paypal/PayPal-Python-SDK

我创建了付款,之后我使用授权付款重定向到付款链接。这将带来paypal页面。

授权付款:

for link in payment.links:
    if link.rel == "approval_url":
        # Convert to str to avoid Google App Engine Unicode issue
        # https://github.com/paypal/rest-api-sdk-python/pull/58
        approval_url = str(link.href)
        print("Redirect for approval: %s" % (approval_url))

更新(我将使用此链接重定向到approval_url):

return HttpResponseRedirect(approval_url)

执行付款

payment = paypalrestsdk.Payment.find("PAY-57363176S1057143SKE2HO3A")

if payment.execute({"payer_id": "DUFRQ8GWYMJXC"}):
  print("Payment execute successfully")
else:
  print(payment.error) # Error Hash

授权付款后,我们还需要执行付款吗?授权中的付款应该已经执行(好吧我猜是因为return_url似乎要执行)那么我应该如何处理return_url以获取(payment id和payer_id)?

从这里: https://github.com/paypal/PayPal-Python-SDK/blob/b376dc78579819cd9566aae2c3a8de9c9026cbfb/paypalrestsdk/api.py 它似乎以这种格式返回

        >>> api.post("v1/payments/payment/PAY-1234/execute", { 'payer_id': '1234' })

应该是views.py和urls.py来处理这种格式吗?

0 个答案:

没有答案