This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove separate paypal button and address views
- Loading branch information
Luuk Veenis
committed
Nov 11, 2016
1 parent
651baf9
commit e3e21a1
Showing
5 changed files
with
78 additions
and
100 deletions.
There are no files selected for viewing
9 changes: 0 additions & 9 deletions
9
lib/views/frontend/solidus_paypal_braintree/_address_field.html.erb
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
lib/views/frontend/solidus_paypal_braintree/_paypal_button.html.erb
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
lib/views/frontend/solidus_paypal_braintree/_paypal_credit_button.html.erb
This file was deleted.
Oops, something went wrong.
42 changes: 38 additions & 4 deletions
42
lib/views/frontend/spree/checkout/payment/_paypal_braintree.html.erb
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,4 +1,38 @@ | ||
<% if current_order.valid? %> | ||
<%= render partial: 'solidus_paypal_braintree/address_field', locals: { shipping_address: current_order.shipping_address } %> | ||
<% end %> | ||
<%= render partial: 'solidus_paypal_braintree/paypal_button' %> | ||
<% address = current_order.ship_address %> | ||
|
||
<!-- Load the client component. --> | ||
<script src="https://js.braintreegateway.com/web/3.4.0/js/client.min.js"></script> | ||
<!-- Load the PayPal component. --> | ||
<script src="https://js.braintreegateway.com/web/3.4.0/js/paypal.min.js"></script> | ||
<!-- Load the data-collector component. --> | ||
<script src="https://js.braintreegateway.com/web/3.4.0/js/data-collector.min.js"></script> | ||
<script src="https://www.paypalobjects.com/api/button.js?" | ||
data-merchant="braintree" | ||
data-id="paypal-button" | ||
data-button="checkout" | ||
data-color="blue" | ||
data-size="medium" | ||
data-shape="pill" | ||
data-button_type="button" | ||
data-button_disabled="true" | ||
></script> | ||
<script> | ||
var address = { | ||
line1: '<%= address.address1 %>', | ||
line2: '<%= address.address2 %>', | ||
city: '<%= address.city %>', | ||
state: '<%= address.state.name %>', | ||
postalCode: '<%= address.zipcode %>', | ||
countryCode: '<%= address.country.iso %>', | ||
phone: '<%= address.phone %>', | ||
recipientName: '<%= "#{address.firstname} #{address.lastname}" %>' | ||
} | ||
var button = new PaypalButton(document.querySelector("#paypal-button")); | ||
|
||
button.initialize({ | ||
flow: 'vault', | ||
enableShippingAddress: true, | ||
shippingAddressOverride: address, | ||
shippingAddressEditable: false | ||
}); | ||
</script> |
49 changes: 40 additions & 9 deletions
49
lib/views/frontend/spree/checkout/payment/_paypal_credit_braintree.html.erb
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,9 +1,40 @@ | ||
<% payment_method = current_store.payment_methods.where(active: true).find_by_type('SolidusPaypalBraintree::Gateway') %> | ||
<% if payment_method %> | ||
<%= render partial: 'solidus_paypal_braintree/address_field', locals: { shipping_address: current_order.shipping_address } %> | ||
<script> | ||
var amount = <%= current_order.total %> | ||
var currency = "<%= current_order.currency %>" | ||
</script> | ||
<%= render partial: 'solidus_paypal_braintree/paypal_credit_button' %> | ||
<% end %> | ||
<% address = current_order.ship_address %> | ||
|
||
<!-- Load the client component. --> | ||
<script src="https://js.braintreegateway.com/web/3.4.0/js/client.min.js"></script> | ||
<!-- Load the PayPal component. --> | ||
<script src="https://js.braintreegateway.com/web/3.4.0/js/paypal.min.js"></script> | ||
<!-- Load the data-collector component. --> | ||
<script src="https://js.braintreegateway.com/web/3.4.0/js/data-collector.min.js"></script> | ||
<script src="https://www.paypalobjects.com/api/button.js?" | ||
data-merchant="braintree" | ||
data-id="paypal-credit-button" | ||
data-button="credit" | ||
data-color="blue" | ||
data-size="medium" | ||
data-shape="pill" | ||
data-button_type="button" | ||
data-button_disabled="true" | ||
></script> | ||
<script> | ||
var address = { | ||
line1: '<%= address.address1 %>', | ||
line2: '<%= address.address2 %>', | ||
city: '<%= address.city %>', | ||
state: '<%= address.state.name %>', | ||
postalCode: '<%= address.zipcode %>', | ||
countryCode: '<%= address.country.iso %>', | ||
phone: '<%= address.phone %>', | ||
recipientName: '<%= "#{address.firstname} #{address.lastname}" %>' | ||
} | ||
var button = new PaypalButton(document.querySelector("#paypal-credit-button")); | ||
|
||
button.initialize({ | ||
flow: 'checkout', | ||
amount: <%= current_order.total %>, | ||
currency: '<%= current_order.currency %>', | ||
enableShippingAddress: true, | ||
shippingAddressOverride: address, | ||
shippingAddressEditable: false | ||
}); | ||
</script> |