0
所以即時通訊測試了貝寶休息sdk和即時通訊使用python作爲我的cgi語言(我知道它也是如此2007),無論如何,我遇到了障礙,因爲我無法得到它將重定向到返回的URL頁面。如何將用戶重定向到一個返回的URL python
我已經嘗試了打印定位方法。這對我沒有用。
# Create Payment Using PayPal Sample
# This sample code demonstrates how you can process a
# PayPal Account based Payment.
# API used: /v1/payments/payment
from paypalrestsdk import Payment
import logging
logging.basicConfig(level=logging.INFO)
# Payment
# A Payment Resource; create one using
# the above types and intent as 'sale'
payment = Payment({
"intent": "sale",
# Payer
# A resource representing a Payer that funds a payment
# Payment Method as 'paypal'
"payer": {
"payment_method": "paypal"},
# Redirect URLs
"redirect_urls": {
"return_url": "http://localhost:3000/payment/execute",
"cancel_url": "http://localhost:3000/"},
# Transaction
# A transaction defines the contract of a
# payment - what is the payment for and who
# is fulfilling it.
"transactions": [{
# ItemList
"item_list": {
"items": [{
"name": "item",
"sku": "item",
"price": "5.00",
"currency": "USD",
"quantity": 1}]},
# Amount
# Let's you specify a payment amount.
"amount": {
"total": "5.00",
"currency": "USD"},
"description": "This is the payment transaction description."}]})
# Create Payment and return status
if payment.create():
print("Payment[%s] created successfully" % (payment.id))
# Redirect the user to given approval url
for link in payment.links:
if link.method == "REDIRECT":
# Convert to str to avoid google appengine unicode issue
# https://github.com/paypal/rest-api-sdk-python/pull/58
redirect_url = str(link.href)
print("Redirect for approval: %s" % (redirect_url))
else:
print("Error while creating payment:")
print(payment.error)
因此,如果你們是新手,在用戶瀏覽器上扔301或302,那真的會有幫助。謝謝。