Class: Dwolla::OffsiteGateway
- Inherits:
-
Object
- Object
- Dwolla::OffsiteGateway
- Defined in:
- lib/dwolla/offsite_gateway.rb
Class Attribute Summary collapse
-
.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
.allow_funding_sources=(value) ⇒ Object (writeonly)
Sets the attribute allow_funding_sources
33 34 35 |
# File 'lib/dwolla/offsite_gateway.rb', line 33 def allow_funding_sources=(value) @allow_funding_sources = value end |
.callback=(value) ⇒ Object (writeonly)
Sets the attribute callback
31 32 33 |
# File 'lib/dwolla/offsite_gateway.rb', line 31 def callback=(value) @callback = value end |
.facilitator_amount=(value) ⇒ Object (writeonly)
Sets the attribute facilitator_amount
34 35 36 |
# File 'lib/dwolla/offsite_gateway.rb', line 34 def facilitator_amount=(value) @facilitator_amount = value end |
.notes=(value) ⇒ Object (writeonly)
Sets the attribute notes
28 29 30 |
# File 'lib/dwolla/offsite_gateway.rb', line 28 def notes=(value) @notes = value end |
.order_id=(value) ⇒ Object (writeonly)
Sets the attribute order_id
29 30 31 |
# File 'lib/dwolla/offsite_gateway.rb', line 29 def order_id=(value) @order_id = value end |
.redirect=(value) ⇒ Object (writeonly)
Sets the attribute redirect
30 31 32 |
# File 'lib/dwolla/offsite_gateway.rb', line 30 def redirect=(value) @redirect = value end |
.shipping=(value) ⇒ Object (writeonly)
Sets the attribute shipping
27 28 29 |
# File 'lib/dwolla/offsite_gateway.rb', line 27 def shipping=(value) @shipping = value end |
.tax=(value) ⇒ Object (writeonly)
Sets the attribute tax
26 27 28 |
# File 'lib/dwolla/offsite_gateway.rb', line 26 def tax=(value) @tax = value end |
.test_mode=(value) ⇒ Object (writeonly)
Sets the attribute test_mode
32 33 34 |
# File 'lib/dwolla/offsite_gateway.rb', line 32 def test_mode=(value) @test_mode = value end |
Class Method Details
.add_product(name = nil, description = nil, price = nil, quantity = 1) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/dwolla/offsite_gateway.rb', line 37 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
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dwolla/offsite_gateway.rb', line 13 def self.clear_session @products = [] @discount = 0 @tax = 0 @shipping = 0 @notes = nil @facilitator_amount = nil @test_mode = false @allow_funding_sources = true @order_id = nil end |
.discount=(discount) ⇒ Object
57 58 59 |
# File 'lib/dwolla/offsite_gateway.rb', line 57 def self.discount=(discount) @discount = -(discount.abs) end |
.get_checkout_url(destinationId) ⇒ Object
61 62 63 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 |
# File 'lib/dwolla/offsite_gateway.rb', line 61 def self.get_checkout_url(destinationId) params = { :key => Dwolla::api_key, :secret => Dwolla::api_secret, :allowFundingSources => @allow_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 } } pp params resp = Dwolla.request(:post, request_url, params, {}, false, false, true) raise APIError.new(resp['Message']) unless resp['Result'] == 'Success' return checkout_url + resp['CheckoutId'] end |
.read_callback(body) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/dwolla/offsite_gateway.rb', line 91 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
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/dwolla/offsite_gateway.rb', line 46 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
99 100 101 |
# File 'lib/dwolla/offsite_gateway.rb', line 99 def self.validate_webhook(signature, body) verify_webhook_signature(signature, body) end |