Implement PayPal fallback for registration payment process and update localization for fallback option (changes button). TODO still need to get fallback working properly in regards to the payment buttons.
This commit is contained in:
parent
1ce328511a
commit
f8b504827c
@ -32,8 +32,7 @@ module RegistrationHelper
|
|||||||
steps -= [:hosting]
|
steps -= [:hosting]
|
||||||
end
|
end
|
||||||
|
|
||||||
steps -= [:payment] unless registration.conference.paypal_email_address.present? && registration.conference.paypal_username.present? && registration.conference.paypal_password.present? && registration.conference.paypal_signature.present?
|
steps -= [:payment, :workshops] if registration.is_attending == 'n'
|
||||||
steps -= [:payment, :workshops] if registration.is_attending == 'n'
|
|
||||||
|
|
||||||
steps.each do |step|
|
steps.each do |step|
|
||||||
# disable the step if we've already found an incomplete step
|
# disable the step if we've already found an incomplete step
|
||||||
|
|||||||
@ -4,7 +4,13 @@
|
|||||||
= save_registration_step do
|
= save_registration_step do
|
||||||
.vertical-registration-step-options
|
.vertical-registration-step-options
|
||||||
.options
|
.options
|
||||||
|
- paypal_configured = @this_conference.paypal_email_address.present? && @this_conference.paypal_username.present? && @this_conference.paypal_password.present? && @this_conference.paypal_signature.present?
|
||||||
- @payment_methods.each do |option|
|
- @payment_methods.each do |option|
|
||||||
- class_name = [:unstyled]
|
- if !paypal_configured && option.to_sym == :paypal
|
||||||
- class_name << :selected if @payment_method.present? && @payment_method.to_sym == option
|
- class_name = [:unstyled]
|
||||||
= button "payment_#{option}".to_sym, value: option, class: class_name
|
- class_name << :selected if @payment_method.present? && @payment_method.to_sym == option
|
||||||
|
= button "payment_paypal_fallback".to_sym, value: option, class: class_name
|
||||||
|
- elsif option.to_sym != :paypal || paypal_configured
|
||||||
|
- class_name = [:unstyled]
|
||||||
|
- class_name << :selected if @payment_method.present? && @payment_method.to_sym == option
|
||||||
|
= button "payment_#{option}".to_sym, value: option, class: class_name
|
||||||
|
|||||||
47
config/initializers/paypal_fallback.rb
Normal file
47
config/initializers/paypal_fallback.rb
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# Monkey-patch for bikecollectives_core gem to gracefully handle missing PayPal credentials
|
||||||
|
# This allows the payment flow to work without PayPal configured
|
||||||
|
if defined?(RegistrationControllerHelper)
|
||||||
|
module PayPalFallback
|
||||||
|
def paypal_configured?(conference)
|
||||||
|
conference.paypal_email_address.present? &&
|
||||||
|
valid_paypal_credential?(conference.paypal_username) &&
|
||||||
|
valid_paypal_credential?(conference.paypal_password) &&
|
||||||
|
valid_paypal_credential?(conference.paypal_signature)
|
||||||
|
end
|
||||||
|
def valid_paypal_credential?(value)
|
||||||
|
value.present? && value.strip.present?
|
||||||
|
end
|
||||||
|
def payment_type_step_update(registration, params)
|
||||||
|
conference = registration.conference
|
||||||
|
payment_type = params[:value].try(:to_sym)
|
||||||
|
if !paypal_configured?(conference) && payment_type == :paypal
|
||||||
|
registration.data ||= {}
|
||||||
|
registration.data['payment_method'] = 'paypal'
|
||||||
|
registration.save!
|
||||||
|
return { status: :complete }
|
||||||
|
end
|
||||||
|
super
|
||||||
|
end
|
||||||
|
def payment_form_step_update(registration, params)
|
||||||
|
conference = registration.conference
|
||||||
|
username = conference.paypal_username
|
||||||
|
password = conference.paypal_password
|
||||||
|
signature = conference.paypal_signature
|
||||||
|
unless valid_paypal_credential?(username) && valid_paypal_credential?(password) && valid_paypal_credential?(signature)
|
||||||
|
Rails.logger.warn "[PayPalFallback] Missing or invalid PayPal credentials for conference #{conference.id}. Username: #{username.present?}, Password: #{password.present?}, Signature: #{signature.present?}"
|
||||||
|
value = (params[:value] || params[:custom_value] || 0).to_f
|
||||||
|
currency = conference.default_currency
|
||||||
|
registration.data ||= {}
|
||||||
|
registration.data['payment_amount'] = value
|
||||||
|
registration.payment_info = {
|
||||||
|
amount: value,
|
||||||
|
currency: currency
|
||||||
|
}.to_yaml
|
||||||
|
registration.save!
|
||||||
|
return { status: :complete }
|
||||||
|
end
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RegistrationControllerHelper.prepend(PayPalFallback)
|
||||||
|
end
|
||||||
@ -2441,6 +2441,7 @@ en:
|
|||||||
cancel_registration: Cancel my registration
|
cancel_registration: Cancel my registration
|
||||||
organization_none: None of the above
|
organization_none: None of the above
|
||||||
payment_paypal: I can pay now online
|
payment_paypal: I can pay now online
|
||||||
|
payment_paypal_fallback: I can pay via host provided link
|
||||||
payment_on_arrival: I can pledge to pay on arrival
|
payment_on_arrival: I can pledge to pay on arrival
|
||||||
payment_none: Not now
|
payment_none: Not now
|
||||||
food_meat: I eat meat and dairy
|
food_meat: I eat meat and dairy
|
||||||
|
|||||||
@ -2011,6 +2011,7 @@ es:
|
|||||||
payment_none: Por ahora no
|
payment_none: Por ahora no
|
||||||
payment_on_arrival: Puedo comprometerme a pagar a mi llegada
|
payment_on_arrival: Puedo comprometerme a pagar a mi llegada
|
||||||
payment_paypal: Puedo pagar ahora con Paypal
|
payment_paypal: Puedo pagar ahora con Paypal
|
||||||
|
payment_paypal_fallback: Puedo pagar mediante un enlace proporcionado por el anfitrión
|
||||||
reopen_registration: Re-abrir mi registro
|
reopen_registration: Re-abrir mi registro
|
||||||
review: Revisar
|
review: Revisar
|
||||||
'yes': Sí
|
'yes': Sí
|
||||||
|
|||||||
@ -1850,6 +1850,7 @@ fr:
|
|||||||
'no': Non
|
'no': Non
|
||||||
maybe: Peut-être
|
maybe: Peut-être
|
||||||
payment_paypal: Je peux payer à l'instant avec Paypal
|
payment_paypal: Je peux payer à l'instant avec Paypal
|
||||||
|
payment_paypal_fallback: Je peux payer via un lien fourni par l'hôte
|
||||||
food_vegan: Je suis végétalien
|
food_vegan: Je suis végétalien
|
||||||
food_vegetarian: Je suis végétarien
|
food_vegetarian: Je suis végétarien
|
||||||
food_meat: Je mange de la viande et des produits laitiers
|
food_meat: Je mange de la viande et des produits laitiers
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user