Skip to content

Commit b2c8ebb

Browse files
author
Helgi Hrafn Gunnarsson
committed
Samples: Redirection for approval of payments no longer determined by HTTP method (link.method == "REDIRECT") but rather as specified by its intended purpose (link.rel == "approval_url").
1 parent 1f7b2a2 commit b2c8ebb

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

samples/order/create.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
print("Payment[%s] created successfully" % (payment.id))
3838
# Redirect the user to given approval url
3939
for link in payment.links:
40-
if link.method == "REDIRECT":
41-
redirect_url = str(link.href)
42-
print("Redirect for approval: %s" % (redirect_url))
40+
if link.rel == "approval_url":
41+
approval_url = str(link.href)
42+
print("Redirect for approval: %s" % (approval_url))
4343
else:
4444
print("Error while creating payment:")
4545
print(payment.error)

samples/payment/create_with_paypal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
print("Payment[%s] created successfully" % (payment.id))
5252
# Redirect the user to given approval url
5353
for link in payment.links:
54-
if link.method == "REDIRECT":
54+
if link.rel == "approval_url":
5555
# Convert to str to avoid google appengine unicode issue
5656
# https://github.com/paypal/rest-api-sdk-python/pull/58
57-
redirect_url = str(link.href)
58-
print("Redirect for approval: %s" % (redirect_url))
57+
approval_url = str(link.href)
58+
print("Redirect for approval: %s" % (approval_url))
5959
else:
6060
print("Error while creating payment:")
6161
print(payment.error)

samples/payment/create_with_paypal_further_capabilities.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@
9191
print("Payment[%s] created successfully" % (payment.id))
9292
# Redirect the user to given approval url
9393
for link in payment.links:
94-
if link.method == "REDIRECT":
94+
if link.rel == "approval_url":
9595
# Convert to str to avoid google appengine unicode issue
9696
# https://github.com/paypal/rest-api-sdk-python/pull/58
97-
redirect_url = str(link.href)
98-
print("Redirect for approval: %s" % (redirect_url))
97+
approval_url = str(link.href)
98+
print("Redirect for approval: %s" % (approval_url))
9999
else:
100100
print("Error while creating payment:")
101101
print(payment.error)

samples/payment/create_with_paypal_security_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454
print("Payment[%s] created successfully" % (payment.id))
5555
# Redirect the user to given approval url
5656
for link in payment.links:
57-
if link.method == "REDIRECT":
57+
if link.rel == "approval_url":
5858
# Convert to str to avoid google appengine unicode issue
5959
# https://github.com/paypal/rest-api-sdk-python/pull/58
60-
redirect_url = str(link.href)
61-
print("Redirect for approval: %s" % (redirect_url))
60+
approval_url = str(link.href)
61+
print("Redirect for approval: %s" % (approval_url))
6262
else:
6363
print("Error while creating payment:")
6464
print(payment.error)

samples/payment_experience/web_profile/create_payment_with_customized_experience.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
print("Payment[%s] created successfully" % (payment.id))
7171
# Redirect the user to given approval url
7272
for link in payment.links:
73-
if link.method == "REDIRECT":
74-
redirect_url = str(link.href)
75-
print("Redirect for approval: %s" % (redirect_url))
73+
if link.rel == "approval_url":
74+
approval_url = str(link.href)
75+
print("Redirect for approval: %s" % (approval_url))
7676
else:
7777
print("Error while creating payment:")
7878
print(payment.error)

samples/subscription/billing_agreements/execute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
})
2727

2828
# After creating the agreement, redirect user to the url provided in links array
29-
# entry with method field set to REDIRECT
29+
# entry designated as "approval_url"
3030
if billing_agreement.create():
3131
print("Billing Agreement created successfully")
3232
for link in billing_agreement.links:

0 commit comments

Comments
 (0)