See also the Transaction response object.

To create a transaction, you must include an Amount and either a PaymentMethodNonce, a PaymentMethodToken, or a CustomerId. Passing a CustomerId is equivalent to passing the PaymentMethodToken of the customer's default payment method.

The following example creates a transaction using a PaymentMethodNonce from a client and instructs that it should be submitted for settlement immediately using Options.SubmitForSettlement. You can see more examples, including using a vaulted payment method, below the parameter reference.

C♯
Copy
Copied
var request = new TransactionRequest
{
    Amount = 10.00M,
    PaymentMethodNonce = nonceFromTheClient,
    Options = new TransactionOptionsRequest
    {
        SubmitForSettlement = true
    }
};

Result<Transaction> result = gateway.Transaction.Sale(request);
if (result.IsSuccess()) {
  // See result.Target for details
} else {
  // Handle errors
}
Parameters
Amount required, Decimal

The billing amount of the request. This value must be greater than 0, and must match the currency format of the merchant account. Can't be greater than the maximum allowed by the processor. Contact our Support team for your specific limit.

BillingAddress

Billing address information associated with a specific customer ID.

AVS rules are not applied when creating a transaction from a Vault record using a payment method token. We still submit the street address and postal code to the processor to run AVS checks. The transaction response includes processor AVS response codes.

Company string

Company name. 255 character maximum.

CountryCodeAlpha2 string

The ISO 3166-1 alpha-2 country code specified in an address. The gateway only accepts specific alpha-2 values.

PayPal transactions must use the alpha-2 format. See PayPal's country code documentation for details.

CountryCodeAlpha3 string

The ISO 3166-1 alpha-3 country code specified in an address. The gateway only accepts specific alpha-3 values.

CountryCodeNumeric string

The ISO 3166-1 numeric country code specified in an address. The gateway only accepts specific numeric values.

CountryName string

The country name specified in an address. We only accept specific country names.

ExtendedAddress string

The extended address information—such as apartment or suite number. 255 character maximum.

FirstName string

The first name. The first name value must be less than or equal to 255 characters.

LastName string

The last name. The last name value must be less than or equal to 255 characters.

Locality string

The locality/city. 255 character maximum.

PostalCode string

The postal code. Postal code must be a string of 4-9 alphanumeric characters, optionally separated by a dash or a space. Spaces, hyphens, and all other special characters are ignored.

Region string

The state or province. For PayPal addresses, the region must meet PayPal's state restrictions; for all other payment methods, it must be less than or equal to 255 characters.

StreetAddress string

The billing street address. 255 character maximum. Required when AVS rules are configured to require street address.

BillingAddressId string

The two-letter value for an address associated with a specific customer ID. The maximum number of addresses per customer is 50.

Channel string

For Partners and shopping carts only

If you are a shopping cart provider or other Braintree Partner, pass a string identifier for your service. For PayPal transactions, this maps to paypal.bn_code.

CreditCard

Typically requires PCI SAQ D compliance

We recommend using PaymentMethodNonce to avoid any PCI concerns with raw credit card data being present on your server.

A credit or debit payment method.

CardholderName string

The name associated with the credit card. Must be less than or equal to 175 characters.

Cvv string

A 3 or 4 digit card verification value assigned to credit cards.

To meet PCI guidelines, CVV will never be stored in the gateway. CVV is not required when creating a transaction from Vault tokens; CVV rules will be applied to transactions if and only if the CVV is supplied with the tokens.

CVV checking can also be done when you create or update the Vault record by using card verification.

ExpirationDate string

The expiration date, formatted MM/YY or MM/YYYY. May be used instead of expiration_month and expiration_year.

ExpirationMonth int

The expiration month of a credit card, formatted MM. May be used with expiration_year, and instead of expiration_date.

ExpirationYear int

The two or four digit year associated with a credit card, formatted YYYY or YY. May be used with expiration_month, and instead of expiration_date.

Number string

The 12-19 digit value consisting of a bank identification number (BIN) and primary account number (PAN).

Token string

An alphanumeric value that references a specific payment method stored in your Vault. Must be less than or equal to 36 characters. If using a custom integration, you can specify what you want the token to be. If not specified, the gateway will generate one that can be accessed on the result. If using our Drop-in UI, you can't specify your own token. Length and format of gateway-generated tokens and IDs may change at any time.

CustomFields

A collection of custom field/value pairs. Fields and values must be less than 255 characters. You must set up each custom field in the Control Panel prior to passing it with a request. Querying this value returns a collection of custom field values stored on the transaction object.

Customer

When storing a new customer in the Vault, you can use this object to specify the customer's details. Only use this parameter when creating a new customer with a new payment method. See the customer object for further detail.

Company string

Company name. 255 character maximum.

Email string

Email address composed of ASCII characters. 255 character maximum.

Fax string

Fax number. 255 character maximum.

FirstName string

The first name. The first name value must be less than or equal to 255 characters.

Id string

A string value that will represent this specific customer in your Vault. 36 character maximum; must be unique within your Vault; valid characters are letters, numbers, -, and _; the words "all" and "new" currently can't be used. If not specified on creation, the gateway will generate an alphanumeric ID that can be accessed on the result. The generated IDs will never start with a leading 0 and are case insensitive.

LastName string

The last name. The last name value must be less than or equal to 255 characters.

Phone string

Phone number. Phone must be 10-14 characters and can only contain numbers, dashes, parentheses and periods.

Website string

Website URL. Must be less than or equal to 255 characters. Website must be well-formed. The URL scheme is optional.

CustomerId string

A string value representing an existing customer in your Vault that you want to charge.

Descriptor

Dynamic descriptors are not enabled on all accounts by default. If you receive a validation error of 92203 or if your dynamic descriptors are not displaying as expected, please contact our Support team.

Dynamic descriptors are sent on a per-transaction basis and define what will appear on your customers' credit card statements for a specific purchase. The clearer the description of your product, the less likely customers will issue chargebacks due to confusion or non-recognition.

See the dynamic descriptor example for additional information.

Name string

The value in the business name field of a customer's statement. The specific length/character requirements for this value depend on your processor. Contact our Support team for assistance.

Phone string

The value in the phone number field of a customer's statement. Phone must be 10-14 characters and can only contain numbers, dashes, parentheses and periods.

Url string

The value in the URL/web address field of a customer's statement. The URL must be 13 characters or shorter.

DeviceData string

Customer device information. Required when creating transactions on the following payment method types:

This value will contain a Fraud Merchant ID as the unique, numeric identifier for a Kount account and a Device Session ID as the unique identifier for a customer device. For PayPal and Venmo transactions, this value will also include a PayPal Correlation ID.

DeviceSessionId string

A unique alphanumeric identifier used by our Advanced Fraud Tools to link a device to transactions.

MerchantAccountId string

The merchant account ID used to create a transaction. Currency is also determined by merchant account ID. If no merchant account ID is specified, we will use your default merchant account.

Options

Optional values that can be passed with a request.

AddBillingAddressToPaymentMethod bool

The option that determines whether the billing address information provided in the request should be added to the payment method specified. This option works only for new payment methods.

HoldInEscrow bool

For Braintree Marketplace merchants only. This value specifies whether a transaction is held in escrow. See Escrow for more detail.

Paypal

PayPal-specific options.

CustomField string

Variable passed directly to PayPal via the API for your own tracking purposes. Customers do not see this value, but you can see it in reports from your PayPal console. It also appears in the Braintree Control Panel on the Transaction Details page of the associated PayPal transaction, and in the CSV file of downloaded transaction searches. Unlike Braintree custom fields, this field does not need to be configured in the Braintree Control Panel.

Description string

Description of the transaction that is displayed to customers in PayPal email receipts. Max 127 characters.

SkipAdvancedFraudChecking boolean

Prevents the transaction from being sent to Kount for evaluation as part of Advanced Fraud Tools checks. Use with caution – once you've skipped checks for a transaction, it is not possible to run them retroactively.

SkipAvs boolean

Skip AVS checks for the transaction. Will result in a processor response code of B for AvsPostalCodeResponseCode and AvsStreetAddressResponseCode, and nil for AvsErrorResponseCode. Use with caution – once you've skipped checks for a transaction, it is not possible to run them retroactively.

SkipCvv boolean

Skip CVV checks for the transaction. Will result in a processor response code of B for CvvResponseCode. Use with caution – once you've skipped checks for a transaction, it is not possible to run them retroactively.

StoreInVault bool

The option that determines whether the payment method should be stored in the Vault, regardless of the transaction's success.

StoreInVaultOnSuccess bool

The option that determines whether the payment method associated with the successful transaction should be stored in the Vault.

StoreShippingAddressInVault bool

The option that determines whether the shipping address information provided with the transaction should be associated with the customer ID specified. When passed, the payment method will always be stored in the Vault.

SubmitForSettlement bool

The option that determines whether an authorized transaction is submitted for settlement.

ThreeDSecure

Options for 3D Secure verification. Can only be used when the payment method nonce parameter is present.

Required bool

Specify whether to require 3D Secure verification to succeed before creating a transaction. Defaults to true unless you explicitly pass false. For more information, see the 3D Secure server-side implementation guide.

OrderId string

Use this field to pass additional information about the transaction. On PayPal transactions, this field maps to the PayPal invoice number. PayPal invoice numbers must be unique in your PayPal business account. Maximum 255 characters or 127 for PayPal transactions.

PaymentMethodNonce string

One-time-use reference to payment information provided by your customer, such as a credit card or PayPal account. Can be passed instead of a PaymentMethodToken parameter.

PaymentMethodToken string

An alphanumeric value that references a specific payment method stored in your Vault. Must be less than or equal to 36 characters. If using a custom integration, you can specify what you want the token to be. If not specified, the gateway will generate one that can be accessed on the result. If using our Drop-in UI, you can't specify your own token. Length and format of gateway-generated tokens and IDs may change at any time.

PurchaseOrderNumber string

A Level II data field that can be used to pass a purchase order identification value of up to 12 ASCII characters for AIB and 17 ASCII characters for all other processors.

Recurring bool

A value indicating whether the transaction is being passed with a recurring ecommerce indicator (ECI) flag. If passed, the amount submitted for settlement must exactly match the authorized amount.

RiskData

Customer device information, which is sent directly to supported processors for fraud analysis. These fields are automatically populated if using Advanced Fraud Tools. Currently only available when processing American Express via Amex Direct. Contact our Support team with any questions.

CustomerBrowser string

The User-Agent header provided by the customer's browser, which gives information about the browser. Maximum 255 characters.

CustomerIp string

The customer's IP address.

ServiceFeeAmount Decimal

The portion of a sub-merchant's transaction revenue that is routed to the master merchant account. If set, this value must be greater than or equal to 0, must match the appropriate currency format, and can't exceed the transaction amount.

Available to Braintree Marketplace merchants and Partners. See charging a service fee and holding funds in escrow on Braintree Marketplace transactions.

SharedBillingAddressId string

For Shared Vault only

The ID of an address belonging to the OAuth application owner. If used in conjunction with a SharedCustomerId, must belong to the specified customer.

SharedCustomerId string

For Shared Vault only

The ID of a customer belonging to the OAuth application owner. If no SharedPaymentMethodToken is specified, the customer's default payment method will be used.

SharedPaymentMethodToken string

For Shared Vault only

The token of a payment method belonging to the OAuth application owner. If no SharedCustomerId is explicitly specified, the customer that owns the payment method is implicitly specified. If used in conjunction with a SharedCustomerId, must belong to the specified customer.

SharedShippingAddressId string

For Shared Vault only

The ID of an address belonging to the OAuth application owner. If used in conjunction with a SharedCustomerId, must belong to the specified customer.

ShippingAddress

Shipping address information associated with a specific customer ID.

Company string

Company name. 255 character maximum.

CountryCodeAlpha2 string

The ISO 3166-1 alpha-2 country code specified in an address. The gateway only accepts specific alpha-2 values.

CountryCodeAlpha3 string

The ISO 3166-1 alpha-3 country code specified in an address. The gateway only accepts specific alpha-3 values.

CountryCodeNumeric string

The ISO 3166-1 numeric country code specified in an address. The gateway only accepts specific numeric values.

CountryName string

The country name specified in an address. We only accept specific country names.

ExtendedAddress string

The extended address information—such as apartment or suite number. 255 character maximum.

FirstName string

The first name. The first name value must be less than or equal to 255 characters. Required if passing a PayPal shipping address.

LastName string

The last name. The last name value must be less than or equal to 255 characters. Required if passing a PayPal shipping address.

Locality string

The locality/city. 255 character maximum. Required if passing a PayPal shipping address.

PostalCode string

The postal code. Postal code must be a string of 4-9 alphanumeric characters, optionally separated by a dash or a space. Spaces, hyphens, and all other special characters are ignored. Required if passing a PayPal shipping address.

Region string

The state or province. For PayPal addresses, the region must meet PayPal's state restrictions; for all other payment methods, it must be less than or equal to 255 characters. Required if passing a PayPal shipping address.

StreetAddress string

The street address. 255 character maximum. Only required for verification when AVS rules are configured to require street address. Required if passing a PayPal shipping address.

ShippingAddressId string

A shipping address associated with a specific customer ID. The maximum number of addresses per customer is 50.

TaxAmount Decimal

A Level II data field that specifies the amount of tax that was included in the total transaction amount. It can't be negative, and it does not add to the total transaction amount.

TaxExempt bool

A Level II data field that indicates whether or not the transaction should be considered eligible for tax exemption. This does not affect the total transaction amount.

ThreeDSecurePassThru

Results of a merchant-performed 3D Secure authentication. You will only need to use these fields if you've performed your own integration with a 3D Secure MPI provider (e.g. Cardinal Centinel). Otherwise, Braintree's SDKs handle this for you in our standard 3D Secure integration.

Cavv string

Cardholder authentication verification value.

EciFlag required, string

Electronic commerce indicator.

Xid string

Transaction identifier resulting from 3D Secure authentication.

TransactionSource string

Specifies the type of ecommerce indicator (ECI) flag to pass with the transaction. Accepted values:

  • recurring_first = Transactions that are initiated by the customer that represent the first in a series of recurring payments or a subscription.
  • recurring = Transactions that are initiated by the merchant for recurring payments or subscriptions.
  • moto = Transactions that are initiated by the customer for mail or telephone orders.
  • merchant = Transactions that are initiated by the merchant for non-recurring transactions or unscheduled payments.

Overrides the separate Recurring param if both are present. If neither param is present, the default ecom ECI flag will be passed and the transaction is assumed to have been initiated by the customer or by a customer interaction.

Examples

Full example

Here is an example of passing in everything a typical merchant might use.

Some parameters are mutually exclusive, so we'll show those in separate examples. If there is anything you want to store with the transaction details that we don't have a field for, you can always use custom fields.

C♯
Copy
Copied
TransactionRequest request = new TransactionRequest
{
    Amount = 10.00M,
    OrderId = "order id",
    MerchantAccountId = "a_merchant_account_id",
    PaymentMethodNonce = nonceFromTheClient,
    Customer = new CustomerRequest
    {
        FirstName = "Drew",
        LastName = "Smith",
        Company = "Braintree",
        Phone = "312-555-1234",
        Fax = "312-555-1235",
        Website = "http://www.example.com",
        Email = "drew@example.com"
    },
    BillingAddress = new AddressRequest
    {
        FirstName = "Paul",
        LastName = "Smith",
        Company = "Braintree",
        StreetAddress = "1 E Main St",
        ExtendedAddress = "Suite 403",
        Locality = "Chicago",
        Region = "IL",
        PostalCode = "60622",
        CountryCodeAlpha2 = "US"
    },
    ShippingAddress = new AddressRequest
    {
        FirstName = "Jen",
        LastName = "Smith",
        Company = "Braintree",
        StreetAddress = "1 E 1st St",
        ExtendedAddress = "Suite 403",
        Locality = "Bartlett",
        Region = "IL",
        PostalCode = "60103",
        CountryCodeAlpha2 = "US"
    },
    Options = new TransactionOptionsRequest
    {
        SubmitForSettlement = true
    },
};

Result<Transaction> result = gateway.Transaction.Sale(request);

If all the parameters are valid, a transaction will be created with a status of submitted_for_settlement and success? will return true.

C♯
Copy
Copied
if (result.IsSuccess())
{
    Transaction transaction = result.Target;
    Console.WriteLine(transaction.Type);   // TransactionType.CREDIT
    Console.WriteLine(transaction.Status); // TransactionStatus.SUBMITTED_FOR_SETTLEMENT
}

Storing in Vault

When creating a transaction, you can also store the payment method in your Vault.

Existing customer with new payment method

To associate this transaction's payment method with an existing customer, pass a CustomerId along with Options.StoreInVault or Options.StoreInVaultOnSuccess as true.

C♯
Copy
Copied
TransactionRequest request = new TransactionRequest
{
    Amount = 10.00M,
    paymentMethodNonce: nonceFromTheClient,
    CustomerId = "the_customer_id",
    Options = new TransactionOptionsRequest
    {
        StoreInVaultOnSuccess = true
    }
};

Result<Transaction> result = gateway.Transaction.Sale(request);

New customer with new payment method

To store a payment method for a new customer, set Options.StoreInVault or Options.StoreInVaultOnSuccess to true on your transaction. You can optionally specify Customer parameters for your new customer, as well:

C♯
Copy
Copied
TransactionRequest request = new TransactionRequest
{
    Amount = 10.00M,
    paymentMethodNonce: nonceFromTheClient,
    Customer = new CustomerRequest
    {
        Id = "a_customer_id"
    },
    Options = new TransactionOptionsRequest
    {
        StoreInVaultOnSuccess = true
    }
};

Result<Transaction> result = gateway.Transaction.Sale(request);
note

storeInVaultOnSuccess vaults the payment method only if the transaction is successful.

Using a vaulted payment method

You can create a transaction using a payment method stored in the Vault by passing a PaymentMethodToken:

C♯
Copy
Copied
var result = gateway.Transaction.Sale(
    new TransactionRequest
    {
        PaymentMethodToken = "the_token",
        Amount = 10.00M
    });

Or use CustomerId, which will use the customer's default payment method:

C♯
Copy
Copied
var result = gateway.Transaction.Sale(
    new TransactionRequest
    {
        CustomerId = "the_customer_id",
        Amount = 10.00M
    });

Specify merchant account

To specify which merchant account to use, pass the MerchantAccountId when creating the transaction.

C♯
Copy
Copied
TransactionRequest request = new TransactionRequest
{
    Amount = 100.00M,
    MerchantAccountId = "your_merchant_account",
    PaymentMethodNonce = nonceFromTheClient
};

Result<Transaction> result = gateway.Transaction.Credit(request);

If you don't specify the merchant account to use to process a transaction, Braintree will process it using your default merchant account.

If you would like to change which merchant account is default, contact our Support team.

Using stored addresses

You can use addresses stored on a customer by passing the address's ID. This works for both the shipping address and billing address.

C♯
Copy
Copied
var result = gateway.Transaction.Sale(
    new TransactionRequest
    {
        CustomerId = "the_customer_id",
        Amount = 10.00M,
        BillingAddressId = "AA",
        ShippingAddressId = "AB"
    });

Custom fields

Whatever you configure as the API name for your custom fields will be used when setting them on the transaction. Here is an example of setting custom fields with API names of custom_field_one and custom_field_two.

C♯
Copy
Copied
var result = gateway.Transaction.Sale(
    new TransactionRequest
    {
        Amount = 10.00M,
        PaymentMethodNonce = nonceFromTheClient,
        CustomFields = new Dictionary<string, string>
        {
            { "custom_field_one", "value one" },
            { "custom_field_two", "value two" }
        }
    });

if (result.IsSuccess())
{
  Dictionary<string, string> customFields = result.Target.CustomFields;
}

Dynamic descriptors

Dynamic descriptors are typically composed of a name and phone number or URL. The name generally includes both the business name and product name, separated by an asterisk (*). Depending on the type of transaction you're creating, the length/character limits may differ from those outlined above. For example, you can only specify up to 18 characters for dynamic descriptor names on Braintree Marketplace transactions. See below for details on PayPal and Braintree Marketplace dynamic descriptors.

Your processor may also restrict which descriptor values you can pass; certain processors allow you to pass URLs instead of phone numbers, while others accept only phone numbers or only names. If your processor supports URLs and you send both a phone number and URL, we will only pass the URL to the processor. Contact Support for more information on your processor's specific requirements.

C♯
Copy
Copied
Result<Transaction> result = gateway.Transaction.Sale(
  new TransactionRequest
  {
      Amount = 10.00M,
      PaymentMethodNonce = nonceFromTheClient,
      Descriptor = new DescriptorRequest
      {
        Name = "company*my product",
        Phone = "3125551212",
        Url = "company.com"
      }
  });

Transaction transaction = result.Target;
transaction.Descriptor.Name;
// "company*my product"

transaction.Descriptor.Phone;
// "3125551212"

PayPal

Only the Name of the descriptor will be passed for PayPal transactions. The PayPal dynamic descriptor includes the prefix PAYPAL * by default and is truncated to a total of 22 characters to follow PayPal's descriptor character limit.

The payment information displayed to a customer in their PayPal account overview does not contain the dynamic descriptor. The information displayed there is data the merchant has configured with PayPal directly (e.g. business name, email address, business contact details).

Braintree Marketplace

The only dynamic descriptor value we will pass for Braintree Marketplace transactions is the Name you specify. We will not send any dynamic Phone or Url values to the processor, but we will pass the Phone from the hard descriptor on your master merchant account.

The dynamic descriptor name can only contain the ASCII characters a-z, A-Z, the numbers 0-9, and the characters .-+ and spaces (it can't contain special characters like Ñ, ü, and é). The maximum length is 18 characters; we will truncate any longer strings. The descriptor we pass to the processor will start with "BT *", followed by the Name you specify.

  • If the specified name is 12 characters or fewer, the descriptor we pass to the processor will end with a randomly generated 6-character string (e.g. 123abc) which identifies the sub-merchant:
    Copy
    Copied
    BT *MYDESCRIPTOR123abc
  • If the specified name is 13 characters or greater, the descriptor we pass to the processor will not end with a randomly generated 6-character string:
    Copy
    Copied
    BT *MYDESCRIPTORISLONG
note

The sub-merchant can't access the 6-character string—we automatically append it to the descriptor name after you submit the transaction request. The string can't be changed, as it is required in order to identify each transaction we process for the sub-merchant.

Hold a Braintree Marketplace transaction in escrow on creation

Upon creating a Braintree Marketplace transaction, you can specify that its funds should be held in escrow. These funds can then be released at your discretion. By default, funds are not held in escrow.

C♯
Copy
Copied
TransactionRequest request = new TransactionRequest
{
   Amount = 100.0m,
   MerchantAccountId = "blue_ladders_store",
   PaymentMethodNonce = nonceFromTheClient,
   Options = new TransactionOptionsRequest
   {
      SubmitForSettlement = true,
      HoldInEscrow = true
   },
   ServiceFeeAmount = 10.00m
};

Result<Transaction> result = gateway.Transaction.Sale(request);

Still have questions?

If you can’t find an answer, contact our Support team.