Transaction Transparent Redirect HTML Fields
These are the HTML fields that can be used when creating transactions using Transparent Redirect.
HTML Fields
<!-- Example -->
<input type="text" name="transaction[customer][first_name]" />
<!-- id can be whatever you want, only name matters for Braintree -->
<input type="text" name="transaction[customer][first_name]" id="whateverYouWant" />
- transaction[customer][first_name]
- transaction[customer][last_name]
- transaction[customer][company]
- transaction[customer][email]
- transaction[customer][phone]
- transaction[customer][fax]
- transaction[customer][website]
- transaction[credit_card][cardholder_name]
- transaction[credit_card][number]
- transaction[credit_card][cvv]
- transaction[credit_card][expiration_date]
- transaction[credit_card][expiration_month]
- transaction[credit_card][expiration_year]
For expiration date, you can either use a single field, transaction[credit_card][expiration_date] or separate fields, transaction[credit_card][expiration_month] and transaction[credit_card][expiration_year].
- transaction[billing][first_name]
- transaction[billing][last_name]
- transaction[billing][company]
- transaction[billing][street_address]
- transaction[billing][extended_address]
- transaction[billing][locality]
- transaction[billing][region]
- transaction[billing][postal_code]
- transaction[billing][country_code_alpha2]
- transaction[billing][country_code_alpha3]
- transaction[billing][country_code_numeric]
- transaction[billing][country_name]
For country, you only need to use one of the four fields for specifying country.
- transaction[shipping][first_name]
- transaction[shipping][last_name]
- transaction[shipping][company]
- transaction[shipping][street_address]
- transaction[shipping][extended_address]
- transaction[shipping][locality]
- transaction[shipping][region]
- transaction[shipping][postal_code]
- transaction[shipping][country_code_alpha2]
- transaction[shipping][country_code_alpha3]
- transaction[shipping][country_code_numeric]
- transaction[shipping][country_name]
For country, you only need to use one of the four fields for specifying country. We only accept a specific list of countries so you will want to make country a select field.
Protected Fields
Any parameters that you want to submit without letting your users select the value should be included in the tr_data. For example, if you’re building a donation site and asking users to enter the amount they would like to donate, you would want to make amount an HTML field.
<input type="text" name="transaction[amount]" />
Otherwise, to ensure a specific amount, add it to the tr_data.
TransactionRequest trParams = new TransactionRequest().
type(Transaction.Type.SALE).
amount(new BigDecimal("10.00"));
String trData = gateway.transparentRedirect().trData(trParams, "http://example.com/url_to_redirect_to");
Do not create amount as a hidden field. Doing so would allow users to tamper with the value. Using tr_data ensures that the parameters cannot be tampered with.
<!-- DO NOT DO THIS -->
<input type="hidden" name="transaction[amount]" value="10.00" />
A few other fields may be included either way. For example, if you want to specify whether a transaction should be stored in the vault or not, pass the store_in_vault option in tr_data. If you have a process where you want to ask the user whether they would like their credit card kept on file for easy checkout on future purchases, then you can expose store_in_vault as a checkbox input.
<input type="checkbox" name="transaction[options][store_in_vault]" value="true" />
Related to storing in vault:
- transaction[options][add_billing_address_to_payment_method]
- transaction[options][store_shipping_address_in_vault]
- transaction[options][store_in_vault_on_success]
Mandatory Protected Fields
These fields must be included in tr_data and cannot be passed as a regular input field.
- transaction[type]
- transaction[order_id]
- transaction[customer][id]
- transaction[credit_card][token]
- transaction[options][submit_for_settlement]
- transaction[customer_id]
- transaction[payment_method_token]
If you’re creating a new customer and storing it in the vault, and you want to specify the customer id, use transaction[customer][id]. If you’re creating a transaction using a customer that’s already in the vault, specify the id of the customer to charge using transaction[customer_id]. Similarly with credit cards, transaction[credit_card][token] is for specifying the token of a new credit card. transaction[payment_method_token] is for referencing an existing payment method in the vault to charge it.
Custom Fields
Custom fields need to be configured in the control panel. Once they are, they can be submitted by creating form fields named transaction[custom_fields][name_that_was_configured_in_control_panel]
Underscore field name variation
Some frameworks have trouble parsing square brackets in HTML field names. For this reason, the gateway supports an alternate field name notation using double underscores instead of square brackets to delimit keys in the field name. So, for example:
transaction[customer_id] becomes transaction__customer_id
transaction[options][store_in_vault] becomes transaction__options__store_in_vault