Class: MerchantSidekick::ActiveMerchant::CreditCardPayment
- Inherits:
-
Payment
- Object
- ActiveRecord::Base
- Payment
- MerchantSidekick::ActiveMerchant::CreditCardPayment
- Defined in:
- lib/merchant_sidekick/active_merchant/credit_card_payment.rb
Class Method Summary collapse
- .authorize(amount, credit_card, options = {}) ⇒ Object
- .capture(amount, authorization, options = {}) ⇒ Object
-
.credit(amount, authorization, options = {}) ⇒ Object
requires :card_number option.
-
.gateway ⇒ Object
Returns an active merchant gateway instance, based on the following:.
- .purchase(amount, credit_card, options = {}) ⇒ Object
-
.transfer(amount, destination_account, options = {}) ⇒ Object
works with paypal payflow.
- .void(amount, authorization, options = {}) ⇒ Object
Instance Method Summary collapse
-
#payment_type ⇒ Object
override in sublcass.
Methods inherited from Payment
class_for, #content_attributes, content_column_names, #content_column_names, #success?
Class Method Details
.authorize(amount, credit_card, options = {}) ⇒ Object
43 44 45 46 47 |
# File 'lib/merchant_sidekick/active_merchant/credit_card_payment.rb', line 43 def (amount, credit_card, = {}) process('authorization', amount, ) do |gw| gw.(amount.cents, credit_card, ) end end |
.capture(amount, authorization, options = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/merchant_sidekick/active_merchant/credit_card_payment.rb', line 49 def capture(amount, , = {}) process('capture', amount, ) do |gw| gw.capture(amount.cents, , ) end end |
.credit(amount, authorization, options = {}) ⇒ Object
requires :card_number option
68 69 70 71 72 |
# File 'lib/merchant_sidekick/active_merchant/credit_card_payment.rb', line 68 def credit(amount, , = {}) process('credit', amount, ) do |gw| gw.credit(amount.cents, , ) end end |
.gateway ⇒ Object
Returns an active merchant gateway instance, based on the following:
* an active merchant gateway instance assigned to the gateway
class accessor
* a merchant sidekick specific gateway identifier,
e.g. :authorize_net_gateway, is passed into the gateway class accessor
* otherwise falls back to the default gateway assigned as
MerchantSidekick::Gateways::Gateway.default_gateway
Declare as needed in the environment.
E.g.
CreditCardPayment.gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new({
:login => @login_id,
:password => @transaction_key
})
or
CreditCardPayment.gateway = :authorize_net_gateway
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/merchant_sidekick/active_merchant/credit_card_payment.rb', line 32 def gateway if @@gateway.is_a? ::ActiveMerchant::Billing::Gateway @@gateway elsif @@gateway.is_a? Symbol @@gateway = "::MerchantSidekick::ActiveMerchant::Gateways::#{@@gateway.to_s.classify}".constantize.gateway @@gateway else @@gateway = MerchantSidekick::Gateway.default_gateway end end |
.purchase(amount, credit_card, options = {}) ⇒ Object
55 56 57 58 59 |
# File 'lib/merchant_sidekick/active_merchant/credit_card_payment.rb', line 55 def purchase(amount, credit_card, = {}) process('purchase', amount, ) do |gw| gw.purchase(amount.cents, credit_card, ) end end |
.transfer(amount, destination_account, options = {}) ⇒ Object
works with paypal payflow
75 76 77 78 79 |
# File 'lib/merchant_sidekick/active_merchant/credit_card_payment.rb', line 75 def transfer(amount, destination_account, ={}) process('transfer', amount, ) do |gw| gw.transfer(amount.cents, destination_account, ) end end |
.void(amount, authorization, options = {}) ⇒ Object
61 62 63 64 65 |
# File 'lib/merchant_sidekick/active_merchant/credit_card_payment.rb', line 61 def void(amount, , = {}) process('void', amount, ) do |gw| gw.void(, ) end end |
Instance Method Details
#payment_type ⇒ Object
override in sublcass
111 112 113 |
# File 'lib/merchant_sidekick/active_merchant/credit_card_payment.rb', line 111 def payment_type :credit_card end |