Is there a way to get the Transaction ID of a sale that I just made. Here is what I have so far:
>>> 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 don't see the TransactionID
in the above output. Actually, I only see the amount
and credit_card
info. How would I get TransactionID from the sale? My use case is that after a user pays for something, I want to store that transaction ID for the purchase.
You're currently looking at the string representation of the object, not all attributes that the Transaction
object has. Try dir(sale.transaction)
to see all the attributes that the object has.
You're most likely looking for the sale.transaction.id
or sale.transaction.order_id
attribute (see docs), depending on whether you want the record/object's identifier or the order identifier from the customer's perspective.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With