Class: Dwolla::OffsiteGateway
- Inherits:
-
Object
- Object
- Dwolla::OffsiteGateway
- Defined in:
- lib/dwolla/offsite_gateway.rb
Class Attribute Summary collapse
-
.additional_funding_sources ⇒ Object
writeonly
Sets the attribute additional_funding_sources.
-
.allow_funding_sources ⇒ Object
writeonly
Sets the attribute allow_funding_sources.
-
.callback ⇒ Object
writeonly
Sets the attribute callback.
-
.facilitator_amount ⇒ Object
writeonly
Sets the attribute facilitator_amount.
-
.notes ⇒ Object
writeonly
Sets the attribute notes.
-
.order_id ⇒ Object
writeonly
Sets the attribute order_id.
-
.redirect ⇒ Object
writeonly
Sets the attribute redirect.
-
.shipping ⇒ Object
writeonly
Sets the attribute shipping.
-
.tax ⇒ Object
writeonly
Sets the attribute tax.
-
.test_mode ⇒ Object
writeonly
Sets the attribute test_mode.
Class Method Summary collapse
- .add_product(name = nil, description = nil, price = nil, quantity = 1) ⇒ Object
- .clear_session ⇒ Object
- .discount=(discount) ⇒ Object
- .get_checkout_url(destinationId) ⇒ Object
- .read_callback(body) ⇒ Object
- .set_customer_info(first_name = nil, last_name = nil, email = nil, city = nil, state = nil, zip = nil) ⇒ Object
- .validate_webhook(signature, body) ⇒ Object
Class Attribute Details
.additional_funding_sources=(value) ⇒ Object (writeonly)
Sets the attribute additional_funding_sources
36 37 38 |
# File 'lib/dwolla/offsite_gateway.rb', line 36 def additional_funding_sources=(value) @additional_funding_sources = value end |
.allow_funding_sources=(value) ⇒ Object (writeonly)
Sets the attribute allow_funding_sources
35 36 37 |
# File 'lib/dwolla/offsite_gateway.rb', line 35 def allow_funding_sources=(value) @allow_funding_sources = value end |
.callback=(value) ⇒ Object (writeonly)
Sets the attribute callback
33 34 35 |
# File 'lib/dwolla/offsite_gateway.rb', line 33 def callback=(value) @callback = value end |
.facilitator_amount=(value) ⇒ Object (writeonly)
Sets the attribute facilitator_amount
37 38 39 |
# File 'lib/dwolla/offsite_gateway.rb', line 37 def facilitator_amount=(value) @facilitator_amount = value end |
.notes=(value) ⇒ Object (writeonly)
Sets the attribute notes
30 31 32 |
# File 'lib/dwolla/offsite_gateway.rb', line 30 def notes=(value) @notes = value end |
.order_id=(value) ⇒ Object (writeonly)
Sets the attribute order_id
31 32 33 |
# File 'lib/dwolla/offsite_gateway.rb', line 31 def order_id=(value) @order_id = value end |
.redirect=(value) ⇒ Object (writeonly)
Sets the attribute redirect
32 33 34 |
# File 'lib/dwolla/offsite_gateway.rb', line 32 def redirect=(value) @redirect = value end |
.shipping=(value) ⇒ Object (writeonly)
Sets the attribute shipping
29 30 31 |
# File 'lib/dwolla/offsite_gateway.rb', line 29 def shipping=(value) @shipping = value end |
.tax=(value) ⇒ Object (writeonly)
Sets the attribute tax
28 29 30 |
# File 'lib/dwolla/offsite_gateway.rb', line 28 def tax=(value) @tax = value end |
.test_mode=(value) ⇒ Object (writeonly)
Sets the attribute test_mode
34 35 36 |
# File 'lib/dwolla/offsite_gateway.rb', line 34 def test_mode=(value) @test_mode = value end |
Class Method Details
.add_product(name = nil, description = nil, price = nil, quantity = 1) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/dwolla/offsite_gateway.rb', line 40 def self.add_product(name=nil, description=nil, price=nil, quantity=1) @products.push({ :name => name, :description => description, :price => price, :quantity => quantity }) end |
.clear_session ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dwolla/offsite_gateway.rb', line 14 def self.clear_session @products = [] @discount = 0 @tax = 0 @shipping = 0 @notes = nil @facilitator_amount = nil @test_mode = false @allow_funding_sources = true @additional_funding_sources = true @order_id = nil end |
.discount=(discount) ⇒ Object
60 61 62 |
# File 'lib/dwolla/offsite_gateway.rb', line 60 def self.discount=(discount) @discount = -(discount.abs) end |
.get_checkout_url(destinationId) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/dwolla/offsite_gateway.rb', line 64 def self.get_checkout_url(destinationId) params = { :key => Dwolla::api_key, :secret => Dwolla::api_secret, :allowFundingSources => @allow_funding_sources, :additionalFundingSources => @additional_funding_sources, :test => @test_mode, :callback => @callback, :redirect => @redirect, :orderId => @order_id, :notes => @notes, :purchaseOrder => { :customerInfo => @customerInfo, :destinationId => destinationId, :orderItems => @products, :facilitatorAmount => @facilitator_amount, :discount => @discount, :shipping => @shipping, :tax => @tax, :total => self.calculate_total } } resp = Dwolla.request(:post, request_url, params, {}, false, false, true) return "No data received." unless resp.is_a?(Hash) raise APIError.new(resp['Message']) unless resp.has_key?('Result') and resp['Result'] == 'Success' return checkout_url + resp['CheckoutId'] end |
.read_callback(body) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/dwolla/offsite_gateway.rb', line 95 def self.read_callback(body) data = JSON.load(body) verify_callback_signature(data['signature'], data['checkoutId'], data['amount']) return data end |
.set_customer_info(first_name = nil, last_name = nil, email = nil, city = nil, state = nil, zip = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dwolla/offsite_gateway.rb', line 49 def self.set_customer_info(first_name=nil, last_name=nil, email=nil, city=nil, state=nil, zip=nil) @customerInfo = { :firstName => first_name, :lastName => last_name, :email => email, :city => city, :state => state, :zip => zip } end |
.validate_webhook(signature, body) ⇒ Object
102 103 104 |
# File 'lib/dwolla/offsite_gateway.rb', line 102 def self.validate_webhook(signature, body) verify_webhook_signature(signature, body) end |