Transparent Redirect

Updating Customersanchor

note

The integration method outlined below is deprecated. Learn more about upgrading to the Braintree SDKs.

To update customers using Transparent Redirect, you’ll need to build an HTML form that submits directly to Braintree. You can:

  • 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 URLanchor

You should set the action attribute of your form to the URL for TransparentRedirect.

  1. Node
gateway.transparentRedirect.url

TR dataanchor

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:

  1. Node
var trData = gateway.transparentRedirect.updateCustomerData({
  redirectUrl: "http://example.com/urlToRedirectTo",
  customerId: "idOfCustomerToUpdate"
});

Then use a hidden field to add to your form:

  1. HTML
<input type="hidden" name="tr_data" value="insert generated tr_data here" />

TR form fieldsanchor

Create text fields for data parameters that you want to have your users enter.

  1. HTML
<input type="text" name="customer[credit_card][number]" />
<input type="text" name="customer[credit_card][expiration_date]" />

You can also include other customer, credit card, and billing address fields. For example:

  1. HTML
<input type="text" name="customer[email]" />
    <input type="text" name="customer[credit_card][cardholder_name]" />
    <input type="text" name="customer[credit_card][billing_address][street_address]" />
    <input type="text" name="customer[credit_card][billing_address][postal_code]" />

See the full list of TR HTML fields.

Create new or update existinganchor

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.

  1. Node
var trData = gateway.transparentRedirect.updateCustomerData({
  redirectUrl: "http://example.com/urlToRedirectTo",
  customerId: "idOfCustomerToUpdate",
  customer: {
    creditCard: {
      options: {
        updateExistingToken: "tokenOfCreditCardToUpdate"
      }
    }
  }
});

TR confirmationanchor

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:

  1. HTML
http://example.com/path?http_status=200&id=vgqssrhqhxfhgrwz&hash=0c3c641f1de3ed1c732c54cab367355350603b28

Use the query string to confirm. You’ll receive a result object just like if you updated a customer using a client library

  1. Node
gateway.transparentRedirect.confirm(queryString, function (err, result) {
});

See alsoanchor