Class: Workarea::Affirm::Gateway
- Inherits:
-
Object
- Object
- Workarea::Affirm::Gateway
- Defined in:
- lib/workarea/affirm/gateway.rb
Instance Attribute Summary collapse
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
-
#test ⇒ Object
readonly
Returns the value of attribute test.
Instance Method Summary collapse
- #authorize(token, order_id) ⇒ Object
- #capture(charge_id, amount, order_id) ⇒ Object
- #get_checkout(token) ⇒ Object
-
#initialize(options = {}) ⇒ Gateway
constructor
A new instance of Gateway.
- #refund(charge_id, amount) ⇒ Object
- #void(charge_id) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Gateway
Returns a new instance of Gateway.
6 7 8 9 10 |
# File 'lib/workarea/affirm/gateway.rb', line 6 def initialize( = {}) @public_key = [:public_key] @private_key = [:private_key] @test = [:test] end |
Instance Attribute Details
#private_key ⇒ Object (readonly)
Returns the value of attribute private_key
4 5 6 |
# File 'lib/workarea/affirm/gateway.rb', line 4 def private_key @private_key end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key
4 5 6 |
# File 'lib/workarea/affirm/gateway.rb', line 4 def public_key @public_key end |
#test ⇒ Object (readonly)
Returns the value of attribute test
4 5 6 |
# File 'lib/workarea/affirm/gateway.rb', line 4 def test @test end |
Instance Method Details
#authorize(token, order_id) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/workarea/affirm/gateway.rb', line 20 def (token, order_id) body = { checkout_token: token, order_id: order_id } response = connection.post do |req| req.url "/api/v2/charges" req.body = body.to_json end Affirm::Response.new(response) end |
#capture(charge_id, amount, order_id) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/workarea/affirm/gateway.rb', line 33 def capture(charge_id, amount, order_id) body = { amount: amount.cents, order_id: order_id } response = connection.post do |req| req.url "api/v2/charges/#{charge_id}/capture" req.body = body.to_json end Affirm::Response.new(response) end |
#get_checkout(token) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/workarea/affirm/gateway.rb', line 12 def get_checkout(token) response = connection.get do |req| req.url "/api/v2/checkout/#{token}" end Affirm::Response.new(response) end |
#refund(charge_id, amount) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/workarea/affirm/gateway.rb', line 46 def refund(charge_id, amount) body = { amount: amount.cents, type: "refund" } response = connection.post do |req| req.url "/api/v2/charges/#{charge_id}/refund" req.body = body.to_json end Affirm::Response.new(response) end |