Class: Jackpot::Gateway
- Inherits:
-
Object
- Object
- Jackpot::Gateway
- Defined in:
- app/models/jackpot/gateway.rb
Overview
Small adapter for Active Merchant gateways Jackpot supports
Instance Method Summary (collapse)
- - (Object) authorize(amount_in_cents, credit_card_token)
- - (Object) capture(money, authorization, options = {})
-
- (Gateway) initialize(adapted_gateway)
constructor
A new instance of Gateway.
- - (Object) process_payment(credit_card_token, amount_in_cents)
- - (Object) store(card)
Constructor Details
- (Gateway) initialize(adapted_gateway)
A new instance of Gateway
6 7 8 |
# File 'app/models/jackpot/gateway.rb', line 6 def initialize(adapted_gateway) @adapted_gateway = adapted_gateway end |
Instance Method Details
- (Object) authorize(amount_in_cents, credit_card_token)
11 12 13 |
# File 'app/models/jackpot/gateway.rb', line 11 def (amount_in_cents, credit_card_token) @adapted_gateway.(amount_in_cents, credit_card_token) end |
- (Object) capture(money, authorization, options = {})
19 20 21 |
# File 'app/models/jackpot/gateway.rb', line 19 def capture(money, , = {}) @adapted_gateway.capture(money, , ) end |
- (Object) process_payment(credit_card_token, amount_in_cents)
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/jackpot/gateway.rb', line 23 def process_payment(credit_card_token, amount_in_cents) if credit_card_token response = Jackpot::Base.gateway.(amount_in_cents, credit_card_token) if response.success? billing_response = Jackpot::Base.gateway.capture(amount_in_cents, response.). else raise Jackpot::Errors::UnauthorizedPayment.new end else raise Jackpot::Errors::CustomerHasNoCardSaved.new end end |
- (Object) store(card)
15 16 17 |
# File 'app/models/jackpot/gateway.rb', line 15 def store(card) @adapted_gateway.store(card) end |