90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/helpers/controller_helpers.rb', line 90
def init_preapproval(params, access_token=nil)
wepay_gateway = WepayRails::Payments::Gateway.new(access_token)
response = wepay_gateway.perform_preapproval(params)
if response[:preapproval_uri].blank?
raise WepayRails::Exceptions::WepayPreapprovalError.new("An error occurred: #{response.inspect}")
end
params.merge!({
:access_token => wepay_gateway.access_token,
:preapproval_id => response[:preapproval_id],
:security_token => response[:security_token],
:preapproval_uri => response[:preapproval_uri]
})
params.delete_if {|k,v| !WepayCheckoutRecord.attribute_names.include? k.to_s}
WepayCheckoutRecord.create(params)
end
|