我正在使用Braintree及其交易重定向服务来处理交易。根据Braintree的文档,您应该能够收集账单信息。我已将表单设置为这样做,但由于某种原因,结果信息不会出现在响应中,或者如果我稍后使用Braintree::Transaction.find
提取结果信息。这是表单代码:
<%= 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> </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 %>
答案 0 :(得分:1)
我在Braintree工作。如果您需要更多帮助,请随意reach out to our support team。
您的表单不是收集帐单邮寄地址信息,只是收集地址信息。如果您将shipping
更改为billing
或添加其他部分:
<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>
生成的交易将有transaction.billing_details
attribute:
<强> transaction.billing_details 强>
用于处理此交易的帐单邮寄地址详细信息。如果帐单邮寄地址存储在Vault中,则billing_address_details是创建事务时Vault中地址的快照。因此,如果在创建事务后更新Vault中的地址,则transaction.billing_address_details.postal_code将返回用于处理事务的上一个邮政编码,而transaction.vault_billing_address.postal_code将返回该地址的当前邮政编码。保险柜。
地址详细信息与地址详细信息页面上的详细信息类似。
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