【发布时间】:2021-09-29 14:51:56
【问题描述】:
我想通过贝宝收款。我需要向用户发送链接并获得报酬。正在成功创建approval_link 链接。但无法使用链接付款。我使用此链接登录,点击付款,但我被重定向到 return_url。我不希望这样,我希望用户不要被重定向到任何地方。你只需要从他那里拿钱就可以了。我的项目不是网站,我没有任何可以重定向客户端的页面。帮助创建付款表单,而无需将客户重定向到其他页面。预先感谢您对我的问题的关注,并为我的英语道歉。
我会简单重复一遍:我们需要一个付款表单,而不需要重定向到其他页面。拿钱就行了请帮忙配置paypalrestsdk.Payment()的参数
import paypalrestsdk
api = paypalrestsdk.set_config(
mode="sandbox",
client_id="XXX",
client_secret="XXX")
token = api.get_access_token()
print(token)
payment = paypalrestsdk.Payment({
"intent": "sale",
"payer": {
"payment_method": "paypal"},
"redirect_urls": {
"return_url": "http://localhost:3000/process",
"cancel_url": "http://localhost:3000/cancel"
},
"transactions": [{
"item_list": {
"items": [{
"name": "item",
"sku": "item",
"price": "1.00",
"currency": "RUB",
"quantity": 1}]},
"amount": {
"total": "1.00",
"currency": "RUB"},
"description": "This is the payment transaction description."}]})
create = payment.create()
if create:
print("Payment created successfully")
else:
print(payment.error)
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))
我尝试不指定重定向链接。如果它们不存在,则不会创建付款。
【问题讨论】: