Skip to content

Commit

Permalink
moved get url
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed May 30, 2016
1 parent 1bb52df commit 53180ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 1 addition & 9 deletions src/examples/app.py
Expand Up @@ -86,7 +86,7 @@ def new_payment(self):
cancel_url = self.url_for("paypal.cancel_payment", absolute = True)
)
)
approval_url = self.get_url(payment["links"], "approval_url")
approval_url = api.get_url(payment["links"], "approval_url")
if approval_url and redirect: self.redirect(approval_url)
return payment

Expand Down Expand Up @@ -116,14 +116,6 @@ def cancel_payment(self):
token = token
)

def get_url(self, links, target):
for link in links:
rel = link.get("rel", None)
href = link.get("href", None)
if not rel == target: continue
return href
return None

def ensure_api(self):
access_token = self.session.get("paypal.access_token", None)
if access_token: return
Expand Down
8 changes: 8 additions & 0 deletions src/paypal/base.py
Expand Up @@ -102,3 +102,11 @@ def oauth_token(self, grant_type = "client_credentials"):
)
self.access_token = contents["access_token"]
return self.access_token

def get_url(self, links, target):
for link in links:
rel = link.get("rel", None)
href = link.get("href", None)
if not rel == target: continue
return href
return None

0 comments on commit 53180ef

Please sign in to comment.