Skip to content

Commit

Permalink
better support for paypal
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed May 30, 2016
1 parent a1ddc69 commit 0b24469
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/budy/models/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def ctt_csv_url(cls, start = None, end = None, absolute = False):
@classmethod
def _pmethods(cls):
methods = dict()
for engine in ("stripe", "easypay"):
for engine in ("stripe", "easypay", "paypal"):
function = getattr(cls, "_pmethods_" + engine)
engine_m = [(value, engine) for value in function()]
methods.update(engine_m)
Expand All @@ -245,6 +245,10 @@ def _pmethods_stripe(cls):
def _pmethods_easypay(cls):
return ("multibanco",)

@classmethod
def _pmethods_paypal(cls):
return ("paypal",)

@classmethod
def _get_api_stripe(cls):
try: import stripe
Expand Down Expand Up @@ -428,7 +432,7 @@ def get_paypal(self, return_url = None, cancel_url = None):
for line in self.lines:
items.append(
dict(
name = line.product.name,
name = line.product.short_description,
price = currency.Currency.format(line.product.price, line.currency),
currency = line.currency,
quantity = line.quantity
Expand Down Expand Up @@ -677,9 +681,11 @@ def _pay_easypay(self, payment_data, warning_d = 172800, cancel_d = 259200):
)
return False

def _pay_paypal(self, return_url = None, cancel_url = None):
def _pay_paypal(self, payment_data):
cls = self.__class__
api = cls._get_api_paypal()
return_url = payment_data.get("return_url", None)
cancel_url = payment_data.get("cancel_url", None)
paypal_order = self.get_paypal(
return_url = return_url,
cancel_url = cancel_url
Expand Down

0 comments on commit 0b24469

Please sign in to comment.