index
int64 0
731k
| package
stringlengths 2
98
⌀ | name
stringlengths 1
76
| docstring
stringlengths 0
281k
⌀ | code
stringlengths 4
1.07M
⌀ | signature
stringlengths 2
42.8k
⌀ |
|---|---|---|---|---|---|
712,057
|
braintree.address_gateway
|
update
| null |
def update(self, customer_id, address_id, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Address.update_signature())
self.__validate_chars_in_args(customer_id, address_id)
response = self.config.http().put(
self.config.base_merchant_path() + "/customers/" + customer_id + "/addresses/" + address_id,
{"address": params}
)
if "address" in response:
return SuccessfulResult({"address": Address(self.gateway, response["address"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, customer_id, address_id, params=None)
|
712,058
|
braintree.amex_express_checkout_card
|
AmexExpressCheckoutCard
|
A class representing Braintree Amex Express Checkout card objects. Deprecated
|
class AmexExpressCheckoutCard(Resource):
"""
A class representing Braintree Amex Express Checkout card objects. Deprecated
"""
def __init__(self, gateway, attributes):
warn("AmexExpressCheckoutCard is deprecated")
Resource.__init__(self, gateway, attributes)
if "subscriptions" in attributes:
self.subscriptions = [braintree.subscription.Subscription(gateway, subscription) for subscription in self.subscriptions]
@property
def expiration_date(self):
return self.expiration_month + "/" + self.expiration_year
|
(gateway, attributes)
|
712,062
|
braintree.amex_express_checkout_card
|
__init__
| null |
def __init__(self, gateway, attributes):
warn("AmexExpressCheckoutCard is deprecated")
Resource.__init__(self, gateway, attributes)
if "subscriptions" in attributes:
self.subscriptions = [braintree.subscription.Subscription(gateway, subscription) for subscription in self.subscriptions]
|
(self, gateway, attributes)
|
712,065
|
braintree.android_pay_card
|
AndroidPayCard
|
A class representing Braintree Android Pay card objects.
|
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()
|
(gateway, attributes)
|
712,069
|
braintree.android_pay_card
|
__init__
| null |
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]
|
(self, gateway, attributes)
|
712,071
|
braintree.android_pay_card
|
card_signature
| null |
@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
|
()
|
712,072
|
braintree.android_pay_card
|
network_token_signature
| null |
@staticmethod
def network_token_signature():
return AndroidPayCard.signature()
|
()
|
712,073
|
braintree.android_pay_card
|
signature
| null |
@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
|
()
|
712,075
|
braintree.apple_pay_card
|
ApplePayCard
|
A class representing Braintree Apple Pay card objects.
|
class ApplePayCard(Resource):
"""
A class representing Braintree Apple Pay card objects.
"""
class CardType(object):
"""
Contants representing the type of the credit card. Available types are:
* Braintree.ApplePayCard.AmEx
* Braintree.ApplePayCard.MasterCard
* Braintree.ApplePayCard.Visa
"""
AmEx = "Apple Pay - American Express"
MasterCard = "Apple Pay - MasterCard"
Visa = "Apple Pay - Visa"
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
@staticmethod
def signature():
options = ["make_default"]
signature = [
"customer_id",
"cardholder_name",
"expiration_month",
"expiration_year",
"number",
"cryptogram",
"eci_indicator",
"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",
"phone_number",
"region",
"street_address"
]
}
]
return signature
|
(gateway, attributes)
|
712,081
|
braintree.apple_pay_card
|
signature
| null |
@staticmethod
def signature():
options = ["make_default"]
signature = [
"customer_id",
"cardholder_name",
"expiration_month",
"expiration_year",
"number",
"cryptogram",
"eci_indicator",
"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",
"phone_number",
"region",
"street_address"
]
}
]
return signature
|
()
|
712,083
|
braintree.apple_pay_gateway
|
ApplePayGateway
| null |
class ApplePayGateway(object):
def __init__(self, gateway):
self.gateway = gateway
self.config = gateway.config
def register_domain(self, domain):
response = self.config.http().post(self.config.base_merchant_path() + "/processing/apple_pay/validate_domains", {'url': domain})
if "response" in response and response["response"]["success"]:
return SuccessfulResult()
elif response["api_error_response"]:
return ErrorResult(self.gateway, response["api_error_response"])
def unregister_domain(self, domain):
self.config.http().delete(self.config.base_merchant_path() + "/processing/apple_pay/unregister_domain?url=" + escape(domain))
return SuccessfulResult()
def registered_domains(self):
response = self.config.http().get(self.config.base_merchant_path() + "/processing/apple_pay/registered_domains")
if "response" in response:
response = ApplePayOptions(response.pop("response"))
return response.domains
|
(gateway)
|
712,085
|
braintree.apple_pay_gateway
|
register_domain
| null |
def register_domain(self, domain):
response = self.config.http().post(self.config.base_merchant_path() + "/processing/apple_pay/validate_domains", {'url': domain})
if "response" in response and response["response"]["success"]:
return SuccessfulResult()
elif response["api_error_response"]:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, domain)
|
712,086
|
braintree.apple_pay_gateway
|
registered_domains
| null |
def registered_domains(self):
response = self.config.http().get(self.config.base_merchant_path() + "/processing/apple_pay/registered_domains")
if "response" in response:
response = ApplePayOptions(response.pop("response"))
return response.domains
|
(self)
|
712,087
|
braintree.apple_pay_gateway
|
unregister_domain
| null |
def unregister_domain(self, domain):
self.config.http().delete(self.config.base_merchant_path() + "/processing/apple_pay/unregister_domain?url=" + escape(domain))
return SuccessfulResult()
|
(self, domain)
|
712,088
|
braintree.braintree_gateway
|
BraintreeGateway
| null |
class BraintreeGateway(object):
def __init__(self, config=None, **kwargs):
if isinstance(config, braintree.configuration.Configuration):
self.config = config
else:
self.config = Configuration(
client_id=kwargs.get("client_id"),
client_secret=kwargs.get("client_secret"),
access_token=kwargs.get("access_token"),
http_strategy=kwargs.get("http_strategy")
)
self.add_on = AddOnGateway(self)
self.address = AddressGateway(self)
self.apple_pay = ApplePayGateway(self)
self.client_token = ClientTokenGateway(self)
self.credit_card = CreditCardGateway(self)
self.customer = CustomerGateway(self)
self.discount = DiscountGateway(self)
self.dispute = DisputeGateway(self)
self.document_upload = DocumentUploadGateway(self)
self.exchange_rate_quote = ExchangeRateQuoteGateway(self)
self.graphql_client = self.config.graphql_client()
self.merchant = MerchantGateway(self)
self.merchant_account = MerchantAccountGateway(self)
self.oauth = OAuthGateway(self)
self.payment_method = PaymentMethodGateway(self)
self.payment_method_nonce = PaymentMethodNonceGateway(self)
self.paypal_account = PayPalAccountGateway(self)
self.plan = PlanGateway(self)
self.sepa_direct_debit_account = SepaDirectDebitAccountGateway(self)
self.settlement_batch_summary = SettlementBatchSummaryGateway(self)
self.subscription = SubscriptionGateway(self)
self.testing = TestingGateway(self)
self.transaction = TransactionGateway(self)
self.transaction_line_item = TransactionLineItemGateway(self)
self.us_bank_account = UsBankAccountGateway(self)
self.us_bank_account_verification = UsBankAccountVerificationGateway(self)
self.verification = CreditCardVerificationGateway(self)
self.webhook_notification = WebhookNotificationGateway(self)
self.webhook_testing = WebhookTestingGateway(self)
|
(config=None, **kwargs)
|
712,089
|
braintree.braintree_gateway
|
__init__
| null |
def __init__(self, config=None, **kwargs):
if isinstance(config, braintree.configuration.Configuration):
self.config = config
else:
self.config = Configuration(
client_id=kwargs.get("client_id"),
client_secret=kwargs.get("client_secret"),
access_token=kwargs.get("access_token"),
http_strategy=kwargs.get("http_strategy")
)
self.add_on = AddOnGateway(self)
self.address = AddressGateway(self)
self.apple_pay = ApplePayGateway(self)
self.client_token = ClientTokenGateway(self)
self.credit_card = CreditCardGateway(self)
self.customer = CustomerGateway(self)
self.discount = DiscountGateway(self)
self.dispute = DisputeGateway(self)
self.document_upload = DocumentUploadGateway(self)
self.exchange_rate_quote = ExchangeRateQuoteGateway(self)
self.graphql_client = self.config.graphql_client()
self.merchant = MerchantGateway(self)
self.merchant_account = MerchantAccountGateway(self)
self.oauth = OAuthGateway(self)
self.payment_method = PaymentMethodGateway(self)
self.payment_method_nonce = PaymentMethodNonceGateway(self)
self.paypal_account = PayPalAccountGateway(self)
self.plan = PlanGateway(self)
self.sepa_direct_debit_account = SepaDirectDebitAccountGateway(self)
self.settlement_batch_summary = SettlementBatchSummaryGateway(self)
self.subscription = SubscriptionGateway(self)
self.testing = TestingGateway(self)
self.transaction = TransactionGateway(self)
self.transaction_line_item = TransactionLineItemGateway(self)
self.us_bank_account = UsBankAccountGateway(self)
self.us_bank_account_verification = UsBankAccountVerificationGateway(self)
self.verification = CreditCardVerificationGateway(self)
self.webhook_notification = WebhookNotificationGateway(self)
self.webhook_testing = WebhookTestingGateway(self)
|
(self, config=None, **kwargs)
|
712,090
|
braintree.client_token
|
ClientToken
| null |
class ClientToken(object):
@staticmethod
def generate(params=None, gateway=None):
if params is None:
params = {}
if gateway is None:
gateway = Configuration.gateway().client_token
return gateway.generate(params)
@staticmethod
def generate_signature():
return [
"customer_id",
"merchant_account_id",
"proxy_merchant_id",
"version",
{"domains": ["__any_key__"]},
{"options": ["make_default", "verify_card", "fail_on_duplicate_payment_method"]}
]
|
()
|
712,091
|
braintree.client_token
|
generate
| null |
@staticmethod
def generate(params=None, gateway=None):
if params is None:
params = {}
if gateway is None:
gateway = Configuration.gateway().client_token
return gateway.generate(params)
|
(params=None, gateway=None)
|
712,092
|
braintree.client_token
|
generate_signature
| null |
@staticmethod
def generate_signature():
return [
"customer_id",
"merchant_account_id",
"proxy_merchant_id",
"version",
{"domains": ["__any_key__"]},
{"options": ["make_default", "verify_card", "fail_on_duplicate_payment_method"]}
]
|
()
|
712,093
|
braintree.configuration
|
Configuration
|
A class representing the configuration of your Braintree account.
You must call configure before any other Braintree operations. ::
braintree.Configuration.configure(
braintree.Environment.Sandbox,
"your_merchant_id",
"your_public_key",
"your_private_key"
)
|
class Configuration(object):
"""
A class representing the configuration of your Braintree account.
You must call configure before any other Braintree operations. ::
braintree.Configuration.configure(
braintree.Environment.Sandbox,
"your_merchant_id",
"your_public_key",
"your_private_key"
)
"""
@staticmethod
def configure(environment, merchant_id, public_key, private_key, **kwargs):
Configuration.environment = Environment.parse_environment(environment)
Configuration.merchant_id = merchant_id
Configuration.public_key = public_key
Configuration.private_key = private_key
Configuration.default_http_strategy = kwargs.get("http_strategy", None)
Configuration.timeout = kwargs.get("timeout", 60)
Configuration.wrap_http_exceptions = kwargs.get("wrap_http_exceptions", False)
@staticmethod
def for_partner(environment, partner_id, public_key, private_key, **kwargs):
return Configuration(
environment=environment,
merchant_id=partner_id,
public_key=public_key,
private_key=private_key,
http_strategy=kwargs.get("http_strategy", None),
timeout=kwargs.get("timeout", 60),
wrap_http_exceptions=kwargs.get("wrap_http_exceptions", False)
)
@staticmethod
def gateway():
return braintree.braintree_gateway.BraintreeGateway(config=Configuration.instantiate())
@staticmethod
def instantiate():
return Configuration(
environment=Configuration.environment,
merchant_id=Configuration.merchant_id,
public_key=Configuration.public_key,
private_key=Configuration.private_key,
http_strategy=Configuration.default_http_strategy,
timeout=Configuration.timeout,
wrap_http_exceptions=Configuration.wrap_http_exceptions
)
@staticmethod
def api_version():
return "6"
@staticmethod
def graphql_api_version():
return "2018-09-10"
def __init__(self, environment=None, merchant_id=None, public_key=None, private_key=None,
client_id=None, client_secret=None, access_token=None, *args, **kwargs):
if len(args) == 2:
public_key, private_key = args
parser = CredentialsParser(client_id=client_id, client_secret=client_secret,
access_token=access_token)
if parser.access_token is not None:
parser.parse_access_token()
self.environment = parser.environment
self.merchant_id = parser.merchant_id
elif parser.client_id is not None or parser.client_secret is not None:
parser.parse_client_credentials()
self.environment = parser.environment
self.merchant_id = merchant_id
else:
self.environment = Environment.parse_environment(environment)
if merchant_id == "":
raise ConfigurationError("Missing merchant_id")
else:
self.merchant_id = merchant_id
if public_key == "":
raise ConfigurationError("Missing public_key")
else:
self.public_key = public_key
if private_key == "":
raise ConfigurationError("Missing private_key")
else:
self.private_key = private_key
self.client_id = parser.client_id
self.client_secret = parser.client_secret
self.access_token = parser.access_token
self.timeout = kwargs.get("timeout", 60)
self.wrap_http_exceptions = kwargs.get("wrap_http_exceptions", False)
http_strategy = kwargs.get("http_strategy", None)
if http_strategy:
self._http_strategy = http_strategy(self, self.environment)
else:
self._http_strategy = self.http()
def base_merchant_path(self):
return "/merchants/" + self.merchant_id
def base_url(self):
return self.environment.protocol + self.environment.server_and_port
def graphql_base_url(self):
return self.environment.protocol + self.environment.graphql_server_and_port + "/graphql"
def http(self):
return braintree.util.http.Http(self)
def graphql_client(self):
return GraphQLClient(self)
def http_strategy(self):
return self._http_strategy
def has_client_credentials(self):
return self.client_secret is not None and self.client_id is not None
def assert_has_client_credentials(self):
if not self.has_client_credentials():
raise ConfigurationError("client_id and client_secret are required")
def has_access_token(self):
return self.access_token is not None
|
(environment=None, merchant_id=None, public_key=None, private_key=None, client_id=None, client_secret=None, access_token=None, *args, **kwargs)
|
712,094
|
braintree.configuration
|
__init__
| null |
def __init__(self, environment=None, merchant_id=None, public_key=None, private_key=None,
client_id=None, client_secret=None, access_token=None, *args, **kwargs):
if len(args) == 2:
public_key, private_key = args
parser = CredentialsParser(client_id=client_id, client_secret=client_secret,
access_token=access_token)
if parser.access_token is not None:
parser.parse_access_token()
self.environment = parser.environment
self.merchant_id = parser.merchant_id
elif parser.client_id is not None or parser.client_secret is not None:
parser.parse_client_credentials()
self.environment = parser.environment
self.merchant_id = merchant_id
else:
self.environment = Environment.parse_environment(environment)
if merchant_id == "":
raise ConfigurationError("Missing merchant_id")
else:
self.merchant_id = merchant_id
if public_key == "":
raise ConfigurationError("Missing public_key")
else:
self.public_key = public_key
if private_key == "":
raise ConfigurationError("Missing private_key")
else:
self.private_key = private_key
self.client_id = parser.client_id
self.client_secret = parser.client_secret
self.access_token = parser.access_token
self.timeout = kwargs.get("timeout", 60)
self.wrap_http_exceptions = kwargs.get("wrap_http_exceptions", False)
http_strategy = kwargs.get("http_strategy", None)
if http_strategy:
self._http_strategy = http_strategy(self, self.environment)
else:
self._http_strategy = self.http()
|
(self, environment=None, merchant_id=None, public_key=None, private_key=None, client_id=None, client_secret=None, access_token=None, *args, **kwargs)
|
712,095
|
braintree.configuration
|
api_version
| null |
@staticmethod
def api_version():
return "6"
|
()
|
712,096
|
braintree.configuration
|
assert_has_client_credentials
| null |
def assert_has_client_credentials(self):
if not self.has_client_credentials():
raise ConfigurationError("client_id and client_secret are required")
|
(self)
|
712,097
|
braintree.configuration
|
base_merchant_path
| null |
def base_merchant_path(self):
return "/merchants/" + self.merchant_id
|
(self)
|
712,098
|
braintree.configuration
|
base_url
| null |
def base_url(self):
return self.environment.protocol + self.environment.server_and_port
|
(self)
|
712,099
|
braintree.configuration
|
configure
| null |
@staticmethod
def configure(environment, merchant_id, public_key, private_key, **kwargs):
Configuration.environment = Environment.parse_environment(environment)
Configuration.merchant_id = merchant_id
Configuration.public_key = public_key
Configuration.private_key = private_key
Configuration.default_http_strategy = kwargs.get("http_strategy", None)
Configuration.timeout = kwargs.get("timeout", 60)
Configuration.wrap_http_exceptions = kwargs.get("wrap_http_exceptions", False)
|
(environment, merchant_id, public_key, private_key, **kwargs)
|
712,100
|
braintree.configuration
|
for_partner
| null |
@staticmethod
def for_partner(environment, partner_id, public_key, private_key, **kwargs):
return Configuration(
environment=environment,
merchant_id=partner_id,
public_key=public_key,
private_key=private_key,
http_strategy=kwargs.get("http_strategy", None),
timeout=kwargs.get("timeout", 60),
wrap_http_exceptions=kwargs.get("wrap_http_exceptions", False)
)
|
(environment, partner_id, public_key, private_key, **kwargs)
|
712,101
|
braintree.configuration
|
gateway
| null |
@staticmethod
def gateway():
return braintree.braintree_gateway.BraintreeGateway(config=Configuration.instantiate())
|
()
|
712,102
|
braintree.configuration
|
graphql_api_version
| null |
@staticmethod
def graphql_api_version():
return "2018-09-10"
|
()
|
712,103
|
braintree.configuration
|
graphql_base_url
| null |
def graphql_base_url(self):
return self.environment.protocol + self.environment.graphql_server_and_port + "/graphql"
|
(self)
|
712,104
|
braintree.configuration
|
graphql_client
| null |
def graphql_client(self):
return GraphQLClient(self)
|
(self)
|
712,105
|
braintree.configuration
|
has_access_token
| null |
def has_access_token(self):
return self.access_token is not None
|
(self)
|
712,106
|
braintree.configuration
|
has_client_credentials
| null |
def has_client_credentials(self):
return self.client_secret is not None and self.client_id is not None
|
(self)
|
712,107
|
braintree.configuration
|
http
| null |
def http(self):
return braintree.util.http.Http(self)
|
(self)
|
712,108
|
braintree.configuration
|
http_strategy
| null |
def http_strategy(self):
return self._http_strategy
|
(self)
|
712,109
|
braintree.configuration
|
instantiate
| null |
@staticmethod
def instantiate():
return Configuration(
environment=Configuration.environment,
merchant_id=Configuration.merchant_id,
public_key=Configuration.public_key,
private_key=Configuration.private_key,
http_strategy=Configuration.default_http_strategy,
timeout=Configuration.timeout,
wrap_http_exceptions=Configuration.wrap_http_exceptions
)
|
()
|
712,110
|
braintree.connected_merchant_paypal_status_changed
|
ConnectedMerchantPayPalStatusChanged
| null |
class ConnectedMerchantPayPalStatusChanged(Resource):
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
@property
def merchant_id(self):
return self.merchant_public_id
|
(gateway, attributes)
|
712,117
|
braintree.connected_merchant_status_transitioned
|
ConnectedMerchantStatusTransitioned
| null |
class ConnectedMerchantStatusTransitioned(Resource):
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
@property
def merchant_id(self):
return self.merchant_public_id
|
(gateway, attributes)
|
712,124
|
braintree.credentials_parser
|
CredentialsParser
| null |
class CredentialsParser(object):
def __init__(self, client_id=None, client_secret=None, access_token=None):
self.client_id = client_id
self.client_secret = client_secret
self.access_token = access_token
def parse_client_credentials(self):
if self.client_id is None and self.client_secret is not None:
raise ConfigurationError("Missing client_id when constructing BraintreeGateway")
if self.client_secret is None and self.client_id is not None:
raise ConfigurationError("Missing client_secret when constructing BraintreeGateway")
if not self.client_id.startswith("client_id"):
raise ConfigurationError("Value passed for client_id is not a client_id")
if not self.client_secret.startswith("client_secret"):
raise ConfigurationError("Value passed for client_secret is not a client_secret")
client_id_environment = self.get_environment(self.client_id)
client_secret_environment = self.get_environment(self.client_secret)
if client_id_environment is client_secret_environment:
self.environment = client_id_environment
else:
raise ConfigurationError(" ".join([
"Mismatched credential environments: client_id environment is:",
str(client_id_environment),
"and client_secret environment is:",
str(client_secret_environment)
]))
def parse_access_token(self):
self.environment = self.get_environment(self.access_token)
self.merchant_id = self.get_merchant_id(self.access_token)
def get_environment(self, credential):
parts = credential.split("$")
return Environment.All.get(parts[1])
def get_merchant_id(self, credential):
parts = credential.split("$")
return parts[2]
|
(client_id=None, client_secret=None, access_token=None)
|
712,125
|
braintree.credentials_parser
|
__init__
| null |
def __init__(self, client_id=None, client_secret=None, access_token=None):
self.client_id = client_id
self.client_secret = client_secret
self.access_token = access_token
|
(self, client_id=None, client_secret=None, access_token=None)
|
712,126
|
braintree.credentials_parser
|
get_environment
| null |
def get_environment(self, credential):
parts = credential.split("$")
return Environment.All.get(parts[1])
|
(self, credential)
|
712,127
|
braintree.credentials_parser
|
get_merchant_id
| null |
def get_merchant_id(self, credential):
parts = credential.split("$")
return parts[2]
|
(self, credential)
|
712,128
|
braintree.credentials_parser
|
parse_access_token
| null |
def parse_access_token(self):
self.environment = self.get_environment(self.access_token)
self.merchant_id = self.get_merchant_id(self.access_token)
|
(self)
|
712,129
|
braintree.credentials_parser
|
parse_client_credentials
| null |
def parse_client_credentials(self):
if self.client_id is None and self.client_secret is not None:
raise ConfigurationError("Missing client_id when constructing BraintreeGateway")
if self.client_secret is None and self.client_id is not None:
raise ConfigurationError("Missing client_secret when constructing BraintreeGateway")
if not self.client_id.startswith("client_id"):
raise ConfigurationError("Value passed for client_id is not a client_id")
if not self.client_secret.startswith("client_secret"):
raise ConfigurationError("Value passed for client_secret is not a client_secret")
client_id_environment = self.get_environment(self.client_id)
client_secret_environment = self.get_environment(self.client_secret)
if client_id_environment is client_secret_environment:
self.environment = client_id_environment
else:
raise ConfigurationError(" ".join([
"Mismatched credential environments: client_id environment is:",
str(client_id_environment),
"and client_secret environment is:",
str(client_secret_environment)
]))
|
(self)
|
712,130
|
braintree.credit_card
|
CreditCard
|
A class representing Braintree CreditCard objects.
An example of creating an credit card with all available fields::
result = braintree.CreditCard.create({
"cardholder_name": "John Doe",
"cvv": "123",
"expiration_date": "12/2012",
"number": "4111111111111111",
"token": "my_token",
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"company": "Braintree",
"street_address": "111 First Street",
"extended_address": "Unit 1",
"locality": "Chicago",
"postal_code": "60606",
"region": "IL",
"country_name": "United States of America"
"phone_number": "312-123-4567"
},
"options": {
"verify_card": True,
"verification_amount": "2.00"
}
})
print(result.credit_card.token)
print(result.credit_card.masked_number)
For more information on CreditCards, see https://developer.paypal.com/braintree/docs/reference/request/credit-card/create/python
|
class CreditCard(Resource):
"""
A class representing Braintree CreditCard objects.
An example of creating an credit card with all available fields::
result = braintree.CreditCard.create({
"cardholder_name": "John Doe",
"cvv": "123",
"expiration_date": "12/2012",
"number": "4111111111111111",
"token": "my_token",
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"company": "Braintree",
"street_address": "111 First Street",
"extended_address": "Unit 1",
"locality": "Chicago",
"postal_code": "60606",
"region": "IL",
"country_name": "United States of America"
"phone_number": "312-123-4567"
},
"options": {
"verify_card": True,
"verification_amount": "2.00"
}
})
print(result.credit_card.token)
print(result.credit_card.masked_number)
For more information on CreditCards, see https://developer.paypal.com/braintree/docs/reference/request/credit-card/create/python
"""
class CardType(object):
"""
Contants representing the type of the credit card. Available types are:
* Braintree.CreditCard.AmEx
* Braintree.CreditCard.CarteBlanche
* Braintree.CreditCard.ChinaUnionPay
* Braintree.CreditCard.DinersClubInternational
* Braintree.CreditCard.Discover
* Braintree.CreditCard.Electron
* Braintree.CreditCard.Elo
* Braintree.CreditCard.Hiper
* Braintree.CreditCard.Hipercard
* Braintree.CreditCard.JCB
* Braintree.CreditCard.Laser
* Braintree.CreditCard.UK_Maestro
* Braintree.CreditCard.Maestro
* Braintree.CreditCard.MasterCard
* Braintree.CreditCard.Solo
* Braintree.CreditCard.Switch
* Braintree.CreditCard.Visa
* Braintree.CreditCard.Unknown
"""
AmEx = "American Express"
CarteBlanche = "Carte Blanche"
ChinaUnionPay = "China UnionPay"
DinersClubInternational = "Diners Club"
Discover = "Discover"
Electron = "Electron"
Elo = "Elo"
Hiper = "Hiper"
Hipercard = "Hipercard"
JCB = "JCB"
Laser = "Laser"
UK_Maestro = "UK Maestro"
Maestro = "Maestro"
MasterCard = "MasterCard"
Solo = "Solo"
Switch = "Switch"
Visa = "Visa"
Unknown = "Unknown"
class CustomerLocation(object):
"""
Contants representing the issuer location of the credit card. Available locations are:
* braintree.CreditCard.CustomerLocation.International
* braintree.CreditCard.CustomerLocation.US
"""
International = "international"
US = "us"
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class CardTypeIndicator(object):
"""
Constants representing the three states for the card type indicator attributes
* braintree.CreditCard.CardTypeIndicator.Yes
* braintree.CreditCard.CardTypeIndicator.No
* braintree.CreditCard.CardTypeIndicator.Unknown
"""
Yes = "Yes"
No = "No"
Unknown = "Unknown"
class DebitNetwork(Enum):
"""
Constants representing the debit networks used for processing a pinless debit transaction
* braintree.CreditCard.DebitNetwork.Accel
* braintree.CreditCard.DebitNetwork.Maestro
* braintree.CreditCard.DebitNetwork.Nyce
* braintree.CreditCard.DebitNetwork.Pulse
* braintree.CreditCard.DebitNetwork.Star
* braintree.CreditCard.DebitNetwork.Star_Access
"""
Accel = "ACCEL"
Maestro= "MAESTRO"
Nyce = "NYCE"
Pulse = "PULSE"
Star = "STAR"
Star_Access = "STAR_ACCESS"
Commercial = DurbinRegulated = Debit = Healthcare = \
CountryOfIssuance = IssuingBank = Payroll = Prepaid = ProductId = CardTypeIndicator
@staticmethod
def create(params=None):
"""
Create a CreditCard.
A number and expiration_date are required. ::
result = braintree.CreditCard.create({
"number": "4111111111111111",
"expiration_date": "12/2012"
})
"""
if params is None:
params = {}
return Configuration.gateway().credit_card.create(params)
@staticmethod
def update(credit_card_token, params=None):
"""
Update an existing CreditCard
By credit_card_id. The params are similar to create::
result = braintree.CreditCard.update("my_credit_card_id", {
"cardholder_name": "John Doe"
})
"""
if params is None:
params = {}
return Configuration.gateway().credit_card.update(credit_card_token, params)
@staticmethod
def delete(credit_card_token):
"""
Delete a credit card
Given a credit_card_id::
result = braintree.CreditCard.delete("my_credit_card_id")
"""
return Configuration.gateway().credit_card.delete(credit_card_token)
@staticmethod
def expired():
""" Return a collection of expired credit cards. """
return Configuration.gateway().credit_card.expired()
@staticmethod
def expiring_between(start_date, end_date):
""" Return a collection of credit cards expiring between the given dates. """
return Configuration.gateway().credit_card.expiring_between(start_date, end_date)
@staticmethod
def find(credit_card_token):
"""
Find a credit card, given a credit_card_id. This does not return
a result object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided
credit_card_id is not found. ::
credit_card = braintree.CreditCard.find("my_credit_card_token")
"""
return Configuration.gateway().credit_card.find(credit_card_token)
@staticmethod
def from_nonce(nonce):
"""
Convert a payment method nonce into a CreditCard. This does not return
a result object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided
credit_card_id is not found. ::
credit_card = braintree.CreditCard.from_nonce("my_payment_method_nonce")
"""
return Configuration.gateway().credit_card.from_nonce(nonce)
@staticmethod
def create_signature():
return CreditCard.signature("create")
@staticmethod
def update_signature():
return CreditCard.signature("update")
@staticmethod
def signature(type):
billing_address_params = [
"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"
]
options = [
"fail_on_duplicate_payment_method",
"make_default",
"skip_advanced_fraud_checking",
"venmo_sdk_session", # NEXT_MJOR_VERSION remove venmo_sdk_session
"verification_account_type",
"verification_amount",
"verification_merchant_account_id",
"verify_card",
{
"adyen":[
"overwrite_brand",
"selected_brand"
]
}
]
three_d_secure_pass_thru = [
"cavv",
"ds_transaction_id",
"eci_flag",
"three_d_secure_version",
"xid"
]
signature = [
"billing_address_id",
"cardholder_name",
"cvv",
"expiration_date",
"expiration_month",
"expiration_year",
"number",
"token",
"venmo_sdk_payment_method_code", # NEXT_MJOR_VERSION remove venmo_sdk_payment_method_code
"device_data",
"payment_method_nonce",
"device_session_id", "fraud_merchant_id", # NEXT_MAJOR_VERSION remove device_session_id and fraud_merchant_id
{
"billing_address": billing_address_params
},
{
"options": options
},
{
"three_d_secure_pass_thru": three_d_secure_pass_thru
}
]
if type == "create":
signature.append("customer_id")
elif type == "update":
billing_address_params.append({"options": ["update_existing"]})
elif type == "update_via_customer":
options.append("update_existing_token")
billing_address_params.append({"options": ["update_existing"]})
else:
raise AttributeError
return signature
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
self.is_expired = self.expired
if "billing_address" in attributes:
self.billing_address = Address(gateway, self.billing_address)
else:
self.billing_address = None
if "subscriptions" in attributes:
self.subscriptions = [braintree.subscription.Subscription(gateway, subscription) for subscription in self.subscriptions]
if "verifications" in attributes:
sorted_verifications = sorted(attributes["verifications"], key=lambda verification: verification["created_at"], reverse=True)
if len(sorted_verifications) > 0:
self.verification = CreditCardVerification(gateway, sorted_verifications[0])
@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 masked_number(self):
"""
Returns the masked number of the CreditCard.
"""
bin = self.bin_extended if hasattr(self, "bin_extended") else self.bin
mask_length = 16 - len(bin) - len(self.last_4)
mask = "*" * mask_length
return bin + mask + self.last_4
|
(gateway, attributes)
|
712,134
|
braintree.credit_card
|
__init__
| null |
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
self.is_expired = self.expired
if "billing_address" in attributes:
self.billing_address = Address(gateway, self.billing_address)
else:
self.billing_address = None
if "subscriptions" in attributes:
self.subscriptions = [braintree.subscription.Subscription(gateway, subscription) for subscription in self.subscriptions]
if "verifications" in attributes:
sorted_verifications = sorted(attributes["verifications"], key=lambda verification: verification["created_at"], reverse=True)
if len(sorted_verifications) > 0:
self.verification = CreditCardVerification(gateway, sorted_verifications[0])
|
(self, gateway, attributes)
|
712,136
|
braintree.credit_card
|
create
|
Create a CreditCard.
A number and expiration_date are required. ::
result = braintree.CreditCard.create({
"number": "4111111111111111",
"expiration_date": "12/2012"
})
|
@staticmethod
def create(params=None):
"""
Create a CreditCard.
A number and expiration_date are required. ::
result = braintree.CreditCard.create({
"number": "4111111111111111",
"expiration_date": "12/2012"
})
"""
if params is None:
params = {}
return Configuration.gateway().credit_card.create(params)
|
(params=None)
|
712,137
|
braintree.credit_card
|
create_signature
| null |
@staticmethod
def create_signature():
return CreditCard.signature("create")
|
()
|
712,138
|
braintree.credit_card
|
delete
|
Delete a credit card
Given a credit_card_id::
result = braintree.CreditCard.delete("my_credit_card_id")
|
@staticmethod
def delete(credit_card_token):
"""
Delete a credit card
Given a credit_card_id::
result = braintree.CreditCard.delete("my_credit_card_id")
"""
return Configuration.gateway().credit_card.delete(credit_card_token)
|
(credit_card_token)
|
712,139
|
braintree.credit_card
|
expired
|
Return a collection of expired credit cards.
|
@staticmethod
def expired():
""" Return a collection of expired credit cards. """
return Configuration.gateway().credit_card.expired()
|
()
|
712,140
|
braintree.credit_card
|
expiring_between
|
Return a collection of credit cards expiring between the given dates.
|
@staticmethod
def expiring_between(start_date, end_date):
""" Return a collection of credit cards expiring between the given dates. """
return Configuration.gateway().credit_card.expiring_between(start_date, end_date)
|
(start_date, end_date)
|
712,141
|
braintree.credit_card
|
find
|
Find a credit card, given a credit_card_id. This does not return
a result object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided
credit_card_id is not found. ::
credit_card = braintree.CreditCard.find("my_credit_card_token")
|
@staticmethod
def find(credit_card_token):
"""
Find a credit card, given a credit_card_id. This does not return
a result object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided
credit_card_id is not found. ::
credit_card = braintree.CreditCard.find("my_credit_card_token")
"""
return Configuration.gateway().credit_card.find(credit_card_token)
|
(credit_card_token)
|
712,142
|
braintree.credit_card
|
from_nonce
|
Convert a payment method nonce into a CreditCard. This does not return
a result object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided
credit_card_id is not found. ::
credit_card = braintree.CreditCard.from_nonce("my_payment_method_nonce")
|
@staticmethod
def from_nonce(nonce):
"""
Convert a payment method nonce into a CreditCard. This does not return
a result object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided
credit_card_id is not found. ::
credit_card = braintree.CreditCard.from_nonce("my_payment_method_nonce")
"""
return Configuration.gateway().credit_card.from_nonce(nonce)
|
(nonce)
|
712,143
|
braintree.credit_card
|
signature
| null |
@staticmethod
def signature(type):
billing_address_params = [
"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"
]
options = [
"fail_on_duplicate_payment_method",
"make_default",
"skip_advanced_fraud_checking",
"venmo_sdk_session", # NEXT_MJOR_VERSION remove venmo_sdk_session
"verification_account_type",
"verification_amount",
"verification_merchant_account_id",
"verify_card",
{
"adyen":[
"overwrite_brand",
"selected_brand"
]
}
]
three_d_secure_pass_thru = [
"cavv",
"ds_transaction_id",
"eci_flag",
"three_d_secure_version",
"xid"
]
signature = [
"billing_address_id",
"cardholder_name",
"cvv",
"expiration_date",
"expiration_month",
"expiration_year",
"number",
"token",
"venmo_sdk_payment_method_code", # NEXT_MJOR_VERSION remove venmo_sdk_payment_method_code
"device_data",
"payment_method_nonce",
"device_session_id", "fraud_merchant_id", # NEXT_MAJOR_VERSION remove device_session_id and fraud_merchant_id
{
"billing_address": billing_address_params
},
{
"options": options
},
{
"three_d_secure_pass_thru": three_d_secure_pass_thru
}
]
if type == "create":
signature.append("customer_id")
elif type == "update":
billing_address_params.append({"options": ["update_existing"]})
elif type == "update_via_customer":
options.append("update_existing_token")
billing_address_params.append({"options": ["update_existing"]})
else:
raise AttributeError
return signature
|
(type)
|
712,144
|
braintree.credit_card
|
update
|
Update an existing CreditCard
By credit_card_id. The params are similar to create::
result = braintree.CreditCard.update("my_credit_card_id", {
"cardholder_name": "John Doe"
})
|
@staticmethod
def update(credit_card_token, params=None):
"""
Update an existing CreditCard
By credit_card_id. The params are similar to create::
result = braintree.CreditCard.update("my_credit_card_id", {
"cardholder_name": "John Doe"
})
"""
if params is None:
params = {}
return Configuration.gateway().credit_card.update(credit_card_token, params)
|
(credit_card_token, params=None)
|
712,145
|
braintree.credit_card
|
update_signature
| null |
@staticmethod
def update_signature():
return CreditCard.signature("update")
|
()
|
712,147
|
braintree.credit_card_gateway
|
CreditCardGateway
| null |
class CreditCardGateway(object):
def __init__(self, gateway):
self.gateway = gateway
self.config = gateway.config
def create(self, params=None):
if params is None:
params = {}
Resource.verify_keys(params, CreditCard.create_signature())
self.__check_for_deprecated_attributes(params)
return self._post("/payment_methods", {"credit_card": params})
def delete(self, credit_card_token):
self.config.http().delete(self.config.base_merchant_path() + "/payment_methods/credit_card/" + credit_card_token)
return SuccessfulResult()
def expired(self):
response = self.config.http().post(self.config.base_merchant_path() + "/payment_methods/all/expired_ids")
return ResourceCollection(None, response, self.__fetch_expired)
def expiring_between(self, start_date, end_date):
formatted_start_date = start_date.strftime("%m%Y")
formatted_end_date = end_date.strftime("%m%Y")
query = "start=%s&end=%s" % (formatted_start_date, formatted_end_date)
response = self.config.http().post(self.config.base_merchant_path() + "/payment_methods/all/expiring_ids?" + query)
return ResourceCollection(query, response, self.__fetch_existing_between)
def find(self, credit_card_token):
try:
if credit_card_token is None or credit_card_token.strip() == "":
raise NotFoundError()
response = self.config.http().get(self.config.base_merchant_path() + "/payment_methods/credit_card/" + credit_card_token)
return CreditCard(self.gateway, response["credit_card"])
except NotFoundError:
raise NotFoundError("payment method with token " + repr(credit_card_token) + " not found")
def forward(self, credit_card_token, receiving_merchant_id):
raise NotFoundError("This method of forwarding payment methods is no longer supported. Please consider the Grant API for similar functionality.")
def from_nonce(self, nonce):
try:
if nonce is None or nonce.strip() == "":
raise NotFoundError()
response = self.config.http().get(self.config.base_merchant_path() + "/payment_methods/from_nonce/" + nonce)
return CreditCard(self.gateway, response["credit_card"])
except NotFoundError:
raise NotFoundError("payment method with nonce " + repr(nonce) + " locked, consumed or not found")
def update(self, credit_card_token, params=None):
if params is None:
params = {}
Resource.verify_keys(params, CreditCard.update_signature())
self.__check_for_deprecated_attributes(params)
response = self.config.http().put(self.config.base_merchant_path() + "/payment_methods/credit_card/" + credit_card_token, {"credit_card": params})
if "credit_card" in response:
return SuccessfulResult({"credit_card": CreditCard(self.gateway, response["credit_card"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def __fetch_expired(self, query, ids):
criteria = {}
criteria["ids"] = IdsSearch.ids.in_list(ids).to_param()
response = self.config.http().post(self.config.base_merchant_path() + "/payment_methods/all/expired", {"search": criteria})
return [CreditCard(self.gateway, item) for item in ResourceCollection._extract_as_array(response["payment_methods"], "credit_card")]
def __fetch_existing_between(self, query, ids):
criteria = {}
criteria["ids"] = IdsSearch.ids.in_list(ids).to_param()
response = self.config.http().post(self.config.base_merchant_path() + "/payment_methods/all/expiring?" + query, {"search": criteria})
return [CreditCard(self.gateway, item) for item in ResourceCollection._extract_as_array(response["payment_methods"], "credit_card")]
def _post(self, url, params=None):
if params is None:
params = {}
response = self.config.http().post(self.config.base_merchant_path() + url, params)
if "credit_card" in response:
return SuccessfulResult({"credit_card": CreditCard(self.gateway, response["credit_card"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
# NEXT_MAJOR_VERSION remove these checks when the attributes are removed
def __check_for_deprecated_attributes(self, params):
if "device_session_id" in params.keys():
warnings.warn("device_session_id is deprecated, use device_data parameter instead", DeprecationWarning)
if "fraud_merchant_id" in params.keys():
warnings.warn("fraud_merchant_id is deprecated, use device_data parameter instead", DeprecationWarning)
if "venmo_sdk_payment_method_code" in params.keys() or "venmo_sdk_session" in params.keys():
warnings.warn("The Venmo SDK integration is Unsupported. Please update your integration to use Pay with Venmo instead.", DeprecationWarning)
|
(gateway)
|
712,148
|
braintree.credit_card_gateway
|
__check_for_deprecated_attributes
| null |
def __check_for_deprecated_attributes(self, params):
if "device_session_id" in params.keys():
warnings.warn("device_session_id is deprecated, use device_data parameter instead", DeprecationWarning)
if "fraud_merchant_id" in params.keys():
warnings.warn("fraud_merchant_id is deprecated, use device_data parameter instead", DeprecationWarning)
if "venmo_sdk_payment_method_code" in params.keys() or "venmo_sdk_session" in params.keys():
warnings.warn("The Venmo SDK integration is Unsupported. Please update your integration to use Pay with Venmo instead.", DeprecationWarning)
|
(self, params)
|
712,149
|
braintree.credit_card_gateway
|
__fetch_existing_between
| null |
def __fetch_existing_between(self, query, ids):
criteria = {}
criteria["ids"] = IdsSearch.ids.in_list(ids).to_param()
response = self.config.http().post(self.config.base_merchant_path() + "/payment_methods/all/expiring?" + query, {"search": criteria})
return [CreditCard(self.gateway, item) for item in ResourceCollection._extract_as_array(response["payment_methods"], "credit_card")]
|
(self, query, ids)
|
712,150
|
braintree.credit_card_gateway
|
__fetch_expired
| null |
def __fetch_expired(self, query, ids):
criteria = {}
criteria["ids"] = IdsSearch.ids.in_list(ids).to_param()
response = self.config.http().post(self.config.base_merchant_path() + "/payment_methods/all/expired", {"search": criteria})
return [CreditCard(self.gateway, item) for item in ResourceCollection._extract_as_array(response["payment_methods"], "credit_card")]
|
(self, query, ids)
|
712,152
|
braintree.credit_card_gateway
|
_post
| null |
def _post(self, url, params=None):
if params is None:
params = {}
response = self.config.http().post(self.config.base_merchant_path() + url, params)
if "credit_card" in response:
return SuccessfulResult({"credit_card": CreditCard(self.gateway, response["credit_card"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, url, params=None)
|
712,153
|
braintree.credit_card_gateway
|
create
| null |
def create(self, params=None):
if params is None:
params = {}
Resource.verify_keys(params, CreditCard.create_signature())
self.__check_for_deprecated_attributes(params)
return self._post("/payment_methods", {"credit_card": params})
|
(self, params=None)
|
712,154
|
braintree.credit_card_gateway
|
delete
| null |
def delete(self, credit_card_token):
self.config.http().delete(self.config.base_merchant_path() + "/payment_methods/credit_card/" + credit_card_token)
return SuccessfulResult()
|
(self, credit_card_token)
|
712,155
|
braintree.credit_card_gateway
|
expired
| null |
def expired(self):
response = self.config.http().post(self.config.base_merchant_path() + "/payment_methods/all/expired_ids")
return ResourceCollection(None, response, self.__fetch_expired)
|
(self)
|
712,156
|
braintree.credit_card_gateway
|
expiring_between
| null |
def expiring_between(self, start_date, end_date):
formatted_start_date = start_date.strftime("%m%Y")
formatted_end_date = end_date.strftime("%m%Y")
query = "start=%s&end=%s" % (formatted_start_date, formatted_end_date)
response = self.config.http().post(self.config.base_merchant_path() + "/payment_methods/all/expiring_ids?" + query)
return ResourceCollection(query, response, self.__fetch_existing_between)
|
(self, start_date, end_date)
|
712,157
|
braintree.credit_card_gateway
|
find
| null |
def find(self, credit_card_token):
try:
if credit_card_token is None or credit_card_token.strip() == "":
raise NotFoundError()
response = self.config.http().get(self.config.base_merchant_path() + "/payment_methods/credit_card/" + credit_card_token)
return CreditCard(self.gateway, response["credit_card"])
except NotFoundError:
raise NotFoundError("payment method with token " + repr(credit_card_token) + " not found")
|
(self, credit_card_token)
|
712,158
|
braintree.credit_card_gateway
|
forward
| null |
def forward(self, credit_card_token, receiving_merchant_id):
raise NotFoundError("This method of forwarding payment methods is no longer supported. Please consider the Grant API for similar functionality.")
|
(self, credit_card_token, receiving_merchant_id)
|
712,159
|
braintree.credit_card_gateway
|
from_nonce
| null |
def from_nonce(self, nonce):
try:
if nonce is None or nonce.strip() == "":
raise NotFoundError()
response = self.config.http().get(self.config.base_merchant_path() + "/payment_methods/from_nonce/" + nonce)
return CreditCard(self.gateway, response["credit_card"])
except NotFoundError:
raise NotFoundError("payment method with nonce " + repr(nonce) + " locked, consumed or not found")
|
(self, nonce)
|
712,160
|
braintree.credit_card_gateway
|
update
| null |
def update(self, credit_card_token, params=None):
if params is None:
params = {}
Resource.verify_keys(params, CreditCard.update_signature())
self.__check_for_deprecated_attributes(params)
response = self.config.http().put(self.config.base_merchant_path() + "/payment_methods/credit_card/" + credit_card_token, {"credit_card": params})
if "credit_card" in response:
return SuccessfulResult({"credit_card": CreditCard(self.gateway, response["credit_card"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, credit_card_token, params=None)
|
712,161
|
braintree.credit_card_verification
|
CreditCardVerification
| null |
class CreditCardVerification(AttributeGetter):
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class Status(object):
"""
Constants representing transaction statuses. Available statuses are:
* braintree.CreditCardVerification.Status.Failed
* braintree.CreditCardVerification.Status.GatewayRejected
* braintree.CreditCardVerification.Status.ProcessorDeclined
* braintree.CreditCardVerification.Status.Verified
"""
Failed = "failed"
GatewayRejected = "gateway_rejected"
ProcessorDeclined = "processor_declined"
Verified = "verified"
def __init__(self, gateway, attributes):
AttributeGetter.__init__(self, attributes)
if "amount" in attributes and getattr(self, "amount", None):
self.amount = Decimal(self.amount)
else:
self.amount = None
if "currency_iso_code" not in attributes:
self.currency_iso_code = None
if "processor_response_code" not in attributes:
self.processor_response_code = None
if "processor_response_text" not in attributes:
self.processor_response_text = None
if "network_response_code" not in attributes:
self.network_response_code = None
if "network_response_text" not in attributes:
self.network_response_text = None
if "risk_data" in attributes:
self.risk_data = RiskData(attributes["risk_data"])
else:
self.risk_data = None
if "three_d_secure_info" in attributes and not attributes["three_d_secure_info"] is None:
self.three_d_secure_info = ThreeDSecureInfo(attributes["three_d_secure_info"])
else:
self.three_d_secure_info = None
@staticmethod
def find(verification_id):
return Configuration.gateway().verification.find(verification_id)
@staticmethod
def search(*query):
return Configuration.gateway().verification.search(*query)
@staticmethod
def create(params):
Resource.verify_keys(params, CreditCardVerification.create_signature())
return Configuration.gateway().verification.create(params)
@staticmethod
def create_signature():
billing_address_params = [
"company", "country_code_alpha2", "country_code_alpha3", "country_code_numeric",
"country_name", "extended_address", "first_name", "last_name", "locality",
"postal_code", "region", "street_address"
]
credit_card_params = [
"number", "cvv", "cardholder_name", "cvv", "expiration_date", "expiration_month",
"expiration_year", {"billing_address": billing_address_params}
]
external_vault_params = [
"previous_network_transaction_id",
"status"
]
options_params = [
"account_type", "amount", "merchant_account_id"
]
risk_data_params = [
"customer_browser",
"customer_ip"
]
three_d_secure_pass_thru_params = [
"eci_flag",
"cavv",
"xid",
"authentication_response",
"directory_response",
"cavv_algorithm",
"ds_transaction_id",
"three_d_secure_version"
]
return [
{"credit_card": credit_card_params},
{"external_vault": external_vault_params},
"intended_transaction_source",
{"options": options_params},
"payment_method_nonce",
{"risk_data": risk_data_params},
"three_d_secure_authentication_id",
{"three_d_secure_pass_thru": three_d_secure_pass_thru_params}]
def __eq__(self, other):
if not isinstance(other, CreditCardVerification):
return False
return self.id == other.id
|
(gateway, attributes)
|
712,162
|
braintree.credit_card_verification
|
__eq__
| null |
def __eq__(self, other):
if not isinstance(other, CreditCardVerification):
return False
return self.id == other.id
|
(self, other)
|
712,163
|
braintree.credit_card_verification
|
__init__
| null |
def __init__(self, gateway, attributes):
AttributeGetter.__init__(self, attributes)
if "amount" in attributes and getattr(self, "amount", None):
self.amount = Decimal(self.amount)
else:
self.amount = None
if "currency_iso_code" not in attributes:
self.currency_iso_code = None
if "processor_response_code" not in attributes:
self.processor_response_code = None
if "processor_response_text" not in attributes:
self.processor_response_text = None
if "network_response_code" not in attributes:
self.network_response_code = None
if "network_response_text" not in attributes:
self.network_response_text = None
if "risk_data" in attributes:
self.risk_data = RiskData(attributes["risk_data"])
else:
self.risk_data = None
if "three_d_secure_info" in attributes and not attributes["three_d_secure_info"] is None:
self.three_d_secure_info = ThreeDSecureInfo(attributes["three_d_secure_info"])
else:
self.three_d_secure_info = None
|
(self, gateway, attributes)
|
712,165
|
braintree.credit_card_verification
|
create
| null |
@staticmethod
def create(params):
Resource.verify_keys(params, CreditCardVerification.create_signature())
return Configuration.gateway().verification.create(params)
|
(params)
|
712,166
|
braintree.credit_card_verification
|
create_signature
| null |
@staticmethod
def create_signature():
billing_address_params = [
"company", "country_code_alpha2", "country_code_alpha3", "country_code_numeric",
"country_name", "extended_address", "first_name", "last_name", "locality",
"postal_code", "region", "street_address"
]
credit_card_params = [
"number", "cvv", "cardholder_name", "cvv", "expiration_date", "expiration_month",
"expiration_year", {"billing_address": billing_address_params}
]
external_vault_params = [
"previous_network_transaction_id",
"status"
]
options_params = [
"account_type", "amount", "merchant_account_id"
]
risk_data_params = [
"customer_browser",
"customer_ip"
]
three_d_secure_pass_thru_params = [
"eci_flag",
"cavv",
"xid",
"authentication_response",
"directory_response",
"cavv_algorithm",
"ds_transaction_id",
"three_d_secure_version"
]
return [
{"credit_card": credit_card_params},
{"external_vault": external_vault_params},
"intended_transaction_source",
{"options": options_params},
"payment_method_nonce",
{"risk_data": risk_data_params},
"three_d_secure_authentication_id",
{"three_d_secure_pass_thru": three_d_secure_pass_thru_params}]
|
()
|
712,167
|
braintree.credit_card_verification
|
find
| null |
@staticmethod
def find(verification_id):
return Configuration.gateway().verification.find(verification_id)
|
(verification_id)
|
712,168
|
braintree.credit_card_verification
|
search
| null |
@staticmethod
def search(*query):
return Configuration.gateway().verification.search(*query)
|
(*query)
|
712,169
|
braintree.credit_card_verification_search
|
CreditCardVerificationSearch
| null |
class CreditCardVerificationSearch:
credit_card_cardholder_name = Search.TextNodeBuilder("credit_card_cardholder_name")
id = Search.TextNodeBuilder("id")
credit_card_expiration_date = Search.EqualityNodeBuilder("credit_card_expiration_date")
credit_card_number = Search.PartialMatchNodeBuilder("credit_card_number")
credit_card_card_type = Search.MultipleValueNodeBuilder("credit_card_card_type", Constants.get_all_constant_values_from_class(CreditCard.CardType))
ids = Search.MultipleValueNodeBuilder("ids")
created_at = Search.RangeNodeBuilder("created_at")
status = Search.MultipleValueNodeBuilder("status", Constants.get_all_constant_values_from_class(CreditCardVerification.Status))
billing_postal_code = Search.TextNodeBuilder("billing_address_details_postal_code")
customer_email = Search.TextNodeBuilder("customer_email")
customer_id = Search.TextNodeBuilder("customer_id")
payment_method_token = Search.TextNodeBuilder("payment_method_token")
|
()
|
712,170
|
braintree.customer
|
Customer
|
A class representing a customer.
An example of creating an customer with all available fields::
result = braintree.Customer.create({
"id": "my_customer_id",
"company": "Some company",
"email": "john.doe@example.com",
"fax": "123-555-1212",
"first_name": "John",
"last_name": "Doe",
"phone": "123-555-1221",
"website": "http://www.example.com",
"credit_card": {
"cardholder_name": "John Doe",
"cvv": "123",
"expiration_date": "12/2012",
"number": "4111111111111111",
"token": "my_token",
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"company": "Braintree",
"street_address": "111 First Street",
"extended_address": "Unit 1",
"locality": "Chicago",
"postal_code": "60606",
"region": "IL",
"country_name": "United States of America"
"phone_number": "312-123-4567"
},
"options": {
"verify_card": True,
"verification_amount": "2.00"
}
},
"custom_fields": {
"my_key": "some value"
}
})
print(result.customer.id)
print(result.customer.first_name)
For more information on Customers, see https://developer.paypal.com/braintree/docs/reference/request/customer/create/python
|
class Customer(Resource):
"""
A class representing a customer.
An example of creating an customer with all available fields::
result = braintree.Customer.create({
"id": "my_customer_id",
"company": "Some company",
"email": "john.doe@example.com",
"fax": "123-555-1212",
"first_name": "John",
"last_name": "Doe",
"phone": "123-555-1221",
"website": "http://www.example.com",
"credit_card": {
"cardholder_name": "John Doe",
"cvv": "123",
"expiration_date": "12/2012",
"number": "4111111111111111",
"token": "my_token",
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"company": "Braintree",
"street_address": "111 First Street",
"extended_address": "Unit 1",
"locality": "Chicago",
"postal_code": "60606",
"region": "IL",
"country_name": "United States of America"
"phone_number": "312-123-4567"
},
"options": {
"verify_card": True,
"verification_amount": "2.00"
}
},
"custom_fields": {
"my_key": "some value"
}
})
print(result.customer.id)
print(result.customer.first_name)
For more information on Customers, see https://developer.paypal.com/braintree/docs/reference/request/customer/create/python
"""
def __repr__(self):
detail_list = [
"id",
"graphql_id",
"company",
"created_at",
"email",
"fax",
"first_name",
"last_name",
"merchant_id",
"phone",
"updated_at",
"website",
]
return super(Customer, self).__repr__(detail_list)
@staticmethod
def all():
""" Return a collection of all customers. """
return Configuration.gateway().customer.all()
@staticmethod
def create(params=None):
"""
Create a Customer
No field is required::
result = braintree.Customer.create({
"company": "Some company",
"first_name": "John"
})
"""
if params is None:
params = {}
return Configuration.gateway().customer.create(params)
@staticmethod
def delete(customer_id):
"""
Delete a customer
Given a customer_id::
result = braintree.Customer.delete("my_customer_id")
"""
return Configuration.gateway().customer.delete(customer_id)
@staticmethod
def find(customer_id, association_filter_id=None):
"""
Find an customer, given a customer_id. This does not return a result
object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided customer_id
is not found. ::
customer = braintree.Customer.find("my_customer_id")
"""
return Configuration.gateway().customer.find(customer_id, association_filter_id)
@staticmethod
def search(*query):
return Configuration.gateway().customer.search(*query)
@staticmethod
def update(customer_id, params=None):
"""
Update an existing Customer
By customer_id. The params are similar to create::
result = braintree.Customer.update("my_customer_id", {
"last_name": "Smith"
})
"""
if params is None:
params = {}
return Configuration.gateway().customer.update(customer_id, params)
@staticmethod
def create_signature():
return [
"company", "email", "fax", "first_name", "id", "last_name", "phone", "website", "device_data", "payment_method_nonce",
"device_session_id", "fraud_merchant_id", # NEXT_MAJOR_VERSION remove device_session_id and fraud_merchant_id
{"risk_data": ["customer_browser", "customer_device_id", "customer_ip", "customer_location_zip", "customer_tenure"]},
{"credit_card": CreditCard.create_signature()},
{"apple_pay_card": ApplePayCard.signature()},
{"android_pay_card": AndroidPayCard.card_signature()},
{"android_pay_network_token": AndroidPayCard.network_token_signature()},
{"custom_fields": ["__any_key__"]},
{"three_d_secure_pass_thru": [
"cavv",
"ds_transaction_id",
"eci_flag",
"three_d_secure_version",
"xid",
]},
{"tax_identifiers": ["country_code", "identifier"]},
{"options": [{"paypal": [
"payee_email",
"order_id",
"custom_field",
"description",
"amount",
{ "shipping": Address.create_signature() }
]}]},
]
@staticmethod
def update_signature():
return [
"company", "email", "fax", "first_name", "id", "last_name", "phone", "website", "device_data", "device_session_id", "fraud_merchant_id", "payment_method_nonce", "default_payment_method_token",
{"credit_card": CreditCard.signature("update_via_customer")},
{"apple_pay_card": ApplePayCard.signature()},
{"android_pay_card": AndroidPayCard.card_signature()},
{"android_pay_network_token": AndroidPayCard.network_token_signature()},
{"three_d_secure_pass_thru": [
"cavv",
"ds_transaction_id",
"eci_flag",
"three_d_secure_version",
"xid",
]},
{"custom_fields": ["__any_key__"]},
{"tax_identifiers": ["country_code", "identifier"]},
{"options": [{"paypal": [
"payee_email",
"order_id",
"custom_field",
"description",
"amount",
{ "shipping": Address.create_signature() }
]}]},
]
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
self.payment_methods = []
if "credit_cards" in attributes:
self.credit_cards = [CreditCard(gateway, credit_card) for credit_card in self.credit_cards]
self.payment_methods += self.credit_cards
if "addresses" in attributes:
self.addresses = [Address(gateway, address) for address in self.addresses]
if "paypal_accounts" in attributes:
self.paypal_accounts = [PayPalAccount(gateway, paypal_account) for paypal_account in self.paypal_accounts]
self.payment_methods += self.paypal_accounts
if "apple_pay_cards" in attributes:
self.apple_pay_cards = [ApplePayCard(gateway, apple_pay_card) for apple_pay_card in self.apple_pay_cards]
self.payment_methods += self.apple_pay_cards
if "android_pay_cards" in attributes:
self.android_pay_cards = [AndroidPayCard(gateway, android_pay_card) for android_pay_card in self.android_pay_cards]
self.payment_methods += self.android_pay_cards
# NEXT_MAJOR_VERSION remove deprecated amex express checkout
if "amex_express_checkout_cards" in attributes:
self.amex_express_checkout_cards = [AmexExpressCheckoutCard(gateway, amex_express_checkout_card) for amex_express_checkout_card in self.amex_express_checkout_cards]
self.payment_methods += self.amex_express_checkout_cards
if "europe_bank_accounts" in attributes:
self.europe_bank_accounts = [EuropeBankAccount(gateway, europe_bank_account) for europe_bank_account in self.europe_bank_accounts]
self.payment_methods += self.europe_bank_accounts
if "venmo_accounts" in attributes:
self.venmo_accounts = [VenmoAccount(gateway, venmo_account) for venmo_account in self.venmo_accounts]
self.payment_methods += self.venmo_accounts
if "sepa_debit_accounts" in attributes:
self.sepa_direct_debit_accounts = [SepaDirectDebitAccount(gateway, sepa_direct_debit_account) for sepa_direct_debit_account in self.sepa_debit_accounts]
self.payment_methods += self.sepa_direct_debit_accounts
if "us_bank_accounts" in attributes:
self.us_bank_accounts = [UsBankAccount(gateway, us_bank_account) for us_bank_account in self.us_bank_accounts]
self.payment_methods += self.us_bank_accounts
if "visa_checkout_cards" in attributes:
self.visa_checkout_cards = [VisaCheckoutCard(gateway, visa_checkout_card) for visa_checkout_card in self.visa_checkout_cards]
self.payment_methods += self.visa_checkout_cards
# NEXT_MAJOR_VERSION remove deprecated masterpass
if "masterpass_cards" in attributes:
self.masterpass_cards = [MasterpassCard(gateway, masterpass_card) for masterpass_card in self.masterpass_cards]
self.payment_methods += self.masterpass_cards
if "samsung_pay_cards" in attributes:
self.samsung_pay_cards = [SamsungPayCard(gateway, samsung_pay_card) for samsung_pay_card in self.samsung_pay_cards]
self.payment_methods += self.samsung_pay_cards
|
(gateway, attributes)
|
712,174
|
braintree.customer
|
__init__
| null |
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
self.payment_methods = []
if "credit_cards" in attributes:
self.credit_cards = [CreditCard(gateway, credit_card) for credit_card in self.credit_cards]
self.payment_methods += self.credit_cards
if "addresses" in attributes:
self.addresses = [Address(gateway, address) for address in self.addresses]
if "paypal_accounts" in attributes:
self.paypal_accounts = [PayPalAccount(gateway, paypal_account) for paypal_account in self.paypal_accounts]
self.payment_methods += self.paypal_accounts
if "apple_pay_cards" in attributes:
self.apple_pay_cards = [ApplePayCard(gateway, apple_pay_card) for apple_pay_card in self.apple_pay_cards]
self.payment_methods += self.apple_pay_cards
if "android_pay_cards" in attributes:
self.android_pay_cards = [AndroidPayCard(gateway, android_pay_card) for android_pay_card in self.android_pay_cards]
self.payment_methods += self.android_pay_cards
# NEXT_MAJOR_VERSION remove deprecated amex express checkout
if "amex_express_checkout_cards" in attributes:
self.amex_express_checkout_cards = [AmexExpressCheckoutCard(gateway, amex_express_checkout_card) for amex_express_checkout_card in self.amex_express_checkout_cards]
self.payment_methods += self.amex_express_checkout_cards
if "europe_bank_accounts" in attributes:
self.europe_bank_accounts = [EuropeBankAccount(gateway, europe_bank_account) for europe_bank_account in self.europe_bank_accounts]
self.payment_methods += self.europe_bank_accounts
if "venmo_accounts" in attributes:
self.venmo_accounts = [VenmoAccount(gateway, venmo_account) for venmo_account in self.venmo_accounts]
self.payment_methods += self.venmo_accounts
if "sepa_debit_accounts" in attributes:
self.sepa_direct_debit_accounts = [SepaDirectDebitAccount(gateway, sepa_direct_debit_account) for sepa_direct_debit_account in self.sepa_debit_accounts]
self.payment_methods += self.sepa_direct_debit_accounts
if "us_bank_accounts" in attributes:
self.us_bank_accounts = [UsBankAccount(gateway, us_bank_account) for us_bank_account in self.us_bank_accounts]
self.payment_methods += self.us_bank_accounts
if "visa_checkout_cards" in attributes:
self.visa_checkout_cards = [VisaCheckoutCard(gateway, visa_checkout_card) for visa_checkout_card in self.visa_checkout_cards]
self.payment_methods += self.visa_checkout_cards
# NEXT_MAJOR_VERSION remove deprecated masterpass
if "masterpass_cards" in attributes:
self.masterpass_cards = [MasterpassCard(gateway, masterpass_card) for masterpass_card in self.masterpass_cards]
self.payment_methods += self.masterpass_cards
if "samsung_pay_cards" in attributes:
self.samsung_pay_cards = [SamsungPayCard(gateway, samsung_pay_card) for samsung_pay_card in self.samsung_pay_cards]
self.payment_methods += self.samsung_pay_cards
|
(self, gateway, attributes)
|
712,175
|
braintree.customer
|
__repr__
| null |
def __repr__(self):
detail_list = [
"id",
"graphql_id",
"company",
"created_at",
"email",
"fax",
"first_name",
"last_name",
"merchant_id",
"phone",
"updated_at",
"website",
]
return super(Customer, self).__repr__(detail_list)
|
(self)
|
712,176
|
braintree.customer
|
all
|
Return a collection of all customers.
|
@staticmethod
def all():
""" Return a collection of all customers. """
return Configuration.gateway().customer.all()
|
()
|
712,177
|
braintree.customer
|
create
|
Create a Customer
No field is required::
result = braintree.Customer.create({
"company": "Some company",
"first_name": "John"
})
|
@staticmethod
def create(params=None):
"""
Create a Customer
No field is required::
result = braintree.Customer.create({
"company": "Some company",
"first_name": "John"
})
"""
if params is None:
params = {}
return Configuration.gateway().customer.create(params)
|
(params=None)
|
712,178
|
braintree.customer
|
create_signature
| null |
@staticmethod
def create_signature():
return [
"company", "email", "fax", "first_name", "id", "last_name", "phone", "website", "device_data", "payment_method_nonce",
"device_session_id", "fraud_merchant_id", # NEXT_MAJOR_VERSION remove device_session_id and fraud_merchant_id
{"risk_data": ["customer_browser", "customer_device_id", "customer_ip", "customer_location_zip", "customer_tenure"]},
{"credit_card": CreditCard.create_signature()},
{"apple_pay_card": ApplePayCard.signature()},
{"android_pay_card": AndroidPayCard.card_signature()},
{"android_pay_network_token": AndroidPayCard.network_token_signature()},
{"custom_fields": ["__any_key__"]},
{"three_d_secure_pass_thru": [
"cavv",
"ds_transaction_id",
"eci_flag",
"three_d_secure_version",
"xid",
]},
{"tax_identifiers": ["country_code", "identifier"]},
{"options": [{"paypal": [
"payee_email",
"order_id",
"custom_field",
"description",
"amount",
{ "shipping": Address.create_signature() }
]}]},
]
|
()
|
712,179
|
braintree.customer
|
delete
|
Delete a customer
Given a customer_id::
result = braintree.Customer.delete("my_customer_id")
|
@staticmethod
def delete(customer_id):
"""
Delete a customer
Given a customer_id::
result = braintree.Customer.delete("my_customer_id")
"""
return Configuration.gateway().customer.delete(customer_id)
|
(customer_id)
|
712,180
|
braintree.customer
|
find
|
Find an customer, given a customer_id. This does not return a result
object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided customer_id
is not found. ::
customer = braintree.Customer.find("my_customer_id")
|
@staticmethod
def find(customer_id, association_filter_id=None):
"""
Find an customer, given a customer_id. This does not return a result
object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided customer_id
is not found. ::
customer = braintree.Customer.find("my_customer_id")
"""
return Configuration.gateway().customer.find(customer_id, association_filter_id)
|
(customer_id, association_filter_id=None)
|
712,181
|
braintree.customer
|
search
| null |
@staticmethod
def search(*query):
return Configuration.gateway().customer.search(*query)
|
(*query)
|
712,182
|
braintree.customer
|
update
|
Update an existing Customer
By customer_id. The params are similar to create::
result = braintree.Customer.update("my_customer_id", {
"last_name": "Smith"
})
|
@staticmethod
def update(customer_id, params=None):
"""
Update an existing Customer
By customer_id. The params are similar to create::
result = braintree.Customer.update("my_customer_id", {
"last_name": "Smith"
})
"""
if params is None:
params = {}
return Configuration.gateway().customer.update(customer_id, params)
|
(customer_id, params=None)
|
712,183
|
braintree.customer
|
update_signature
| null |
@staticmethod
def update_signature():
return [
"company", "email", "fax", "first_name", "id", "last_name", "phone", "website", "device_data", "device_session_id", "fraud_merchant_id", "payment_method_nonce", "default_payment_method_token",
{"credit_card": CreditCard.signature("update_via_customer")},
{"apple_pay_card": ApplePayCard.signature()},
{"android_pay_card": AndroidPayCard.card_signature()},
{"android_pay_network_token": AndroidPayCard.network_token_signature()},
{"three_d_secure_pass_thru": [
"cavv",
"ds_transaction_id",
"eci_flag",
"three_d_secure_version",
"xid",
]},
{"custom_fields": ["__any_key__"]},
{"tax_identifiers": ["country_code", "identifier"]},
{"options": [{"paypal": [
"payee_email",
"order_id",
"custom_field",
"description",
"amount",
{ "shipping": Address.create_signature() }
]}]},
]
|
()
|
712,185
|
braintree.customer_gateway
|
CustomerGateway
| null |
class CustomerGateway(object):
def __init__(self, gateway):
self.gateway = gateway
self.config = gateway.config
def all(self):
response = self.config.http().post(self.config.base_merchant_path() + "/customers/advanced_search_ids")
return ResourceCollection({}, response, self.__fetch)
def create(self, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Customer.create_signature())
self.__check_for_deprecated_attributes(params)
return self._post("/customers", {"customer": params})
def delete(self, customer_id):
self.config.http().delete(self.config.base_merchant_path() + "/customers/" + customer_id)
return SuccessfulResult()
def find(self, customer_id, association_filter_id=None):
try:
if customer_id is None or customer_id.strip() == "":
raise NotFoundError()
query_params = ""
if association_filter_id:
query_params = "?association_filter_id=" + association_filter_id
response = self.config.http().get(self.config.base_merchant_path() + "/customers/" + customer_id + query_params)
return Customer(self.gateway, response["customer"])
except NotFoundError:
raise NotFoundError("customer with id " + repr(customer_id) + " not found")
def search(self, *query):
if isinstance(query[0], list):
query = query[0]
response = self.config.http().post(self.config.base_merchant_path() + "/customers/advanced_search_ids", {"search": self.__criteria(query)})
return ResourceCollection(query, response, self.__fetch)
def update(self, customer_id, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Customer.update_signature())
self.__check_for_deprecated_attributes(params)
response = self.config.http().put(self.config.base_merchant_path() + "/customers/" + customer_id, {"customer": params})
if "customer" in response:
return SuccessfulResult({"customer": Customer(self.gateway, response["customer"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def __criteria(self, query):
criteria = {}
for term in query:
if criteria.get(term.name):
criteria[term.name] = dict(list(criteria[term.name].items()) + list(term.to_param().items()))
else:
criteria[term.name] = term.to_param()
return criteria
def __fetch(self, query, ids):
criteria = self.__criteria(query)
criteria["ids"] = braintree.customer_search.CustomerSearch.ids.in_list(ids).to_param()
response = self.config.http().post(self.config.base_merchant_path() + "/customers/advanced_search", {"search": criteria})
return [Customer(self.gateway, item) for item in ResourceCollection._extract_as_array(response["customers"], "customer")]
def _post(self, url, params=None):
if params is None:
params = {}
response = self.config.http().post(self.config.base_merchant_path() + url, params)
if "customer" in response:
return SuccessfulResult({"customer": Customer(self.gateway, response["customer"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
else:
pass
def __check_for_deprecated_attributes(self, params):
if "device_session_id" in params.keys():
warnings.warn("device_session_id is deprecated, use device_data parameter instead", DeprecationWarning)
if "fraud_merchant_id" in params.keys():
warnings.warn("fraud_merchant_id is deprecated, use device_data parameter instead", DeprecationWarning)
|
(gateway)
|
712,186
|
braintree.customer_gateway
|
__check_for_deprecated_attributes
| null |
def __check_for_deprecated_attributes(self, params):
if "device_session_id" in params.keys():
warnings.warn("device_session_id is deprecated, use device_data parameter instead", DeprecationWarning)
if "fraud_merchant_id" in params.keys():
warnings.warn("fraud_merchant_id is deprecated, use device_data parameter instead", DeprecationWarning)
|
(self, params)
|
712,187
|
braintree.customer_gateway
|
__criteria
| null |
def __criteria(self, query):
criteria = {}
for term in query:
if criteria.get(term.name):
criteria[term.name] = dict(list(criteria[term.name].items()) + list(term.to_param().items()))
else:
criteria[term.name] = term.to_param()
return criteria
|
(self, query)
|
712,188
|
braintree.customer_gateway
|
__fetch
| null |
def __fetch(self, query, ids):
criteria = self.__criteria(query)
criteria["ids"] = braintree.customer_search.CustomerSearch.ids.in_list(ids).to_param()
response = self.config.http().post(self.config.base_merchant_path() + "/customers/advanced_search", {"search": criteria})
return [Customer(self.gateway, item) for item in ResourceCollection._extract_as_array(response["customers"], "customer")]
|
(self, query, ids)
|
712,190
|
braintree.customer_gateway
|
_post
| null |
def _post(self, url, params=None):
if params is None:
params = {}
response = self.config.http().post(self.config.base_merchant_path() + url, params)
if "customer" in response:
return SuccessfulResult({"customer": Customer(self.gateway, response["customer"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
else:
pass
|
(self, url, params=None)
|
712,191
|
braintree.customer_gateway
|
all
| null |
def all(self):
response = self.config.http().post(self.config.base_merchant_path() + "/customers/advanced_search_ids")
return ResourceCollection({}, response, self.__fetch)
|
(self)
|
712,192
|
braintree.customer_gateway
|
create
| null |
def create(self, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Customer.create_signature())
self.__check_for_deprecated_attributes(params)
return self._post("/customers", {"customer": params})
|
(self, params=None)
|
712,193
|
braintree.customer_gateway
|
delete
| null |
def delete(self, customer_id):
self.config.http().delete(self.config.base_merchant_path() + "/customers/" + customer_id)
return SuccessfulResult()
|
(self, customer_id)
|
712,194
|
braintree.customer_gateway
|
find
| null |
def find(self, customer_id, association_filter_id=None):
try:
if customer_id is None or customer_id.strip() == "":
raise NotFoundError()
query_params = ""
if association_filter_id:
query_params = "?association_filter_id=" + association_filter_id
response = self.config.http().get(self.config.base_merchant_path() + "/customers/" + customer_id + query_params)
return Customer(self.gateway, response["customer"])
except NotFoundError:
raise NotFoundError("customer with id " + repr(customer_id) + " not found")
|
(self, customer_id, association_filter_id=None)
|
712,195
|
braintree.customer_gateway
|
search
| null |
def search(self, *query):
if isinstance(query[0], list):
query = query[0]
response = self.config.http().post(self.config.base_merchant_path() + "/customers/advanced_search_ids", {"search": self.__criteria(query)})
return ResourceCollection(query, response, self.__fetch)
|
(self, *query)
|
712,196
|
braintree.customer_gateway
|
update
| null |
def update(self, customer_id, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Customer.update_signature())
self.__check_for_deprecated_attributes(params)
response = self.config.http().put(self.config.base_merchant_path() + "/customers/" + customer_id, {"customer": params})
if "customer" in response:
return SuccessfulResult({"customer": Customer(self.gateway, response["customer"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, customer_id, params=None)
|
712,197
|
braintree.customer_search
|
CustomerSearch
| null |
class CustomerSearch:
address_extended_address = Search.TextNodeBuilder("address_extended_address")
address_first_name = Search.TextNodeBuilder("address_first_name")
address_last_name = Search.TextNodeBuilder("address_last_name")
address_locality = Search.TextNodeBuilder("address_locality")
address_postal_code = Search.TextNodeBuilder("address_postal_code")
address_region = Search.TextNodeBuilder("address_region")
address_street_address = Search.TextNodeBuilder("address_street_address")
address_country_name = Search.TextNodeBuilder("address_country_name")
cardholder_name = Search.TextNodeBuilder("cardholder_name")
company = Search.TextNodeBuilder("company")
created_at = Search.RangeNodeBuilder("created_at")
credit_card_expiration_date = Search.EqualityNodeBuilder("credit_card_expiration_date")
credit_card_number = Search.TextNodeBuilder("credit_card_number")
email = Search.TextNodeBuilder("email")
fax = Search.TextNodeBuilder("fax")
first_name = Search.TextNodeBuilder("first_name")
id = Search.TextNodeBuilder("id")
ids = Search.MultipleValueNodeBuilder("ids")
last_name = Search.TextNodeBuilder("last_name")
payment_method_token = Search.TextNodeBuilder("payment_method_token")
payment_method_token_with_duplicates = Search.IsNodeBuilder("payment_method_token_with_duplicates")
phone = Search.TextNodeBuilder("phone")
website = Search.TextNodeBuilder("website")
paypal_account_email = Search.TextNodeBuilder("paypal_account_email")
|
()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.