This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix credit card page for Balanced cards
- Loading branch information
1 parent
4fca7e0
commit 39567d0
Showing
4 changed files
with
51 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import braintree | ||
import balanced | ||
|
||
class CreditCard: | ||
def __init__(self, *args, **kwargs): | ||
fields = [ | ||
'number', | ||
'expiration_year', | ||
'expiration_month', | ||
'address_postal_code', | ||
'cardholder_name' | ||
] | ||
for field in fields: | ||
setattr(self, field, kwargs.pop(field, '')) | ||
|
||
@classmethod | ||
def from_route(cls, route): | ||
if route.network == 'braintree-cc': | ||
card = braintree.PaymentMethod.find(route.address) | ||
return cls( | ||
number=card.masked_number, | ||
expiration_month=card.expiration_month, | ||
expiration_year=card.expiration_year, | ||
address_postal_code=card.billing_address.postal_code, | ||
cardholder_name=card.cardholder_name | ||
) | ||
else: | ||
assert route.network == 'balanced-cc' | ||
card = balanced.Card.fetch(route.address) | ||
return cls( | ||
number=card.number, | ||
expiration_month=card.expiration_month, | ||
expiration_year=card.expiration_year, | ||
address_postal_code=card.address['postal_code'], | ||
cardholder_name=card.name | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters