lib/helpers/controller_helpers.rb in wepay-rails-0.2.1 vs lib/helpers/controller_helpers.rb in wepay-rails-0.2.2

- old
+ new

@@ -109,11 +109,25 @@ # :shipping_fee No The amount that you want to charge for shipping. # :charge_tax No A boolean value (0 or 1). If set to 1 and the account has a relevant tax entry (see /account/set_tax), then tax will be charged. def init_checkout_and_send_user_to_wepay(params, wepayable_object=nil) initialize_wepay_access_token(wepayable_object) if wepayable_object.present? response = wepay_gateway.perform_checkout(params) - checkout = WepayCheckoutRecord.create(params.merge({ checkout_id: response['checkout_id'] })) - raise WepayRails::Exceptions::InitializeCheckoutError.new("A problem occurred while trying to checkout. Wepay didn't send us back a checkout uri. Response was: #{response.inspect}, Params were: #{params}, Token was: #{wepay_access_token}") unless response && response.has_key?('checkout_uri') + + unless response && response.has_key?('checkout_uri') + raise WepayRails::Exceptions::InitializeCheckoutError.new("A problem occurred while trying to checkout. + Wepay didn't send us back a checkout uri. Response was: #{response.inspect}, + Params were: #{params}, Token was: #{wepay_access_token}") + end + + wcr_params = { + :auth_code => wepay_gateway.wepay_auth_code, + :access_token => wepay_access_token, + :checkout_id => response['checkout_id'] + } + + params.merge!(wcr_params) + + WepayCheckoutRecord.create(params) redirect_to response['checkout_uri'] and return end end end end