Search code examples
braintree

How to verify credit card and post a sale in a single API transaction?


edit:

tl;dr: you can't.

You have to create a payment method in order to verify it. Creating a sale does NOT invoke verification, even if verification is enabled globally.

original:

I'm reading about credit card verification, which apparently isn't done automatically during Braintree_Transaction::sale(), but I don't see any options to enable verification on calling sale().

Do I really have to implement (at least) two separate API transactions just to verify a credit card?

Ideally I would like to use a single call to ::sale() to perform validation, authorization, and capture.

I have already enabled verification through my control panel, and I'm using test credit card number 4000111111111115 which, is supposed to be declined, but i'm getting successful transactions with it.

Do I have to create a payment method separately in order to perform validation, even if I have global validation enabled?


Solution

  • Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

    To test card verification results, please adjust the amount of your transaction. Because these cards are not linked to real accounts, Braintree cannot make the small authorization charges that are made in production, and instead the API must rely on the amount of the test transaction to dictate the expected response.

    In a Production environment, Card verification is triggered by the creation of payment methods, not by transactions. To enable verification, either enable it across all payment methods, or add the verifyCard option to your PaymentMethod::Create call. The response to PaymentMethod::Create in either of these cases will contain a creditCardVerification object if the verification fails for any reason, allowing you to stop the transaction before sale is called.