Reputation: 401
What is the correct way of reading the return object from the Braintree_PaymentMethod::create call ? I would like to access the auto-generated token.
I am doing this currently:
$result = $output->paymentMethod->_attributes['token']
I couldn't find it in the Braintree documentation.
Upvotes: 0
Views: 248
Reputation: 743
Below is a snippet demonstrating how to retrieve the token from a successful payment method creation.
$result = Braintree_PaymentMethod::create(array(
'customerId' => 'existing-customer',
'paymentMethodNonce' => 'valid-nonce'
));
$token = $result->paymentMethod->token;
More information about result objects
Upvotes: 3