Skip to content

Commit

Permalink
better redirect url support
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed May 30, 2016
1 parent 0b24469 commit 22c5b2e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/budy/controllers/api/order.py
Expand Up @@ -345,11 +345,15 @@ def set_voucher(self, key):
def wait_payment(self, key):
empty_bag = self.field("empty_bag", True, cast = bool)
order = budy.Order.get(key = key, rules = False)
order.wait_payment_s(notify = True)
result = order.wait_payment_s(notify = True)
bag = budy.Bag.from_session()
if empty_bag and bag: bag.empty_s()
order = order.reload(map = True)
return order
redirect_url = result if type(result) in appier.legacy.STRINGS else None
return dict(
redirect_url = redirect_url,
order = order
)

@appier.route("/api/orders/<str:key>/pay", "PUT", json = True)
@appier.ensure(token = "user")
Expand All @@ -361,7 +365,8 @@ def pay(self, key):
bag = budy.Bag.from_session()
if empty_bag and bag: bag.empty_s()
order = order.reload(map = True)
redirect_url = result if type(result) in appier.legacy.STRINGS else None
return dict(
result = result,
redirect_url = redirect_url,
order = order
)

0 comments on commit 22c5b2e

Please sign in to comment.