Transparent Redirect
Updating Credit Cards
Note
The integration method outlined below is deprecated.
Learn more about upgrading to the Braintree SDKs.
- Update a credit card
- Update a credit card and billing address
- Update a credit card and create a new billing address
Form action URL
- HTML
<form method="POST" action="<%= Braintree::TransparentRedirect.url %>">
TR data
The form needs to include a hidden field named tr_data
. It needs to include the URL
that Braintree will redirect the user to after storing the form params. It also needs to include the
token of the credit card to update. Generating the TR Data:
- Ruby
tr_data = Braintree::TransparentRedirect.update_credit_card_data(
:redirect_url => "http://example.com/url_to_redirect_to",
:payment_method_token => "token_of_payment_method_to_update"
)
- HTML
<input type="hidden" name="tr_data" value="<%= tr_data %>" />
tr_data
to your form.
TR form fields
Create text fields for data parameters that you want to have your users enter.
- HTML
undefined
- HTML
undefined
Create new or update existing
If you’re updating a billing address along with the credit card, you’ll need to set the
update_existing
option of the billing address in the TR data. If this is not set, a new
address will be created instead of an existing one being updated.
- Ruby
tr_data = Braintree::TransparentRedirect.update_credit_card_data(
:redirect_url => "http://example.com/url_to_redirect_to",
:payment_method_token => "token_of_payment_method_to_update",
:credit_card => {
:billing_address => {
:options => {
:update_existing => true
}
}
}
)
TR confirmation
Before the credit card is actually created, you will need to confirm the TR request. For the
confirmation, you will need to use the query string from the URL on the Redirect. Braintree will add
parameters to the query string that identify the request, so the redirect URL will look something
like:
- HTML
http://example.com/path?http_status=200&id=vgqssrhqhxfhgrwz&hash=0c3c641f1de3ed1c732c54cab367355350603b28
- Ruby
result = Braintree::TransparentRedirect.confirm(query_string)