solidus_paypal_braintree 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +7 -0
- data/Rakefile +1 -4
- data/app/assets/javascripts/solidus_paypal_braintree/client.js +1 -1
- data/app/assets/javascripts/solidus_paypal_braintree/paypal_button.js +19 -8
- data/app/assets/javascripts/spree/backend/solidus_paypal_braintree.js +2 -2
- data/app/assets/javascripts/spree/frontend/paypal_button.js +15 -13
- data/app/controllers/solidus_paypal_braintree/client_tokens_controller.rb +2 -1
- data/app/models/solidus_paypal_braintree/gateway.rb +11 -5
- data/app/models/solidus_paypal_braintree/transaction_import.rb +2 -1
- data/app/views/spree/shared/_apple_pay_button.html.erb +27 -0
- data/app/views/spree/shared/_paypal_braintree_head_scripts.html.erb +19 -0
- data/app/views/spree/shared/_paypal_cart_button.html.erb +22 -0
- data/app/views/spree/shared/_paypal_checkout_button.html.erb +27 -0
- data/lib/controllers/frontend/solidus_paypal_braintree/transactions_controller.rb +2 -1
- data/lib/generators/solidus_paypal_braintree/install/install_generator.rb +0 -1
- data/lib/solidus_paypal_braintree/engine.rb +11 -1
- data/lib/solidus_paypal_braintree/version.rb +1 -1
- data/lib/views/frontend/spree/checkout/payment/_paypal_braintree.html.erb +3 -76
- metadata +25 -9
- data/app/overrides/admin_navigation_menu.rb +0 -6
- data/lib/views/backend/solidus_paypal_braintree/configurations/_admin_tab.html.erb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4532cc1c243930da786249db6885159a0dbbdcd33c93cdbafc4e97bd78f14938
|
4
|
+
data.tar.gz: dea753bf431d112a13398b4a62083bceccdbdb95f9cd265a08c0eaf1636f5e8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee52c4df8624682f72c3de3169284435868f3c70e502398c28142bba67648964d1cd2fcea89e3b72c94d075fcc01ac9cfd955f54b489ecb33eefd68d0553541f
|
7
|
+
data.tar.gz: 4d71c81ee1f5c5d70579c84ce186df98951e91de9acb1ef8c6b68cba94b3013daf10d9869c32ce6dd4e3fb7145e5bf9c6f9c42a2e9249aa69b5a09dc21896ce1
|
data/README.md
CHANGED
@@ -180,6 +180,13 @@ var button = new PaypalButton(document.querySelector("#your-button-id"));
|
|
180
180
|
button.setTokenizeCallback(your-callback);
|
181
181
|
```
|
182
182
|
|
183
|
+
### Express checkout from the cart
|
184
|
+
|
185
|
+
A PayPal button can also be included on the cart view to enable express checkouts:
|
186
|
+
```ruby
|
187
|
+
render "spree/shared/paypal_cart_button"
|
188
|
+
```
|
189
|
+
|
183
190
|
## Optional configuration
|
184
191
|
|
185
192
|
### Accepting multiple currencies
|
data/Rakefile
CHANGED
@@ -4,14 +4,11 @@ Bundler::GemHelper.install_tasks
|
|
4
4
|
|
5
5
|
begin
|
6
6
|
require 'spree/testing_support/extension_rake'
|
7
|
-
require 'rubocop/rake_task'
|
8
7
|
require 'rspec/core/rake_task'
|
9
8
|
|
10
9
|
RSpec::Core::RakeTask.new(:spec)
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
task default: %i(first_run rubocop spec)
|
11
|
+
task default: %i(first_run spec)
|
15
12
|
rescue LoadError
|
16
13
|
# no rspec available
|
17
14
|
end
|
@@ -168,7 +168,7 @@ SolidusPaypalBraintree.Client.prototype._createDataCollector = function() {
|
|
168
168
|
};
|
169
169
|
|
170
170
|
SolidusPaypalBraintree.Client.prototype._createPaypal = function() {
|
171
|
-
return SolidusPaypalBraintree.PromiseShim.convertBraintreePromise(braintree.
|
171
|
+
return SolidusPaypalBraintree.PromiseShim.convertBraintreePromise(braintree.paypalCheckout.create, [{
|
172
172
|
client: this._braintreeInstance
|
173
173
|
}]).then(function (paypalInstance) {
|
174
174
|
this._paypalInstance = paypalInstance;
|
@@ -4,15 +4,18 @@
|
|
4
4
|
* @constructor
|
5
5
|
* @param {object} element - The DOM element of your PayPal button
|
6
6
|
*/
|
7
|
-
SolidusPaypalBraintree.PaypalButton = function(element, paypalOptions) {
|
7
|
+
SolidusPaypalBraintree.PaypalButton = function(element, paypalOptions, options) {
|
8
8
|
this._element = element;
|
9
9
|
this._paypalOptions = paypalOptions || {};
|
10
|
+
this._options = options || {};
|
10
11
|
this._client = null;
|
12
|
+
this._environment = this._paypalOptions.environment || 'sandbox';
|
13
|
+
delete this._paypalOptions.environment;
|
11
14
|
|
12
15
|
if(!this._element) {
|
13
16
|
throw new Error("Element for the paypal button must be present on the page");
|
14
17
|
}
|
15
|
-
}
|
18
|
+
};
|
16
19
|
|
17
20
|
/**
|
18
21
|
* Creates the PayPal session using the provided options and enables the button
|
@@ -31,10 +34,17 @@ SolidusPaypalBraintree.PaypalButton.prototype.initialize = function() {
|
|
31
34
|
SolidusPaypalBraintree.PaypalButton.prototype.initializeCallback = function() {
|
32
35
|
this._paymentMethodId = this._client.paymentMethodId;
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
paypal.Button.render({
|
38
|
+
env: this._environment,
|
39
|
+
|
40
|
+
payment: function () {
|
41
|
+
return this._client.getPaypalInstance().createPayment(this._paypalOptions);
|
42
|
+
}.bind(this),
|
43
|
+
|
44
|
+
onAuthorize: function (data, actions) {
|
45
|
+
return this._client.getPaypalInstance().tokenizePayment(data, this._tokenizeCallback.bind(this));
|
46
|
+
}.bind(this)
|
47
|
+
}, this._element);
|
38
48
|
};
|
39
49
|
|
40
50
|
/**
|
@@ -60,7 +70,7 @@ SolidusPaypalBraintree.PaypalButton.prototype._tokenizeCallback = function(token
|
|
60
70
|
window.location.href = response.redirectUrl;
|
61
71
|
},
|
62
72
|
error: function(xhr) {
|
63
|
-
console.error("Error submitting transaction")
|
73
|
+
console.error("Error submitting transaction");
|
64
74
|
},
|
65
75
|
});
|
66
76
|
};
|
@@ -74,6 +84,7 @@ SolidusPaypalBraintree.PaypalButton.prototype._tokenizeCallback = function(token
|
|
74
84
|
SolidusPaypalBraintree.PaypalButton.prototype._transactionParams = function(payload) {
|
75
85
|
return {
|
76
86
|
"payment_method_id" : this._paymentMethodId,
|
87
|
+
"options": this._options,
|
77
88
|
"transaction" : {
|
78
89
|
"email" : payload.details.email,
|
79
90
|
"phone" : payload.details.phone,
|
@@ -81,7 +92,7 @@ SolidusPaypalBraintree.PaypalButton.prototype._transactionParams = function(payl
|
|
81
92
|
"payment_type" : payload.type,
|
82
93
|
"address_attributes" : this._addressParams(payload)
|
83
94
|
}
|
84
|
-
}
|
95
|
+
};
|
85
96
|
};
|
86
97
|
|
87
98
|
/**
|
@@ -68,8 +68,8 @@ $(function() {
|
|
68
68
|
if (!$paymentForm.length || !$hostedFields.length) { return; }
|
69
69
|
|
70
70
|
$.when(
|
71
|
-
$.getScript("https://js.braintreegateway.com/web/3.
|
72
|
-
$.getScript("https://js.braintreegateway.com/web/3.
|
71
|
+
$.getScript("https://js.braintreegateway.com/web/3.34.0/js/client.min.js"),
|
72
|
+
$.getScript("https://js.braintreegateway.com/web/3.34.0/js/hosted-fields.min.js")
|
73
73
|
).done(function() {
|
74
74
|
$hostedFields.each(function() {
|
75
75
|
var $this = $(this),
|
@@ -1,32 +1,34 @@
|
|
1
1
|
//= require solidus_paypal_braintree/paypal_button
|
2
2
|
|
3
|
+
// This is the PayPal button on the cart page
|
3
4
|
$(document).ready(function() {
|
4
5
|
if (document.getElementById("empty-cart")) {
|
5
6
|
$.when(
|
6
|
-
$.getScript("https://js.braintreegateway.com/web/3.
|
7
|
-
$.getScript("https://js.braintreegateway.com/web/3.
|
8
|
-
$.getScript("https://js.braintreegateway.com/web/3.
|
7
|
+
$.getScript("https://js.braintreegateway.com/web/3.31.0/js/client.min.js"),
|
8
|
+
$.getScript("https://js.braintreegateway.com/web/3.31.0/js/paypal-checkout.min.js"),
|
9
|
+
$.getScript("https://js.braintreegateway.com/web/3.31.0/js/data-collector.min.js")
|
9
10
|
).done(function() {
|
11
|
+
$("#content").append('<div id="paypal-button"/>');
|
10
12
|
$('<script/>').attr({
|
11
|
-
'data-
|
12
|
-
'data-id' : "paypal-button",
|
13
|
-
'data-button' : "checkout",
|
14
|
-
'data-color' : "blue",
|
15
|
-
'data-size' : "medium",
|
16
|
-
'data-shape' : "pill",
|
17
|
-
'data-button_type' : "button",
|
18
|
-
'data-button_disabled' : "true"
|
13
|
+
'data-version-4' : "true"
|
19
14
|
}).
|
20
15
|
load(function() {
|
21
16
|
var paypalOptions = {
|
22
17
|
flow: 'vault',
|
23
18
|
enableShippingAddress: true
|
24
19
|
}
|
25
|
-
var
|
20
|
+
var options = {
|
21
|
+
restart_checkout: true
|
22
|
+
}
|
23
|
+
var button = new SolidusPaypalBraintree.createPaypalButton(
|
24
|
+
document.querySelector("#paypal-button"),
|
25
|
+
paypalOptions,
|
26
|
+
options
|
27
|
+
);
|
26
28
|
return button.initialize();
|
27
29
|
}).
|
28
30
|
insertAfter("#content").
|
29
|
-
attr('src', 'https://www.paypalobjects.com/api/
|
31
|
+
attr('src', 'https://www.paypalobjects.com/api/checkout.js');
|
30
32
|
});
|
31
33
|
}
|
32
34
|
});
|
@@ -14,7 +14,8 @@ module SolidusPaypalBraintree
|
|
14
14
|
if params[:payment_method_id]
|
15
15
|
@gateway = ::SolidusPaypalBraintree::Gateway.find_by!(id: params[:payment_method_id])
|
16
16
|
else
|
17
|
-
|
17
|
+
store_payment_methods_scope = current_store.payment_methods.empty? ? ::SolidusPaypalBraintree::Gateway.all : ::SolidusPaypalBraintree::Gateway.where(id: current_store.payment_method_ids)
|
18
|
+
@gateway = ::SolidusPaypalBraintree::Gateway.where(active: true).merge(store_payment_methods_scope).first!
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -57,7 +57,7 @@ module SolidusPaypalBraintree
|
|
57
57
|
merchant_id: preferred_merchant_id,
|
58
58
|
public_key: preferred_public_key,
|
59
59
|
private_key: preferred_private_key,
|
60
|
-
logger:
|
60
|
+
logger: logger
|
61
61
|
}
|
62
62
|
end
|
63
63
|
|
@@ -171,16 +171,16 @@ module SolidusPaypalBraintree
|
|
171
171
|
# Otherwise, we return false so Solidus creates a refund instead.
|
172
172
|
#
|
173
173
|
# @api public
|
174
|
-
# @param
|
174
|
+
# @param payment [Spree::Payment] the payment to void
|
175
175
|
# @return [Response|FalseClass]
|
176
|
-
def try_void(
|
177
|
-
transaction = braintree.transaction.find(response_code)
|
176
|
+
def try_void(payment)
|
177
|
+
transaction = braintree.transaction.find(payment.response_code)
|
178
178
|
if transaction.status.in? SolidusPaypalBraintree::Gateway::VOIDABLE_STATUSES
|
179
179
|
# Sometimes Braintree returns a voidable status although it is not voidable anymore.
|
180
180
|
# When we try to void that transaction we receive an error and need to return false
|
181
181
|
# so Solidus can create a refund instead.
|
182
182
|
begin
|
183
|
-
void(response_code, nil, {})
|
183
|
+
void(payment.response_code, nil, {})
|
184
184
|
rescue ActiveMerchant::ConnectionError => e
|
185
185
|
e.message.match(NON_VOIDABLE_STATUS_ERROR_REGEXP) ? false : raise(e)
|
186
186
|
end
|
@@ -261,6 +261,12 @@ module SolidusPaypalBraintree
|
|
261
261
|
|
262
262
|
private
|
263
263
|
|
264
|
+
def logger
|
265
|
+
Braintree::Configuration.logger.clone.tap do |logger|
|
266
|
+
logger.level = Rails.logger.level
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
264
270
|
def dollars(cents)
|
265
271
|
Money.new(cents).dollars
|
266
272
|
end
|
@@ -35,7 +35,7 @@ module SolidusPaypalBraintree
|
|
35
35
|
order.user
|
36
36
|
end
|
37
37
|
|
38
|
-
def import!(end_state)
|
38
|
+
def import!(end_state, restart_checkout: false)
|
39
39
|
if valid?
|
40
40
|
order.email = user.try!(:email) || transaction.email
|
41
41
|
|
@@ -51,6 +51,7 @@ module SolidusPaypalBraintree
|
|
51
51
|
amount: order.total
|
52
52
|
|
53
53
|
order.save!
|
54
|
+
order.restart_checkout_flow if restart_checkout
|
54
55
|
advance_order(payment, end_state)
|
55
56
|
else
|
56
57
|
raise InvalidImportError,
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<% address = current_order.ship_address %>
|
2
|
+
|
3
|
+
<button id="apple-pay-button" class="apple-pay-button"></button>
|
4
|
+
|
5
|
+
<script>
|
6
|
+
var applePayButtonElement = document.getElementById('apple-pay-button');
|
7
|
+
var applePayOptions = {
|
8
|
+
paymentMethodId: <%= id %>,
|
9
|
+
storeName: "<%= current_store.name %>",
|
10
|
+
orderEmail: "<%= current_order.email %>",
|
11
|
+
amount: "<%= current_order.total %>",
|
12
|
+
shippingContact: {
|
13
|
+
emailAddress: '<%= current_order.email %>',
|
14
|
+
familyName: '<%= address.firstname %>',
|
15
|
+
givenName: '<%= address.lastname %>',
|
16
|
+
phoneNumber: '<%= address.phone %>',
|
17
|
+
addressLines: ['<%= address.address1 %>','<%= address.address2 %>'],
|
18
|
+
locality: '<%= address.city %>',
|
19
|
+
administrativeArea: '<%= address.state.name %>',
|
20
|
+
postalCode: '<%= address.zipcode %>',
|
21
|
+
country: '<%= address.country.name %>',
|
22
|
+
countryCode: '<%= address.country.iso %>'
|
23
|
+
}
|
24
|
+
};
|
25
|
+
var button = new SolidusPaypalBraintree.createApplePayButton(applePayButtonElement, applePayOptions);
|
26
|
+
button.initialize();
|
27
|
+
</script>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% content_for :head do %>
|
2
|
+
<script src="https://js.braintreegateway.com/web/3.34.0/js/client.min.js"></script>
|
3
|
+
<script src="https://js.braintreegateway.com/web/3.34.0/js/data-collector.min.js"></script>
|
4
|
+
|
5
|
+
<% if current_store.braintree_configuration.paypal? %>
|
6
|
+
<script src="https://js.braintreegateway.com/web/3.34.0/js/paypal-checkout.min.js"></script>
|
7
|
+
<script src="https://www.paypalobjects.com/api/checkout.js" data-version-4></script>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% if current_store.braintree_configuration.credit_card? %>
|
11
|
+
<script src="https://js.braintreegateway.com/web/3.34.0/js/hosted-fields.min.js"></script>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<% if current_store.braintree_configuration.apple_pay? %>
|
15
|
+
<script src="https://js.braintreegateway.com/web/3.34.0/js/apple-pay.min.js"></script>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<%= javascript_include_tag "solidus_paypal_braintree/checkout" %>
|
19
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= render "spree/shared/paypal_braintree_head_scripts" %>
|
2
|
+
|
3
|
+
<div id="paypal-button"></div>
|
4
|
+
|
5
|
+
<script>
|
6
|
+
var paypalOptions = {
|
7
|
+
flow: 'vault',
|
8
|
+
enableShippingAddress: true,
|
9
|
+
environment: '<%= Rails.env.production? ? "production" : "sandbox" %>'
|
10
|
+
}
|
11
|
+
var options = {
|
12
|
+
restart_checkout: true
|
13
|
+
}
|
14
|
+
|
15
|
+
var button = new SolidusPaypalBraintree.createPaypalButton(
|
16
|
+
document.querySelector("#paypal-button"),
|
17
|
+
paypalOptions,
|
18
|
+
options
|
19
|
+
)
|
20
|
+
|
21
|
+
button.initialize();
|
22
|
+
</script>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<% address = current_order.ship_address %>
|
2
|
+
|
3
|
+
<div id="paypal-button"></div>
|
4
|
+
|
5
|
+
<script>
|
6
|
+
var address = {
|
7
|
+
line1: '<%= address.address1 %>',
|
8
|
+
line2: '<%= address.address2 %>',
|
9
|
+
city: '<%= address.city %>',
|
10
|
+
state: '<%= address.state.name %>',
|
11
|
+
postalCode: '<%= address.zipcode %>',
|
12
|
+
countryCode: '<%= address.country.iso %>',
|
13
|
+
phone: '<%= address.phone %>',
|
14
|
+
recipientName: '<%= "#{address.firstname} #{address.lastname}" %>'
|
15
|
+
}
|
16
|
+
|
17
|
+
var paypalOptions = {
|
18
|
+
flow: 'vault',
|
19
|
+
enableShippingAddress: true,
|
20
|
+
shippingAddressOverride: address,
|
21
|
+
shippingAddressEditable: false,
|
22
|
+
environment: '<%= Rails.env.production? ? "production" : "sandbox" %>'
|
23
|
+
}
|
24
|
+
|
25
|
+
var button = new SolidusPaypalBraintree.createPaypalButton(document.querySelector("#paypal-button"), paypalOptions);
|
26
|
+
button.initialize();
|
27
|
+
</script>
|
@@ -15,10 +15,11 @@ class SolidusPaypalBraintree::TransactionsController < Spree::StoreController
|
|
15
15
|
def create
|
16
16
|
transaction = SolidusPaypalBraintree::Transaction.new transaction_params
|
17
17
|
import = SolidusPaypalBraintree::TransactionImport.new(current_order, transaction)
|
18
|
+
restart_checkout = params[:options] && params[:options][:restart_checkout] == "true"
|
18
19
|
|
19
20
|
respond_to do |format|
|
20
21
|
if import.valid?
|
21
|
-
import.import!(import_state)
|
22
|
+
import.import!(import_state, restart_checkout: restart_checkout)
|
22
23
|
|
23
24
|
format.html { redirect_to redirect_url(import) }
|
24
25
|
format.json { render json: { redirectUrl: redirect_url(import) } }
|
@@ -5,7 +5,6 @@ module SolidusPaypalBraintree
|
|
5
5
|
|
6
6
|
def add_javascripts
|
7
7
|
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require solidus_paypal_braintree/frontend\n"
|
8
|
-
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/paypal_button\n"
|
9
8
|
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/solidus_paypal_braintree\n"
|
10
9
|
end
|
11
10
|
|
@@ -27,7 +27,6 @@ module SolidusPaypalBraintree
|
|
27
27
|
config.assets.precompile += [
|
28
28
|
'solidus_paypal_braintree/checkout.js',
|
29
29
|
'solidus_paypal_braintree/frontend.js',
|
30
|
-
'spree/frontend/paypal_button.js',
|
31
30
|
'spree/frontend/apple_pay_button.js'
|
32
31
|
]
|
33
32
|
paths["app/controllers"] << "lib/controllers/frontend"
|
@@ -49,6 +48,17 @@ module SolidusPaypalBraintree
|
|
49
48
|
end
|
50
49
|
|
51
50
|
paths["app/views"] << "lib/views/backend"
|
51
|
+
|
52
|
+
initializer "solidus_paypal_braintree_admin_menu_item", after: "register_solidus_paypal_braintree_gateway" do |app|
|
53
|
+
Spree::Backend::Config.configure do |config|
|
54
|
+
config.menu_items << config.class::MenuItem.new(
|
55
|
+
[:braintree],
|
56
|
+
'cc-paypal',
|
57
|
+
url: '/solidus_paypal_braintree/configurations/list',
|
58
|
+
condition: -> { can?(:list, SolidusPaypalBraintree::Configuration) }
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
52
62
|
end
|
53
63
|
end
|
54
64
|
end
|
@@ -1,59 +1,9 @@
|
|
1
|
-
<% address = current_order.ship_address %>
|
2
1
|
<% id = payment_method.id %>
|
3
2
|
|
4
|
-
|
5
|
-
<script src="https://js.braintreegateway.com/web/3.22.1/js/client.min.js"></script>
|
6
|
-
<script src="https://js.braintreegateway.com/web/3.22.1/js/data-collector.min.js"></script>
|
7
|
-
|
8
|
-
<% if current_store.braintree_configuration.paypal? %>
|
9
|
-
<script src="https://js.braintreegateway.com/web/3.22.1/js/paypal.min.js"></script>
|
10
|
-
<% end %>
|
11
|
-
|
12
|
-
<% if current_store.braintree_configuration.credit_card? %>
|
13
|
-
<script src="https://js.braintreegateway.com/web/3.22.1/js/hosted-fields.min.js"></script>
|
14
|
-
<% end %>
|
15
|
-
|
16
|
-
<% if current_store.braintree_configuration.apple_pay? %>
|
17
|
-
<script src="https://js.braintreegateway.com/web/3.22.1/js/apple-pay.min.js"></script>
|
18
|
-
<% end %>
|
19
|
-
|
20
|
-
<%= javascript_include_tag "solidus_paypal_braintree/checkout" %>
|
21
|
-
<% end %>
|
3
|
+
<%= render "spree/shared/paypal_braintree_head_scripts" %>
|
22
4
|
|
23
5
|
<% if current_store.braintree_configuration.paypal? %>
|
24
|
-
|
25
|
-
data-merchant="braintree"
|
26
|
-
data-id="paypal-button"
|
27
|
-
data-button="checkout"
|
28
|
-
data-color="blue"
|
29
|
-
data-size="medium"
|
30
|
-
data-shape="pill"
|
31
|
-
data-button_type="button"
|
32
|
-
data-button_disabled="true"
|
33
|
-
></script>
|
34
|
-
|
35
|
-
<script>
|
36
|
-
var address = {
|
37
|
-
line1: '<%= address.address1 %>',
|
38
|
-
line2: '<%= address.address2 %>',
|
39
|
-
city: '<%= address.city %>',
|
40
|
-
state: '<%= address.state.name %>',
|
41
|
-
postalCode: '<%= address.zipcode %>',
|
42
|
-
countryCode: '<%= address.country.iso %>',
|
43
|
-
phone: '<%= address.phone %>',
|
44
|
-
recipientName: '<%= "#{address.firstname} #{address.lastname}" %>'
|
45
|
-
}
|
46
|
-
|
47
|
-
var paypalOptions = {
|
48
|
-
flow: 'vault',
|
49
|
-
enableShippingAddress: true,
|
50
|
-
shippingAddressOverride: address,
|
51
|
-
shippingAddressEditable: false
|
52
|
-
}
|
53
|
-
|
54
|
-
var button = new SolidusPaypalBraintree.createPaypalButton(document.querySelector("#paypal-button"), paypalOptions);
|
55
|
-
button.initialize();
|
56
|
-
</script>
|
6
|
+
<%= render "spree/shared/paypal_checkout_button" %>
|
57
7
|
<% end %>
|
58
8
|
|
59
9
|
<% if current_store.braintree_configuration.credit_card? %>
|
@@ -63,28 +13,5 @@
|
|
63
13
|
<% end %>
|
64
14
|
|
65
15
|
<% if current_store.braintree_configuration.apple_pay? %>
|
66
|
-
|
67
|
-
<script>
|
68
|
-
var applePayButtonElement = document.getElementById('apple-pay-button');
|
69
|
-
var applePayOptions = {
|
70
|
-
paymentMethodId: <%= id %>,
|
71
|
-
storeName: "<%= current_store.name %>",
|
72
|
-
orderEmail: "<%= current_order.email %>",
|
73
|
-
amount: "<%= current_order.total %>",
|
74
|
-
shippingContact: {
|
75
|
-
emailAddress: '<%= current_order.email %>',
|
76
|
-
familyName: '<%= address.firstname %>',
|
77
|
-
givenName: '<%= address.lastname %>',
|
78
|
-
phoneNumber: '<%= address.phone %>',
|
79
|
-
addressLines: ['<%= address.address1 %>','<%= address.address2 %>'],
|
80
|
-
locality: '<%= address.city %>',
|
81
|
-
administrativeArea: '<%= address.state.name %>',
|
82
|
-
postalCode: '<%= address.zipcode %>',
|
83
|
-
country: '<%= address.country.name %>',
|
84
|
-
countryCode: '<%= address.country.iso %>'
|
85
|
-
}
|
86
|
-
};
|
87
|
-
var button = new SolidusPaypalBraintree.createApplePayButton(applePayButtonElement, applePayOptions);
|
88
|
-
button.initialize();
|
89
|
-
</script>
|
16
|
+
<%= render "spree/shared/apple_pay_button" %>
|
90
17
|
<% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_paypal_braintree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stembolt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus
|
@@ -76,16 +76,30 @@ dependencies:
|
|
76
76
|
name: capybara
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- - "
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
81
|
+
version: '0'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- - "
|
86
|
+
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: puma
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
104
|
name: capybara-screenshot
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -317,9 +331,12 @@ files:
|
|
317
331
|
- app/models/solidus_paypal_braintree/transaction_address.rb
|
318
332
|
- app/models/solidus_paypal_braintree/transaction_import.rb
|
319
333
|
- app/models/spree/store_decorator.rb
|
320
|
-
- app/
|
334
|
+
- app/views/spree/shared/_apple_pay_button.html.erb
|
321
335
|
- app/views/spree/shared/_braintree_errors.html.erb
|
322
336
|
- app/views/spree/shared/_braintree_hosted_fields.html.erb
|
337
|
+
- app/views/spree/shared/_paypal_braintree_head_scripts.html.erb
|
338
|
+
- app/views/spree/shared/_paypal_cart_button.html.erb
|
339
|
+
- app/views/spree/shared/_paypal_checkout_button.html.erb
|
323
340
|
- config/initializers/braintree.rb
|
324
341
|
- config/locales/en.yml
|
325
342
|
- config/locales/it.yml
|
@@ -341,7 +358,6 @@ files:
|
|
341
358
|
- lib/solidus_paypal_braintree/factories.rb
|
342
359
|
- lib/solidus_paypal_braintree/request_protection.rb
|
343
360
|
- lib/solidus_paypal_braintree/version.rb
|
344
|
-
- lib/views/backend/solidus_paypal_braintree/configurations/_admin_tab.html.erb
|
345
361
|
- lib/views/backend/solidus_paypal_braintree/configurations/list.html.erb
|
346
362
|
- lib/views/backend/spree/admin/payments/source_forms/_paypal_braintree.html.erb
|
347
363
|
- lib/views/backend/spree/admin/payments/source_views/_paypal_braintree.html.erb
|
@@ -368,7 +384,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
368
384
|
version: '0'
|
369
385
|
requirements: []
|
370
386
|
rubyforge_project:
|
371
|
-
rubygems_version: 2.
|
387
|
+
rubygems_version: 2.7.6
|
372
388
|
signing_key:
|
373
389
|
specification_version: 4
|
374
390
|
summary: Officially supported Paypal/Braintree extension
|
@@ -1,6 +0,0 @@
|
|
1
|
-
Deface::Override.new(
|
2
|
-
virtual_path: "spree/admin/shared/_settings_sub_menu",
|
3
|
-
name: "solidus_paypal_braintree_admin_navigation_configuration",
|
4
|
-
insert_bottom: "[data-hook='admin_settings_sub_tabs']",
|
5
|
-
partial: "solidus_paypal_braintree/configurations/admin_tab"
|
6
|
-
)
|