Pregunta

I am using Braintree and their transaction redirect service in order to process transactions. According to Braintree's documentation, you should be able to collect billing information. I have the form set up to do so, but for some reason the billing information is not present in the response, or in the transaction if I pull it later using Braintree::Transaction.find. Here is the form code:

    <%= form_tag(Braintree::TransparentRedirect.url, method: "post", id: 'braintree-transaction-form') do %>
    <%= hidden_field_tag :tr_data, @tr_data  %>
    <%= hidden_field_tag :amount, @dress.price %>

    <fieldset>
      <legend>Credit Card Information</legend>

        <div class="large-12 columns">
          <%= label_tag "transaction[credit_card][number]", "Credit card number" %>
          <%= text_field_tag "transaction[credit_card][number]", nil, { 'data-encrypted-name' => 'transaction[credit_card][number]' }  %>
        </div>

        <div class="large-8 columns">
          <%= label_tag 'transaction[credit_card][cardholder_name]', "Cardholder Name" %>
          <%= text_field_tag 'transaction[credit_card][cardholder_name]' %>
        </div>
        <div class="large-2 columns">
          <%= label_tag 'transaction[credit_card][expiration_month]', "Expiration Date" %>
          <%= text_field_tag 'transaction[credit_card][expiration_month]', nil, { 'max-length' => 2, 'data-encrypted-name' => 'transaction[credit_card][expiration_month]', 'placeholder' => 'MM' } %>
        </div>
        <div class="large-2 columns">
          <label>&nbsp;</label>
          <%= text_field_tag 'transaction[credit_card][expiration_year]', nil,  { 'max-length' => 4, 'data-encrypted-name' => 'transaction[credit_card][expiration_year]', 'placeholder' => 'YYYY' } %>
        </div>

        <div class="large-3 columns end">
          <%= label_tag 'transaction[credit_card][cvv]', "CVV" %>
          <%= text_field_tag 'transaction[credit_card][cvv]', nil, { 'max-length' => 4, 'data-encrypted-name' => 'transaction[credit_card][cvv]' } %>
        </div>
    </fieldset>

    <fieldset>
      <legend>Shipping Information</legend>

      <div class='large-6 columns'>
        <%= label_tag 'transaction[shipping][first_name]',  "First Name" %>
        <%= text_field_tag 'transaction[shipping][first_name]' %>
      </div>

      <div class='large-6 columns'>
        <%= label_tag 'transaction[shipping][last_name]', "Last Name" %>
        <%= text_field_tag 'transaction[shipping][last_name]' %>
      </div>

      <div class='large-12 columns'>
        <%= label_tag 'transaction[shipping][street_address]', "Address Line 1" %>
        <%= text_field_tag 'transaction[shipping][street_address]' %>
      </div>

      <div class='large-12 columns'>
        <%= label_tag 'transaction[shipping][extended_address]', "Address Line 2" %>
        <%= text_field_tag 'transaction[shipping][extended_address]' %>
      </div>

      <div class='large-4 columns'>
        <%= label_tag 'transaction[shipping][locality]', "City" %>
        <%= text_field_tag 'transaction[shipping][locality]' %>
      </div>

      <div class='large-4 columns'>
        <%= label_tag 'transaction[shipping][region]', "State" %>
        <%= text_field_tag 'transaction[shipping][region]' %>
      </div>

      <div class='large-4 columns'>
        <%= label_tag 'transaction[shipping][postal_code]', "Zip Code" %>
        <%= text_field_tag 'transaction[shipping][postal_code]' %>
      </div>

</fieldset>

<%= submit_tag "Get The Dress!", { 'class' => 'large button expand' } %>

  <% end %>
¿Fue útil?

Solución

I work at Braintree. If you need more help, feel free to reach out to our support team.

Your form isn't gathering billing address info, just shipping address info. If you change shipping to billing or add another section:

<fieldset>
  <legend>billing Information</legend>

  <div class='large-6 columns'>
    <%= label_tag 'transaction[billing][first_name]',  "First Name" %>
    <%= text_field_tag 'transaction[billing][first_name]' %>
  </div>

  <div class='large-6 columns'>
    <%= label_tag 'transaction[billing][last_name]', "Last Name" %>
    <%= text_field_tag 'transaction[billing][last_name]' %>
  </div>

  <div class='large-12 columns'>
    <%= label_tag 'transaction[billing][street_address]', "Address Line 1" %>
    <%= text_field_tag 'transaction[billing][street_address]' %>
  </div>

  <div class='large-12 columns'>
    <%= label_tag 'transaction[billing][extended_address]', "Address Line 2" %>
    <%= text_field_tag 'transaction[billing][extended_address]' %>
  </div>

  <div class='large-4 columns'>
    <%= label_tag 'transaction[billing][locality]', "City" %>
    <%= text_field_tag 'transaction[billing][locality]' %>
  </div>

  <div class='large-4 columns'>
    <%= label_tag 'transaction[billing][region]', "State" %>
    <%= text_field_tag 'transaction[billing][region]' %>
  </div>

  <div class='large-4 columns'>
    <%= label_tag 'transaction[billing][postal_code]', "Zip Code" %>
    <%= text_field_tag 'transaction[billing][postal_code]' %>
  </div>
</fieldset>

                                                                                           

the resulting transaction will have a transaction.billing_details attribute:

transaction.billing_details

The billing address details used to process this transaction. If billing address was stored in the Vault, then the billing_address_details is a snapshot of the address in the Vault at the time the transaction was created. So if the address in the Vault is updated after the transaction is created, transaction.billing_address_details.postal_code will return the previous postal code that was used to process the transaction, while transaction.vault_billing_address.postal_code will return the current postal code for the address in the Vault.

The address details are similar to those found on the address details page.

transaction.billing_details.company
transaction.billing_details.country_code_alpha2
transaction.billing_details.country_code_alpha3
transaction.billing_details.country_code_numeric
transaction.billing_details.country_name
transaction.billing_details.extended_address
transaction.billing_details.first_name
transaction.billing_details.last_name
transaction.billing_details.locality
transaction.billing_details.postal_code
transaction.billing_details.region
transaction.billing_details.street_address
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top