solidus_paypal_braintree 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +0 -18
- data/CHANGELOG.md +9 -0
- data/README.md +9 -0
- data/lib/generators/solidus_paypal_braintree/install/install_generator.rb +2 -36
- data/lib/solidus_paypal_braintree/engine.rb +0 -56
- data/lib/solidus_paypal_braintree/version.rb +1 -1
- data/lib/solidus_paypal_braintree.rb +1 -6
- data/solidus_paypal_braintree.gemspec +7 -5
- data/spec/controllers/solidus_paypal_braintree/checkouts_controller_spec.rb +5 -5
- data/spec/controllers/solidus_paypal_braintree/client_tokens_controller_spec.rb +2 -2
- data/spec/controllers/solidus_paypal_braintree/configurations_controller_spec.rb +2 -2
- data/spec/controllers/solidus_paypal_braintree/transactions_controller_spec.rb +5 -5
- data/spec/features/backend/configuration_spec.rb +3 -3
- data/spec/features/backend/new_payment_spec.rb +1 -1
- data/spec/features/frontend/braintree_credit_card_checkout_spec.rb +3 -3
- data/spec/fixtures/views/spree/orders/edit.html.erb +1 -1
- data/spec/helpers/solidus_paypal_braintree/braintree_admin_helper_spec.rb +1 -1
- data/spec/helpers/solidus_paypal_braintree/braintree_checkout_helper_spec.rb +5 -5
- data/spec/models/solidus_paypal_braintree/address_spec.rb +1 -1
- data/spec/models/solidus_paypal_braintree/avs_result_spec.rb +1 -1
- data/spec/models/solidus_paypal_braintree/gateway_spec.rb +11 -11
- data/spec/models/solidus_paypal_braintree/response_spec.rb +1 -1
- data/spec/models/solidus_paypal_braintree/source_spec.rb +2 -2
- data/spec/models/solidus_paypal_braintree/transaction_address_spec.rb +1 -1
- data/spec/models/solidus_paypal_braintree/transaction_import_spec.rb +12 -12
- data/spec/models/solidus_paypal_braintree/transaction_spec.rb +2 -2
- data/spec/requests/spree/api/orders_controller_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- data/spec/support/gateway_helpers.rb +3 -3
- metadata +9 -174
- data/app/assets/config/solidus_paypal_braintree_manifest.js +0 -1
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_blue_button_280x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_blue_button_320x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_blue_button_375x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_white_button_280x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_white_button_320x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_active_white_button_375x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_acceptance_mark.svg +0 -15
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_button_280x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_button_320x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_button_375x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_blue_logo.svg +0 -18
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_acceptance_mark.svg +0 -20
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_button_280x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_button_320x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_button_375x48.svg +0 -19
- data/app/assets/images/solidus_paypal_braintree/venmo/venmo_white_logo.svg +0 -18
- data/app/assets/javascripts/solidus_paypal_braintree/apple_pay_button.js +0 -179
- data/app/assets/javascripts/solidus_paypal_braintree/checkout.js +0 -108
- data/app/assets/javascripts/solidus_paypal_braintree/client.js +0 -239
- data/app/assets/javascripts/solidus_paypal_braintree/constants.js +0 -89
- data/app/assets/javascripts/solidus_paypal_braintree/frontend.js +0 -14
- data/app/assets/javascripts/solidus_paypal_braintree/hosted_form.js +0 -46
- data/app/assets/javascripts/solidus_paypal_braintree/paypal_button.js +0 -178
- data/app/assets/javascripts/solidus_paypal_braintree/paypal_messaging.js +0 -22
- data/app/assets/javascripts/solidus_paypal_braintree/promise.js +0 -20
- data/app/assets/javascripts/solidus_paypal_braintree/venmo_button.js +0 -86
- data/app/assets/javascripts/spree/backend/solidus_paypal_braintree.js +0 -96
- data/app/assets/javascripts/spree/frontend/paypal_button.js +0 -34
- data/app/assets/javascripts/spree/frontend/solidus_paypal_braintree.js +0 -1
- data/app/assets/stylesheets/spree/backend/solidus_paypal_braintree.css +0 -4
- data/app/assets/stylesheets/spree/backend/solidus_paypal_braintree.scss +0 -28
- data/app/assets/stylesheets/spree/frontend/solidus_paypal_braintree.css +0 -51
- data/app/decorators/controllers/solidus_paypal_braintree/admin_payments_controller_decorator.rb +0 -11
- data/app/decorators/controllers/solidus_paypal_braintree/checkout_controller_decorator.rb +0 -11
- data/app/decorators/controllers/solidus_paypal_braintree/client_tokens_controller.rb +0 -41
- data/app/decorators/controllers/solidus_paypal_braintree/orders_controller_decorator.rb +0 -11
- data/app/decorators/models/solidus_paypal_braintree/spree/store_decorator.rb +0 -20
- data/app/decorators/models/solidus_paypal_braintree/spree/user_decorator.rb +0 -13
- data/app/helpers/solidus_paypal_braintree/braintree_admin_helper.rb +0 -23
- data/app/helpers/solidus_paypal_braintree/braintree_checkout_helper.rb +0 -60
- data/app/models/application_record.rb +0 -5
- data/app/models/solidus_paypal_braintree/address.rb +0 -64
- data/app/models/solidus_paypal_braintree/avs_result.rb +0 -69
- data/app/models/solidus_paypal_braintree/configuration.rb +0 -39
- data/app/models/solidus_paypal_braintree/customer.rb +0 -8
- data/app/models/solidus_paypal_braintree/gateway.rb +0 -433
- data/app/models/solidus_paypal_braintree/response.rb +0 -80
- data/app/models/solidus_paypal_braintree/source.rb +0 -135
- data/app/models/solidus_paypal_braintree/transaction.rb +0 -31
- data/app/models/solidus_paypal_braintree/transaction_address.rb +0 -88
- data/app/models/solidus_paypal_braintree/transaction_import.rb +0 -98
- data/app/overrides/spree/payments/payment/add_paypal_funding_source_to_payment.rb +0 -9
- data/app/views/spree/api/payments/source_views/_paypal_braintree.json.jbuilder +0 -3
- data/app/views/spree/checkout/existing_payment/_paypal_braintree.html.erb +0 -10
- data/app/views/spree/shared/_apple_pay_button.html.erb +0 -27
- data/app/views/spree/shared/_braintree_errors.html.erb +0 -16
- data/app/views/spree/shared/_braintree_hosted_fields.html.erb +0 -43
- data/app/views/spree/shared/_paypal_braintree_head_scripts.html.erb +0 -26
- data/app/views/spree/shared/_paypal_cart_button.html.erb +0 -38
- data/app/views/spree/shared/_paypal_messaging.html.erb +0 -13
- data/app/views/spree/shared/_venmo_button.html.erb +0 -33
- data/config/locales/en.yml +0 -96
- data/config/locales/it.yml +0 -56
- data/config/routes.rb +0 -14
- data/db/migrate/20160830061749_create_solidus_paypal_braintree_sources.rb +0 -16
- data/db/migrate/20160906201711_create_solidus_paypal_braintree_customers.rb +0 -13
- data/db/migrate/20161114231422_create_solidus_paypal_braintree_configurations.rb +0 -11
- data/db/migrate/20161125172005_add_braintree_configuration_to_stores.rb +0 -7
- data/db/migrate/20170203191030_add_credit_card_to_braintree_configuration.rb +0 -6
- data/db/migrate/20170505193712_add_null_constraint_to_sources.rb +0 -32
- data/db/migrate/20170508085402_add_not_null_constraint_to_sources_payment_type.rb +0 -11
- data/db/migrate/20190705115327_add_paypal_button_preferences_to_braintree_configurations.rb +0 -5
- data/db/migrate/20190911141712_add_3d_secure_to_braintree_configuration.rb +0 -5
- data/db/migrate/20211222170950_add_paypal_funding_source_to_solidus_paypal_braintree_sources.rb +0 -5
- data/db/migrate/20220104150301_add_venmo_to_braintree_configuration.rb +0 -5
- data/lib/controllers/backend/solidus_paypal_braintree/configurations_controller.rb +0 -48
- data/lib/controllers/frontend/solidus_paypal_braintree/checkouts_controller.rb +0 -31
- data/lib/controllers/frontend/solidus_paypal_braintree/transactions_controller.rb +0 -67
- data/lib/generators/solidus_paypal_braintree/install/templates/initializer.rb +0 -6
- data/lib/solidus_paypal_braintree/country_mapper.rb +0 -37
- data/lib/solidus_paypal_braintree/extension_configuration.rb +0 -23
- data/lib/solidus_paypal_braintree/request_protection.rb +0 -21
- data/lib/solidus_paypal_braintree/testing_support/factories.rb +0 -53
- data/lib/views/backend/solidus_paypal_braintree/configurations/list.html.erb +0 -63
- data/lib/views/backend/spree/admin/payments/source_forms/_paypal_braintree.html.erb +0 -16
- data/lib/views/backend/spree/admin/payments/source_views/_paypal_braintree.html.erb +0 -39
- data/lib/views/backend/spree/admin/shared/preference_fields/_preference_select.html.erb +0 -13
- data/lib/views/backend_v1.2/spree/admin/payments/source_forms/_paypal_braintree.html.erb +0 -16
- data/lib/views/backend_v2.4/spree/admin/shared/preference_fields/_hash.html.erb +0 -12
- data/lib/views/frontend/solidus_paypal_braintree/payments/_payment.html.erb +0 -12
- data/lib/views/frontend/spree/checkout/payment/_paypal_braintree.html.erb +0 -23
- data/lib/views/frontend/spree/shared/_paypal_checkout_button.html.erb +0 -32
@@ -1,88 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_model'
|
4
|
-
require 'solidus_paypal_braintree/country_mapper'
|
5
|
-
|
6
|
-
module SolidusPaypalBraintree
|
7
|
-
class TransactionAddress
|
8
|
-
include ActiveModel::Model
|
9
|
-
include ActiveModel::Validations::Callbacks
|
10
|
-
include SolidusPaypalBraintree::CountryMapper
|
11
|
-
|
12
|
-
attr_accessor :country_code, :name, :city, :zip, :state_code,
|
13
|
-
:address_line_1, :address_line_2, :first_name, :last_name
|
14
|
-
|
15
|
-
validates :address_line_1, :city, :zip, :country_code, presence: true
|
16
|
-
validates :name, presence: true, unless: ->(address){ address.first_name.present? }
|
17
|
-
|
18
|
-
before_validation do
|
19
|
-
self.country_code = country_code.presence || "us"
|
20
|
-
end
|
21
|
-
|
22
|
-
validates :spree_country, presence: true
|
23
|
-
validates :state_code, :spree_state, presence: true, if: :should_match_state_model?
|
24
|
-
|
25
|
-
def initialize(attributes = {})
|
26
|
-
country_name = attributes.delete(:country_name) || ""
|
27
|
-
if attributes[:country_code].blank?
|
28
|
-
attributes[:country_code] = iso_from_name(country_name)
|
29
|
-
end
|
30
|
-
|
31
|
-
super(attributes)
|
32
|
-
end
|
33
|
-
|
34
|
-
def spree_country
|
35
|
-
country_code && (@country ||= ::Spree::Country.find_by(iso: country_code.upcase))
|
36
|
-
end
|
37
|
-
|
38
|
-
def spree_state
|
39
|
-
spree_country && state_code && ( @state ||= spree_country.states.find_by(
|
40
|
-
::Spree::State.arel_table[:name].matches(state_code).or(
|
41
|
-
::Spree::State.arel_table[:abbr].matches(state_code)
|
42
|
-
)
|
43
|
-
))
|
44
|
-
end
|
45
|
-
|
46
|
-
def to_spree_address
|
47
|
-
address = ::Spree::Address.new(
|
48
|
-
city: city,
|
49
|
-
country: spree_country,
|
50
|
-
address1: address_line_1,
|
51
|
-
address2: address_line_2,
|
52
|
-
zipcode: zip
|
53
|
-
)
|
54
|
-
|
55
|
-
if SolidusSupport.combined_first_and_last_name_in_address?
|
56
|
-
address.name = begin
|
57
|
-
if first_name.nil?
|
58
|
-
name
|
59
|
-
else
|
60
|
-
[first_name, last_name].join(" ")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
else
|
64
|
-
::Spree::Deprecation.warn("first_name and last_name are deprecated. Use name instead.", caller)
|
65
|
-
if first_name.nil?
|
66
|
-
first, last = SolidusPaypalBraintree::Address.split_name(name)
|
67
|
-
address.firstname = first
|
68
|
-
address.lastname = last || "(left blank)"
|
69
|
-
else
|
70
|
-
address.firstname = first_name
|
71
|
-
address.lastname = last_name || "(left blank)"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
if spree_state
|
76
|
-
address.state = spree_state
|
77
|
-
else
|
78
|
-
address.state_name = state_code
|
79
|
-
end
|
80
|
-
address
|
81
|
-
end
|
82
|
-
|
83
|
-
# Check to see if this address should match to a state model in the database
|
84
|
-
def should_match_state_model?
|
85
|
-
spree_country&.states_required?
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_model'
|
4
|
-
|
5
|
-
module SolidusPaypalBraintree
|
6
|
-
class TransactionImport
|
7
|
-
class InvalidImportError < StandardError; end
|
8
|
-
|
9
|
-
include ActiveModel::Model
|
10
|
-
|
11
|
-
validate do
|
12
|
-
errors.add("Address", "is invalid") if address && !address.valid?
|
13
|
-
|
14
|
-
if !transaction.valid?
|
15
|
-
transaction.errors.each do |error|
|
16
|
-
errors.add(error.attribute, error.message)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
errors.none?
|
20
|
-
end
|
21
|
-
|
22
|
-
attr_reader :transaction, :order
|
23
|
-
|
24
|
-
def initialize(order, transaction)
|
25
|
-
@order = order
|
26
|
-
@transaction = transaction
|
27
|
-
end
|
28
|
-
|
29
|
-
def source
|
30
|
-
SolidusPaypalBraintree::Source.new(
|
31
|
-
nonce: transaction.nonce,
|
32
|
-
payment_type: transaction.payment_type,
|
33
|
-
payment_method: transaction.payment_method,
|
34
|
-
paypal_funding_source: transaction.paypal_funding_source,
|
35
|
-
user: user
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
delegate :user, to: :order
|
40
|
-
|
41
|
-
def import!(end_state, restart_checkout: false)
|
42
|
-
if valid?
|
43
|
-
order.email = user&.email || transaction.email
|
44
|
-
|
45
|
-
if address
|
46
|
-
order.shipping_address = order.billing_address = address
|
47
|
-
# work around a bug in most solidus versions
|
48
|
-
# about tax zone cachine between address changes
|
49
|
-
order.instance_variable_set(:@tax_zone, nil)
|
50
|
-
end
|
51
|
-
|
52
|
-
payment = order.payments.new(
|
53
|
-
source: source,
|
54
|
-
payment_method: transaction.payment_method,
|
55
|
-
amount: order.total
|
56
|
-
)
|
57
|
-
|
58
|
-
order.save!
|
59
|
-
order.restart_checkout_flow if restart_checkout
|
60
|
-
advance_order(payment, end_state)
|
61
|
-
else
|
62
|
-
raise InvalidImportError,
|
63
|
-
"Validation failed: #{errors.full_messages.join(', ')}"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def address
|
68
|
-
transaction.address && transaction.address.to_spree_address.tap do |address|
|
69
|
-
address.phone = transaction.phone
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def state_before_current?(state)
|
74
|
-
steps = order.checkout_steps
|
75
|
-
steps.index(state) < (steps.index(order.state) || 0)
|
76
|
-
end
|
77
|
-
|
78
|
-
protected
|
79
|
-
|
80
|
-
def advance_order(payment, end_state)
|
81
|
-
return if state_before_current?(end_state)
|
82
|
-
|
83
|
-
until order.state == end_state
|
84
|
-
order.next!
|
85
|
-
update_payment_total(payment) if order.payment?
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def update_payment_total(payment)
|
90
|
-
payment_total = order.payments.where(state: %w[checkout pending]).sum(:amount)
|
91
|
-
payment_difference = order.outstanding_balance - payment_total
|
92
|
-
|
93
|
-
return unless payment_difference != 0
|
94
|
-
|
95
|
-
payment.update!(amount: payment.amount + payment_difference)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Deface::Override.new(
|
4
|
-
name: "payments/payment/add_paypal_funding_source_to_payment",
|
5
|
-
virtual_path: "spree/payments/_payment",
|
6
|
-
original: "0b5b5ae53626059cb3a202ef95d10827dd399925",
|
7
|
-
insert_after: "erb[loud]:contains('content_tag(:span, payment.payment_method.name)')",
|
8
|
-
partial: "solidus_paypal_braintree/payments/payment"
|
9
|
-
)
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<tr id="<%= dom_id(wallet_payment_source, 'spree')%>" class="<%= cycle('even', 'odd') %>">
|
2
|
-
<td>
|
3
|
-
<%= radio_button_tag "order[wallet_payment_source_id]",
|
4
|
-
wallet_payment_source.id,
|
5
|
-
default,
|
6
|
-
class: "existing-cc-radio" %>
|
7
|
-
</td>
|
8
|
-
<td><%= wallet_payment_source.payment_source.friendly_payment_type %></td>
|
9
|
-
<td><%= wallet_payment_source.payment_source.display_number %></td>
|
10
|
-
</tr>
|
@@ -1,27 +0,0 @@
|
|
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
|
-
givenName: '<%= address.firstname %>',
|
15
|
-
familyName: '<%= 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>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<script type="text/javascript">
|
2
|
-
BraintreeError.DEFAULT = "<%= I18n.t('solidus_paypal_braintree.errors.default_error')%>"
|
3
|
-
BraintreeError.PAYPAL_POPUP_CLOSED = "<%= I18n.t('solidus_paypal_braintree.errors.paypal_popup_closed') %>"
|
4
|
-
BraintreeError.HOSTED_FIELDS_FIELDS_EMPTY = "<%= I18n.t('solidus_paypal_braintree.errors.empty_fields')%>"
|
5
|
-
BraintreeError.HOSTED_FIELDS_FIELDS_INVALID = "<%= I18n.t('solidus_paypal_braintree.errors.invalid_fields')%>"
|
6
|
-
BraintreeError.HOSTED_FIELDS_FAILED_TOKENIZATION = "<%= I18n.t('solidus_paypal_braintree.errors.invalid_card')%>"
|
7
|
-
BraintreeError.HOSTED_FIELDS_TOKENIZATION_NETWORK_ERROR = "<%= I18n.t('solidus_paypal_braintree.errors.network_error')%>"
|
8
|
-
BraintreeError.HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME = "<%= I18n.t('solidus_paypal_braintree.errors.duplicate_iframe')%>"
|
9
|
-
BraintreeError.HOSTED_FIELDS_TOKENIZATION_FAIL_ON_DUPLICATE = "<%= I18n.t('solidus_paypal_braintree.errors.fail_on_duplicate')%>"
|
10
|
-
BraintreeError.HOSTED_FIELDS_TOKENIZATION_CVV_VERIFICATION_FAILED = "<%= I18n.t('solidus_paypal_braintree.errors.cvv_verification_failed')%>"
|
11
|
-
BraintreeError.THREEDS_AUTHENTICATION_FAILED = "<%= t('solidus_paypal_braintree.errors.threeds.authentication_failed') %>";
|
12
|
-
BraintreeError.THREEDS_CARDINAL_SDK_ERROR = "<%= t('solidus_paypal_braintree.errors.threeds.authentication_failed') %>";
|
13
|
-
BraintreeError.VENMO_CANCELED = "<%= t('solidus_paypal_braintree.errors.venmo.canceled') %>";
|
14
|
-
BraintreeError.VENMO_DESKTOP_CANCELED = "<%= t('solidus_paypal_braintree.errors.venmo.desktop_canceled') %>";
|
15
|
-
BraintreeError.VENMO_APP_CANCELED = "<%= t('solidus_paypal_braintree.errors.venmo.app_canceled') %>";
|
16
|
-
</script>
|
@@ -1,43 +0,0 @@
|
|
1
|
-
<% if defined?(id) && !defined?(payment_method) %>
|
2
|
-
<% payment_method = Spree::PaymentMethod.find(id) %>
|
3
|
-
<% Spree::Deprecation.warn(
|
4
|
-
"passing id to _braintree_hosted_fields.html.erb is deprecated. Please pass the payment_method directly.",
|
5
|
-
caller
|
6
|
-
) %>
|
7
|
-
<% end %>
|
8
|
-
|
9
|
-
<% prefix = "payment_source[#{payment_method.id}]" %>
|
10
|
-
|
11
|
-
<div class="hosted-fields">
|
12
|
-
<div class="field" data-hook="card_number">
|
13
|
-
<%= label_tag "card_number#{payment_method.id}", Spree::CreditCard.human_attribute_name(:number), class: "required" %>
|
14
|
-
<div class="input" id="card_number<%= payment_method.id %>"></div>
|
15
|
-
</div>
|
16
|
-
|
17
|
-
<div class="field" data-hook="card_expiration">
|
18
|
-
<%= label_tag "card_expiry#{payment_method.id}", Spree::CreditCard.human_attribute_name(:expiration), class: "required" %>
|
19
|
-
<div class="input" id="card_expiry<%= payment_method.id %>"></div>
|
20
|
-
</div>
|
21
|
-
|
22
|
-
<div class="field" data-hook="card_code">
|
23
|
-
<%= label_tag "card_code#{payment_method.id}", Spree::CreditCard.human_attribute_name(:card_code), class: "required" %>
|
24
|
-
<div class="input" id="card_code<%= payment_method.id %>"></div>
|
25
|
-
|
26
|
-
<a href="/content/cvv" class="info cvvLink" target="_blank">
|
27
|
-
(<%= I18n.t("spree.what_is_this") %>)
|
28
|
-
</a>
|
29
|
-
</div>
|
30
|
-
|
31
|
-
<div class="clear"></div>
|
32
|
-
<input type="hidden" name="<%= prefix %>[payment_type]" value="<%= SolidusPaypalBraintree::Source::CREDIT_CARD %>">
|
33
|
-
<input type="hidden" id="payment_method_nonce" name="<%= prefix %>[nonce]">
|
34
|
-
</div>
|
35
|
-
|
36
|
-
|
37
|
-
<script>
|
38
|
-
<% if current_store.braintree_configuration.three_d_secure? %>
|
39
|
-
var threeDSecureOptions = <%= raw braintree_3ds_options_for(current_order).to_json %>;
|
40
|
-
<% end -%>
|
41
|
-
var credit_card_fields_style = <%= raw payment_method.preferred_credit_card_fields_style.to_json %>
|
42
|
-
var placeholder_text = <%= raw payment_method.preferred_placeholder_text.to_json %>
|
43
|
-
</script>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<% content_for :head do %>
|
2
|
-
<script src="https://js.braintreegateway.com/web/3.84.0/js/client.min.js"></script>
|
3
|
-
<script src="https://js.braintreegateway.com/web/3.84.0/js/data-collector.min.js"></script>
|
4
|
-
|
5
|
-
<% if current_store.braintree_configuration.paypal? %>
|
6
|
-
<script src="https://js.braintreegateway.com/web/3.84.0/js/paypal-checkout.min.js"></script>
|
7
|
-
<% end %>
|
8
|
-
|
9
|
-
<% if current_store.braintree_configuration.credit_card? %>
|
10
|
-
<script src="https://js.braintreegateway.com/web/3.84.0/js/hosted-fields.min.js"></script>
|
11
|
-
|
12
|
-
<% if current_store.braintree_configuration.three_d_secure? %>
|
13
|
-
<script src="https://js.braintreegateway.com/web/3.84.0/js/three-d-secure.min.js"></script>
|
14
|
-
<% end %>
|
15
|
-
<% end %>
|
16
|
-
|
17
|
-
<% if current_store.braintree_configuration.apple_pay? %>
|
18
|
-
<script src="https://js.braintreegateway.com/web/3.84.0/js/apple-pay.min.js"></script>
|
19
|
-
<% end %>
|
20
|
-
|
21
|
-
<% if current_store.braintree_configuration.venmo? %>
|
22
|
-
<script src="https://js.braintreegateway.com/web/3.84.0/js/venmo.min.js"></script>
|
23
|
-
<% end %>
|
24
|
-
|
25
|
-
<%= javascript_include_tag "solidus_paypal_braintree/checkout" %>
|
26
|
-
<% end %>
|
@@ -1,38 +0,0 @@
|
|
1
|
-
<%= render "spree/shared/paypal_braintree_head_scripts" %>
|
2
|
-
|
3
|
-
<div id="paypal-button"></div>
|
4
|
-
<div data-pp-message data-pp-placement="payment" data-pp-amount="<%= current_order.total %>"></div>
|
5
|
-
|
6
|
-
<script>
|
7
|
-
var paypalOptions = {
|
8
|
-
flow: '<%= SolidusPaypalBraintree::Gateway.first.preferred_paypal_flow %>',
|
9
|
-
amount: '<%= current_order.total %>',
|
10
|
-
currency: '<%= current_order.currency %>',
|
11
|
-
enableShippingAddress: true,
|
12
|
-
buyerCountry: '<%= SolidusPaypalBraintree::Gateway.first.preferred_force_buyer_country %>',
|
13
|
-
environment: '<%= Rails.env.production? ? "production" : "sandbox" %>',
|
14
|
-
locale: '<%= paypal_button_preference(:paypal_button_locale, store: current_store) %>',
|
15
|
-
useDataCollector: <%= SolidusPaypalBraintree::Gateway.first.preferred_use_data_collector %>,
|
16
|
-
style: {
|
17
|
-
color: '<%= paypal_button_preference(:paypal_button_color, store: current_store) %>',
|
18
|
-
shape: '<%= paypal_button_preference(:paypal_button_shape, store: current_store) %>',
|
19
|
-
label: '<%= paypal_button_preference(:paypal_button_label, store: current_store) %>',
|
20
|
-
layout: '<%= paypal_button_preference(:paypal_button_layout, store: current_store) %>',
|
21
|
-
<% if paypal_button_preference(:paypal_button_layout, store: current_store) == "horizontal" %>
|
22
|
-
tagline: '<%= paypal_button_preference(:paypal_button_tagline, store: current_store) %>',
|
23
|
-
<% end %>
|
24
|
-
messaging: '<%= paypal_button_preference(:paypal_button_messaging, store: current_store) %>'
|
25
|
-
}
|
26
|
-
}
|
27
|
-
var options = {
|
28
|
-
restart_checkout: true
|
29
|
-
}
|
30
|
-
|
31
|
-
var button = new SolidusPaypalBraintree.createPaypalButton(
|
32
|
-
document.querySelector("#paypal-button"),
|
33
|
-
paypalOptions,
|
34
|
-
options
|
35
|
-
)
|
36
|
-
|
37
|
-
button.initialize();
|
38
|
-
</script>
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<%= render "spree/shared/paypal_braintree_head_scripts" %>
|
2
|
-
|
3
|
-
<div data-pp-message data-pp-placement="<%= options[:placement] %>" data-pp-amount="<%= options[:total] %>"></div>
|
4
|
-
|
5
|
-
<script>
|
6
|
-
var message = new SolidusPaypalBraintree.createPaypalMessaging(
|
7
|
-
{
|
8
|
-
currency: "<%= options[:currency] %>"
|
9
|
-
}
|
10
|
-
)
|
11
|
-
|
12
|
-
message.initialize();
|
13
|
-
</script>
|
@@ -1,33 +0,0 @@
|
|
1
|
-
<%= button_tag '', id: 'venmo-button', class: 'venmo-button', type: 'button' %>
|
2
|
-
|
3
|
-
<% store = Spree::Store.default %>
|
4
|
-
<% style = venmo_button_style(store) %>
|
5
|
-
|
6
|
-
<style>
|
7
|
-
.venmo-button {
|
8
|
-
width: <%= style[:width] %>px;
|
9
|
-
background-image: url('<%= venmo_button_asset_url(style)%>');
|
10
|
-
}
|
11
|
-
.venmo-button:active, .venmo-button:hover {
|
12
|
-
background-color: transparent !important;
|
13
|
-
background-image: url('<%= venmo_button_asset_url(style, active: true)%>') !important;
|
14
|
-
}
|
15
|
-
</style>
|
16
|
-
|
17
|
-
<% prefix = "payment_source[#{payment_method.id}]" %>
|
18
|
-
|
19
|
-
<div class="venmo-fields">
|
20
|
-
<div class="clear"></div>
|
21
|
-
<input disabled type="hidden" name="<%= prefix %>[payment_type]" value="<%= SolidusPaypalBraintree::Source::VENMO %>">
|
22
|
-
<input disabled type="hidden" id="venmo_payment_method_nonce" name="<%= prefix %>[nonce]">
|
23
|
-
</div>
|
24
|
-
|
25
|
-
<script>
|
26
|
-
var venmoButtonElement = document.getElementById('venmo-button');
|
27
|
-
var venmoOptions = {
|
28
|
-
newBrowserTabSupported: <%= SolidusPaypalBraintree::Gateway.first.preferred_venmo_new_tab_support %>,
|
29
|
-
flow: '<%= SolidusPaypalBraintree::Gateway.first.preferred_paypal_flow %>'
|
30
|
-
};
|
31
|
-
var button = new SolidusPaypalBraintree.createVenmoButton(venmoButtonElement, venmoOptions);
|
32
|
-
button.initialize();
|
33
|
-
</script>
|
data/config/locales/en.yml
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
en:
|
2
|
-
activerecord:
|
3
|
-
models:
|
4
|
-
solidus_paypal_braintree/gateway: Braintree
|
5
|
-
attributes:
|
6
|
-
solidus_paypal_braintree/configuration:
|
7
|
-
paypal: PayPal
|
8
|
-
apple_pay: Apple Pay
|
9
|
-
credit_card: Credit Card
|
10
|
-
three_d_secure: 3D Secure
|
11
|
-
venmo: Venmo
|
12
|
-
spree:
|
13
|
-
admin:
|
14
|
-
tab:
|
15
|
-
braintree: Braintree
|
16
|
-
client_sdk_enabled: Client SDK enabled?
|
17
|
-
environment: Environment
|
18
|
-
merchant_currency_map: Merchant currency map
|
19
|
-
merchant_id: Merchant ID
|
20
|
-
paypal_payee_email_map: Paypal payee email map
|
21
|
-
private_key: Private key
|
22
|
-
public_key: Public key
|
23
|
-
token_generation_enabled: Token generation enabled?
|
24
|
-
paypal_flow: PayPal flow
|
25
|
-
paypal_funding: 'PayPal Funding: %{funding}'
|
26
|
-
paypal_funding_source: 'PayPal Funding Source'
|
27
|
-
solidus_paypal_braintree:
|
28
|
-
braintree: Braintree
|
29
|
-
nonce: Nonce
|
30
|
-
token: Token
|
31
|
-
errors:
|
32
|
-
default_error: "Something bad happened!"
|
33
|
-
paypal_popup_closed: "PayPal popup has been closed before payment completion."
|
34
|
-
empty_fields: "All fields are empty! Please fill out the form."
|
35
|
-
invalid_fields: "Some payment input fields are invalid."
|
36
|
-
invalid_card: "Credit card data is incorrect."
|
37
|
-
network_error: "Network error occurred."
|
38
|
-
duplicate_iframe: "Duplicate Braintree iframe."
|
39
|
-
fail_on_duplicate: "This payment method already exists in your vault."
|
40
|
-
cvv_verification_failed: "CVV did not pass verification."
|
41
|
-
threeds:
|
42
|
-
authentication_failed: "3D Secure authentication failed. Please try again using a different payment method."
|
43
|
-
venmo:
|
44
|
-
canceled: "App is not available or you aborted the payment flow."
|
45
|
-
desktop_canceled: "Venmo authorization was canceled by closing the Venmo Desktop modal."
|
46
|
-
app_canceled: "Payment flow was canceled."
|
47
|
-
payment_type:
|
48
|
-
label: Payment Type
|
49
|
-
apple_pay_card: Apple Pay
|
50
|
-
credit_card: Credit Card
|
51
|
-
pay_pal_account: PayPal
|
52
|
-
venmo_account: Venmo
|
53
|
-
configurations:
|
54
|
-
title: Braintree Configurations
|
55
|
-
tab: Braintree
|
56
|
-
update_success: Successfully updated Braintree configurations.
|
57
|
-
update_error: An error occurred while updating Braintree configurations.
|
58
|
-
gateway_rejection_reasons:
|
59
|
-
avs: AVS check failed.
|
60
|
-
avs_and_cvv: AVS and CVV check failed.
|
61
|
-
cvv: CVV check failed.
|
62
|
-
duplicate: Duplicate transaction.
|
63
|
-
fraud: Credit card was rejected because of potential fraud.
|
64
|
-
three_d_secure: 3D Secure check failed.
|
65
|
-
transaction_statuses:
|
66
|
-
authorization_expired: Payment authorization has expired.
|
67
|
-
failed: An error occurred when sending the transaction to the processor.
|
68
|
-
gateway_rejected: Gateway rejected this transaction.
|
69
|
-
processor_declined: Processor declined this transaction.
|
70
|
-
settlement_declined: Settlement was declined by processor.
|
71
|
-
paypal_funding_sources:
|
72
|
-
applepay: 'Apple Pay'
|
73
|
-
bancontact: 'Bancontact'
|
74
|
-
blik: 'BLIK'
|
75
|
-
boleto: 'Boleto'
|
76
|
-
card: 'Credit or debit card'
|
77
|
-
credit: 'PayPal Credit'
|
78
|
-
eps: 'eps'
|
79
|
-
giropay: 'giropay'
|
80
|
-
ideal: 'iDEAL'
|
81
|
-
itau: 'Itau'
|
82
|
-
maxima: 'Maxima'
|
83
|
-
mercadopago: 'Mercado Pago'
|
84
|
-
mybank: 'MyBank'
|
85
|
-
oxxo: 'Oxxo'
|
86
|
-
p24: 'Przelewy24'
|
87
|
-
paylater: 'Pay Later'
|
88
|
-
paypal: 'PayPal'
|
89
|
-
payu: 'PayU'
|
90
|
-
sepa: 'SEPA-Lastschrift'
|
91
|
-
sofort: 'Sofort'
|
92
|
-
trustly: 'Trustly'
|
93
|
-
venmo: 'Venmo'
|
94
|
-
verkkopankki: 'Verkkopankki'
|
95
|
-
wechatpay: 'WeChat Pay'
|
96
|
-
zimpler: 'Zimpler'
|
data/config/locales/it.yml
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
it:
|
2
|
-
activerecord:
|
3
|
-
models:
|
4
|
-
solidus_paypal_braintree/gateway: Braintree
|
5
|
-
spree:
|
6
|
-
admin:
|
7
|
-
tab:
|
8
|
-
braintree: Braintree
|
9
|
-
client_sdk_enabled: Client SDK abilitato?
|
10
|
-
environment: Environment
|
11
|
-
merchant_currency_map: Associazioni tra merchant Braintree e valute
|
12
|
-
merchant_id: Merchant ID
|
13
|
-
paypal_payee_email_map: Associazioni tra email beneficiari PayPal e valute
|
14
|
-
private_key: Private key
|
15
|
-
public_key: Public key
|
16
|
-
token_generation_enabled: Generazione dei Token abilitata?
|
17
|
-
paypal_flow: Flusso PayPal
|
18
|
-
solidus_paypal_braintree:
|
19
|
-
braintree: Braintree
|
20
|
-
nonce: Nonce
|
21
|
-
token: Token
|
22
|
-
errors:
|
23
|
-
default_error: Qualcosa è andato storto!
|
24
|
-
paypal_popup_closed: La finestra di PayPal è stata chiusa prima di completare il pagamento.
|
25
|
-
empty_fields: I campi non possono essere vuoti!
|
26
|
-
invalid_fields: Alcuni campi non sono corretti.
|
27
|
-
invalid_card: I dati della carta di credito non sono corretti.
|
28
|
-
network_error: Si è verificato un errore di rete.
|
29
|
-
duplicate_iframe: Ci sono due iframe di Braintree.
|
30
|
-
fail_on_duplicate: Questo metodo di pagamento esiste già.
|
31
|
-
cvv_verification_failed: Il codice CVV non è corretto.
|
32
|
-
threeds:
|
33
|
-
authentication_failed: "Autenticazione 3D Secure fallita. Riprova usando un altro metodo di pagamento."
|
34
|
-
payment_type:
|
35
|
-
label: Metodo di Pagamento
|
36
|
-
apple_pay_card: Apple Pay
|
37
|
-
credit_card: Carta di credito
|
38
|
-
pay_pal_account: PayPal
|
39
|
-
configurations:
|
40
|
-
title: Configurazioni di Braintree
|
41
|
-
tab: Braintree
|
42
|
-
update_success: Configurazioni di Braintree aggiornate con successo.
|
43
|
-
update_error: Si è verificato un errore durante l'aggiornamento delle configurazioni di Braintree.
|
44
|
-
gateway_rejection_reasons:
|
45
|
-
avs: Controllo AVS fallito.
|
46
|
-
avs_and_cvv: Controlli AVS e CVV falliti.
|
47
|
-
cvv: Controllo CVV fallito.
|
48
|
-
duplicate: Transazione duplicata.
|
49
|
-
fraud: La carta di credito è stata rifiutata a seguito di un potenziale uso fraudolento.
|
50
|
-
three_d_secure: Controllo '3D Secure' fallito.
|
51
|
-
transaction_statuses:
|
52
|
-
authorization_expired: L'autorizzazione di pagamento è scaduta.
|
53
|
-
failed: Si è verificato un errore durante l'invio della transazione al sistema di pagamento.
|
54
|
-
gateway_rejected: Il gateway di pagamento ha rifiutato questa transazione.
|
55
|
-
processor_declined: Il sistema di pagamento ha rifiutato questa transazione.
|
56
|
-
settlement_declined: Il saldo di questa transazione è stato rifiutato dal sistema di pagamento.
|
data/config/routes.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
SolidusPaypalBraintree::Engine.routes.draw do
|
4
|
-
resource :checkout, only: [:update, :edit]
|
5
|
-
resource :client_token, only: [:create], format: :json
|
6
|
-
resource :transactions, only: [:create]
|
7
|
-
|
8
|
-
resources :configurations do
|
9
|
-
collection do
|
10
|
-
get :list
|
11
|
-
post :update
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class CreateSolidusPaypalBraintreeSources < SolidusSupport::Migration[4.2]
|
2
|
-
def change
|
3
|
-
create_table :solidus_paypal_braintree_sources do |t|
|
4
|
-
t.string :nonce
|
5
|
-
t.string :token
|
6
|
-
t.string :payment_type
|
7
|
-
t.integer :user_id, index: true
|
8
|
-
t.references :customer, index: true
|
9
|
-
t.references :payment_method, index: true
|
10
|
-
|
11
|
-
t.timestamps null: false
|
12
|
-
end
|
13
|
-
|
14
|
-
add_foreign_key :solidus_paypal_braintree_sources, :spree_payment_methods, column: :payment_method_id
|
15
|
-
end
|
16
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class CreateSolidusPaypalBraintreeCustomers < SolidusSupport::Migration[4.2]
|
2
|
-
def change
|
3
|
-
create_table :solidus_paypal_braintree_customers do |t|
|
4
|
-
t.references :user
|
5
|
-
t.string :braintree_customer_id
|
6
|
-
|
7
|
-
t.timestamps
|
8
|
-
end
|
9
|
-
|
10
|
-
add_index :solidus_paypal_braintree_customers, :user_id, unique: true, name: "index_braintree_customers_on_user_id"
|
11
|
-
add_index :solidus_paypal_braintree_customers, :braintree_customer_id, unique: true, name: "index_braintree_customers_on_braintree_customer_id" # rubocop:disable Layout/LineLength
|
12
|
-
end
|
13
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class CreateSolidusPaypalBraintreeConfigurations < SolidusSupport::Migration[4.2]
|
2
|
-
def change
|
3
|
-
create_table :solidus_paypal_braintree_configurations do |t|
|
4
|
-
t.boolean :paypal, null: false, default: false
|
5
|
-
t.boolean :apple_pay, null: false, default: false
|
6
|
-
t.integer :store_id, null: false, index: true, foreign_key: { references: :spree_stores }
|
7
|
-
|
8
|
-
t.timestamps null: false
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
class AddBraintreeConfigurationToStores < SolidusSupport::Migration[4.2]
|
2
|
-
# The content of this migration has been removed because store's Braintree
|
3
|
-
# configuration doesn't already have paypal_button_preferences fields, so
|
4
|
-
# their validations will break this migration.
|
5
|
-
#
|
6
|
-
# Ref here for more info https://github.com/solidusio/solidus_paypal_braintree/pull/249
|
7
|
-
end
|