Skip to content

Commit

Permalink
new cancel data
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jun 9, 2016
1 parent 83e3b40 commit e58d94e
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/budy/models/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ class Order(bundle.Bundle):
type = dict
)

cancel_data = appier.field(
type = dict
)

notifications = appier.field(
type = list,
index = True,
Expand Down Expand Up @@ -380,9 +384,17 @@ def end_pay_s(
if notify: self.notify_s()
return result

def cancel_s(self, cancel_data = {}, notify = False):
def cancel_s(
self,
cancel_data = {},
strict = False,
notify = False
):
cancel_data.update(self.cancel_data)
result = self._cancel(cancel_data, strict = strict)
self.mark_canceled_s()
if notify: self.notify_s()
return result

def use_vouchers_s(self, reset = True):
"""
Expand Down Expand Up @@ -776,3 +788,15 @@ def _end_pay_paypal(self, payment_data):
payer_id = payment_data["payer_id"]
api.execute_payment(payment_id, payer_id)
return True

def _cancel(self, cancel_data, strict = False):
cls = self.__class__
if self.payable == 0.0: return
methods = cls._pmethods()
type = cancel_data.get("engine", None)
type = cancel_data.get("type", type)
method = methods.get(type, type)
has_function = hasattr(self, "_cancel_" + method)
if not has_function and not strict: return
function = getattr(self, "_cancel_" + method)
return function(cancel_data)

0 comments on commit e58d94e

Please sign in to comment.