I want to validate credit card details in one stage and register our website user and then do transaction with same credit card. Is there any way to validation credit card details without doing transaction in braintree payment gateway?
1 Answers
1
votes
Full disclosure: I work for Braintree.
Yes, it's possible to verify a credit card before charging it. First, make sure your account is set up for card verification in the control panel. For the flow you are describing, you can create a customer with the verifyCard
flag set to true
:
$result = Braintree_Customer::create([
'firstName' => 'Your',
'lastName' => 'Customer',
'email' => 'customer@example.com',
'creditCard' => [
'options' => [
'verifyCard' => 'true'
],
],
'paymentMethodNonce' => 'the-nonce',
]);
If the customer is created successfully, you can inspect the result for a CreditCardVerification object.
$verification = $result->customer->creditCards[0]->verification
You can then pull the payment method token off the created customer and use it to create a transaction.
$token = $result->customer->creditCards[0]->token
If you have additional questions about your integration, please reach out to Braintree support.