Skip to content

Commit

Permalink
Merge pull request #59 from seand7565/verify_email
Browse files Browse the repository at this point in the history
Verify email address is verified before allowing payment method to be available
  • Loading branch information
seand7565 authored Jul 16, 2020
2 parents 889790d + 0000da2 commit ca27d64
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def payment_method_params
type: SolidusPaypalCommercePlatform::PaymentMethod,
preferred_client_id: api_credentials.client_id,
preferred_client_secret: api_credentials.client_secret,
preferred_test_mode: SolidusPaypalCommercePlatform.config.env.sandbox?
preferred_test_mode: SolidusPaypalCommercePlatform.config.env.sandbox?,
available_to_users: false,
available_to_admin: false
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class PaymentMethod < SolidusSupport.payment_method_parent_class
preference :paypal_button_layout, :paypal_select, default: "vertical"
preference :display_on_cart, :boolean, default: true
preference :display_on_product_page, :boolean, default: true
preference :paypal_email_confirmed, :boolean, default: false

def partial_name
"paypal_commerce_platform"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

Deface::Override.new(
name: "payment_methods/form/insert_email_verification_notification",
virtual_path: "spree/admin/payment_methods/_form",
original: "471a995989ea93a58118c80be38fafcd1fd3ee69",
replace: "erb[loud]:contains('f.check_box :available_to_users')",
partial: "solidus_paypal_commerce_platform/admin/payment_methods/available_to_users"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% if @payment_method.type == "SolidusPaypalCommercePlatform::PaymentMethod" && !@payment_method.preferences[:paypal_email_confirmed] %>
<%= f.check_box :available_to_users, disabled: true %>
<%= f.field_hint :available_to_users %>
<% else %>
<%= f.check_box :available_to_users %>
<% end %>
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
en:
spree:
hints:
solidus_paypal_commerce_platform/payment_method:
available_to_users: You must verify that your email is confirmed with PayPal before allowing users to check out.
payment_source: source
activerecord:
attributes:
Expand Down

0 comments on commit ca27d64

Please sign in to comment.