【发布时间】:2016-08-11 02:55:18
【问题描述】:
我已使用PayPal-Python-SDK 以下列方式集成了 PayPal 付款流程。
- 在我们的网站上订购。至此,我知道要向访客收取多少费用。
- 我通过将
mode参数传递为live(不是sandbox)、客户端ID 和live设置的客户端密码来配置paypalrestsdk模块。 - 我使用
paypalrestsdk.Payment创建了一个付款,我向其中传递了大量参数,包括return_url、cancel_url、price、currency、quantity和其他一些参数。 - 如果付款创建没有错误,我会从创建的付款中获得
redirect_url。 - 用户点击链接将他重定向到
redirect_url,这是他填写PayPal详细信息或信用卡详细信息的PayPal页面。 - 用户支付了相应金额并被重定向回我们的网站。
- 作为最后一步,我检查 DB 中是否有一条记录带有来自 GET 或 POST 参数的付款 ID,如果 DB 中有一条记录,我将其标记为
paid。
现在,问题是整个过程运行良好且符合预期,但资金并未从用于付款的 PayPal 账户中流出。钱也不会从信用卡中流出。当然,用于收款的帐户不会收到钱。
这是生成付款的代码:
# Configure SDK.
paypalrestsdk.configure({
'mode': settings.PAYPAL_MODE, # This one is set to 'live'.
'client_id': settings.PAYPAL_CLIENT_ID,
'client_secret': settings.PAYPAL_SECRET,
})
# Create a payment.
payment = paypalrestsdk.Payment({
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": '...', # Here's the return URL.
"cancel_url": '...', # Here's the cancel URL.
},
"transactions": [{
"item_list": {
"items": [{
"name": "Invoice Payment #1",
"sku": "item",
"price": "1.00", # This is set to 1 for testing only.
"currency": "AUD",
"quantity": 1
}]
},
"amount": {
"total": "1.00", # Same as above.
"currency": "AUD"
},
"description": "Invoice Payment #1"
}]
})
# Get the payment URL if successful.
if payment.create():
for link in payment.links:
if link.method == "REDIRECT":
redirect_url = str(link.href)
"..."
# Pass this variable to the HTML template context.
else:
"..."
# Handle the error.
所以,我将redirect_url 传递给用户。用户发起支付。付款得到了正确处理,但钱没有被转移或收到。
我是不是做错了什么?
PS:这是我刚刚发现的一个类似问题——“Paypal App does not receive money via REST”。
【问题讨论】:
标签: python rest paypal payment