I first created a customer with the help of API, when a customer created successfully then it returned me customerId, with the help of customerId I created a credit card.
// for creating user
gateway->customer()->create([
'firstName' => $firstName,
'lastName' => $lastName,
'company' => $company,
'email' => $email,
'phone' => $phone,
'fax' => $fax,
'website' => $website
]);
//for creating card
$result = $this->gateway->creditCard()->create([
'customerId' => $customerId,
'number' => $number,
'expirationDate' => $expirationDate,
'cvv' => $cvv
After saving card in vault successfully it gives me a token In order to retrive data of card I did this:
$result = $this->gateway->creditCard()->find($token);
and it returned me the card detail, Now I want to perform payment with this card detail or token(as I am confused). previously I successfully done payment with drop in UI but I want to use vault this time
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
Now that you have the payment method token, you can pass that value as a parameter to the Transaction Sale API Call in order to complete a transaction with the saved payment method as opposed to a payment method nonce, which represents a single use payment method.
Example
$result = $gateway->transaction()->sale(
[
'paymentMethodToken' => 'the_payment_method_token',
'amount' => '100.00'
]
);