How to get Braintree transaction ID

Is there a way I got the transaction ID for the sale I just made. Here is what I still have:

>>> sale=braintree.Transaction.sale({'amount': '0.05', 'customer_id': '17419473'}) >>> sale.transaction <Transaction {amount: Decimal('0.05'), credit_card: {u'bin': u'411111', u'expiration_month': u'12', u'unique_number_identifier': u'a05f827ae3578b49d685ee2200dfaa97', u'prepaid': u'Unknown', u'expiration_year': u'2024', u'durbin_regulated': u'Unknown', u'payroll': u'Unknown', u'debit': u'Unknown', u'commercial': u'Unknown', u'issuing_bank': u'Unknown', u'last_4': u'1111', u'card_type': u'Visa', u'cardholder_name': None, u'token': u'9k5jxr', u'customer_location': u'US', u'image_url': u'https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=sandbox', u'country_of_issuance': u'Unknown', u'healthcare': u'Unknown', u'venmo_sdk': False, u'product_id': u'Unknown'}} at 4510688208> 

Unfortunately, I do not see TransactionID in the above release. In fact, I only see the amount and credit_card . How can I get a TransactionID from a sale? My use case is that after the user pays for something, I want to save this transaction ID for the purchase.

+6
source share
2 answers

You are currently viewing the string representation of the object, not all the attributes that the Transaction object has. Try dir(sale.transaction) to see all the attributes that the object has.

Most likely you are looking for the attribute sale.transaction.id or sale.transaction.order_id (see docs ), depending on whether you want the record / object identifier or order identifier from the point of view of the client.

+8
source

sale.transaction.id should provide you with a transaction id.

+2
source

Source: https://habr.com/ru/post/978116/


All Articles