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,391
|
braintree.plan
|
create
| null |
@staticmethod
def create(params=None):
if params is None:
params = {}
return Configuration.gateway().plan.create(params)
|
(params=None)
|
712,392
|
braintree.plan
|
create_signature
| null |
@staticmethod
def create_signature():
return [
"billing_day_of_month",
"billing_frequency",
"currency_iso_code",
"description",
"id",
"merchant_id",
"name",
"number_of_billing_cycles",
"price",
"trial_duration",
"trial_duration_unit",
"trial_period"
] + Plan._add_on_discount_signature()
|
()
|
712,393
|
braintree.plan
|
find
| null |
@staticmethod
def find(subscription_id):
return Configuration.gateway().plan.find(subscription_id)
|
(subscription_id)
|
712,394
|
braintree.plan
|
update
| null |
@staticmethod
def update(subscription_id, params=None):
if params is None:
params = {}
return Configuration.gateway().plan.update(subscription_id, params)
|
(subscription_id, params=None)
|
712,395
|
braintree.plan
|
update_signature
| null |
@staticmethod
def update_signature():
return [
"billing_day_of_month",
"billing_frequency",
"currency_iso_code",
"description",
"id",
"merchant_id",
"name",
"number_of_billing_cycles",
"price",
"trial_duration",
"trial_duration_unit",
"trial_period"
] + Plan._add_on_discount_signature()
|
()
|
712,397
|
braintree.plan_gateway
|
PlanGateway
| null |
class PlanGateway(object):
def __init__(self, gateway):
self.gateway = gateway
self.config = gateway.config
def all(self):
response = self.config.http().get(self.config.base_merchant_path() + "/plans/")
return [Plan(self.gateway, item) for item in ResourceCollection._extract_as_array(response, "plans")]
def create(self, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Plan.create_signature())
response = self.config.http().post(self.config.base_merchant_path() + "/plans", {"plan": params})
if "plan" in response:
return SuccessfulResult({"plan": Plan(self.gateway, response["plan"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def find(self, plan_id):
try:
if plan_id is None or plan_id.strip() == "":
raise NotFoundError()
response = self.config.http().get(self.config.base_merchant_path() + "/plans/" + plan_id)
return Plan(self.gateway, response["plan"])
except NotFoundError:
raise NotFoundError("Plan with id " + repr(plan_id) + " not found")
def update(self, plan_id, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Plan.update_signature())
response = self.config.http().put(self.config.base_merchant_path() + "/plans/" + plan_id, {"plan": params})
if "plan" in response:
return SuccessfulResult({"plan": Plan(self.gateway, response["plan"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(gateway)
|
712,399
|
braintree.plan_gateway
|
all
| null |
def all(self):
response = self.config.http().get(self.config.base_merchant_path() + "/plans/")
return [Plan(self.gateway, item) for item in ResourceCollection._extract_as_array(response, "plans")]
|
(self)
|
712,400
|
braintree.plan_gateway
|
create
| null |
def create(self, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Plan.create_signature())
response = self.config.http().post(self.config.base_merchant_path() + "/plans", {"plan": params})
if "plan" in response:
return SuccessfulResult({"plan": Plan(self.gateway, response["plan"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, params=None)
|
712,401
|
braintree.plan_gateway
|
find
| null |
def find(self, plan_id):
try:
if plan_id is None or plan_id.strip() == "":
raise NotFoundError()
response = self.config.http().get(self.config.base_merchant_path() + "/plans/" + plan_id)
return Plan(self.gateway, response["plan"])
except NotFoundError:
raise NotFoundError("Plan with id " + repr(plan_id) + " not found")
|
(self, plan_id)
|
712,402
|
braintree.plan_gateway
|
update
| null |
def update(self, plan_id, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Plan.update_signature())
response = self.config.http().put(self.config.base_merchant_path() + "/plans/" + plan_id, {"plan": params})
if "plan" in response:
return SuccessfulResult({"plan": Plan(self.gateway, response["plan"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, plan_id, params=None)
|
712,403
|
braintree.processor_response_types
|
ProcessorResponseTypes
|
A set of constants representing processor response types.
|
class ProcessorResponseTypes(object):
"""
A set of constants representing processor response types.
"""
Approved = "approved"
SoftDeclined = "soft_declined"
HardDeclined = "hard_declined"
|
()
|
712,404
|
braintree.resource_collection
|
ResourceCollection
|
A class representing results from a search. Supports the iterator protocol::
results = braintree.Transaction.search("411111")
for transaction in results:
print transaction.id
|
class ResourceCollection(object):
"""
A class representing results from a search. Supports the iterator protocol::
results = braintree.Transaction.search("411111")
for transaction in results:
print transaction.id
"""
def __init__(self, query, results, method):
if "search_results" not in results:
raise UnexpectedError("Unprocessable entity due to an invalid request")
self.__ids = results["search_results"]["ids"]
self.__method = method
self.__page_size = results["search_results"]["page_size"]
self.__query = query
@property
def maximum_size(self):
"""
Returns the approximate size of the results. The size is approximate due to race conditions when pulling
back results. Due to its inexact nature, maximum_size should be avoided.
"""
return len(self.__ids)
@property
def first(self):
""" Returns the first item in the results. """
return self.__method(self.__query, self.__ids[0:1])[0]
@property
def items(self):
""" Returns a generator allowing iteration over all of the results. """
for batch in self.__batch_ids():
for item in self.__method(self.__query, batch):
yield item
@property
def ids(self):
""" Returns the list of ids in the search result. """
return self.__ids
def __iter__(self):
return self.items
def __batch_ids(self):
for i in range(0, len(self.__ids), self.__page_size):
yield self.__ids[i:i+self.__page_size]
@staticmethod
def _extract_as_array(results, attribute):
if not attribute in results:
return []
value = results[attribute]
if not isinstance(value, list):
value = [value]
return value
|
(query, results, method)
|
712,405
|
braintree.resource_collection
|
__batch_ids
| null |
def __batch_ids(self):
for i in range(0, len(self.__ids), self.__page_size):
yield self.__ids[i:i+self.__page_size]
|
(self)
|
712,406
|
braintree.resource_collection
|
__init__
| null |
def __init__(self, query, results, method):
if "search_results" not in results:
raise UnexpectedError("Unprocessable entity due to an invalid request")
self.__ids = results["search_results"]["ids"]
self.__method = method
self.__page_size = results["search_results"]["page_size"]
self.__query = query
|
(self, query, results, method)
|
712,407
|
braintree.resource_collection
|
__iter__
| null |
def __iter__(self):
return self.items
|
(self)
|
712,408
|
braintree.resource_collection
|
_extract_as_array
| null |
@staticmethod
def _extract_as_array(results, attribute):
if not attribute in results:
return []
value = results[attribute]
if not isinstance(value, list):
value = [value]
return value
|
(results, attribute)
|
712,409
|
braintree.risk_data
|
RiskData
| null |
class RiskData(AttributeGetter):
def __init__(self, attributes):
AttributeGetter.__init__(self, attributes)
if "liability_shift" in attributes:
self.liability_shift = LiabilityShift(attributes["liability_shift"])
|
(attributes)
|
712,410
|
braintree.risk_data
|
__init__
| null |
def __init__(self, attributes):
AttributeGetter.__init__(self, attributes)
if "liability_shift" in attributes:
self.liability_shift = LiabilityShift(attributes["liability_shift"])
|
(self, attributes)
|
712,412
|
braintree.samsung_pay_card
|
SamsungPayCard
| null |
class SamsungPayCard(Resource):
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
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]
@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):
return self.bin + "******" + self.last_4
|
(gateway, attributes)
|
712,416
|
braintree.samsung_pay_card
|
__init__
| null |
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
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]
|
(self, gateway, attributes)
|
712,419
|
braintree.search
|
Search
|
Collection of classes used to build search queries.
Each Builder class defines one or more methods that returns a Node
object with the name of the field, the comparator, and the value.
|
class Search:
"""
Collection of classes used to build search queries.
Each Builder class defines one or more methods that returns a Node
object with the name of the field, the comparator, and the value.
"""
class IsNodeBuilder(object):
"""Builds a query for value equality."""
def __init__(self, name):
self.name = name
def __eq__(self, value):
return self.is_equal(value)
def is_equal(self, value):
return Search.Node(self.name, {"is": value})
class EqualityNodeBuilder(IsNodeBuilder):
"""Builds a query for value inequality."""
def __ne__(self, value):
return self.is_not_equal(value)
def is_not_equal(self, value):
return Search.Node(self.name, {"is_not": value})
class KeyValueNodeBuilder(object):
"""Builds a query based on a key-value map."""
def __init__(self, name):
self.name = name
def __eq__(self, value):
return self.is_equal(value)
def is_equal(self, value):
return Search.Node(self.name, value)
def __ne__(self, value):
return self.is_not_equal(value)
def is_not_equal(self, value):
return Search.Node(self.name, not value)
class PartialMatchNodeBuilder(EqualityNodeBuilder):
"""Builds a query for matching parts of a sequence."""
def starts_with(self, value):
return Search.Node(self.name, {"starts_with": value})
def ends_with(self, value):
return Search.Node(self.name, {"ends_with": value})
class EndsWithNodeBuilder(object):
def __init__(self, name):
self.name = name
def ends_with(self, value):
return Search.Node(self.name, {"ends_with": value})
class TextNodeBuilder(PartialMatchNodeBuilder):
"""Builds a query for matching any part of a sequence."""
def contains(self, value):
return Search.Node(self.name, {"contains": value})
class Node(object):
"""Container for part of a search query."""
def __init__(self, name, dict):
self.name = name
self.dict = dict
def to_param(self):
return self.dict
class MultipleValueNodeBuilder(object):
"""Builds a query to check membership in a sequence."""
def __init__(self, name, whitelist = []):
if "chargeback_protection_level" == name:
warnings.warn("Use protection_level parameter instead", DeprecationWarning)
self.name = name
self.whitelist = whitelist
def in_list(self, *values):
if isinstance(values[0], list):
values = values[0]
invalid_args = set(values) - set(self.whitelist)
if len(self.whitelist) > 0 and len(invalid_args) > 0:
error_string = "Invalid argument(s) for %s: %s" % (self.name, ", ".join(invalid_args))
raise AttributeError(error_string)
return Search.Node(self.name, list(values))
def __eq__(self, value):
return self.in_list([value])
class MultipleValueOrTextNodeBuilder(TextNodeBuilder, MultipleValueNodeBuilder):
"""Builder node supporting contains and in_list."""
def __init__(self, name, whitelist = []):
Search.MultipleValueNodeBuilder.__init__(self, name, whitelist)
class RangeNodeBuilder(object):
"""Builds a query supporting <=, >=, or == value."""
def __init__(self, name):
self.name = name
def __eq__(self, value):
return self.is_equal(value)
def is_equal(self, value):
return Search.EqualityNodeBuilder(self.name) == value
def __ge__(self, min):
return self.greater_than_or_equal_to(min)
def greater_than_or_equal_to(self, min):
return Search.Node(self.name, {"min": min})
def __le__(self, max):
return self.less_than_or_equal_to(max)
def less_than_or_equal_to(self, max):
return Search.Node(self.name, {"max": max})
def between(self, min, max):
return Search.Node(self.name, {"min": min, "max": max})
|
()
|
712,420
|
braintree.sepa_direct_debit_account
|
SepaDirectDebitAccount
| null |
class SepaDirectDebitAccount(Resource):
@staticmethod
def find(sepa_direct_debit_account_token):
return Configuration.gateway().sepa_direct_debit_account.find(sepa_direct_debit_account_token)
@staticmethod
def delete(sepa_direct_debit_account_token):
return Configuration.gateway().sepa_direct_debit_account.delete(sepa_direct_debit_account_token)
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
if "subscriptions" in attributes:
self.subscriptions = [braintree.subscription.Subscription(gateway, subscription) for subscription in self.subscriptions]
|
(gateway, attributes)
|
712,426
|
braintree.sepa_direct_debit_account
|
delete
| null |
@staticmethod
def delete(sepa_direct_debit_account_token):
return Configuration.gateway().sepa_direct_debit_account.delete(sepa_direct_debit_account_token)
|
(sepa_direct_debit_account_token)
|
712,427
|
braintree.sepa_direct_debit_account
|
find
| null |
@staticmethod
def find(sepa_direct_debit_account_token):
return Configuration.gateway().sepa_direct_debit_account.find(sepa_direct_debit_account_token)
|
(sepa_direct_debit_account_token)
|
712,429
|
braintree.settlement_batch_summary
|
SettlementBatchSummary
| null |
class SettlementBatchSummary(Resource):
@staticmethod
def generate(settlement_date, group_by_custom_field=None):
return Configuration.gateway().settlement_batch_summary.generate(settlement_date, group_by_custom_field)
|
(gateway, attributes)
|
712,435
|
braintree.settlement_batch_summary
|
generate
| null |
@staticmethod
def generate(settlement_date, group_by_custom_field=None):
return Configuration.gateway().settlement_batch_summary.generate(settlement_date, group_by_custom_field)
|
(settlement_date, group_by_custom_field=None)
|
712,437
|
braintree.signature_service
|
SignatureService
| null |
class SignatureService(object):
def __init__(self, private_key, hashfunc=Crypto.sha1_hmac_hash):
self.private_key = private_key
self.hmac_hash = hashfunc
def sign(self, data):
equalities = ['%s=%s' % (str(key), str(data[key])) for key in data]
data_string = '&'.join(equalities)
return "%s|%s" % (self.hash(data_string), data_string)
def hash(self, data):
return self.hmac_hash(self.private_key, data)
|
(private_key, hashfunc=<function Crypto.sha1_hmac_hash at 0x7f681e4fc280>)
|
712,438
|
braintree.signature_service
|
__init__
| null |
def __init__(self, private_key, hashfunc=Crypto.sha1_hmac_hash):
self.private_key = private_key
self.hmac_hash = hashfunc
|
(self, private_key, hashfunc=<function Crypto.sha1_hmac_hash at 0x7f681e4fc280>)
|
712,439
|
braintree.signature_service
|
hash
| null |
def hash(self, data):
return self.hmac_hash(self.private_key, data)
|
(self, data)
|
712,440
|
braintree.signature_service
|
sign
| null |
def sign(self, data):
equalities = ['%s=%s' % (str(key), str(data[key])) for key in data]
data_string = '&'.join(equalities)
return "%s|%s" % (self.hash(data_string), data_string)
|
(self, data)
|
712,441
|
braintree.status_event
|
StatusEvent
| null |
class StatusEvent(Resource):
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
self.amount = Decimal(self.amount)
|
(gateway, attributes)
|
712,448
|
braintree.subscription
|
Subscription
|
A class representing a Subscription.
An example of creating a subscription with all available fields::
result = braintree.Subscription.create({
"id": "my_subscription_id",
"merchant_account_id": "merchant_account_one",
"payment_method_token": "my_payment_token",
"plan_id": "some_plan_id",
"price": "29.95",
"trial_duration": 1,
"trial_duration_unit": braintree.Subscription.TrialDurationUnit.Month,
"trial_period": True
})
For more information on Subscriptions, see https://developer.paypal.com/braintree/docs/reference/request/subscription/create/python
|
class Subscription(Resource):
"""
A class representing a Subscription.
An example of creating a subscription with all available fields::
result = braintree.Subscription.create({
"id": "my_subscription_id",
"merchant_account_id": "merchant_account_one",
"payment_method_token": "my_payment_token",
"plan_id": "some_plan_id",
"price": "29.95",
"trial_duration": 1,
"trial_duration_unit": braintree.Subscription.TrialDurationUnit.Month,
"trial_period": True
})
For more information on Subscriptions, see https://developer.paypal.com/braintree/docs/reference/request/subscription/create/python
"""
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class TrialDurationUnit(object):
"""
Constants representing trial duration units. Available types are:
* braintree.Subscription.TrialDurationUnit.Day
* braintree.Subscription.TrialDurationUnit.Month
"""
Day = "day"
Month = "month"
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class Source(object):
Api = "api"
ControlPanel = "control_panel"
Recurring = "recurring"
# 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 subscription statuses. Available statuses are:
* braintree.Subscription.Status.Active
* braintree.Subscription.Status.Canceled
* braintree.Subscription.Status.Expired
* braintree.Subscription.Status.PastDue
* braintree.Subscription.Status.Pending
"""
Active = "Active"
Canceled = "Canceled"
Expired = "Expired"
PastDue = "Past Due"
Pending = "Pending"
@staticmethod
def create(params=None):
"""
Create a Subscription
Token and Plan are required:::
result = braintree.Subscription.create({
"payment_method_token": "my_payment_token",
"plan_id": "some_plan_id",
})
"""
if params is None:
params = {}
return Configuration.gateway().subscription.create(params)
@staticmethod
def create_signature():
return [
"billing_day_of_month",
"first_billing_date",
"id",
"merchant_account_id",
"never_expires",
"number_of_billing_cycles",
"payment_method_nonce",
"payment_method_token",
"plan_id",
"price",
"trial_duration",
"trial_duration_unit",
"trial_period",
{
"descriptor": ["name", "phone", "url"]
},
{
"options": [
"do_not_inherit_add_ons_or_discounts",
"start_immediately",
{
"paypal": ["description"]
}
]
}
] + Subscription._add_ons_discounts_signature()
@staticmethod
def find(subscription_id):
"""
Find a subscription given a subscription_id. This does not return a result
object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>`
if the provided subscription_id is not found. ::
subscription = braintree.Subscription.find("my_subscription_id")
"""
return Configuration.gateway().subscription.find(subscription_id)
@staticmethod
def retry_charge(subscription_id, amount=None, submit_for_settlement=False):
return Configuration.gateway().subscription.retry_charge(subscription_id, amount, submit_for_settlement)
@staticmethod
def update(subscription_id, params=None):
"""
Update an existing subscription
By subscription_id. The params are similar to create::
result = braintree.Subscription.update("my_subscription_id", {
"price": "9.99",
})
"""
if params is None:
params = {}
return Configuration.gateway().subscription.update(subscription_id, params)
@staticmethod
def cancel(subscription_id):
"""
Cancel a subscription
By subscription_id::
result = braintree.Subscription.cancel("my_subscription_id")
"""
return Configuration.gateway().subscription.cancel(subscription_id)
@staticmethod
def search(*query):
"""
Allows searching on subscriptions. There are two types of fields that are searchable: text and
multiple value fields. Searchable text fields are:
- plan_id
- days_past_due
Searchable multiple value fields are:
- status
For text fields, you can search using the following operators: ==, !=, starts_with, ends_with
and contains. For multiple value fields, you can search using the in_list operator. An example::
braintree.Subscription.search([
braintree.SubscriptionSearch.plan_id.starts_with("abc"),
braintree.SubscriptionSearch.days_past_due == "30",
braintree.SubscriptionSearch.status.in_list([braintree.Subscription.Status.PastDue])
])
"""
return Configuration.gateway().subscription.search(*query)
@staticmethod
def update_signature():
return [
"id",
"merchant_account_id",
"never_expires",
"number_of_billing_cycles",
"payment_method_nonce",
"payment_method_token",
"plan_id",
"price",
{
"descriptor": [ "name", "phone", "url" ]
},
{
"options": [
"prorate_charges",
"replace_all_add_ons_and_discounts",
"revert_subscription_on_proration_failure",
{
"paypal": [ "description" ]
}
]
}
] + Subscription._add_ons_discounts_signature()
@staticmethod
def _add_ons_discounts_signature():
return [
{
"add_ons": [{
"add": ["amount", "inherited_from_id", "never_expires", "number_of_billing_cycles", "quantity"],
"remove": ["__any_key__"],
"update": ["amount", "existing_id", "never_expires", "number_of_billing_cycles", "quantity"]
}],
"discounts": [{
"add": ["amount", "inherited_from_id", "never_expires", "number_of_billing_cycles", "quantity"],
"remove": ["__any_key__"],
"update": ["amount", "existing_id", "never_expires", "number_of_billing_cycles", "quantity"]
}]
}
]
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
if "price" in attributes:
self.price = Decimal(self.price)
if "balance" in attributes:
self.balance = Decimal(self.balance)
if "next_billing_period_amount" in attributes:
self.next_billing_period_amount = Decimal(self.next_billing_period_amount)
if "add_ons" in attributes:
self.add_ons = [AddOn(gateway, add_on) for add_on in self.add_ons]
if "descriptor" in attributes:
self.descriptor = Descriptor(gateway, attributes.pop("descriptor"))
if "description" in attributes:
self.description = attributes["description"]
if "discounts" in attributes:
self.discounts = [Discount(gateway, discount) for discount in self.discounts]
if "status_history" in attributes:
self.status_history = [SubscriptionStatusEvent(gateway, status_event) for status_event in self.status_history]
if "transactions" in attributes:
self.transactions = [Transaction(gateway, transaction) for transaction in self.transactions]
|
(gateway, attributes)
|
712,452
|
braintree.subscription
|
__init__
| null |
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
if "price" in attributes:
self.price = Decimal(self.price)
if "balance" in attributes:
self.balance = Decimal(self.balance)
if "next_billing_period_amount" in attributes:
self.next_billing_period_amount = Decimal(self.next_billing_period_amount)
if "add_ons" in attributes:
self.add_ons = [AddOn(gateway, add_on) for add_on in self.add_ons]
if "descriptor" in attributes:
self.descriptor = Descriptor(gateway, attributes.pop("descriptor"))
if "description" in attributes:
self.description = attributes["description"]
if "discounts" in attributes:
self.discounts = [Discount(gateway, discount) for discount in self.discounts]
if "status_history" in attributes:
self.status_history = [SubscriptionStatusEvent(gateway, status_event) for status_event in self.status_history]
if "transactions" in attributes:
self.transactions = [Transaction(gateway, transaction) for transaction in self.transactions]
|
(self, gateway, attributes)
|
712,454
|
braintree.subscription
|
_add_ons_discounts_signature
| null |
@staticmethod
def _add_ons_discounts_signature():
return [
{
"add_ons": [{
"add": ["amount", "inherited_from_id", "never_expires", "number_of_billing_cycles", "quantity"],
"remove": ["__any_key__"],
"update": ["amount", "existing_id", "never_expires", "number_of_billing_cycles", "quantity"]
}],
"discounts": [{
"add": ["amount", "inherited_from_id", "never_expires", "number_of_billing_cycles", "quantity"],
"remove": ["__any_key__"],
"update": ["amount", "existing_id", "never_expires", "number_of_billing_cycles", "quantity"]
}]
}
]
|
()
|
712,455
|
braintree.subscription
|
cancel
|
Cancel a subscription
By subscription_id::
result = braintree.Subscription.cancel("my_subscription_id")
|
@staticmethod
def cancel(subscription_id):
"""
Cancel a subscription
By subscription_id::
result = braintree.Subscription.cancel("my_subscription_id")
"""
return Configuration.gateway().subscription.cancel(subscription_id)
|
(subscription_id)
|
712,456
|
braintree.subscription
|
create
|
Create a Subscription
Token and Plan are required:::
result = braintree.Subscription.create({
"payment_method_token": "my_payment_token",
"plan_id": "some_plan_id",
})
|
@staticmethod
def create(params=None):
"""
Create a Subscription
Token and Plan are required:::
result = braintree.Subscription.create({
"payment_method_token": "my_payment_token",
"plan_id": "some_plan_id",
})
"""
if params is None:
params = {}
return Configuration.gateway().subscription.create(params)
|
(params=None)
|
712,457
|
braintree.subscription
|
create_signature
| null |
@staticmethod
def create_signature():
return [
"billing_day_of_month",
"first_billing_date",
"id",
"merchant_account_id",
"never_expires",
"number_of_billing_cycles",
"payment_method_nonce",
"payment_method_token",
"plan_id",
"price",
"trial_duration",
"trial_duration_unit",
"trial_period",
{
"descriptor": ["name", "phone", "url"]
},
{
"options": [
"do_not_inherit_add_ons_or_discounts",
"start_immediately",
{
"paypal": ["description"]
}
]
}
] + Subscription._add_ons_discounts_signature()
|
()
|
712,458
|
braintree.subscription
|
find
|
Find a subscription given a subscription_id. This does not return a result
object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>`
if the provided subscription_id is not found. ::
subscription = braintree.Subscription.find("my_subscription_id")
|
@staticmethod
def find(subscription_id):
"""
Find a subscription given a subscription_id. This does not return a result
object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>`
if the provided subscription_id is not found. ::
subscription = braintree.Subscription.find("my_subscription_id")
"""
return Configuration.gateway().subscription.find(subscription_id)
|
(subscription_id)
|
712,459
|
braintree.subscription
|
retry_charge
| null |
@staticmethod
def retry_charge(subscription_id, amount=None, submit_for_settlement=False):
return Configuration.gateway().subscription.retry_charge(subscription_id, amount, submit_for_settlement)
|
(subscription_id, amount=None, submit_for_settlement=False)
|
712,460
|
braintree.subscription
|
search
|
Allows searching on subscriptions. There are two types of fields that are searchable: text and
multiple value fields. Searchable text fields are:
- plan_id
- days_past_due
Searchable multiple value fields are:
- status
For text fields, you can search using the following operators: ==, !=, starts_with, ends_with
and contains. For multiple value fields, you can search using the in_list operator. An example::
braintree.Subscription.search([
braintree.SubscriptionSearch.plan_id.starts_with("abc"),
braintree.SubscriptionSearch.days_past_due == "30",
braintree.SubscriptionSearch.status.in_list([braintree.Subscription.Status.PastDue])
])
|
@staticmethod
def search(*query):
"""
Allows searching on subscriptions. There are two types of fields that are searchable: text and
multiple value fields. Searchable text fields are:
- plan_id
- days_past_due
Searchable multiple value fields are:
- status
For text fields, you can search using the following operators: ==, !=, starts_with, ends_with
and contains. For multiple value fields, you can search using the in_list operator. An example::
braintree.Subscription.search([
braintree.SubscriptionSearch.plan_id.starts_with("abc"),
braintree.SubscriptionSearch.days_past_due == "30",
braintree.SubscriptionSearch.status.in_list([braintree.Subscription.Status.PastDue])
])
"""
return Configuration.gateway().subscription.search(*query)
|
(*query)
|
712,461
|
braintree.subscription
|
update
|
Update an existing subscription
By subscription_id. The params are similar to create::
result = braintree.Subscription.update("my_subscription_id", {
"price": "9.99",
})
|
@staticmethod
def update(subscription_id, params=None):
"""
Update an existing subscription
By subscription_id. The params are similar to create::
result = braintree.Subscription.update("my_subscription_id", {
"price": "9.99",
})
"""
if params is None:
params = {}
return Configuration.gateway().subscription.update(subscription_id, params)
|
(subscription_id, params=None)
|
712,462
|
braintree.subscription
|
update_signature
| null |
@staticmethod
def update_signature():
return [
"id",
"merchant_account_id",
"never_expires",
"number_of_billing_cycles",
"payment_method_nonce",
"payment_method_token",
"plan_id",
"price",
{
"descriptor": [ "name", "phone", "url" ]
},
{
"options": [
"prorate_charges",
"replace_all_add_ons_and_discounts",
"revert_subscription_on_proration_failure",
{
"paypal": [ "description" ]
}
]
}
] + Subscription._add_ons_discounts_signature()
|
()
|
712,464
|
braintree.subscription_gateway
|
SubscriptionGateway
| null |
class SubscriptionGateway(object):
def __init__(self, gateway):
self.gateway = gateway
self.config = gateway.config
def cancel(self, subscription_id):
response = self.config.http().put(self.config.base_merchant_path() + "/subscriptions/" + subscription_id + "/cancel")
if "subscription" in response:
return SuccessfulResult({"subscription": Subscription(self.gateway, response["subscription"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def create(self, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Subscription.create_signature())
response = self.config.http().post(self.config.base_merchant_path() + "/subscriptions", {"subscription": params})
if "subscription" in response:
return SuccessfulResult({"subscription": Subscription(self.gateway, response["subscription"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def find(self, subscription_id):
try:
if subscription_id is None or subscription_id.strip() == "":
raise NotFoundError()
response = self.config.http().get(self.config.base_merchant_path() + "/subscriptions/" + subscription_id)
return Subscription(self.gateway, response["subscription"])
except NotFoundError:
raise NotFoundError("subscription with id " + repr(subscription_id) + " not found")
def retry_charge(self, subscription_id, amount=None, submit_for_settlement=False):
response = self.config.http().post(self.config.base_merchant_path() + "/transactions", {"transaction": {
"amount": amount,
"subscription_id": subscription_id,
"type": Transaction.Type.Sale,
"options": {"submit_for_settlement": submit_for_settlement}
}})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def search(self, *query):
if isinstance(query[0], list):
query = query[0]
response = self.config.http().post(self.config.base_merchant_path() + "/subscriptions/advanced_search_ids", {"search": self.__criteria(query)})
return ResourceCollection(query, response, self.__fetch)
def update(self, subscription_id, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Subscription.update_signature())
response = self.config.http().put(self.config.base_merchant_path() + "/subscriptions/" + subscription_id, {"subscription": params})
if "subscription" in response:
return SuccessfulResult({"subscription": Subscription(self.gateway, response["subscription"])})
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.subscription_search.SubscriptionSearch.ids.in_list(ids).to_param()
response = self.config.http().post(self.config.base_merchant_path() + "/subscriptions/advanced_search", {"search": criteria})
return [Subscription(self.gateway, item) for item in ResourceCollection._extract_as_array(response["subscriptions"], "subscription")]
|
(gateway)
|
712,466
|
braintree.subscription_gateway
|
__fetch
| null |
def __fetch(self, query, ids):
criteria = self.__criteria(query)
criteria["ids"] = braintree.subscription_search.SubscriptionSearch.ids.in_list(ids).to_param()
response = self.config.http().post(self.config.base_merchant_path() + "/subscriptions/advanced_search", {"search": criteria})
return [Subscription(self.gateway, item) for item in ResourceCollection._extract_as_array(response["subscriptions"], "subscription")]
|
(self, query, ids)
|
712,468
|
braintree.subscription_gateway
|
cancel
| null |
def cancel(self, subscription_id):
response = self.config.http().put(self.config.base_merchant_path() + "/subscriptions/" + subscription_id + "/cancel")
if "subscription" in response:
return SuccessfulResult({"subscription": Subscription(self.gateway, response["subscription"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, subscription_id)
|
712,469
|
braintree.subscription_gateway
|
create
| null |
def create(self, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Subscription.create_signature())
response = self.config.http().post(self.config.base_merchant_path() + "/subscriptions", {"subscription": params})
if "subscription" in response:
return SuccessfulResult({"subscription": Subscription(self.gateway, response["subscription"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, params=None)
|
712,470
|
braintree.subscription_gateway
|
find
| null |
def find(self, subscription_id):
try:
if subscription_id is None or subscription_id.strip() == "":
raise NotFoundError()
response = self.config.http().get(self.config.base_merchant_path() + "/subscriptions/" + subscription_id)
return Subscription(self.gateway, response["subscription"])
except NotFoundError:
raise NotFoundError("subscription with id " + repr(subscription_id) + " not found")
|
(self, subscription_id)
|
712,471
|
braintree.subscription_gateway
|
retry_charge
| null |
def retry_charge(self, subscription_id, amount=None, submit_for_settlement=False):
response = self.config.http().post(self.config.base_merchant_path() + "/transactions", {"transaction": {
"amount": amount,
"subscription_id": subscription_id,
"type": Transaction.Type.Sale,
"options": {"submit_for_settlement": submit_for_settlement}
}})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, subscription_id, amount=None, submit_for_settlement=False)
|
712,472
|
braintree.subscription_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() + "/subscriptions/advanced_search_ids", {"search": self.__criteria(query)})
return ResourceCollection(query, response, self.__fetch)
|
(self, *query)
|
712,473
|
braintree.subscription_gateway
|
update
| null |
def update(self, subscription_id, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Subscription.update_signature())
response = self.config.http().put(self.config.base_merchant_path() + "/subscriptions/" + subscription_id, {"subscription": params})
if "subscription" in response:
return SuccessfulResult({"subscription": Subscription(self.gateway, response["subscription"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, subscription_id, params=None)
|
712,474
|
braintree.subscription_search
|
SubscriptionSearch
| null |
class SubscriptionSearch:
billing_cycles_remaining = Search.RangeNodeBuilder("billing_cycles_remaining")
created_at = Search.RangeNodeBuilder("created_at")
days_past_due = Search.RangeNodeBuilder("days_past_due")
id = Search.TextNodeBuilder("id")
ids = Search.MultipleValueNodeBuilder("ids")
in_trial_period = Search.MultipleValueNodeBuilder("in_trial_period")
merchant_account_id = Search.MultipleValueNodeBuilder("merchant_account_id")
next_billing_date = Search.RangeNodeBuilder("next_billing_date")
plan_id = Search.MultipleValueOrTextNodeBuilder("plan_id")
price = Search.RangeNodeBuilder("price")
status = Search.MultipleValueNodeBuilder("status", Constants.get_all_constant_values_from_class(Subscription.Status))
transaction_id = Search.TextNodeBuilder("transaction_id")
|
()
|
712,475
|
braintree.subscription_status_event
|
SubscriptionStatusEvent
| null |
class SubscriptionStatusEvent(Resource):
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
self.balance = Decimal(self.balance)
self.price = Decimal(self.price)
|
(gateway, attributes)
|
712,479
|
braintree.subscription_status_event
|
__init__
| null |
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
self.balance = Decimal(self.balance)
self.price = Decimal(self.price)
|
(self, gateway, attributes)
|
712,482
|
braintree.successful_result
|
SuccessfulResult
|
An instance of this class is returned from most operations when the request is successful. Call the name of the resource (eg, customer, credit_card, etc) to get the object::
result = Transaction.sale({..})
if result.is_success:
transaction = result.transaction
else:
print [error.code for error in result.errors.all]
|
class SuccessfulResult(AttributeGetter):
"""
An instance of this class is returned from most operations when the request is successful. Call the name of the resource (eg, customer, credit_card, etc) to get the object::
result = Transaction.sale({..})
if result.is_success:
transaction = result.transaction
else:
print [error.code for error in result.errors.all]
"""
@property
def is_success(self):
""" Returns whether the result from the gateway is a successful response. """
return True
|
(attributes=None)
|
712,485
|
braintree.testing_gateway
|
TestingGateway
| null |
class TestingGateway(object):
def __init__(self, gateway):
self.gateway = gateway
self.config = gateway.config
def make_past_due(self, subscription_id, number_of_days_past_due=1):
self.__check_environment()
self.config.http().put(self.config.base_merchant_path() + "/subscriptions/%s/make_past_due?days_past_due=%s" % (subscription_id, number_of_days_past_due))
def escrow_transaction(self, transaction_id):
self.__check_environment()
self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/escrow")
def settle_transaction(self, transaction_id):
self.__check_environment()
return self.__create_result(self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/settle"))
def settlement_confirm_transaction(self, transaction_id):
self.__check_environment()
return self.__create_result(self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/settlement_confirm"))
def settlement_decline_transaction(self, transaction_id):
self.__check_environment()
return self.__create_result(self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/settlement_decline"))
def settlement_pending_transaction(self, transaction_id):
self.__check_environment()
return self.__create_result(self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/settlement_pending"))
def create_3ds_verification(self, merchant_account_id, params):
self.__check_environment()
response = self.config.http().post(self.config.base_merchant_path() + "/three_d_secure/create_verification/" + merchant_account_id, {
"three_d_secure_verification": params
})
return response["three_d_secure_verification"]["three_d_secure_authentication_id"]
def __create_result(self, response):
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def __check_environment(self):
if self.config.environment == braintree.Environment.Production:
raise TestOperationPerformedInProductionError()
|
(gateway)
|
712,486
|
braintree.testing_gateway
|
__check_environment
| null |
def __check_environment(self):
if self.config.environment == braintree.Environment.Production:
raise TestOperationPerformedInProductionError()
|
(self)
|
712,487
|
braintree.testing_gateway
|
__create_result
| null |
def __create_result(self, response):
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, response)
|
712,489
|
braintree.testing_gateway
|
create_3ds_verification
| null |
def create_3ds_verification(self, merchant_account_id, params):
self.__check_environment()
response = self.config.http().post(self.config.base_merchant_path() + "/three_d_secure/create_verification/" + merchant_account_id, {
"three_d_secure_verification": params
})
return response["three_d_secure_verification"]["three_d_secure_authentication_id"]
|
(self, merchant_account_id, params)
|
712,490
|
braintree.testing_gateway
|
escrow_transaction
| null |
def escrow_transaction(self, transaction_id):
self.__check_environment()
self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/escrow")
|
(self, transaction_id)
|
712,491
|
braintree.testing_gateway
|
make_past_due
| null |
def make_past_due(self, subscription_id, number_of_days_past_due=1):
self.__check_environment()
self.config.http().put(self.config.base_merchant_path() + "/subscriptions/%s/make_past_due?days_past_due=%s" % (subscription_id, number_of_days_past_due))
|
(self, subscription_id, number_of_days_past_due=1)
|
712,492
|
braintree.testing_gateway
|
settle_transaction
| null |
def settle_transaction(self, transaction_id):
self.__check_environment()
return self.__create_result(self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/settle"))
|
(self, transaction_id)
|
712,493
|
braintree.testing_gateway
|
settlement_confirm_transaction
| null |
def settlement_confirm_transaction(self, transaction_id):
self.__check_environment()
return self.__create_result(self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/settlement_confirm"))
|
(self, transaction_id)
|
712,494
|
braintree.testing_gateway
|
settlement_decline_transaction
| null |
def settlement_decline_transaction(self, transaction_id):
self.__check_environment()
return self.__create_result(self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/settlement_decline"))
|
(self, transaction_id)
|
712,495
|
braintree.testing_gateway
|
settlement_pending_transaction
| null |
def settlement_pending_transaction(self, transaction_id):
self.__check_environment()
return self.__create_result(self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/settlement_pending"))
|
(self, transaction_id)
|
712,496
|
braintree.three_d_secure_info
|
ThreeDSecureInfo
| null |
class ThreeDSecureInfo(AttributeGetter):
pass
|
(attributes=None)
|
712,499
|
braintree.transaction
|
Transaction
|
A class representing Braintree Transaction objects.
An example of creating a sale transaction with all available fields::
result = Transaction.sale({
"amount": "100.00",
"order_id": "123",
"channel": "MyShoppingCartProvider",
"credit_card": {
"number": "5105105105105100",
"expiration_date": "05/2011",
"cvv": "123"
},
"customer": {
"first_name": "Dan",
"last_name": "Smith",
"company": "Braintree",
"email": "dan@example.com",
"phone": "419-555-1234",
"fax": "419-555-1235",
"website": "https://www.braintreepayments.com"
},
"billing": {
"first_name": "Carl",
"last_name": "Jones",
"company": "Braintree",
"street_address": "123 E Main St",
"extended_address": "Suite 403",
"locality": "Chicago",
"region": "IL",
"postal_code": "60622",
"country_name": "United States of America"
"phone_number": "312-123-4567"
},
"shipping": {
"first_name": "Andrew",
"last_name": "Mason",
"company": "Braintree",
"street_address": "456 W Main St",
"extended_address": "Apt 2F",
"locality": "Bartlett",
"region": "IL",
"postal_code": "60103",
"country_name": "United States of America"
"phone_number": "312-123-4567"
}
})
print(result.transaction.amount)
print(result.transaction.order_id)
For more information on Transactions, see https://developer.paypal.com/braintree/docs/reference/request/transaction/sale/python
|
class Transaction(Resource):
"""
A class representing Braintree Transaction objects.
An example of creating a sale transaction with all available fields::
result = Transaction.sale({
"amount": "100.00",
"order_id": "123",
"channel": "MyShoppingCartProvider",
"credit_card": {
"number": "5105105105105100",
"expiration_date": "05/2011",
"cvv": "123"
},
"customer": {
"first_name": "Dan",
"last_name": "Smith",
"company": "Braintree",
"email": "dan@example.com",
"phone": "419-555-1234",
"fax": "419-555-1235",
"website": "https://www.braintreepayments.com"
},
"billing": {
"first_name": "Carl",
"last_name": "Jones",
"company": "Braintree",
"street_address": "123 E Main St",
"extended_address": "Suite 403",
"locality": "Chicago",
"region": "IL",
"postal_code": "60622",
"country_name": "United States of America"
"phone_number": "312-123-4567"
},
"shipping": {
"first_name": "Andrew",
"last_name": "Mason",
"company": "Braintree",
"street_address": "456 W Main St",
"extended_address": "Apt 2F",
"locality": "Bartlett",
"region": "IL",
"postal_code": "60103",
"country_name": "United States of America"
"phone_number": "312-123-4567"
}
})
print(result.transaction.amount)
print(result.transaction.order_id)
For more information on Transactions, see https://developer.paypal.com/braintree/docs/reference/request/transaction/sale/python
"""
def __repr__(self):
detail_list = [
"id",
"graphql_id",
"additional_processor_response",
"amount",
"acquirer_reference_number",
"authorization_adjustments",
"authorization_expires_at",
"avs_error_response_code",
"avs_postal_code_response_code",
"avs_street_address_response_code",
"channel",
"created_at",
"credit_card_details",
"currency_iso_code",
"customer_id",
"cvv_response_code",
"debit_network",
"discount_amount",
"disputes",
"escrow_status",
"gateway_rejection_reason",
"installments",
"liability_shift",
"master_merchant_account_id",
"merchant_account_id",
"merchant_advice_code",
"merchant_advice_code_text",
"network_response_code",
"network_response_text",
"network_transaction_id",
"order_id",
"packages",
"payment_instrument_type",
"payment_method_token",
"plan_id",
"processed_with_network_token",
"processor_authorization_code",
"processor_response_code",
"processor_response_text",
"processor_settlement_response_code",
"processor_settlement_response_text",
"purchase_order_number",
"recurring",
"refund_id",
"refunded_transaction_id",
"retried",
"retried_transaction_id",
"retrieval_reference_number",
"retry_ids",
"service_fee_amount",
"settlement_batch_id",
"shipping_amount",
"ships_from_postal_code",
"status",
"status_history",
"sub_merchant_account_id",
"subscription_id",
"tax_amount",
"tax_exempt",
"type",
"updated_at",
"voice_referral_number",
]
return super(Transaction, self).__repr__(detail_list)
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class CreatedUsing(object):
"""
Constants representing how the transaction was created. Available types are:
* braintree.Transaction.CreatedUsing.FullInformation
* braintree.Transaction.CreatedUsing.Token
"""
FullInformation = "full_information"
Token = "token"
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class GatewayRejectionReason(object):
"""
Constants representing gateway rejection reasons. Available types are:
* braintree.Transaction.GatewayRejectionReason.Avs
* braintree.Transaction.GatewayRejectionReason.AvsAndCvv
* braintree.Transaction.GatewayRejectionReason.Cvv
* braintree.Transaction.GatewayRejectionReason.Duplicate
* braintree.Transaction.GatewayRejectionReason.ExcessiveRetry
* braintree.Transaction.GatewayRejectionReason.Fraud
* braintree.Transaction.GatewayRejectionReason.RiskThreshold
* braintree.Transaction.GatewayRejectionReason.ThreeDSecure
* braintree.Transaction.GatewayRejectionReason.TokenIssuance
"""
ApplicationIncomplete = "application_incomplete"
Avs = "avs"
AvsAndCvv = "avs_and_cvv"
Cvv = "cvv"
Duplicate = "duplicate"
ExcessiveRetry = "excessive_retry"
Fraud = "fraud"
RiskThreshold = "risk_threshold"
ThreeDSecure = "three_d_secure"
TokenIssuance = "token_issuance"
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class ReasonCode(object):
ANY_REASON_CODE = 'any_reason_code'
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class Source(object):
Api = "api"
ControlPanel = "control_panel"
Recurring = "recurring"
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class EscrowStatus(object):
"""
Constants representing transaction escrow statuses. Available statuses are:
* braintree.Transaction.EscrowStatus.HoldPending
* braintree.Transaction.EscrowStatus.Held
* braintree.Transaction.EscrowStatus.ReleasePending
* braintree.Transaction.EscrowStatus.Released
* braintree.Transaction.EscrowStatus.Refunded
"""
HoldPending = "hold_pending"
Held = "held"
ReleasePending = "release_pending"
Released = "released"
Refunded = "refunded"
# 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.Transaction.Status.AuthorizationExpired
* braintree.Transaction.Status.Authorized
* braintree.Transaction.Status.Authorizing
* braintree.Transaction.Status.SettlementPending
* braintree.Transaction.Status.SettlementDeclined
* braintree.Transaction.Status.Failed
* braintree.Transaction.Status.GatewayRejected
* braintree.Transaction.Status.ProcessorDeclined
* braintree.Transaction.Status.Settled
* braintree.Transaction.Status.Settling
* braintree.Transaction.Status.SubmittedForSettlement
* braintree.Transaction.Status.Voided
"""
AuthorizationExpired = "authorization_expired"
Authorized = "authorized"
Authorizing = "authorizing"
Failed = "failed"
GatewayRejected = "gateway_rejected"
ProcessorDeclined = "processor_declined"
Settled = "settled"
SettlementConfirmed = "settlement_confirmed"
SettlementDeclined = "settlement_declined"
SettlementFailed = "settlement_failed"
SettlementPending = "settlement_pending"
Settling = "settling"
SubmittedForSettlement = "submitted_for_settlement"
Voided = "voided"
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class Type(object):
"""
Constants representing transaction types. Available types are:
* braintree.Transaction.Type.Credit
* braintree.Transaction.Type.Sale
"""
Credit = "credit"
Sale = "sale"
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class IndustryType(object):
Lodging = "lodging"
TravelAndCruise = "travel_cruise"
TravelAndFlight = "travel_flight"
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class AdditionalCharge(object):
Restaurant = "restaurant"
GiftShop = "gift_shop"
MiniBar = "mini_bar"
Telephone = "telephone"
Laundry = "laundry"
Other = "other"
@staticmethod
def adjust_authorization(transaction_id, amount):
"""
adjust authorization for an existing transaction.
It expects a `transaction_id` and `amount`, which is the new total authorization amount
result = braintree.Transaction.adjust_authorization("my_transaction_id", "amount")
"""
return Configuration.gateway().transaction.adjust_authorization(transaction_id, amount)
@staticmethod
def clone_transaction(transaction_id, params):
return Configuration.gateway().transaction.clone_transaction(transaction_id, params)
@staticmethod
def cancel_release(transaction_id):
"""
Cancels a pending release from escrow for a transaction.
Requires the transaction id::
result = braintree.Transaction.cancel_release("my_transaction_id")
"""
return Configuration.gateway().transaction.cancel_release(transaction_id)
@staticmethod
def credit(params=None):
"""
Creates a transaction of type Credit.
Amount is required. Also, a credit card,
customer_id or payment_method_token is required. ::
result = braintree.Transaction.credit({
"amount": "100.00",
"payment_method_token": "my_token"
})
result = braintree.Transaction.credit({
"amount": "100.00",
"credit_card": {
"number": "4111111111111111",
"expiration_date": "12/2012"
}
})
result = braintree.Transaction.credit({
"amount": "100.00",
"customer_id": "my_customer_id"
})
"""
if params is None:
params = {}
params["type"] = Transaction.Type.Credit
return Transaction.create(params)
@staticmethod
def find(transaction_id):
"""
Find a transaction, given a transaction_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. ::
transaction = braintree.Transaction.find("my_transaction_id")
"""
return Configuration.gateway().transaction.find(transaction_id)
@staticmethod
def hold_in_escrow(transaction_id):
"""
Holds an existing submerchant transaction for escrow.
It expects a transaction_id.::
result = braintree.Transaction.hold_in_escrow("my_transaction_id")
"""
return Configuration.gateway().transaction.hold_in_escrow(transaction_id)
@staticmethod
def refund(transaction_id, amount_or_options=None):
"""
Refunds an existing transaction.
It expects a transaction_id.::
result = braintree.Transaction.refund("my_transaction_id")
"""
return Configuration.gateway().transaction.refund(transaction_id, amount_or_options)
@staticmethod
def sale(params=None):
"""
Creates a transaction of type Sale. Amount is required. Also, a credit card,
customer_id or payment_method_token is required. ::
result = braintree.Transaction.sale({
"amount": "100.00",
"payment_method_token": "my_token"
})
result = braintree.Transaction.sale({
"amount": "100.00",
"credit_card": {
"number": "4111111111111111",
"expiration_date": "12/2012"
}
})
result = braintree.Transaction.sale({
"amount": "100.00",
"customer_id": "my_customer_id"
})
"""
if params is None:
params = {}
if "recurring" in params.keys():
warnings.warn("Use transaction_source parameter instead", DeprecationWarning)
params["type"] = Transaction.Type.Sale
return Transaction.create(params)
@staticmethod
def search(*query):
return Configuration.gateway().transaction.search(*query)
@staticmethod
def release_from_escrow(transaction_id):
"""
Submits an escrowed transaction for release.
Requires the transaction id::
result = braintree.Transaction.release_from_escrow("my_transaction_id")
"""
return Configuration.gateway().transaction.release_from_escrow(transaction_id)
@staticmethod
def submit_for_settlement(transaction_id, amount=None, params=None):
"""
Submits an authorized transaction for settlement.
Requires the transaction id::
result = braintree.Transaction.submit_for_settlement("my_transaction_id")
"""
if params is None:
params = {}
return Configuration.gateway().transaction.submit_for_settlement(transaction_id, amount, params)
@staticmethod
def update_details(transaction_id, params=None):
"""
Updates existing details for transaction submitted_for_settlement.
Requires the transaction id::
result = braintree.Transaction.update_details("my_transaction_id", {
"amount": "100.00",
"order_id": "123",
"descriptor": {
"name": "123*123456789012345678",
"phone": "3334445555",
"url": "url.com"
}
)
"""
if params is None:
params = {}
return Configuration.gateway().transaction.update_details(transaction_id, params)
@staticmethod
def void(transaction_id):
"""
Voids an existing transaction.
It expects a transaction_id.::
result = braintree.Transaction.void("my_transaction_id")
"""
return Configuration.gateway().transaction.void(transaction_id)
@staticmethod
def create(params):
"""
Creates a transaction. Amount and type are required. Also, a credit card,
customer_id or payment_method_token is required. ::
result = braintree.Transaction.sale({
"type": braintree.Transaction.Type.Sale,
"amount": "100.00",
"payment_method_token": "my_token"
})
result = braintree.Transaction.sale({
"type": braintree.Transaction.Type.Sale,
"amount": "100.00",
"credit_card": {
"number": "4111111111111111",
"expiration_date": "12/2012"
}
})
result = braintree.Transaction.sale({
"type": braintree.Transaction.Type.Sale,
"amount": "100.00",
"customer_id": "my_customer_id"
})
"""
return Configuration.gateway().transaction.create(params)
@staticmethod
def clone_signature():
return ["amount", "channel", {"options": ["submit_for_settlement"]}]
@staticmethod
def create_signature():
return [
"amount", "customer_id", "merchant_account_id", "order_id", "channel",
"payment_method_token", "purchase_order_number", "recurring", "transaction_source", "shipping_address_id",
"device_data", "billing_address_id", "payment_method_nonce", "product_sku", "tax_amount",
"shared_payment_method_token", "shared_customer_id", "shared_billing_address_id", "shared_shipping_address_id", "shared_payment_method_nonce",
"discount_amount", "shipping_amount", "ships_from_postal_code",
"tax_exempt", "three_d_secure_authentication_id", "three_d_secure_token", # NEXT_MAJOR_VERSION Remove three_d_secure_token
"type", "venmo_sdk_payment_method_code", # NEXT_MJOR_VERSION remove venmo_sdk_payment_method_code
"service_fee_amount", "sca_exemption","exchange_rate_quote_id",
"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": [
"token", "cardholder_name", "cvv", "expiration_date", "expiration_month", "expiration_year", "number",
{"payment_reader_card_details": ["encrypted_card_data", "key_serial_number"]}
]
},
{
"customer": [
"id", "company", "email", "fax", "first_name", "last_name", "phone", "website"
]
},
{
"billing": [
"first_name", "last_name", "company", "country_code_alpha2", "country_code_alpha3",
"country_code_numeric", "country_name", "extended_address", "locality",
"phone_number", "postal_code", "region", "street_address"
]
},
{
"shipping": [
"first_name", "last_name", "company", "country_code_alpha2", "country_code_alpha3",
"country_code_numeric", "country_name", "extended_address", "locality",
"phone_number", "postal_code", "region", "shipping_method", "street_address"
]
},
{
"three_d_secure_pass_thru": [
"eci_flag",
"cavv",
"xid",
"authentication_response",
"directory_response",
"cavv_algorithm",
"ds_transaction_id",
"three_d_secure_version"
]
},
{
"options": [
"add_billing_address_to_payment_method",
"hold_in_escrow",
"store_in_vault",
"store_in_vault_on_success",
"store_shipping_address_in_vault",
"submit_for_settlement",
"venmo_sdk_session", # NEXT_MJOR_VERSION remove venmo_sdk_session
"payee_id",
"payee_email",
"skip_advanced_fraud_checking",
"skip_avs",
"skip_cvv",
{
"credit_card": [
"account_type",
"process_debit_as_credit"
],
"paypal": [
"payee_id",
"payee_email",
"custom_field",
"description",
{"supplementary_data": ["__any_key__"]}
],
"three_d_secure": [
"required"
],
"amex_rewards": [
"request_id",
"points",
"currency_amount",
"currency_iso_code"
],
"venmo_merchant_data": [
"venmo_merchant_public_id",
"originating_transaction_id",
"originating_merchant_id",
"originating_merchant_kind"
],
"venmo": [
"profile_id"
],
},
{
"adyen": [
"overwrite_brand",
"selected_brand"
]
},
{
"processing_overrides": [
"customer_email",
"customer_first_name",
"customer_last_name",
"customer_tax_identifier"
]
}
]
},
{"custom_fields": ["__any_key__"]},
{"external_vault": ["status", "previous_network_transaction_id"]},
{"descriptor": ["name", "phone", "url"]},
{"paypal_account": ["payee_id", "payee_email", "payer_id", "payment_id"]},
{"industry":
[
"industry_type",
{
"data": [
"folio_number", "check_in_date", "check_out_date", "departure_date", "lodging_check_in_date", "lodging_check_out_date", "travel_package", "lodging_name", "room_rate",
"passenger_first_name", "passenger_last_name", "passenger_middle_initial", "passenger_title", "issued_date", "travel_agency_name", "travel_agency_code", "ticket_number",
"issuing_carrier_code", "customer_code", "fare_amount", "fee_amount", "room_tax", "tax_amount", "restricted_ticket", "no_show", "advanced_deposit", "fire_safe", "property_phone", "arrival_date", "ticket_issuer_address", "date_of_birth", "country_code",
{
"legs": [
"conjunction_ticket", "exchange_ticket", "coupon_number", "service_class", "carrier_code", "fare_basis_code", "flight_number", "departure_date", "departure_airport_code", "departure_time",
"arrival_airport_code", "arrival_time", "stopover_permitted", "fare_amount", "fee_amount", "tax_amount", "endorsement_or_restrictions"
]
},
{
"additional_charges": [
"kind", "amount"
],
}
]
}
]
},
{"line_items":
[
"commodity_code", "description", "discount_amount", "image_url", "kind", "name", "product_code", "quantity", "tax_amount", "total_amount", "unit_amount", "unit_of_measure", "unit_tax_amount", "upc_code", "upc_type", "url",
]
},
{"apple_pay_card": ["number", "cardholder_name", "cryptogram", "expiration_month", "expiration_year", "eci_indicator"]},
# NEXT_MAJOR_VERSION use google_pay_card in public API (map to android_pay_card internally)
{"android_pay_card": ["number", "cryptogram", "expiration_month", "expiration_year", "eci_indicator", "source_card_type", "source_card_last_four", "google_transaction_id"]},
{"installments": {"count"}},
]
@staticmethod
def submit_for_settlement_signature():
return [
"order_id",
{"descriptor": ["name", "phone", "url"]},
"purchase_order_number",
"tax_amount",
"tax_exempt",
"discount_amount",
"shipping_amount",
"ships_from_postal_code",
{"industry":
[
"industry_type",
{
"data": [
"advanced_deposit", "arrival_date", "check_in_date", "check_out_date", "customer_code", "departure_date", "fare_amount", "fee_amount", "fire_safe", "folio_number", "issued_date", "issuing_carrier_code",
"lodging_check_in_date", "lodging_check_out_date", "lodging_name", "no_show", "passenger_first_name", "passenger_last_name", "passenger_middle_initial", "passenger_title", "property_phone",
"restricted_ticket", "room_rate", "room_tax", "tax_amount", "ticket_issuer_address", "ticket_number", "travel_agency_code", "travel_agency_name", "travel_package",
{
"legs": [
"arrival_airport_code", "arrival_time", "carrier_code", "conjunction_ticket", "coupon_number", "departure_airport_code", "departure_date", "departure_time", "endorsement_or_restrictions",
"exchange_ticket", "fare_amount", "fare_basis_code", "fee_amount", "flight_number", "service_class", "stopover_permitted", "tax_amount"
]
},
{
"additional_charges": [
"amount", "kind"
],
}
]
}
]
},
{"line_items":
[
"commodity_code", "description", "discount_amount", "image_url", "kind", "name", "product_code", "quantity", "tax_amount", "total_amount", "unit_amount", "unit_of_measure", "unit_tax_amount", "upc_code", "upc_type", "url,"
]
},
{"shipping":
[
"first_name", "last_name", "company", "country_code_alpha2", "country_code_alpha3",
"country_code_numeric", "country_name", "extended_address", "locality",
"postal_code", "region", "street_address",
]
},
{"industry":
[
"industry_type",
{
"data": [
"folio_number", "check_in_date", "check_out_date", "departure_date", "lodging_check_in_date", "lodging_check_out_date", "travel_package", "lodging_name", "room_rate",
"passenger_first_name", "passenger_last_name", "passenger_middle_initial", "passenger_title", "issued_date", "travel_agency_name", "travel_agency_code", "ticket_number",
"issuing_carrier_code", "customer_code", "fare_amount", "fee_amount", "room_tax", "tax_amount", "restricted_ticket", "no_show", "advanced_deposit", "fire_safe", "property_phone", "arrival_date", "ticket_issuer_address", "date_of_birth", "country_code",
{
"legs": [
"conjunction_ticket", "exchange_ticket", "coupon_number", "service_class", "carrier_code", "fare_basis_code", "flight_number", "departure_date", "departure_airport_code", "departure_time",
"arrival_airport_code", "arrival_time", "stopover_permitted", "fare_amount", "fee_amount", "tax_amount", "endorsement_or_restrictions"
]
},
{
"additional_charges": [
"kind", "amount"
],
}
]
}
]
},
]
@staticmethod
def package_tracking_signature():
return [ "carrier", "notify_payer", "tracking_number",
{ "line_items": [
"commodity_code", "description", "discount_amount", "image_url", "kind", "name",
"product_code", "quantity", "tax_amount", "total_amount", "unit_amount", "unit_of_measure",
"unit_tax_amount", "upc_code", "upc_type", "url"
]
},
]
@staticmethod
def package_tracking(transaction_id, params=None):
"""
Creates a request to send package tracking information for a transaction which has already submitted for settlement.
Requires the transaction id of the transaction and the package tracking request details::
result = braintree.Transaction.package_tracking("my_transaction_id", params )
"""
if params is None:
params = {}
return Configuration.gateway().transaction.package_tracking(transaction_id, params)
@staticmethod
def update_details_signature():
return ["amount", "order_id", {"descriptor": ["name", "phone", "url"]}]
@staticmethod
def refund_signature():
return ["amount", "order_id", "merchant_account_id"]
@staticmethod
def submit_for_partial_settlement(transaction_id, amount, params=None):
"""
Creates a partial settlement transaction for an authorized transaction
Requires the transaction id of the authorized transaction and an amount::
result = braintree.Transaction.submit_for_partial_settlement("my_transaction_id", "20.00")
"""
if params is None:
params = {}
return Configuration.gateway().transaction.submit_for_partial_settlement(transaction_id, amount, params)
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
self.amount = Decimal(self.amount)
if "tax_amount" in attributes and getattr(self, "tax_amount", None):
self.tax_amount = Decimal(self.tax_amount)
if "discount_amount" in attributes and getattr(self, "discount_amount", None):
self.discount_amount = Decimal(self.discount_amount)
if "shipping_amount" in attributes and getattr(self, "shipping_amount", None):
self.shipping_amount = Decimal(self.shipping_amount)
if "billing" in attributes:
self.billing_details = Address(gateway, attributes.pop("billing"))
if "credit_card" in attributes:
self.credit_card_details = CreditCard(gateway, attributes.pop("credit_card"))
if "shipments" in attributes:
self.packages = [PackageDetails(detail) for detail in self.shipments]
if "paypal" in attributes:
self.paypal_details = PayPalAccount(gateway, attributes.pop("paypal"))
if "paypal_here" in attributes:
self.paypal_here_details = PayPalHere(gateway, attributes.pop("paypal_here"))
if "local_payment" in attributes:
self.local_payment_details = LocalPayment(gateway, attributes.pop("local_payment"))
if "sepa_debit_account_detail" in attributes:
self.sepa_direct_debit_account_details = SepaDirectDebitAccount(gateway, attributes.pop("sepa_debit_account_detail"))
if "europe_bank_account" in attributes:
self.europe_bank_account_details = EuropeBankAccount(gateway, attributes.pop("europe_bank_account"))
if "us_bank_account" in attributes:
self.us_bank_account = UsBankAccount(gateway, attributes.pop("us_bank_account"))
if "apple_pay" in attributes:
self.apple_pay_details = ApplePayCard(gateway, attributes.pop("apple_pay"))
# NEXT_MAJOR_VERSION rename to google_pay_card_details
if "android_pay_card" in attributes:
self.android_pay_card_details = AndroidPayCard(gateway, attributes.pop("android_pay_card"))
# NEXT_MAJOR_VERSION remove amex express checkout
if "amex_express_checkout_card" in attributes:
self.amex_express_checkout_card_details = AmexExpressCheckoutCard(gateway, attributes.pop("amex_express_checkout_card"))
if "venmo_account" in attributes:
self.venmo_account_details = VenmoAccount(gateway, attributes.pop("venmo_account"))
if "visa_checkout_card" in attributes:
self.visa_checkout_card_details = VisaCheckoutCard(gateway, attributes.pop("visa_checkout_card"))
# NEXt_MAJOR_VERSION remove masterpass
if "masterpass_card" in attributes:
self.masterpass_card_details = MasterpassCard(gateway, attributes.pop("masterpass_card"))
if "samsung_pay_card" in attributes:
self.samsung_pay_card_details = SamsungPayCard(gateway, attributes.pop("samsung_pay_card"))
if "meta_checkout_card" in attributes:
self.meta_checkout_card_details = MetaCheckoutCard(gateway, attributes.pop("meta_checkout_card"))
if "meta_checkout_token" in attributes:
self.meta_checkout_token_details = MetaCheckoutToken(gateway, attributes.pop("meta_checkout_token"))
if "sca_exemption_requested" in attributes:
self.sca_exemption_requested = attributes.pop("sca_exemption_requested")
else:
self.sca_exemption_requested = None
if "customer" in attributes:
self.customer_details = Customer(gateway, attributes.pop("customer"))
if "shipping" in attributes:
self.shipping_details = Address(gateway, attributes.pop("shipping"))
if "add_ons" in attributes:
self.add_ons = [AddOn(gateway, add_on) for add_on in self.add_ons]
if "discounts" in attributes:
self.discounts = [Discount(gateway, discount) for discount in self.discounts]
if "status_history" in attributes:
self.status_history = [StatusEvent(gateway, status_event) for status_event in self.status_history]
if "subscription" in attributes:
self.subscription_details = SubscriptionDetails(attributes.pop("subscription"))
if "descriptor" in attributes:
self.descriptor = Descriptor(gateway, attributes.pop("descriptor"))
if "disbursement_details" in attributes:
self.disbursement_details = DisbursementDetail(attributes.pop("disbursement_details"))
if "disputes" in attributes:
self.disputes = [Dispute(dispute) for dispute in self.disputes]
if "authorization_adjustments" in attributes:
self.authorization_adjustments = [AuthorizationAdjustment(authorization_adjustment) for authorization_adjustment in self.authorization_adjustments]
if "payment_instrument_type" in attributes:
self.payment_instrument_type = attributes["payment_instrument_type"]
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
if "facilitated_details" in attributes:
self.facilitated_details = FacilitatedDetails(attributes.pop("facilitated_details"))
if "facilitator_details" in attributes:
self.facilitator_details = FacilitatorDetails(attributes.pop("facilitator_details"))
if "network_transaction_id" in attributes:
self.network_transaction_id = attributes["network_transaction_id"]
@property
def vault_billing_address(self):
"""
The vault billing address associated with this transaction
"""
return self.gateway.address.find(self.customer_details.id, self.billing_details.id)
@property
def vault_credit_card(self):
"""
The vault credit card associated with this transaction
"""
if self.credit_card_details.token is None:
return None
return self.gateway.credit_card.find(self.credit_card_details.token)
@property
def vault_customer(self):
"""
The vault customer associated with this transaction
"""
if self.customer_details.id is None:
return None
return self.gateway.customer.find(self.customer_details.id)
@property
def is_disbursed(self):
return self.disbursement_details.is_valid
@property
def line_items(self):
"""
The line items associated with this transaction
"""
return self.gateway.transaction_line_item.find_all(self.id)
|
(gateway, attributes)
|
712,503
|
braintree.transaction
|
__init__
| null |
def __init__(self, gateway, attributes):
Resource.__init__(self, gateway, attributes)
self.amount = Decimal(self.amount)
if "tax_amount" in attributes and getattr(self, "tax_amount", None):
self.tax_amount = Decimal(self.tax_amount)
if "discount_amount" in attributes and getattr(self, "discount_amount", None):
self.discount_amount = Decimal(self.discount_amount)
if "shipping_amount" in attributes and getattr(self, "shipping_amount", None):
self.shipping_amount = Decimal(self.shipping_amount)
if "billing" in attributes:
self.billing_details = Address(gateway, attributes.pop("billing"))
if "credit_card" in attributes:
self.credit_card_details = CreditCard(gateway, attributes.pop("credit_card"))
if "shipments" in attributes:
self.packages = [PackageDetails(detail) for detail in self.shipments]
if "paypal" in attributes:
self.paypal_details = PayPalAccount(gateway, attributes.pop("paypal"))
if "paypal_here" in attributes:
self.paypal_here_details = PayPalHere(gateway, attributes.pop("paypal_here"))
if "local_payment" in attributes:
self.local_payment_details = LocalPayment(gateway, attributes.pop("local_payment"))
if "sepa_debit_account_detail" in attributes:
self.sepa_direct_debit_account_details = SepaDirectDebitAccount(gateway, attributes.pop("sepa_debit_account_detail"))
if "europe_bank_account" in attributes:
self.europe_bank_account_details = EuropeBankAccount(gateway, attributes.pop("europe_bank_account"))
if "us_bank_account" in attributes:
self.us_bank_account = UsBankAccount(gateway, attributes.pop("us_bank_account"))
if "apple_pay" in attributes:
self.apple_pay_details = ApplePayCard(gateway, attributes.pop("apple_pay"))
# NEXT_MAJOR_VERSION rename to google_pay_card_details
if "android_pay_card" in attributes:
self.android_pay_card_details = AndroidPayCard(gateway, attributes.pop("android_pay_card"))
# NEXT_MAJOR_VERSION remove amex express checkout
if "amex_express_checkout_card" in attributes:
self.amex_express_checkout_card_details = AmexExpressCheckoutCard(gateway, attributes.pop("amex_express_checkout_card"))
if "venmo_account" in attributes:
self.venmo_account_details = VenmoAccount(gateway, attributes.pop("venmo_account"))
if "visa_checkout_card" in attributes:
self.visa_checkout_card_details = VisaCheckoutCard(gateway, attributes.pop("visa_checkout_card"))
# NEXt_MAJOR_VERSION remove masterpass
if "masterpass_card" in attributes:
self.masterpass_card_details = MasterpassCard(gateway, attributes.pop("masterpass_card"))
if "samsung_pay_card" in attributes:
self.samsung_pay_card_details = SamsungPayCard(gateway, attributes.pop("samsung_pay_card"))
if "meta_checkout_card" in attributes:
self.meta_checkout_card_details = MetaCheckoutCard(gateway, attributes.pop("meta_checkout_card"))
if "meta_checkout_token" in attributes:
self.meta_checkout_token_details = MetaCheckoutToken(gateway, attributes.pop("meta_checkout_token"))
if "sca_exemption_requested" in attributes:
self.sca_exemption_requested = attributes.pop("sca_exemption_requested")
else:
self.sca_exemption_requested = None
if "customer" in attributes:
self.customer_details = Customer(gateway, attributes.pop("customer"))
if "shipping" in attributes:
self.shipping_details = Address(gateway, attributes.pop("shipping"))
if "add_ons" in attributes:
self.add_ons = [AddOn(gateway, add_on) for add_on in self.add_ons]
if "discounts" in attributes:
self.discounts = [Discount(gateway, discount) for discount in self.discounts]
if "status_history" in attributes:
self.status_history = [StatusEvent(gateway, status_event) for status_event in self.status_history]
if "subscription" in attributes:
self.subscription_details = SubscriptionDetails(attributes.pop("subscription"))
if "descriptor" in attributes:
self.descriptor = Descriptor(gateway, attributes.pop("descriptor"))
if "disbursement_details" in attributes:
self.disbursement_details = DisbursementDetail(attributes.pop("disbursement_details"))
if "disputes" in attributes:
self.disputes = [Dispute(dispute) for dispute in self.disputes]
if "authorization_adjustments" in attributes:
self.authorization_adjustments = [AuthorizationAdjustment(authorization_adjustment) for authorization_adjustment in self.authorization_adjustments]
if "payment_instrument_type" in attributes:
self.payment_instrument_type = attributes["payment_instrument_type"]
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
if "facilitated_details" in attributes:
self.facilitated_details = FacilitatedDetails(attributes.pop("facilitated_details"))
if "facilitator_details" in attributes:
self.facilitator_details = FacilitatorDetails(attributes.pop("facilitator_details"))
if "network_transaction_id" in attributes:
self.network_transaction_id = attributes["network_transaction_id"]
|
(self, gateway, attributes)
|
712,504
|
braintree.transaction
|
__repr__
| null |
def __repr__(self):
detail_list = [
"id",
"graphql_id",
"additional_processor_response",
"amount",
"acquirer_reference_number",
"authorization_adjustments",
"authorization_expires_at",
"avs_error_response_code",
"avs_postal_code_response_code",
"avs_street_address_response_code",
"channel",
"created_at",
"credit_card_details",
"currency_iso_code",
"customer_id",
"cvv_response_code",
"debit_network",
"discount_amount",
"disputes",
"escrow_status",
"gateway_rejection_reason",
"installments",
"liability_shift",
"master_merchant_account_id",
"merchant_account_id",
"merchant_advice_code",
"merchant_advice_code_text",
"network_response_code",
"network_response_text",
"network_transaction_id",
"order_id",
"packages",
"payment_instrument_type",
"payment_method_token",
"plan_id",
"processed_with_network_token",
"processor_authorization_code",
"processor_response_code",
"processor_response_text",
"processor_settlement_response_code",
"processor_settlement_response_text",
"purchase_order_number",
"recurring",
"refund_id",
"refunded_transaction_id",
"retried",
"retried_transaction_id",
"retrieval_reference_number",
"retry_ids",
"service_fee_amount",
"settlement_batch_id",
"shipping_amount",
"ships_from_postal_code",
"status",
"status_history",
"sub_merchant_account_id",
"subscription_id",
"tax_amount",
"tax_exempt",
"type",
"updated_at",
"voice_referral_number",
]
return super(Transaction, self).__repr__(detail_list)
|
(self)
|
712,505
|
braintree.transaction
|
adjust_authorization
|
adjust authorization for an existing transaction.
It expects a `transaction_id` and `amount`, which is the new total authorization amount
result = braintree.Transaction.adjust_authorization("my_transaction_id", "amount")
|
@staticmethod
def adjust_authorization(transaction_id, amount):
"""
adjust authorization for an existing transaction.
It expects a `transaction_id` and `amount`, which is the new total authorization amount
result = braintree.Transaction.adjust_authorization("my_transaction_id", "amount")
"""
return Configuration.gateway().transaction.adjust_authorization(transaction_id, amount)
|
(transaction_id, amount)
|
712,506
|
braintree.transaction
|
cancel_release
|
Cancels a pending release from escrow for a transaction.
Requires the transaction id::
result = braintree.Transaction.cancel_release("my_transaction_id")
|
@staticmethod
def cancel_release(transaction_id):
"""
Cancels a pending release from escrow for a transaction.
Requires the transaction id::
result = braintree.Transaction.cancel_release("my_transaction_id")
"""
return Configuration.gateway().transaction.cancel_release(transaction_id)
|
(transaction_id)
|
712,507
|
braintree.transaction
|
clone_signature
| null |
@staticmethod
def clone_signature():
return ["amount", "channel", {"options": ["submit_for_settlement"]}]
|
()
|
712,508
|
braintree.transaction
|
clone_transaction
| null |
@staticmethod
def clone_transaction(transaction_id, params):
return Configuration.gateway().transaction.clone_transaction(transaction_id, params)
|
(transaction_id, params)
|
712,509
|
braintree.transaction
|
create
|
Creates a transaction. Amount and type are required. Also, a credit card,
customer_id or payment_method_token is required. ::
result = braintree.Transaction.sale({
"type": braintree.Transaction.Type.Sale,
"amount": "100.00",
"payment_method_token": "my_token"
})
result = braintree.Transaction.sale({
"type": braintree.Transaction.Type.Sale,
"amount": "100.00",
"credit_card": {
"number": "4111111111111111",
"expiration_date": "12/2012"
}
})
result = braintree.Transaction.sale({
"type": braintree.Transaction.Type.Sale,
"amount": "100.00",
"customer_id": "my_customer_id"
})
|
@staticmethod
def create(params):
"""
Creates a transaction. Amount and type are required. Also, a credit card,
customer_id or payment_method_token is required. ::
result = braintree.Transaction.sale({
"type": braintree.Transaction.Type.Sale,
"amount": "100.00",
"payment_method_token": "my_token"
})
result = braintree.Transaction.sale({
"type": braintree.Transaction.Type.Sale,
"amount": "100.00",
"credit_card": {
"number": "4111111111111111",
"expiration_date": "12/2012"
}
})
result = braintree.Transaction.sale({
"type": braintree.Transaction.Type.Sale,
"amount": "100.00",
"customer_id": "my_customer_id"
})
"""
return Configuration.gateway().transaction.create(params)
|
(params)
|
712,510
|
braintree.transaction
|
create_signature
| null |
@staticmethod
def create_signature():
return [
"amount", "customer_id", "merchant_account_id", "order_id", "channel",
"payment_method_token", "purchase_order_number", "recurring", "transaction_source", "shipping_address_id",
"device_data", "billing_address_id", "payment_method_nonce", "product_sku", "tax_amount",
"shared_payment_method_token", "shared_customer_id", "shared_billing_address_id", "shared_shipping_address_id", "shared_payment_method_nonce",
"discount_amount", "shipping_amount", "ships_from_postal_code",
"tax_exempt", "three_d_secure_authentication_id", "three_d_secure_token", # NEXT_MAJOR_VERSION Remove three_d_secure_token
"type", "venmo_sdk_payment_method_code", # NEXT_MJOR_VERSION remove venmo_sdk_payment_method_code
"service_fee_amount", "sca_exemption","exchange_rate_quote_id",
"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": [
"token", "cardholder_name", "cvv", "expiration_date", "expiration_month", "expiration_year", "number",
{"payment_reader_card_details": ["encrypted_card_data", "key_serial_number"]}
]
},
{
"customer": [
"id", "company", "email", "fax", "first_name", "last_name", "phone", "website"
]
},
{
"billing": [
"first_name", "last_name", "company", "country_code_alpha2", "country_code_alpha3",
"country_code_numeric", "country_name", "extended_address", "locality",
"phone_number", "postal_code", "region", "street_address"
]
},
{
"shipping": [
"first_name", "last_name", "company", "country_code_alpha2", "country_code_alpha3",
"country_code_numeric", "country_name", "extended_address", "locality",
"phone_number", "postal_code", "region", "shipping_method", "street_address"
]
},
{
"three_d_secure_pass_thru": [
"eci_flag",
"cavv",
"xid",
"authentication_response",
"directory_response",
"cavv_algorithm",
"ds_transaction_id",
"three_d_secure_version"
]
},
{
"options": [
"add_billing_address_to_payment_method",
"hold_in_escrow",
"store_in_vault",
"store_in_vault_on_success",
"store_shipping_address_in_vault",
"submit_for_settlement",
"venmo_sdk_session", # NEXT_MJOR_VERSION remove venmo_sdk_session
"payee_id",
"payee_email",
"skip_advanced_fraud_checking",
"skip_avs",
"skip_cvv",
{
"credit_card": [
"account_type",
"process_debit_as_credit"
],
"paypal": [
"payee_id",
"payee_email",
"custom_field",
"description",
{"supplementary_data": ["__any_key__"]}
],
"three_d_secure": [
"required"
],
"amex_rewards": [
"request_id",
"points",
"currency_amount",
"currency_iso_code"
],
"venmo_merchant_data": [
"venmo_merchant_public_id",
"originating_transaction_id",
"originating_merchant_id",
"originating_merchant_kind"
],
"venmo": [
"profile_id"
],
},
{
"adyen": [
"overwrite_brand",
"selected_brand"
]
},
{
"processing_overrides": [
"customer_email",
"customer_first_name",
"customer_last_name",
"customer_tax_identifier"
]
}
]
},
{"custom_fields": ["__any_key__"]},
{"external_vault": ["status", "previous_network_transaction_id"]},
{"descriptor": ["name", "phone", "url"]},
{"paypal_account": ["payee_id", "payee_email", "payer_id", "payment_id"]},
{"industry":
[
"industry_type",
{
"data": [
"folio_number", "check_in_date", "check_out_date", "departure_date", "lodging_check_in_date", "lodging_check_out_date", "travel_package", "lodging_name", "room_rate",
"passenger_first_name", "passenger_last_name", "passenger_middle_initial", "passenger_title", "issued_date", "travel_agency_name", "travel_agency_code", "ticket_number",
"issuing_carrier_code", "customer_code", "fare_amount", "fee_amount", "room_tax", "tax_amount", "restricted_ticket", "no_show", "advanced_deposit", "fire_safe", "property_phone", "arrival_date", "ticket_issuer_address", "date_of_birth", "country_code",
{
"legs": [
"conjunction_ticket", "exchange_ticket", "coupon_number", "service_class", "carrier_code", "fare_basis_code", "flight_number", "departure_date", "departure_airport_code", "departure_time",
"arrival_airport_code", "arrival_time", "stopover_permitted", "fare_amount", "fee_amount", "tax_amount", "endorsement_or_restrictions"
]
},
{
"additional_charges": [
"kind", "amount"
],
}
]
}
]
},
{"line_items":
[
"commodity_code", "description", "discount_amount", "image_url", "kind", "name", "product_code", "quantity", "tax_amount", "total_amount", "unit_amount", "unit_of_measure", "unit_tax_amount", "upc_code", "upc_type", "url",
]
},
{"apple_pay_card": ["number", "cardholder_name", "cryptogram", "expiration_month", "expiration_year", "eci_indicator"]},
# NEXT_MAJOR_VERSION use google_pay_card in public API (map to android_pay_card internally)
{"android_pay_card": ["number", "cryptogram", "expiration_month", "expiration_year", "eci_indicator", "source_card_type", "source_card_last_four", "google_transaction_id"]},
{"installments": {"count"}},
]
|
()
|
712,511
|
braintree.transaction
|
credit
|
Creates a transaction of type Credit.
Amount is required. Also, a credit card,
customer_id or payment_method_token is required. ::
result = braintree.Transaction.credit({
"amount": "100.00",
"payment_method_token": "my_token"
})
result = braintree.Transaction.credit({
"amount": "100.00",
"credit_card": {
"number": "4111111111111111",
"expiration_date": "12/2012"
}
})
result = braintree.Transaction.credit({
"amount": "100.00",
"customer_id": "my_customer_id"
})
|
@staticmethod
def credit(params=None):
"""
Creates a transaction of type Credit.
Amount is required. Also, a credit card,
customer_id or payment_method_token is required. ::
result = braintree.Transaction.credit({
"amount": "100.00",
"payment_method_token": "my_token"
})
result = braintree.Transaction.credit({
"amount": "100.00",
"credit_card": {
"number": "4111111111111111",
"expiration_date": "12/2012"
}
})
result = braintree.Transaction.credit({
"amount": "100.00",
"customer_id": "my_customer_id"
})
"""
if params is None:
params = {}
params["type"] = Transaction.Type.Credit
return Transaction.create(params)
|
(params=None)
|
712,512
|
braintree.transaction
|
find
|
Find a transaction, given a transaction_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. ::
transaction = braintree.Transaction.find("my_transaction_id")
|
@staticmethod
def find(transaction_id):
"""
Find a transaction, given a transaction_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. ::
transaction = braintree.Transaction.find("my_transaction_id")
"""
return Configuration.gateway().transaction.find(transaction_id)
|
(transaction_id)
|
712,513
|
braintree.transaction
|
hold_in_escrow
|
Holds an existing submerchant transaction for escrow.
It expects a transaction_id.::
result = braintree.Transaction.hold_in_escrow("my_transaction_id")
|
@staticmethod
def hold_in_escrow(transaction_id):
"""
Holds an existing submerchant transaction for escrow.
It expects a transaction_id.::
result = braintree.Transaction.hold_in_escrow("my_transaction_id")
"""
return Configuration.gateway().transaction.hold_in_escrow(transaction_id)
|
(transaction_id)
|
712,514
|
braintree.transaction
|
package_tracking
|
Creates a request to send package tracking information for a transaction which has already submitted for settlement.
Requires the transaction id of the transaction and the package tracking request details::
result = braintree.Transaction.package_tracking("my_transaction_id", params )
|
@staticmethod
def package_tracking(transaction_id, params=None):
"""
Creates a request to send package tracking information for a transaction which has already submitted for settlement.
Requires the transaction id of the transaction and the package tracking request details::
result = braintree.Transaction.package_tracking("my_transaction_id", params )
"""
if params is None:
params = {}
return Configuration.gateway().transaction.package_tracking(transaction_id, params)
|
(transaction_id, params=None)
|
712,515
|
braintree.transaction
|
package_tracking_signature
| null |
@staticmethod
def package_tracking_signature():
return [ "carrier", "notify_payer", "tracking_number",
{ "line_items": [
"commodity_code", "description", "discount_amount", "image_url", "kind", "name",
"product_code", "quantity", "tax_amount", "total_amount", "unit_amount", "unit_of_measure",
"unit_tax_amount", "upc_code", "upc_type", "url"
]
},
]
|
()
|
712,516
|
braintree.transaction
|
refund
|
Refunds an existing transaction.
It expects a transaction_id.::
result = braintree.Transaction.refund("my_transaction_id")
|
@staticmethod
def refund(transaction_id, amount_or_options=None):
"""
Refunds an existing transaction.
It expects a transaction_id.::
result = braintree.Transaction.refund("my_transaction_id")
"""
return Configuration.gateway().transaction.refund(transaction_id, amount_or_options)
|
(transaction_id, amount_or_options=None)
|
712,517
|
braintree.transaction
|
refund_signature
| null |
@staticmethod
def refund_signature():
return ["amount", "order_id", "merchant_account_id"]
|
()
|
712,518
|
braintree.transaction
|
release_from_escrow
|
Submits an escrowed transaction for release.
Requires the transaction id::
result = braintree.Transaction.release_from_escrow("my_transaction_id")
|
@staticmethod
def release_from_escrow(transaction_id):
"""
Submits an escrowed transaction for release.
Requires the transaction id::
result = braintree.Transaction.release_from_escrow("my_transaction_id")
"""
return Configuration.gateway().transaction.release_from_escrow(transaction_id)
|
(transaction_id)
|
712,519
|
braintree.transaction
|
sale
|
Creates a transaction of type Sale. Amount is required. Also, a credit card,
customer_id or payment_method_token is required. ::
result = braintree.Transaction.sale({
"amount": "100.00",
"payment_method_token": "my_token"
})
result = braintree.Transaction.sale({
"amount": "100.00",
"credit_card": {
"number": "4111111111111111",
"expiration_date": "12/2012"
}
})
result = braintree.Transaction.sale({
"amount": "100.00",
"customer_id": "my_customer_id"
})
|
@staticmethod
def sale(params=None):
"""
Creates a transaction of type Sale. Amount is required. Also, a credit card,
customer_id or payment_method_token is required. ::
result = braintree.Transaction.sale({
"amount": "100.00",
"payment_method_token": "my_token"
})
result = braintree.Transaction.sale({
"amount": "100.00",
"credit_card": {
"number": "4111111111111111",
"expiration_date": "12/2012"
}
})
result = braintree.Transaction.sale({
"amount": "100.00",
"customer_id": "my_customer_id"
})
"""
if params is None:
params = {}
if "recurring" in params.keys():
warnings.warn("Use transaction_source parameter instead", DeprecationWarning)
params["type"] = Transaction.Type.Sale
return Transaction.create(params)
|
(params=None)
|
712,520
|
braintree.transaction
|
search
| null |
@staticmethod
def search(*query):
return Configuration.gateway().transaction.search(*query)
|
(*query)
|
712,521
|
braintree.transaction
|
submit_for_partial_settlement
|
Creates a partial settlement transaction for an authorized transaction
Requires the transaction id of the authorized transaction and an amount::
result = braintree.Transaction.submit_for_partial_settlement("my_transaction_id", "20.00")
|
@staticmethod
def submit_for_partial_settlement(transaction_id, amount, params=None):
"""
Creates a partial settlement transaction for an authorized transaction
Requires the transaction id of the authorized transaction and an amount::
result = braintree.Transaction.submit_for_partial_settlement("my_transaction_id", "20.00")
"""
if params is None:
params = {}
return Configuration.gateway().transaction.submit_for_partial_settlement(transaction_id, amount, params)
|
(transaction_id, amount, params=None)
|
712,522
|
braintree.transaction
|
submit_for_settlement
|
Submits an authorized transaction for settlement.
Requires the transaction id::
result = braintree.Transaction.submit_for_settlement("my_transaction_id")
|
@staticmethod
def submit_for_settlement(transaction_id, amount=None, params=None):
"""
Submits an authorized transaction for settlement.
Requires the transaction id::
result = braintree.Transaction.submit_for_settlement("my_transaction_id")
"""
if params is None:
params = {}
return Configuration.gateway().transaction.submit_for_settlement(transaction_id, amount, params)
|
(transaction_id, amount=None, params=None)
|
712,523
|
braintree.transaction
|
submit_for_settlement_signature
| null |
@staticmethod
def submit_for_settlement_signature():
return [
"order_id",
{"descriptor": ["name", "phone", "url"]},
"purchase_order_number",
"tax_amount",
"tax_exempt",
"discount_amount",
"shipping_amount",
"ships_from_postal_code",
{"industry":
[
"industry_type",
{
"data": [
"advanced_deposit", "arrival_date", "check_in_date", "check_out_date", "customer_code", "departure_date", "fare_amount", "fee_amount", "fire_safe", "folio_number", "issued_date", "issuing_carrier_code",
"lodging_check_in_date", "lodging_check_out_date", "lodging_name", "no_show", "passenger_first_name", "passenger_last_name", "passenger_middle_initial", "passenger_title", "property_phone",
"restricted_ticket", "room_rate", "room_tax", "tax_amount", "ticket_issuer_address", "ticket_number", "travel_agency_code", "travel_agency_name", "travel_package",
{
"legs": [
"arrival_airport_code", "arrival_time", "carrier_code", "conjunction_ticket", "coupon_number", "departure_airport_code", "departure_date", "departure_time", "endorsement_or_restrictions",
"exchange_ticket", "fare_amount", "fare_basis_code", "fee_amount", "flight_number", "service_class", "stopover_permitted", "tax_amount"
]
},
{
"additional_charges": [
"amount", "kind"
],
}
]
}
]
},
{"line_items":
[
"commodity_code", "description", "discount_amount", "image_url", "kind", "name", "product_code", "quantity", "tax_amount", "total_amount", "unit_amount", "unit_of_measure", "unit_tax_amount", "upc_code", "upc_type", "url,"
]
},
{"shipping":
[
"first_name", "last_name", "company", "country_code_alpha2", "country_code_alpha3",
"country_code_numeric", "country_name", "extended_address", "locality",
"postal_code", "region", "street_address",
]
},
{"industry":
[
"industry_type",
{
"data": [
"folio_number", "check_in_date", "check_out_date", "departure_date", "lodging_check_in_date", "lodging_check_out_date", "travel_package", "lodging_name", "room_rate",
"passenger_first_name", "passenger_last_name", "passenger_middle_initial", "passenger_title", "issued_date", "travel_agency_name", "travel_agency_code", "ticket_number",
"issuing_carrier_code", "customer_code", "fare_amount", "fee_amount", "room_tax", "tax_amount", "restricted_ticket", "no_show", "advanced_deposit", "fire_safe", "property_phone", "arrival_date", "ticket_issuer_address", "date_of_birth", "country_code",
{
"legs": [
"conjunction_ticket", "exchange_ticket", "coupon_number", "service_class", "carrier_code", "fare_basis_code", "flight_number", "departure_date", "departure_airport_code", "departure_time",
"arrival_airport_code", "arrival_time", "stopover_permitted", "fare_amount", "fee_amount", "tax_amount", "endorsement_or_restrictions"
]
},
{
"additional_charges": [
"kind", "amount"
],
}
]
}
]
},
]
|
()
|
712,524
|
braintree.transaction
|
update_details
|
Updates existing details for transaction submitted_for_settlement.
Requires the transaction id::
result = braintree.Transaction.update_details("my_transaction_id", {
"amount": "100.00",
"order_id": "123",
"descriptor": {
"name": "123*123456789012345678",
"phone": "3334445555",
"url": "url.com"
}
)
|
@staticmethod
def update_details(transaction_id, params=None):
"""
Updates existing details for transaction submitted_for_settlement.
Requires the transaction id::
result = braintree.Transaction.update_details("my_transaction_id", {
"amount": "100.00",
"order_id": "123",
"descriptor": {
"name": "123*123456789012345678",
"phone": "3334445555",
"url": "url.com"
}
)
"""
if params is None:
params = {}
return Configuration.gateway().transaction.update_details(transaction_id, params)
|
(transaction_id, params=None)
|
712,525
|
braintree.transaction
|
update_details_signature
| null |
@staticmethod
def update_details_signature():
return ["amount", "order_id", {"descriptor": ["name", "phone", "url"]}]
|
()
|
712,527
|
braintree.transaction
|
void
|
Voids an existing transaction.
It expects a transaction_id.::
result = braintree.Transaction.void("my_transaction_id")
|
@staticmethod
def void(transaction_id):
"""
Voids an existing transaction.
It expects a transaction_id.::
result = braintree.Transaction.void("my_transaction_id")
"""
return Configuration.gateway().transaction.void(transaction_id)
|
(transaction_id)
|
712,528
|
braintree.transaction_amounts
|
TransactionAmounts
|
A class of constants for transaction amounts that will cause different statuses.
|
class TransactionAmounts(object):
""" A class of constants for transaction amounts that will cause different statuses. """
Authorize = "1000.00"
Decline = "2000.00"
HardDecline = "2015.00"
Fail = "3000.00"
|
()
|
712,529
|
braintree.transaction_details
|
TransactionDetails
| null |
class TransactionDetails(AttributeGetter):
def __init__(self, attributes):
AttributeGetter.__init__(self, attributes)
if getattr(self, "amount", None) is not None:
self.amount = Decimal(self.amount)
|
(attributes)
|
712,530
|
braintree.transaction_details
|
__init__
| null |
def __init__(self, attributes):
AttributeGetter.__init__(self, attributes)
if getattr(self, "amount", None) is not None:
self.amount = Decimal(self.amount)
|
(self, attributes)
|
712,532
|
braintree.transaction_gateway
|
TransactionGateway
| null |
class TransactionGateway(object):
def __init__(self, gateway):
self.gateway = gateway
self.config = gateway.config
def adjust_authorization(self, transaction_id, amount):
transaction_params = {"amount": amount}
response = self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/adjust_authorization", {"transaction": transaction_params})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def clone_transaction(self, transaction_id, params):
Resource.verify_keys(params, Transaction.clone_signature())
return self._post("/transactions/" + transaction_id + "/clone", {"transaction-clone": params})
def cancel_release(self, transaction_id):
response = self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/cancel_release", {})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def create(self, params):
Resource.verify_keys(params, Transaction.create_signature())
self.__check_for_deprecated_attributes(params)
return self._post("/transactions", {"transaction": params})
def credit(self, params):
if params is None:
params = {}
params["type"] = Transaction.Type.Credit
return self.create(params)
def find(self, transaction_id):
try:
if transaction_id is None or transaction_id.strip() == "":
raise NotFoundError()
response = self.config.http().get(self.config.base_merchant_path() + "/transactions/" + transaction_id)
return Transaction(self.gateway, response["transaction"])
except NotFoundError:
raise NotFoundError("transaction with id " + repr(transaction_id) + " not found")
def hold_in_escrow(self, transaction_id):
"""
Holds an existing submerchant transaction for escrow. It expects a transaction_id. ::
result = braintree.Transaction.hold_in_escrow("my_transaction_id")
"""
response = self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/hold_in_escrow", {})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def refund(self, transaction_id, amount_or_options=None):
"""
Refunds an existing transaction. It expects a transaction_id. ::
result = braintree.Transaction.refund("my_transaction_id")
"""
if isinstance(amount_or_options, dict):
options = amount_or_options
else:
options = {
"amount": amount_or_options
}
Resource.verify_keys(options, Transaction.refund_signature())
response = self.config.http().post(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/refund", {"transaction": options})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def sale(self, params):
if "recurring" in params.keys():
warnings.warn("Use transaction_source parameter instead", DeprecationWarning)
params.update({"type": "sale"})
return self.create(params)
def search(self, *query):
if isinstance(query[0], list):
query = query[0]
response = self.config.http().post(self.config.base_merchant_path() + "/transactions/advanced_search_ids", {"search": self.__criteria(query)})
if "search_results" in response:
return ResourceCollection(query, response, self.__fetch)
else:
raise RequestTimeoutError("search timeout")
def release_from_escrow(self, transaction_id):
response = self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/release_from_escrow", {})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def submit_for_settlement(self, transaction_id, amount=None, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Transaction.submit_for_settlement_signature())
transaction_params = {"amount": amount}
transaction_params.update(params)
response = self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/submit_for_settlement",
{"transaction": transaction_params})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def update_details(self, transaction_id, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Transaction.update_details_signature())
response = self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/update_details",
{"transaction": params})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def submit_for_partial_settlement(self, transaction_id, amount, params=None):
if params is None:
params = {}
Resource.verify_keys(params, Transaction.submit_for_settlement_signature())
transaction_params = {"amount": amount}
transaction_params.update(params)
response = self.config.http().post(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/submit_for_partial_settlement",
{"transaction": transaction_params})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def package_tracking(self, transaction_id, params=None):
try:
if params is None:
params = {}
if transaction_id is None or transaction_id.strip() == "":
raise NotFoundError()
Resource.verify_keys(params, Transaction.package_tracking_signature())
response = self.config.http().post(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/shipments", {"shipment": params})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
except NotFoundError:
raise NotFoundError("transaction with id " + repr(transaction_id) + " not found")
def void(self, transaction_id):
response = self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/void")
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
def __fetch(self, query, ids):
criteria = self.__criteria(query)
criteria["ids"] = braintree.transaction_search.TransactionSearch.ids.in_list(ids).to_param()
response = self.config.http().post(self.config.base_merchant_path() + "/transactions/advanced_search", {"search": criteria})
if "credit_card_transactions" in response:
return [Transaction(self.gateway, item) for item in ResourceCollection._extract_as_array(response["credit_card_transactions"], "transaction")]
else:
raise RequestTimeoutError("search timeout")
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 _post(self, url, params=None):
if params is None:
params = {}
response = self.config.http().post(self.config.base_merchant_path() + url, params)
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
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 "three_d_secure_token" in params.keys():
warnings.warn("three_d_secure_token is deprecated, use three_d_secure_authentication_id 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,533
|
braintree.transaction_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 "three_d_secure_token" in params.keys():
warnings.warn("three_d_secure_token is deprecated, use three_d_secure_authentication_id 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,535
|
braintree.transaction_gateway
|
__fetch
| null |
def __fetch(self, query, ids):
criteria = self.__criteria(query)
criteria["ids"] = braintree.transaction_search.TransactionSearch.ids.in_list(ids).to_param()
response = self.config.http().post(self.config.base_merchant_path() + "/transactions/advanced_search", {"search": criteria})
if "credit_card_transactions" in response:
return [Transaction(self.gateway, item) for item in ResourceCollection._extract_as_array(response["credit_card_transactions"], "transaction")]
else:
raise RequestTimeoutError("search timeout")
|
(self, query, ids)
|
712,537
|
braintree.transaction_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 "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, url, params=None)
|
712,538
|
braintree.transaction_gateway
|
adjust_authorization
| null |
def adjust_authorization(self, transaction_id, amount):
transaction_params = {"amount": amount}
response = self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/adjust_authorization", {"transaction": transaction_params})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, transaction_id, amount)
|
712,539
|
braintree.transaction_gateway
|
cancel_release
| null |
def cancel_release(self, transaction_id):
response = self.config.http().put(self.config.base_merchant_path() + "/transactions/" + transaction_id + "/cancel_release", {})
if "transaction" in response:
return SuccessfulResult({"transaction": Transaction(self.gateway, response["transaction"])})
elif "api_error_response" in response:
return ErrorResult(self.gateway, response["api_error_response"])
|
(self, transaction_id)
|
712,540
|
braintree.transaction_gateway
|
clone_transaction
| null |
def clone_transaction(self, transaction_id, params):
Resource.verify_keys(params, Transaction.clone_signature())
return self._post("/transactions/" + transaction_id + "/clone", {"transaction-clone": params})
|
(self, transaction_id, params)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.