1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
import braintree
from braintree.resource import Resource
# NEXT_MAJOR_VERSION - rename to GooglePayCard
class AndroidPayCard(Resource):
"""
A class representing Braintree Android Pay card objects.
"""
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
if hasattr(self, 'expired'):
self.is_expired = self.expired
if "subscriptions" in attributes:
self.subscriptions = [braintree.subscription.Subscription(gateway, subscription) for subscription in self.subscriptions]
@property
def expiration_date(self):
if not self.expiration_month or not self.expiration_year:
return None
return self.expiration_month + "/" + self.expiration_year
@property
def last_4(self):
return self.virtual_card_last_4
@property
def card_type(self):
return self.virtual_card_type
@staticmethod
def signature():
options = ["make_default"]
signature = [
"customer_id",
"cardholder_name",
"cryptogram",
"google_transaction_id",
"expiration_month",
"expiration_year",
"number",
"token",
"eci_indicator",
{
"options": options
},
{
"billing_address": [
"company",
"country_code_alpha2",
"country_code_alpha3",
"country_code_numeric",
"country_name",
"extended_address",
"first_name",
"last_name",
"locality",
"postal_code",
"region",
"street_address",
"phone_number"
]
}
]
return signature
@staticmethod
def card_signature():
options = ["make_default"]
signature = [
"customer_id",
"cardholder_name",
"google_transaction_id",
"expiration_month",
"expiration_year",
"number",
"token",
{
"options": options
},
{
"billing_address": [
"company",
"country_code_alpha2",
"country_code_alpha3",
"country_code_numeric",
"country_name",
"extended_address",
"first_name",
"last_name",
"locality",
"postal_code",
"region",
"street_address",
"phone_number"
]
}
]
return signature
@staticmethod
def network_token_signature():
return AndroidPayCard.signature()
|