def transparent_redirect_create_url():
        """
        Returns the url to be used for creating Transactions through transparent redirect.
        """

        warnings.warn("Please use TransparentRedirect.url instead", DeprecationWarning)
        return Configuration.base_merchant_url() + "/transactions/all/create_via_transparent_redirect_request"
Example #2
0
    def transparent_redirect_create_url():
        """
        Returns the url to be used for creating Transactions through transparent redirect.
        """

        warnings.warn("Please use TransparentRedirect.url instead", DeprecationWarning)
        return Configuration.gateway().transaction.transparent_redirect_create_url()
Example #3
0
    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)
Example #4
0
    def __http_do(self, http_verb, path, params=None):
        if self.environment.is_ssl:
            self.__verify_ssl()
            conn = httplib.HTTPSConnection(self.environment.server, self.environment.port)
        else:
            conn = httplib.HTTPConnection(self.environment.server, self.environment.port)

        conn.request(
            http_verb,
            Configuration.base_merchant_path() + path,
            params and XmlUtil.xml_from_dict(params),
            self.__headers()
        )
        response = conn.getresponse()
        status = response.status

        if Http.is_error_status(status):
            conn.close()
            Http.raise_exception_from_status(status)
        else:
            data = response.read()
            conn.close()
            if len(data.strip()) == 0:
                return {}
            else:
                return XmlUtil.dict_from_xml(data)
 def sale(ideal_payment_id, transactionRequest):
     request = transactionRequest.copy()
     request["payment_method_nonce"] = ideal_payment_id
     if not "options" in request:
         request["options"] = {}
     request["options"]["submit_for_settlement"] = True
     return Configuration.gateway().transaction.sale(request)
Example #6
0
    def refund(transaction_id, amount=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)
Example #7
0
    def submit_for_settlement(transaction_id, amount=None):
        """
        Submits an authorized transaction for settlement. ::

            result = braintree.Transaction.submit_for_settlement("my_transaction_id")
        """

        return Configuration.gateway().transaction.submit_for_settlement(transaction_id, amount)
Example #8
0
    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)
Example #9
0
    def delete(customer_id):
        """
        Delete a customer, given a customer_id::

            result = braintree.Customer.delete("my_customer_id")
        """

        return Configuration.gateway().customer.delete(customer_id)
Example #10
0
 def __headers(self):
     return {
         "Accept": "application/xml",
         "Authorization": self.__authorization_header(),
         "Content-type": "application/xml",
         "User-Agent": "Braintree Python " + version.Version,
         "X-ApiVersion": Configuration.api_version(),
     }
    def cancel(subscription_id):
        """
        Cancel a subscription by subscription_id:::

            result = braintree.Subscription.cancel("my_subscription_id")
        """

        return Configuration.gateway().subscription.cancel(subscription_id)
Example #12
0
    def delete(customer_id, address_id):
        """
        Delete an address, given a customer_id and address_id::

            result = braintree.Address.delete("my_customer_id", "my_address_id")
        """

        return Configuration.gateway().address.delete(customer_id, address_id)
    def confirm(query_string):
        """
        Confirms a transparent redirect request. It expects the query string from the
        redirect request. The query string should _not_ include the leading "?" character. ::

            result = braintree.TransparentRedirect.confirm("foo=bar&id=12345")
        """
        return Configuration.gateway().transparent_redirect.confirm(query_string)
    def delete(credit_card_token):
        """
        Delete a credit card, given a credit_card_id::

            result = braintree.CreditCard.delete("my_credit_card_id")
        """

        return Configuration.gateway().credit_card.delete(credit_card_token)
Example #15
0
    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)
Example #16
0
    def find(customer_id, address_id):
        """
        Find an address, given a customer_id and address_id. This does not return
        a result object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided
        customer_id/address_id are not found. ::

            address = braintree.Address.find("my_customer_id", "my_address_id")
        """
        return Configuration.gateway().address.find(customer_id, address_id)
Example #17
0
    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)
    def find_all(transaction_id):
        """
        Find all line items on a transaction, given a transaction_id. This returns an array of TransactionLineItems.
        This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided
        transaction_id is not found. ::

            transaction_line_items = braintree.TransactionLineItem.find_all("my_transaction_id")
        """
        return Configuration.gateway().transaction_line_item.find_all(transaction_id)
Example #19
0
    def find(credit_card_token):
        """
        Find a credit card, given a credit_card_id. This does not return
        a result object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided
        credit_card_id is not found. ::

            credit_card = braintree.CreditCard.find("my_credit_card_token")
        """
        return Configuration.gateway().credit_card.find(credit_card_token)
    def from_nonce(nonce):
        """
        Convert a payment method nonce into a CreditCard. This does not return
        a result object. This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided
        credit_card_id is not found. ::

            credit_card = braintree.CreditCard.from_nonce("my_payment_method_nonce")
        """
        return Configuration.gateway().credit_card.from_nonce(nonce)
    def update(credit_card_token, params={}):
        """
        Update an existing CreditCard by credit_card_id.  The params are similar to create::

            result = braintree.CreditCard.update("my_credit_card_id", {
                "cardholder_name": "John Doe"
            })
        """

        return Configuration.gateway().credit_card.update(credit_card_token, params)
Example #22
0
    def remove_evidence(id, evidence_id):
        """
        Remove evidence on a dispute.
        This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided dispute_id or evidence_id
        is not found. ::

            result = braintree.Dispute.remove_evidence("my_dispute_id", "my_evidence_id")
        """

        return Configuration.gateway().dispute.remove_evidence(id, evidence_id)
Example #23
0
    def accept(id):
        """
        Accept a dispute, given a dispute_id.
        This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided dispute_id
        is not found. ::

            result = braintree.Dispute.accept("my_dispute_id")
        """

        return Configuration.gateway().dispute.accept(id)
Example #24
0
    def find(id):
        """
        Find an dispute, given a dispute_id.  This does not return a result
        object.  This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided dispute_id
        is not found. ::

            dispute = braintree.Dispute.find("my_dispute_id")
        """

        return Configuration.gateway().dispute.find(id)
Example #25
0
    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)
Example #26
0
    def update(customer_id, address_id, params={}):
        """
        Update an existing Address. A customer_id and address_id are required::

            result = braintree.Address.update("my_customer_id", "my_address_id", {
                "first_name": "John"
            })
        """

        return Configuration.gateway().address.update(customer_id, address_id, params)
Example #27
0
    def find(customer_id):
        """
        Find an customer, given a customer_id.  This does not return a result
        object.  This will raise a :class:`NotFoundError <braintree.exceptions.not_found_error.NotFoundError>` if the provided customer_id
        is not found. ::

            customer = braintree.Customer.find("my_customer_id")
        """

        return Configuration.gateway().customer.find(customer_id)
Example #28
0
    def update(customer_id, params={}):
        """
        Update an existing Customer by customer_id.  The params are similar to create::

            result = braintree.Customer.update("my_customer_id", {
                "last_name": "Smith"
            })
        """

        return Configuration.gateway().customer.update(customer_id, params)
Example #29
0
    def confirm_transparent_redirect(query_string):
        """
        Confirms a transparent redirect request. It expects the query string from the
        redirect request. The query string should _not_ include the leading "?" character. ::

            result = braintree.Transaction.confirm_transparent_redirect_request("foo=bar&id=12345")
        """

        warnings.warn("Please use TransparentRedirect.confirm instead", DeprecationWarning)
        return Configuration.gateway().transaction.confirm_transparent_redirect(query_string)
Example #30
0
    def generate(params=None, gateway=None):

        if gateway is None:
            gateway = Configuration.gateway().client_token

        if params and "options" in params and not "customer_id" in params:
            for option in ["verify_card", "make_default", "fail_on_duplicate_payment_method"]:
                if option in params["options"]:
                    raise exceptions.InvalidSignatureError("cannot specify %s without a customer_id" % option)

        return gateway.generate(params)
Example #31
0
 def expired():
     """ Return a collection of expired credit cards. """
     return Configuration.gateway().credit_card.expired()
Example #32
0
 def get_gateway():
     config = Configuration("development",
                            "integration_merchant_id",
                            public_key="integration_public_key",
                            private_key="integration_private_key")
     return BraintreeGateway(config)
Example #33
0
 def search(*query):
     return Configuration.gateway().customer.search(*query)
Example #34
0
 def all():
     """ Return a collection of all customers. """
     return Configuration.gateway().customer.all()
Example #35
0
 def search(*query):
     return Configuration.gateway().transaction.search(*query)
Example #36
0
 def create(params={}):
     return Configuration.gateway().merchant_account.create(params)
Example #37
0
 def update(id, attributes):
     return Configuration.gateway().merchant_account.update(id, attributes)
Example #38
0
 def find(id):
     return Configuration.gateway().merchant_account.find(id)
Example #39
0
 def setUp(self):
     config = Configuration(braintree.Environment.Production, "", "", "")
     braintree_gateway = BraintreeGateway(config)
     self.gateway = TestingGateway(braintree_gateway)
Example #40
0
 def transparent_redirect_update_url():
     """
     Returns the url to be used for updating CreditCards through transparent redirect.
     """
     warnings.warn("Please use TransparentRedirect.url instead", DeprecationWarning)
     return Configuration.gateway().credit_card.transparent_redirect_update_url()
Example #41
0
 def tr_data_for_sale(tr_data, redirect_url):
     """
     Builds tr_data for a Transaction of type Sale
     """
     return Configuration.gateway().transaction.tr_data_for_sale(tr_data, redirect_url)
Example #42
0
    def tr_data_for_update(tr_data, redirect_url):
        """
        Builds tr_data for CreditCard updating.
        """

        return Configuration.gateway().credit_card.tr_data_for_update(tr_data, redirect_url)
Example #43
0
 def clone_transaction(transaction_id, params):
     return Configuration.gateway().transaction.clone_transaction(transaction_id, params)
Example #44
0
    def forward(credit_card_token, receiving_merchant_id):
        """
        This method has been deprecated. Please consider the Grant API instead.
        """

        return Configuration.gateway().credit_card.forward(credit_card_token, receiving_merchant_id)
Example #45
0
    def tr_data_for_update(tr_data, redirect_url):
        """ Builds tr_data for updating a Customer. """

        return Configuration.gateway().customer.tr_data_for_update(
            tr_data, redirect_url)
Example #46
0
 def expiring_between(start_date, end_date):
     """ Return a collection of credit cards expiring between the given dates. """
     return Configuration.gateway().credit_card.expiring_between(start_date, end_date)
 def find(ideal_payment_id):
     return Configuration.gateway().ideal_payment.find(ideal_payment_id)
Example #48
0
 def line_items(transaction_id):
     """
     Find a transaction's line items, 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 transaction_id is not found. ::
     """
     return Configuration.gateway().transaction_line_item.find_all(transaction_id)