Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get transaction ID in braintree sale

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.

like image 241
David542 Avatar asked Nov 12 '14 22:11

David542


1 Answers

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.

like image 174
Simeon Visser Avatar answered Oct 12 '22 13:10

Simeon Visser