class Bodega::PaymentMethod::Paypal
Public Instance Methods
checkout_url(success_url, cancel_url, params = {})
click to toggle source
# File lib/bodega/payment_method/paypal.rb, line 8 def checkout_url(success_url, cancel_url, params = {}) response = client.setup(request, success_url, cancel_url) response.redirect_uri end
complete!(options = {})
click to toggle source
# File lib/bodega/payment_method/paypal.rb, line 13 def complete!(options = {}) response = client.checkout!( options[:token], options[:PayerID], request ) response.payment_info.last.transaction_id end
Protected Instance Methods
client()
click to toggle source
# File lib/bodega/payment_method/paypal.rb, line 23 def client ::Paypal.sandbox! if Bodega.config.test_mode @client ||= ::Paypal::Express::Request.new( username: Bodega.config.paypal.username, password: Bodega.config.paypal.password, signature: Bodega.config.paypal.signature ) end
request()
click to toggle source
# File lib/bodega/payment_method/paypal.rb, line 32 def request @request ||= ::Paypal::Payment::Request.new( amount: order.total.to_f, description: order.summary, items: order.order_products.map {|order_product| { name: order_product.name, amount: order_product.price.to_f, quantity: order_product.quantity } }, shipping_amount: order.shipping.to_f, tax_amount: order.tax.to_f ) end