Reputation: 11
How do I retrieve the customer id from my sale result with braintree. I am able to get the transaction id but I do not understand the results fully. Thanks
$result = $gateway->transaction()->sale($sale);
if ($result->success){
$btree_cust_id = $result->transaction->customer->id;
$btree_transacton_id = $result->transaction->id;
echo "Braintree Customer ID : ".$btree_cust_id." Transaction ID: ".$btree_transacton_id;
}
Upvotes: 1
Views: 2623
Reputation: 896
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
According to the Braintree developer docs, a Transaction result object has a customerDetails
attribute which itself has an id
attribute.
As such, you can retrieve the customer id with $result->transaction->customerDetails->id
.
Upvotes: 4