-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from jhawthorn/hosted_fields
Use braintree's Hosted Fields
- Loading branch information
Showing
8 changed files
with
113 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,43 @@ | ||
<%= image_tag 'credit_cards/credit_card.gif', :id => 'credit-card-image' %> | ||
<% param_prefix = "payment_source[#{payment_method.id}]" %> | ||
<div class="braintree-payment"> | ||
<div class="braintree-cc-input"> | ||
<%= image_tag 'credit_cards/credit_card.gif', :id => 'credit-card-image' %> | ||
<% param_prefix = "payment_source[#{payment_method.id}]" %> | ||
|
||
<p class="field"> | ||
<%= label_tag "name_on_card_#{payment_method.id}", Spree.t(:name_on_card) %><span class="required">*</span><br /> | ||
<%= text_field_tag "#{param_prefix}[name]", "#{@order.billing_firstname} #{@order.billing_lastname}", { id: "name_on_card_#{payment_method.id}", :autocomplete => "cc-name" } %> | ||
</p> | ||
<p class="field"> | ||
<%= label_tag "name_on_card_#{payment_method.id}", Spree.t(:name_on_card) %><span class="required">*</span><br /> | ||
<%= text_field_tag "#{param_prefix}[name]", "#{@order.billing_firstname} #{@order.billing_lastname}", { id: "name_on_card_#{payment_method.id}", :autocomplete => "cc-name" } %> | ||
</p> | ||
|
||
<p class="field" data-hook="card_number"> | ||
<%= label_tag "card_number", Spree.t(:card_number) %><span class="required">*</span><br /> | ||
<%= text_field_tag "", '', {:id => 'card_number', :class => 'required cardNumber', :size => 19, :maxlength => 19, :autocomplete => "cc-number", type: "tel", :data => { "braintree-name" => "number" }} %> | ||
| ||
<span id="card_type" style="display:none;"> | ||
( <span id="looks_like" ><%= Spree.t(:card_type_is) %> <span id="type"></span></span> | ||
<span id="unrecognized"><%= Spree.t(:unrecognized_card_type) %></span> | ||
) | ||
</span> | ||
</p> | ||
<p class="field" data-hook="card_number"> | ||
<%= label_tag "braintree_card_number", Spree.t(:card_number) %><span class="required">*</span><br /> | ||
<label for="braintree_card_number" id="braintree_card_number" class="braintree-hosted-field"></label> | ||
| ||
<span id="card_type" style="display:none;"> | ||
( <span id="looks_like" ><%= Spree.t(:card_type_is) %> <span id="type"></span></span> | ||
<span id="unrecognized"><%= Spree.t(:unrecognized_card_type) %></span> | ||
) | ||
</span> | ||
</p> | ||
|
||
<p class="field" data-hook="card_expiration"> | ||
<%= label_tag "card_expiry", Spree.t(:expiration) %><span class="required">*</span><br /> | ||
<%= text_field_tag "#{param_prefix}[expiry]", '', {:id => 'card_expiry', :class => "required cardExpiry", :placeholder => "MM / YY", type: "tel"} %> | ||
<%= hidden_field_tag "", '', :id => 'braintree_expiration_date', :data => { "braintree-name" => "expiration_date" } %> | ||
</p> | ||
<p class="field" data-hook="card_expiration"> | ||
<%= label_tag "braintree_card_expiry", Spree.t(:expiration) %><span class="required">*</span><br /> | ||
<label for="braintree_card_expiry" id="braintree_card_expiry" class="braintree-hosted-field"></label> | ||
</p> | ||
|
||
<p class="field" data-hook="card_code"> | ||
<%= label_tag "card_code", Spree.t(:card_code) %><span class="required">*</span><br /> | ||
<%= text_field_tag "", '', {:id => 'card_code', :class => 'required cardCode', :size => 5, type: "tel", autocomplete: "off", :data => { "braintree-name" => "cvv" }} %> | ||
<%= link_to "(#{Spree.t(:what_is_this)})", spree.cvv_path, :target => '_blank', "data-hook" => "cvv_link", :id => "cvv_link" %> | ||
</p> | ||
<p class="field" data-hook="card_code"> | ||
<%= label_tag "braintree_card_code", Spree.t(:card_code) %><span class="required">*</span><br /> | ||
|
||
<% if @order.bill_address %> | ||
<%= fields_for "#{param_prefix}[address_attributes]", @order.bill_address do |f| %> | ||
<%= render :partial => 'spree/address/form_hidden', :locals => { :form => f } %> | ||
<label for="braintree_card_code" id="braintree_card_code" class="braintree-hosted-field card-code"></label> | ||
<%= link_to "(#{Spree.t(:what_is_this)})", spree.cvv_path, :target => '_blank', "data-hook" => "cvv_link", :id => "cvv_link" %> | ||
</p> | ||
</div> | ||
|
||
<% if @order.bill_address %> | ||
<%= fields_for "#{param_prefix}[address_attributes]", @order.bill_address do |f| %> | ||
<%= render :partial => 'spree/address/form_hidden', :locals => { :form => f } %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= hidden_field_tag "#{param_prefix}[cc_type]", '', :id => "cc_type", :class => 'ccType' %> | ||
<%= hidden_field_tag "order[payments_attributes][][payment_method_nonce]", '', :id => "payment_method_nonce" %> | ||
<%= hidden_field_tag "#{param_prefix}[cc_type]", '', :id => "cc_type", :class => 'ccType' %> | ||
<%= hidden_field_tag "order[payments_attributes][][payment_method_nonce]", '', :id => "payment_method_nonce" %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
lib/assets/stylesheets/spree/frontend/solidus_braintree.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.braintree-hosted-field { | ||
display: inline-block; | ||
border: 1px solid #d9d9db; | ||
font-family: "Ubuntu", sans-serif; | ||
font-size: 13px; | ||
height: 2em; | ||
width: 16em; | ||
cursor: text; | ||
padding: 0 5px; | ||
|
||
&.braintree-hosted-fields-focused { | ||
border-color: #00ADEE; | ||
} | ||
|
||
&.braintree-hosted-fields-valid { | ||
border-color: #63CE63; | ||
} | ||
|
||
&.braintree-hosted-fields-invalid { | ||
border-color: red; | ||
} | ||
|
||
&.card-code { | ||
width: 6em; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters