Braintree Gateway Guide

close

Services and Compatibility

Payment Gateway Company Name:
Braintree
Services that work with Spreedly:
  • Braintree
Supported operations:
Purchase, Authorize, Capture, Refund, Void, Verify, Store
Supported payment types:
Credit Card, Apple Pay, Android Pay, Google Pay
Spreedly 3DS2 Global Supported
Yes
Gateway Specific 3DS1 Supported
No
Gateway Specific 3D2 Supported
No
Regions:
Asia Pacific, Europe, North America
API endpoint URL:
Multiple; contact success@spreedly.com for more information

Authentication and Security

Specific names for credentials:
orange mode:
Login, Password
blue mode:
Merchant Account ID, Merchant ID, Public Key, Private Key

Onboarding Merchants in:

Additional Notes

As noted above, Braintree is supported on Spreedly 3DS2 Global. In order to register with our 3DS2 Global solution certain data fields are necessary to register. In order to obtain the necessary MID and ABIN fields from Braintree to onboard with Spreedly 3DS2 Global, please reach out to success@spreedly.com.

Currency restrictions

It is important to note that only one currency is permitted per merchant account; a separate gateway token is required for each currency you wish to support, and thus merchant account you need. If you send a different currency than what the merchant account is configured for, the transaction will display it as the attempted currency, but Braintree will in fact process the amount as the currency configured for that merchant account, with no conversion.

Adding a Braintree gateway

There are actually two different “modes” that you can use to authenticate with the Braintree gateway: Blue and Orange.

Blue mode

You just need to supply a merchant_id, public_key, and private_key:


curl https://core.spreedly.com/v1/gateways.xml \
  -u 'C7cRfNJGODKh4Iu5Ox3PToKjniY:4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ' \
  -H 'Content-Type: application/xml' \
  -d '<gateway>
        <gateway_type>braintree</gateway_type>
        <mode>blue</mode>
        <merchant_id>MyMerchantId</merchant_id>
        <public_key>MyPublicKey</public_key>
        <private_key>MyPrivateKey</private_key>
      </gateway>'

<gateway>
  <token>ImfYGPoGfh2wtZ9tYMxCi5iuyoO</token>
  <gateway_type>braintree</gateway_type>
  <name>Braintree</name>
  <description nil="true"/>
  <merchant_id>MyMerchantId</merchant_id>
  <public_key>MyPublicKey</public_key>
  <merchant_account_id nil="true"/>
  <characteristics>
    <supports_purchase type="boolean">true</supports_purchase>
    <supports_authorize type="boolean">true</supports_authorize>
    <supports_capture type="boolean">true</supports_capture>
    <supports_credit type="boolean">true</supports_credit>
    <supports_general_credit type="boolean">false</supports_general_credit>
    <supports_void type="boolean">true</supports_void>
    <supports_adjust type="boolean">false</supports_adjust>
    <supports_verify type="boolean">true</supports_verify>
    <supports_reference_purchase type="boolean">false</supports_reference_purchase>
    <supports_purchase_via_preauthorization type="boolean">false</supports_purchase_via_preauthorization>
    <supports_offsite_purchase type="boolean">false</supports_offsite_purchase>
    <supports_offsite_authorize type="boolean">false</supports_offsite_authorize>
    <supports_3dsecure_purchase type="boolean">false</supports_3dsecure_purchase>
    <supports_3dsecure_authorize type="boolean">false</supports_3dsecure_authorize>
    <supports_3dsecure_2_mpi_purchase type="boolean">true</supports_3dsecure_2_mpi_purchase>
    <supports_3dsecure_2_mpi_authorize type="boolean">true</supports_3dsecure_2_mpi_authorize>
    <supports_store type="boolean">true</supports_store>
    <supports_remove type="boolean">false</supports_remove>
    <supports_fraud_review type="boolean">false</supports_fraud_review>
  </characteristics>
  <credentials>
    <credential>
      <name>merchant_id</name>
      <value>MyMerchantId</value>
    </credential>
    <credential>
      <name>public_key</name>
      <value>MyPublicKey</value>
    </credential>
    <credential>
      <name>merchant_account_id</name>
      <value nil="true"/>
    </credential>
  </credentials>
  <gateway_settings>
  </gateway_settings>
  <gateway_specific_fields>
    <gateway_specific_field>descriptor_name</gateway_specific_field>
    <gateway_specific_field>descriptor_phone</gateway_specific_field>
    <gateway_specific_field>descriptor_url</gateway_specific_field>
    <gateway_specific_field>service_fee_amount</gateway_specific_field>
    <gateway_specific_field>merchant_account_id</gateway_specific_field>
    <gateway_specific_field>hold_in_escrow</gateway_specific_field>
    <gateway_specific_field>customer_id</gateway_specific_field>
    <gateway_specific_field>custom_fields</gateway_specific_field>
    <gateway_specific_field>recurring</gateway_specific_field>
    <gateway_specific_field>transaction_source</gateway_specific_field>
    <gateway_specific_field>map_to_customer_id</gateway_specific_field>
    <gateway_specific_field>skip_advanced_fraud_checking</gateway_specific_field>
    <gateway_specific_field>tax_amount</gateway_specific_field>
    <gateway_specific_field>tax_exempt</gateway_specific_field>
    <gateway_specific_field>purchase_order_number</gateway_specific_field>
    <gateway_specific_field>shipping_amount</gateway_specific_field>
    <gateway_specific_field>discount_amount</gateway_specific_field>
    <gateway_specific_field>ships_from_postal_code</gateway_specific_field>
    <gateway_specific_field>line_items</gateway_specific_field>
    <gateway_specific_field>device_data</gateway_specific_field>
    <gateway_specific_field>skip_avs</gateway_specific_field>
    <gateway_specific_field>skip_cvv</gateway_specific_field>
    <gateway_specific_field>travel_data</gateway_specific_field>
    <gateway_specific_field>lodging_data</gateway_specific_field>
  </gateway_specific_fields>
  <payment_methods>
    <payment_method>credit_card</payment_method>
    <payment_method>third_party_token</payment_method>
    <payment_method>apple_pay</payment_method>
    <payment_method>android_pay</payment_method>
    <payment_method>google_pay</payment_method>
  </payment_methods>
  <state>retained</state>
  <redacted type="boolean">false</redacted>
  <sandbox type="boolean">false</sandbox>
  <created_at type="dateTime">2020-06-16T13:17:03Z</created_at>
  <updated_at type="dateTime">2020-06-16T13:17:03Z</updated_at>
  <mode>blue</mode>
</gateway>


env = Spreedly::Environment.new('C7cRfNJGODKh4Iu5Ox3PToKjniY', '4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ', base_url: 'https://core.spreedly.com')
env.add_gateway(:braintree, mode: 'blue', merchant_id: 'MyMerchantID',
               public_key: 'MyPublicKey', private_key: 'MyPrivateKey')


#<Spreedly::Gateway:0x007fe33399d270
@token="aRSuBPhP5La4Lb6j6pFqT9cc1KA",
@created_at="2017-07-27T17:47:57Z",
@updated_at="2017-07-27T17:47:57Z",
@gateway_type="braintree",
@state="retained",
@name="Braintree",
@credentials={"merchant_id"=>"MyMerchantID", "public_key"=>"MyPublicKey", "merchant_account_id"=>""}>

Blue mode with merchant account ID

You can also optionally specify a merchant_account_id if you have multiple merchant accounts processing against the same Braintree gateway account. You can do so like this:


curl https://core.spreedly.com/v1/gateways.xml \
  -u 'C7cRfNJGODKh4Iu5Ox3PToKjniY:4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ' \
  -H 'Content-Type: application/xml' \
  -d '<gateway>
        <gateway_type>braintree</gateway_type>
        <mode>blue</mode>
        <merchant_id>MyMerchantId</merchant_id>
        <public_key>MyPublicKey</public_key>
        <private_key>MyPrivateKey</private_key>
        <merchant_account_id>My Merchant Account ID</merchant_account_id>
      </gateway>'

<gateway>
  <token>UxWm7aj59pihLf2iLppxsp1f3dh</token>
  <gateway_type>braintree</gateway_type>
  <name>Braintree</name>
  <description nil="true"/>
  <merchant_id>MyMerchantId</merchant_id>
  <public_key>MyPublicKey</public_key>
  <merchant_account_id>My Merchant Account ID</merchant_account_id>
  <characteristics>
    <supports_purchase type="boolean">true</supports_purchase>
    <supports_authorize type="boolean">true</supports_authorize>
    <supports_capture type="boolean">true</supports_capture>
    <supports_credit type="boolean">true</supports_credit>
    <supports_general_credit type="boolean">false</supports_general_credit>
    <supports_void type="boolean">true</supports_void>
    <supports_verify type="boolean">true</supports_verify>
    <supports_reference_purchase type="boolean">false</supports_reference_purchase>
    <supports_purchase_via_preauthorization type="boolean">false</supports_purchase_via_preauthorization>
    <supports_offsite_purchase type="boolean">false</supports_offsite_purchase>
    <supports_offsite_authorize type="boolean">false</supports_offsite_authorize>
    <supports_3dsecure_purchase type="boolean">false</supports_3dsecure_purchase>
    <supports_3dsecure_authorize type="boolean">false</supports_3dsecure_authorize>
    <supports_store type="boolean">true</supports_store>
    <supports_remove type="boolean">false</supports_remove>
    <supports_fraud_review type="boolean">false</supports_fraud_review>
    <supports_disburse type="boolean">false</supports_disburse>
  </characteristics>
  <credentials>
    <credential>
      <name>merchant_id</name>
      <value>MyMerchantId</value>
    </credential>
    <credential>
      <name>public_key</name>
      <value>MyPublicKey</value>
    </credential>
    <credential>
      <name>merchant_account_id</name>
      <value>My Merchant Account ID</value>
    </credential>
  </credentials>
  <gateway_specific_fields>
    <gateway_specific_field>descriptor_name</gateway_specific_field>
    <gateway_specific_field>descriptor_phone</gateway_specific_field>
    <gateway_specific_field>descriptor_url</gateway_specific_field>
    <gateway_specific_field>service_fee_amount</gateway_specific_field>
    <gateway_specific_field>merchant_account_id</gateway_specific_field>
    <gateway_specific_field>hold_in_escrow</gateway_specific_field>
    <gateway_specific_field>customer_id</gateway_specific_field>
    <gateway_specific_field>custom_fields</gateway_specific_field>
    <gateway_specific_field>recurring</gateway_specific_field>
    <gateway_specific_field>map_to_customer_id</gateway_specific_field>
  </gateway_specific_fields>
  <payment_methods>
    <payment_method>credit_card</payment_method>
    <payment_method>third_party_token</payment_method>
    <payment_method>apple_pay</payment_method>
    <payment_method>android_pay</payment_method>
  </payment_methods>
  <state>retained</state>
  <redacted type="boolean">false</redacted>
  <created_at type="dateTime">2017-07-27T17:48:04Z</created_at>
  <updated_at type="dateTime">2017-07-27T17:48:04Z</updated_at>
  <mode>blue</mode>
</gateway>


env = Spreedly::Environment.new('C7cRfNJGODKh4Iu5Ox3PToKjniY', '4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ', base_url: 'https://core.spreedly.com')
env.add_gateway(:braintree, mode: 'blue', merchant_id: 'MyMerchantID',
                public_key: 'MyPublicKey', private_key: 'MyPrivateKey',
                merchant_account_id: 'My Merchant Acount ID')


#<Spreedly::Gateway:0x007fe332b0b6f8
@token="H4fjJQBO7oxcdOgfVJpPWxGjEzw",
@created_at="2017-07-27T17:48:05Z",
@updated_at="2017-07-27T17:48:05Z",
@gateway_type="braintree",
@state="retained",
@name="Braintree",
@credentials={"merchant_id"=>"MyMerchantID", "public_key"=>"MyPublicKey", "merchant_account_id"=>"My Merchant Acount ID"}>

Orange mode

You just need to supply a login and password:


curl https://core.spreedly.com/v1/gateways.xml \
  -u 'C7cRfNJGODKh4Iu5Ox3PToKjniY:4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ' \
  -H 'Content-Type: application/xml' \
  -d '<gateway>
        <gateway_type>braintree</gateway_type>
        <mode>orange</mode>
        <login>MyLogin</login>
        <password>MyPassword</password>
      </gateway>'

<gateway>
  <token>AEeze9vF90AOK8ZjW502s25v819</token>
  <gateway_type>braintree</gateway_type>
  <name>Braintree</name>
  <description nil="true"/>
  <login>MyLogin</login>
  <characteristics>
    <supports_purchase type="boolean">true</supports_purchase>
    <supports_authorize type="boolean">true</supports_authorize>
    <supports_capture type="boolean">true</supports_capture>
    <supports_credit type="boolean">true</supports_credit>
    <supports_general_credit type="boolean">false</supports_general_credit>
    <supports_void type="boolean">true</supports_void>
    <supports_verify type="boolean">true</supports_verify>
    <supports_reference_purchase type="boolean">false</supports_reference_purchase>
    <supports_purchase_via_preauthorization type="boolean">false</supports_purchase_via_preauthorization>
    <supports_offsite_purchase type="boolean">false</supports_offsite_purchase>
    <supports_offsite_authorize type="boolean">false</supports_offsite_authorize>
    <supports_3dsecure_purchase type="boolean">false</supports_3dsecure_purchase>
    <supports_3dsecure_authorize type="boolean">false</supports_3dsecure_authorize>
    <supports_store type="boolean">true</supports_store>
    <supports_remove type="boolean">false</supports_remove>
    <supports_fraud_review type="boolean">false</supports_fraud_review>
    <supports_disburse type="boolean">false</supports_disburse>
  </characteristics>
  <credentials>
    <credential>
      <name>login</name>
      <value>MyLogin</value>
    </credential>
  </credentials>
  <gateway_specific_fields>
    <gateway_specific_field>descriptor_name</gateway_specific_field>
    <gateway_specific_field>descriptor_phone</gateway_specific_field>
    <gateway_specific_field>descriptor_url</gateway_specific_field>
    <gateway_specific_field>service_fee_amount</gateway_specific_field>
    <gateway_specific_field>merchant_account_id</gateway_specific_field>
    <gateway_specific_field>hold_in_escrow</gateway_specific_field>
    <gateway_specific_field>customer_id</gateway_specific_field>
    <gateway_specific_field>custom_fields</gateway_specific_field>
    <gateway_specific_field>recurring</gateway_specific_field>
    <gateway_specific_field>map_to_customer_id</gateway_specific_field>
    <gateway_specific_field>skip_advanced_fraud_checking</gateway_specific_field>
  </gateway_specific_fields>
  <payment_methods>
    <payment_method>credit_card</payment_method>
    <payment_method>third_party_token</payment_method>
    <payment_method>apple_pay</payment_method>
    <payment_method>android_pay</payment_method>
  </payment_methods>
  <state>retained</state>
  <redacted type="boolean">false</redacted>
  <created_at type="dateTime">2018-04-25T20:07:18Z</created_at>
  <updated_at type="dateTime">2018-04-25T20:07:18Z</updated_at>
  <mode>orange</mode>
</gateway>


env = Spreedly::Environment.new('C7cRfNJGODKh4Iu5Ox3PToKjniY', '4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ', base_url: 'https://core.spreedly.com')
env.add_gateway(:braintree, mode: 'orange', login: 'MyLogin', password: 'MyPassword')


#<Spreedly::Gateway:0x007fe332a68ae8
@token="L2IF5sL3vUCYTpdaCnbHpAz0toV",
@created_at="2017-07-27T17:48:08Z",
@updated_at="2017-07-27T17:48:08Z",
@gateway_type="braintree",
@state="retained",
@name="Braintree",
@credentials={"login"=>"MyLogin"}>

Third-party 3D Secure 2 auth data

Spreedly will automatically handle the field mapping for sending third-party 3DS2 authentication data to Braintree. For more information about how to use this feature, see the 3DS2 Third-party Authentication Guide. Spreedly fields map to the relevant Braintree fields as described in the following table.

Spreedly Field Braintree Field
three_ds_version three_d_secure_version
ecommerce_indicator eci_flag
authentication_value cavv
authentication_value_algorithm cavv_algorithm
directory_server_transaction_id ds_transaction_id
directory_response_status directory_response
authentication_response_status authentication_response

Gateway specific fields

When interacting with a Braintree gateway to run transactions, there are a number of gateway specific fields you can specify. See the details below the example for more information on each field.


curl https://core.spreedly.com/v1/gateways/LlkjmEk0xNkcWrNixXa1fvNoTP4/store.xml \
  -u 'C7cRfNJGODKh4Iu5Ox3PToKjniY:4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ' \
  -H 'Content-Type: application/xml' \
  -d '<transaction>
        <payment_method_token>56wyNnSmuA6CWYP7w0MiYCVIbW6</payment_method_token>
        <amount>100</amount>
        <currency_code>USD</currency_code>
        <gateway_specific_fields>
          <braintree>
            <customer_id>103</customer_id>
            <descriptor_name>company*theproduct</descriptor_name>
            <descriptor_phone>1331131131</descriptor_phone>
            <descriptor_url>company.com</descriptor_url>
            <merchant_account_id>TheId</merchant_account_id>
            <hold_in_escrow>true</hold_in_escrow>
            <recurring>true</recurring>
            <transaction_source>recurring</transaction_source>
            <service_fee_amount>23.44</service_fee_amount>
            <map_to_customer_id>true</map_to_customer_id>
            <skip_advanced_fraud_checking>true</skip_advanced_fraud_checking>
            <skip_avs>true</skip_avs>
            <skip_cvv>true</skip_cvv>
            <tax_amount>30</tax_amount>
            <tax_exempt>true</tax_exempt>
            <purchase_order_number>873645</purchase_order_number>
            <shipping_amount>200</shipping_amount>
            <discount_amount>300</discount_amount>
            <ships_from_postal_code>90210</ships_from_postal_code>
            <line_items>
              <![CDATA[
                [{"product_description": "coffee mug", "product_code": 1234}]
              ]]>
            </line_items>
            <device_data>device data</device_data>
            <travel_data>
              <travel_package>flight</travel_package>
              <departure_date>2050-07-22</departure_date>
              <lodging_check_in_date>2050-07-22</lodging_check_in_date>
              <lodging_check_out_date>2050-07-25</lodging_check_out_date>
              <lodging_name>Best Hotel Ever</lodging_name>
            </travel_data>
            <lodging_data>
              <folio_number>ABC123</folio_number>
              <check_in_date>2050-12-22</check_in_date>
              <check_out_date>2050-12-25</check_out_date>
              <room_rate>80.00</room_rate>
            </lodging_data>
            <account_type>credit</account_type>
            <allow_card_verification>true</allow_card_verification>
          </braintree>
        </gateway_specific_fields>
      </transaction>'

<transaction>
  <created_at type="dateTime">2021-04-13T14:32:43Z</created_at>
  <currency_code>USD</currency_code>
  <updated_at type="dateTime">2021-04-13T14:32:43Z</updated_at>
  <succeeded type="boolean">true</succeeded>
  <token>CdOcRNEo1lRaonHyTqHpGFfabrb</token>
  <state>succeeded</state>
  <gateway_specific_fields>
    <braintree>
      <customer_id>103</customer_id>
      <descriptor_name>company*theproduct</descriptor_name>
      <descriptor_phone>1331131131</descriptor_phone>
      <descriptor_url>company.com</descriptor_url>
      <merchant_account_id>TheId</merchant_account_id>
      <hold_in_escrow>true</hold_in_escrow>
      <recurring>true</recurring>
      <transaction_source>recurring</transaction_source>
      <service_fee_amount>23.44</service_fee_amount>
      <map_to_customer_id>true</map_to_customer_id>
      <skip_advanced_fraud_checking>true</skip_advanced_fraud_checking>
      <skip_avs>true</skip_avs>
      <skip_cvv>true</skip_cvv>
      <tax_amount>30</tax_amount>
      <tax_exempt>true</tax_exempt>
      <purchase_order_number>873645</purchase_order_number>
      <shipping_amount>200</shipping_amount>
      <discount_amount>300</discount_amount>
      <ships_from_postal_code>90210</ships_from_postal_code>
      <line_items>
              
                [{"product_description": "coffee mug", "product_code": 1234}]
              
            </line_items>
      <device_data>device data</device_data>
      <travel_data>
        <travel_package>flight</travel_package>
        <departure_date>2050-07-22</departure_date>
        <lodging_check_in_date>2050-07-22</lodging_check_in_date>
        <lodging_check_out_date>2050-07-25</lodging_check_out_date>
        <lodging_name>Best Hotel Ever</lodging_name>
      </travel_data>
      <lodging_data>
        <folio_number>ABC123</folio_number>
        <check_in_date>2050-12-22</check_in_date>
        <check_out_date>2050-12-25</check_out_date>
        <room_rate>80.00</room_rate>
      </lodging_data>
      <account_type>credit</account_type>
      <allow_card_verification>true</allow_card_verification>
    </braintree>
  </gateway_specific_fields>
  <gateway_specific_response_fields>
  </gateway_specific_response_fields>
  <transaction_type>Store</transaction_type>
  <third_party_token nil="true"/>
  <gateway_transaction_id>52</gateway_transaction_id>
  <gateway_latency_ms type="integer">1</gateway_latency_ms>
  <message key="messages.transaction_succeeded">Succeeded!</message>
  <gateway_token>T11bJAANtTWnxl36GYjKWvbNK0g</gateway_token>
  <gateway_type>test</gateway_type>
  <payment_method>
    <token>KPfAdcvGOX9fWgbGlkommUX8INA</token>
    <created_at type="dateTime">2021-04-13T14:32:43Z</created_at>
    <updated_at type="dateTime">2021-04-13T14:32:43Z</updated_at>
    <gateway_type>test</gateway_type>
    <storage_state>retained</storage_state>
    <metadata nil="true"/>
    <third_party_token>test_vault:4111111111111111</third_party_token>
    <payment_method_type>third_party_token</payment_method_type>
    <errors>
    </errors>
  </payment_method>
  <basis_payment_method>
    <token>1rpKvP8zOUhj4Y9EDrIoIYQzzD5</token>
    <created_at type="dateTime">2017-06-26T17:04:38Z</created_at>
    <updated_at type="dateTime">2021-04-13T14:32:43Z</updated_at>
    <email>joey@example.com</email>
    <data>
      <my_payment_method_identifier>448</my_payment_method_identifier>
      <extra_stuff>
        <some_other_things>Can be anything really</some_other_things>
      </extra_stuff>
    </data>
    <storage_state>retained</storage_state>
    <test type="boolean">true</test>
    <metadata>
      <key>string value</key>
    </metadata>
    <callback_url nil="true"/>
    <last_four_digits>1111</last_four_digits>
    <first_six_digits>411111</first_six_digits>
    <card_type>visa</card_type>
    <first_name>Newfirst</first_name>
    <last_name>Newlast</last_name>
    <month type="integer">3</month>
    <year type="integer">2032</year>
    <address1 nil="true"/>
    <address2 nil="true"/>
    <city nil="true"/>
    <state nil="true"/>
    <zip nil="true"/>
    <country nil="true"/>
    <phone_number nil="true"/>
    <company nil="true"/>
    <full_name>Newfirst Newlast</full_name>
    <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
    <shipping_address1 nil="true"/>
    <shipping_address2 nil="true"/>
    <shipping_city nil="true"/>
    <shipping_state nil="true"/>
    <shipping_zip nil="true"/>
    <shipping_country nil="true"/>
    <shipping_phone_number nil="true"/>
    <payment_method_type>credit_card</payment_method_type>
    <errors>
    </errors>
    <verification_value></verification_value>
    <number>XXXX-XXXX-XXXX-1111</number>
    <fingerprint>e3cef43464fc832f6e04f187df25af497994</fingerprint>
  </basis_payment_method>
  <response>
    <success type="boolean">true</success>
    <message>Successful store</message>
    <avs_code nil="true"/>
    <avs_message nil="true"/>
    <cvv_code nil="true"/>
    <cvv_message nil="true"/>
    <pending type="boolean">false</pending>
    <result_unknown type="boolean">false</result_unknown>
    <error_code nil="true"/>
    <error_detail nil="true"/>
    <cancelled type="boolean">false</cancelled>
    <fraud_review nil="true"/>
    <created_at type="dateTime">2021-04-13T14:32:43Z</created_at>
    <updated_at type="dateTime">2021-04-13T14:32:43Z</updated_at>
  </response>
</transaction>


env = Spreedly::Environment.new('C7cRfNJGODKh4Iu5Ox3PToKjniY', '4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ', base_url: 'https://core.spreedly.com')
env.purchase_on_gateway("LlkjmEk0xNkcWrNixXa1fvNoTP4", "56wyNnSmuA6CWYP7w0MiYCVIbW6", 4432,
  gateway_specific_fields: {
    braintree: {
      customer_id: "103",
      descriptor_name: "company*theproduct",
      descriptor_phone: "1331131131",
      descriptor_url: "company.com",
      merchant_account_id: "TheId",
      hold_in_escrow: "true",
      recurring: "true",
      service_fee_amount: "23.44",
      map_to_customer_id: "true",
      skip_advanced_fraud_checking: "true",
      risk_data: {
        customer_browser: "User-Agent Header",
        customer_ip: "127.0.0.1"
      }
    }
  }
)


#<Spreedly::Purchase:0x00007fde70125da8
@token="ILXCYXgZvoXawCaD9HO43moG0yq",
@created_at="2021-04-28T18:29:23Z",
@updated_at="2021-04-28T18:29:23Z",
@state="succeeded",
@message="Succeeded!",
@succeeded="true",
@order_id="",
@ip="",
@description="",
@gateway_token="T11bJAANtTWnxl36GYjKWvbNK0g",
@gateway_transaction_id="50",
@email="",
@transaction_type="Purchase",
@merchant_name_descriptor="",
@merchant_location_descriptor="",
@on_test_gateway="true",
@currency_code="USD",
@callback_url="",
@stored_credential_initiator="",
@stored_credential_reason_type="",
@amount="4432",
@response,=
#<Spreedly::Response:0x00007fde7015ae68
@success="true",
@pending="false",
@cancelled="false",
@fraud_review="",
@created_at="2021-04-28T18:29:23Z",
@updated_at="2021-04-28T18:29:23Z",
@message="Successful purchase",
@avs_code="",
@avs_message="",
@cvv_code="",
@cvv_message="",
@error_code="",
@error_detail="">,
@shipping_address,=
#<Spreedly::ShippingAddress:0x00007fde70129340
@name="Newfirst Newlast",
@address1="",
@address2="",
@city="",
@state="",
@zip="",
@country="",
@phone_number="">,
@gateway_specific_fields={:braintree=>{:customer_id=>"103", :descriptor_name=>"company*theproduct", :descriptor_phone=>"1331131131", :descriptor_url=>"company.com", :merchant_account_id=>"TheId", :hold_in_escrow=>"true", :recurring=>"true", :service_fee_amount=>"23.44", :map_to_customer_id=>"true", :skip_advanced_fraud_checking=>"true", :risk_data=>"\n        User-Agent Header\n        127.0.0.1\n      "}},
@gateway_specific_response_fields={},
@payment_method,=
#<Spreedly::CreditCard:0x00007fde701687c0
@token="1rpKvP8zOUhj4Y9EDrIoIYQzzD5",
@created_at="2017-06-26T17:04:38Z",
@updated_at="2021-04-26T18:48:29Z",
@email="joey@example.com",
@storage_state="retained",
@data="<my_payment_method_identifier>448</my_payment_method_identifier>\n      <extra_stuff>\n        <some_other_things>Can be anything really</some_other_things>\n      </extra_stuff>",
@payment_method_type="credit_card",
@first_name="Newfirst",
@last_name="Newlast",
@full_name="Newfirst Newlast",
@month="3",
@year="2032",
@number="XXXX-XXXX-XXXX-1111",
@last_four_digits="1111",
@first_six_digits="411111",
@card_type="visa",
@verification_value="",
@address1="",
@address2="",
@city="",
@state="",
@zip="",
@country="",
@phone_number="",
@company="",
@fingerprint="e3cef43464fc832f6e04f187df25af497994",
@eligible_for_card_updater="true",
@errors=[]>>

Braintree Blue customer ID

Braintree’s vault (when using the “blue” API) has a top-level concept of a Customer, and the Spreedly API allows limited interaction with the Customer when storing credit cards in Braintree’s vault.

If you specify the customer_id as a gateway specific field, the Spreedly API will use that customer id when adding the card, and if the customer already exists it will add the card to the customer rather than throwing a duplicate customer error.

Braintree dynamic descriptors

Braintree dynamic descriptors can be used by the merchant to define what will appear on the customer’s credit card statement for the purchase. You can specify the descriptor_name, descriptor_phone, and descriptor_url.

Service fee amount

You can specify a service_fee_amount.

Merchant account ID

You can specify a per-transaction merchant_account_id that will overide the default merchant_account_id.

Hold in escrow

You can specify hold_in_escrow. The merchant_account_id field MUST be submitted with this field.

Recurring

Set this optional gateway specific field to "true" to enable the recurring flag in authorize and purchase transactions. By default it’s disabled.

Transaction source

You can specify a transaction_source.

Map to customer ID

When using migrated payment methods created with Braintree customer_id as reference, set map_to_customer_id true on authorize and purchase transactions. It allows Spreedly to pass on the Braintree reference correctly.

Skip advanced fraud checking

Set this optional gateway specific field to "true" to enable the skip_advanced_fraud_checking flag in authorize and purchase transactions.

Skip AVS

Set this optional gateway specific field to "true" to enable the skip_avs flag in authorize and purchase transactions.

Skip CVV

Set this optional gateway specific field to "true" to enable the skip_cvv flag in authorize and purchase transactions.

Level 2 data

Level 2 processing requires purchase_order_number and tax_amount and/or tax_exempt (boolean).

Level 3 data

For Level 3 processing, Level 2 fields are required along with line_items, an array of JSON objects detailing the line items of the purchase, and the following fields:

  • shipping_amount
  • discount_amount
  • ships_from_postal_code
  • A postal code in the shipping address
  • A country in the shipping address

Travel and lodging data

The travel_data and lodging_data gateway specific fields can be used to send optional industry-specific fields on transactions. Information for only one industry type may be sent per transaction.

Account Type

The account_type gateway specific field can be used to specify the account type (credit or debit). Note that this field can only be used when the merchant_account_id is configured to use BRL currency.

Allow Card Verification

The allow_card_verification gateway specific field can be used to trigger a $0 verification in place of the standard authorization/void process. Please note that use of the $0 verification requires it being enabled on the merchant’s account. This is a manual process that has to be enabled by the merchant’s CSM at Braintree.

Risk Data

The risk_data gateway specific field can be used as part of Braintree’s fraud tools. The field contains customer device information, which is used by supported processors for fraud analysis. See Braintree’s risk data documentation for more details on how this information is used.

Custom fields

Custom fields provide an easy way to collect additional information about your customers or their purchase, like the name of the product they purchased. They can be included when creating a transaction or adding a customer to the Vault, and can be stored in the Braintree gateway for reporting purposes

Note that custom fields cannot be created via an API request so you’ll need to configure them directly in the Control Panel. See Braintree’s custom fields documentation for more information.


curl https://core.spreedly.com/v1/gateways/LlkjmEk0xNkcWrNixXa1fvNoTP4/purchase.xml \
  -u 'C7cRfNJGODKh4Iu5Ox3PToKjniY:4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ' \
  -H 'Content-Type: application/xml' \
  -d '<transaction>
        <payment_method_token>56wyNnSmuA6CWYP7w0MiYCVIbW6</payment_method_token>
        <amount>100</amount>
        <currency_code>USD</currency_code>
        <gateway_specific_fields>
          <braintree>
            <custom_fields>
              <work_email>TheWorkEmail</work_email>
              <cat_name>Waffles</cat_name>
            </custom_fields>
          </braintree>
        </gateway_specific_fields>
      </transaction>'

<transaction>
  <on_test_gateway type="boolean">true</on_test_gateway>
  <created_at type="dateTime">2017-07-27T17:47:57Z</created_at>
  <updated_at type="dateTime">2017-07-27T17:47:57Z</updated_at>
  <succeeded type="boolean">true</succeeded>
  <state>succeeded</state>
  <token>3xwFfEH9SYPCfCFBJuhHlAZJKaZ</token>
  <transaction_type>Purchase</transaction_type>
  <order_id nil="true"/>
  <ip nil="true"/>
  <description nil="true"/>
  <email nil="true"/>
  <merchant_name_descriptor nil="true"/>
  <merchant_location_descriptor nil="true"/>
  <gateway_specific_fields>
    <braintree>
      <custom_fields>
        <work_email>TheWorkEmail</work_email>
        <cat_name>Waffles</cat_name>
      </custom_fields>
    </braintree>
  </gateway_specific_fields>
  <gateway_specific_response_fields>
  </gateway_specific_response_fields>
  <gateway_transaction_id>54</gateway_transaction_id>
  <gateway_latency_ms type="integer">51</gateway_latency_ms>
  <amount type="integer">100</amount>
  <currency_code>USD</currency_code>
  <retain_on_success type="boolean">false</retain_on_success>
  <payment_method_added type="boolean">false</payment_method_added>
  <message key="messages.transaction_succeeded">Succeeded!</message>
  <gateway_token>T11bJAANtTWnxl36GYjKWvbNK0g</gateway_token>
  <shipping_address>
    <name>Newfirst Newlast</name>
    <address1 nil="true"/>
    <address2 nil="true"/>
    <city nil="true"/>
    <state nil="true"/>
    <zip nil="true"/>
    <country nil="true"/>
    <phone_number nil="true"/>
  </shipping_address>
  <response>
    <success type="boolean">true</success>
    <message>Successful purchase</message>
    <avs_code nil="true"/>
    <avs_message nil="true"/>
    <cvv_code nil="true"/>
    <cvv_message nil="true"/>
    <pending type="boolean">false</pending>
    <result_unknown type="boolean">false</result_unknown>
    <error_code></error_code>
    <error_detail nil="true"/>
    <cancelled type="boolean">false</cancelled>
    <fraud_review nil="true"/>
    <created_at type="dateTime">2017-07-27T17:47:57Z</created_at>
    <updated_at type="dateTime">2017-07-27T17:47:57Z</updated_at>
  </response>
  <api_urls>
  </api_urls>
  <payment_method>
    <token>1rpKvP8zOUhj4Y9EDrIoIYQzzD5</token>
    <created_at type="dateTime">2017-06-26T17:04:38Z</created_at>
    <updated_at type="dateTime">2017-07-27T17:47:55Z</updated_at>
    <email>joey@example.com</email>
    <data>
      <my_payment_method_identifier>448</my_payment_method_identifier>
      <extra_stuff>
        <some_other_things>Can be anything really</some_other_things>
      </extra_stuff>
    </data>
    <storage_state>retained</storage_state>
    <test type="boolean">true</test>
    <last_four_digits>1111</last_four_digits>
    <first_six_digits>411111</first_six_digits>
    <card_type>visa</card_type>
    <first_name>Newfirst</first_name>
    <last_name>Newlast</last_name>
    <month type="integer">3</month>
    <year type="integer">2032</year>
    <address1 nil="true"/>
    <address2 nil="true"/>
    <city nil="true"/>
    <state nil="true"/>
    <zip nil="true"/>
    <country nil="true"/>
    <phone_number nil="true"/>
    <company nil="true"/>
    <full_name>Newfirst Newlast</full_name>
    <eligible_for_card_updater nil="true"/>
    <shipping_address1 nil="true"/>
    <shipping_address2 nil="true"/>
    <shipping_city nil="true"/>
    <shipping_state nil="true"/>
    <shipping_zip nil="true"/>
    <shipping_country nil="true"/>
    <shipping_phone_number nil="true"/>
    <payment_method_type>credit_card</payment_method_type>
    <errors>
    </errors>
    <verification_value></verification_value>
    <number>XXXX-XXXX-XXXX-1111</number>
    <fingerprint>e3cef43464fc832f6e04f187df25af497994</fingerprint>
  </payment_method>
</transaction>


env = Spreedly::Environment.new('C7cRfNJGODKh4Iu5Ox3PToKjniY', '4UIuWybmdythfNGPqAqyQnYha6s451ri0fYAo4p3drZUi7q2Jf4b7HKg8etDtoKJ', base_url: 'https://core.spreedly.com')
env.purchase_on_gateway("LlkjmEk0xNkcWrNixXa1fvNoTP4", "56wyNnSmuA6CWYP7w0MiYCVIbW6", 4432,
  gateway_specific_fields: {
    braintree: {
      custom_fields: {
        work_email: "TheWorkEmail",
        cat_name: "Waffles"
      }
    }
  }
)


#<Spreedly::Purchase:0x007fe3338ddcb8
@token="FKE0rlBSngfMZnf0Gt2ihcDR3NF",
@created_at="2017-07-27T17:47:58Z",
@updated_at="2017-07-27T17:47:58Z",
@state="succeeded",
@message="Succeeded!",
@succeeded="true",
@order_id="",
@ip="",
@description="",
@gateway_token="T11bJAANtTWnxl36GYjKWvbNK0g",
@gateway_transaction_id="58",
@email="",
@merchant_name_descriptor="",
@merchant_location_descriptor="",
@on_test_gateway="true",
@currency_code="USD",
@amount="4432",
@response,=
#<Spreedly::Response:0x007fe3338af6d8
@success="true",
@pending="false",
@cancelled="false",
@fraud_review="",
@created_at="2017-07-27T17:47:58Z",
@updated_at="2017-07-27T17:47:58Z",
@message="Successful purchase",
@avs_code="",
@avs_message="",
@cvv_code="",
@cvv_message="",
@error_code="",
@error_detail="">,
@shipping_address,=
#<Spreedly::ShippingAddress:0x007fe33388f310
@name="Newfirst Newlast",
@address1="",
@address2="",
@city="",
@state="",
@zip="",
@country="",
@phone_number="">,
@gateway_specific_fields={:braintree=>{:custom_fields=>"\n        TheWorkEmail\n        Waffles\n      "}},
@payment_method,=
#<Spreedly::CreditCard:0x007fe33385ad90
@token="1rpKvP8zOUhj4Y9EDrIoIYQzzD5",
@created_at="2017-06-26T17:04:38Z",
@updated_at="2017-07-27T17:47:57Z",
@email="joey@example.com",
@storage_state="retained",
@data="<my_payment_method_identifier>448</my_payment_method_identifier>\n      <extra_stuff>\n        <some_other_things>Can be anything really</some_other_things>\n      </extra_stuff>",
@first_name="Newfirst",
@last_name="Newlast",
@full_name="Newfirst Newlast",
@month="3",
@year="2032",
@number="XXXX-XXXX-XXXX-1111",
@last_four_digits="1111",
@first_six_digits="411111",
@card_type="visa",
@verification_value="",
@address1="",
@address2="",
@city="",
@state="",
@zip="",
@country="",
@phone_number="",
@company="",
@fingerprint="e3cef43464fc832f6e04f187df25af497994",
@eligible_for_card_updater="",
@errors=[]>>

Gateway specific response fields

A response from Braintree gateway may contain additional fields which you can find in the gateway_specific_response_fields. These currently include additional_processor_response if it is enabled for your account, as well as risk_data fields.

For example:

<transaction>
  <token>LgpTNGjsWQs9DwdxcbreUVz0R8p</token>
  <transaction_type>Purchase</transaction_type>
  <gateway_specific_response_fields>
     <braintree>
       <additional_processor_response>2004</additional_processor_response>
       <risk_data_decision>Approve</risk_data_decision>
       <risk_data_device_data_captured>true</risk_data_device_data_captured>
       <risk_data_id>123</risk_data_id>
     </braintree>
  </gateway_specific_response_fields>
</transaction>

If you’d like to request any gateway_specific_fields or gateway_specific_response_fields, please contact Support with your request and the gateway documentation for the fields of interest.

MIT Support on 3DS2 Global

By properly setting the transaction_source gateway specific field, you can ensure that your recurring transactions have the best chance of being marked as out of scope, or check out Spreedly’s implementation of stored credentials.

You should be performing 3DS on the first transaction as usual and pass the transaction_source field with the subsequent transactions:

  • set the transaction_source field to "unscheduled" and do not pass the recurring gateway specific field for unscheduled transactions
  • set the transaction_source field to "recurring" for recurring transactions