Transparent Redirect
Updating Customers
Note
The integration method outlined below is deprecated.
Learn more about upgrading to the Braintree SDKs.
- Update a customer
- Update a customer and a credit card
- Update a customer, credit card, and billing address
- Update a customer and create a new credit card
- Update a customer and credit card, and create a new billing address
Form action URL
You should set the action attribute of your form to the URL for TransparentRedirect. You’ll want to
set the Transparent Redirect URL in your controller action. In
ASP.NET MVC, for example:
- C#
ViewData["TransparentRedirectURL"] = gateway.TransparentRedirect.Url;
- HTML
<form id="NewPaymentForm" action="<%= ViewData["TransparentRedirectURL"] %>" method="post" autocomplete="off">
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
ID of the customer to update. Generating the TR data:
- C#
ViewData["TrData"] = gateway.TrData(
new CustomerRequest {
CustomerId = "id_of_customer_to_update"
},
"http://example.com/url_to_redirect_to"
);
- HTML
<input id="tr_data" name="tr_data" type="hidden" value="<%= ViewData["TrData"] %>" />
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 credit card along with the customer, you’ll need to set the token of the credit
card to update in the TR data. If this is not set, a new credit card will be created instead of an
existing one updated.
- C#
ViewData["TrData"] = gateway.TrData(
new CustomerRequest {
CustomerId = "id_of_customer_to_update",
CreditCard = new CreditCardRequest() {
Options = new CreditCardOptionsRequest() {
UpdateExistingToken = "token_of_credit_card_to_update"
}
}
},
"http://example.com/url_to_redirect_to"
);
TR confirmation
Before the customer 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
- C#
Result<transaction> result = gateway.TransparentRedirect.ConfirmCustomer(Request.Url.Query);