Module: ODDB::Html::State::PayPal::Checkout
Instance Attribute Summary
Attributes included from LoginMethods
#desired_input
Instance Method Summary
collapse
Methods included from Download
#collect
compressed_download, #compressed_download
#login_
Instance Method Details
#ajax_autofill ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/oddb/html/state/paypal/checkout.rb', line 25
def ajax_autofill
email = @session.user_input(:email)
prefs = {}
keys = checkout_keys()
keys.delete(:email)
prefs.update ODDB::Util::Yus.get_preferences(email, keys)
prefs.store(:email, email) unless prefs.empty?
AjaxCheckout.new(@session, prefs)
end
|
#checkout ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/oddb/html/state/paypal/checkout.rb', line 34
def checkout
missing_keys = [:email, :pass] - @session.input_keys
if(@session.logged_in?)
@user = @session.user
elsif(missing_keys.empty?)
begin
@user ||= @session.login
reconsider_permissions(@user)
@session.force_login(@user)
rescue Yus::UnknownEntityError
rescue Yus::AuthenticationError
@errors.store(:pass, create_error(:e_authentication_error, :pass, nil))
end
end
input = user_input(checkout_keys(), checkout_mandatory())
if(error?)
self
else
create_user(input)
@model.yus_name = @user.name
@model.save
State::PayPal::Redirect.new(@session, @model)
end
rescue SBSM::ProcessingError => err
@errors.store(err.key, err)
self
end
|
#checkout_keys ⇒ Object
70
71
72
|
# File 'lib/oddb/html/state/paypal/checkout.rb', line 70
def checkout_keys
checkout_mandatory()
end
|
#checkout_mandatory ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/oddb/html/state/paypal/checkout.rb', line 63
def checkout_mandatory
keys = [ :salutation, :name_last, :name_first, ]
unless(@session.logged_in?)
keys.push(:email, :pass, :confirm_pass)
end
keys
end
|
#create_user(input) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/oddb/html/state/paypal/checkout.rb', line 73
def create_user(input)
hash = input.dup
hash.delete(:confirm_pass)
pass = hash.delete(:pass)
hash.each { |key, val| @session.set_cookie_input(key, val) }
email = hash.delete(:email)
unless(@user.is_a?(Util::KnownUser))
@user = ODDB::Util::Yus.create_user(email, pass)
end
hash.delete_if { |key, value| value.to_s.empty? }
@user.set_preferences(hash) unless(hash.empty?)
reconsider_permissions(@user)
@session.force_login(@user)
rescue Yus::DuplicateNameError => e
raise create_error(:e_duplicate_email, :email, input[:email])
rescue RuntimeError, Yus::YusError => e
raise create_error(e.message, :email, input[:email])
end
|