Creating transactions

Using Braintree_Transaction::sale() is the simplest way to create a credit card transaction.

You can create a transaction with just an amount and a paymentMethodNonce relayed from your client and immediately submit it for settlement:

PHP
$result = Braintree_Transaction::sale([
  'amount' => '10.00',
  'paymentMethodNonce' => nonceFromTheClient,
  'options' => [
    'submitForSettlement' => True
  ]
]);

If you want to create a new payment method in the Vault upon a successful transaction, use the options.storeInVaultOnSuccess option. If a $customerId is not included, a new customer will be created.

Card verification

When a payment method is a credit or debit card, you can use card verification to verify that the card data matches a valid, open account before storing or updating it in the Vault.

There are two ways to perform card verification. You can run one-time requests using options.verifyCard when:

Alternatively, you can always run verification regardless of the presence of $verifyCard by enabling card verification in the Control Panel.

In both cases, the gateway verifies cards by running either a $0 or $1 authorization and then automatically voiding it. If you'd like, you can specify a different options.verificationAmount to use for the authorization.

PHP
$result = Braintree_PaymentMethod::create([
  'customerId' => 'the_customer_id',
  'paymentMethodNonce' => nonceFromTheClient,
  'options' => [
    'verifyCard' => true,
    'verificationMerchantAccountId' => 'the_merchant_account_id',
    'verificationAmount' => '2.00',
  ]
]);
important

If you are using our Advanced Fraud Tools, we strongly recommend passing $deviceData each time you verify a card.

Verification results

You'll receive a Braintree_CreditCardVerification response object within a Braintree_Customer or Braintree_PaymentMethod result if:

  1. A verification ran, and
  2. It was returned with a status of processor_declined or gateway_rejected

Successful results will not return a verification response object.

Reasons for unsuccessful verification results

You can check the processorResponseCode and processorResponseText for the specific reason that a verification was processor_declined.

PHP
$result = Braintree_PaymentMethod::create([
    'customerId' => 'the_customer_id',
    'paymentMethodNonce' => nonceFromTheClient,
    'options' => [
        'verifyCard' => true
    ]
]);

$result->success;
// false

$verification = $result->creditCardVerification;
$verification->status;
// "processor_declined"

$verification->processorResponseCode;
// "2000"

$verification->processorResponseText;
// "Do Not Honor"

If the status is gateway_rejected, you can check the gatewayRejectionReason for the specific reason. Learn more about gateway rejections.

PHP
$result->success;
// false

$verification = $result->creditCardVerification;
$verification->status;
// "gateway_rejected"

$verification->gatewayRejectionReason;
// "cvv"

Verifications on sub-merchant accounts

For those using Braintree Marketplace, verifications cannot be done using sub-merchant accounts. See Braintree Marketplace Verifications for more details.

See also

Next: Testing and Go Live →

Still Have Questions?

If you can’t find an answer, give us a call at 877.434.2894 or contact our Support team