Class: ActiveMerchant::Billing::SpreedlyCoreGateway
- Defined in:
- lib/active_merchant/billing/gateways/spreedly_core.rb
Overview
Public: This gateway allows you to interact with any gateway you’ve created in Spreedly Core (spreedlycore.com). It’s an adapter which can be particularly useful if you already have code interacting with ActiveMerchant and want to easily take advantage of Core’s vault.
Constant Summary
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#authorize(money, payment_method, options = {}) ⇒ Object
Public: Run an authorize transaction.
- #capture(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ SpreedlyCoreGateway
constructor
Public: Create a new Spreedly Core Gateway.
-
#purchase(money, payment_method, options = {}) ⇒ Object
Public: Run a purchase transaction.
- #refund(money, authorization, options = {}) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
Public: Store a credit card in the Spreedly Core vault and retain it.
-
#unstore(authorization, options = {}) ⇒ Object
Public: Redact the CreditCard in Spreedly Core.
- #void(authorization, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?, #test?
Methods included from CreditCardFormatting
Constructor Details
#initialize(options = {}) ⇒ SpreedlyCoreGateway
Public: Create a new Spreedly Core Gateway.
options - A hash of options:
:login - Your Spreedly Core API login.
:password - Your Spreedly Core API secret.
:gateway_token - The token of the gateway you've created in
Spreedly Core.
30 31 32 33 |
# File 'lib/active_merchant/billing/gateways/spreedly_core.rb', line 30 def initialize( = {}) requires!(, :login, :password, :gateway_token) super end |
Instance Method Details
#authorize(money, payment_method, options = {}) ⇒ Object
Public: Run an authorize transaction.
money - The monetary amount of the transaction in cents. payment_method - The CreditCard or the Spreedly Core payment method
token.
options - A standard ActiveMerchant options hash
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/active_merchant/billing/gateways/spreedly_core.rb', line 58 def (money, payment_method, = {}) if payment_method.is_a?(String) (money, payment_method, ) else MultiResponse.run do |r| r.process { save_card(false, payment_method, ) } r.process { (money, r., ) } end end end |
#capture(money, authorization, options = {}) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/active_merchant/billing/gateways/spreedly_core.rb', line 69 def capture(money, , ={}) request = build_xml_request('transaction') do |doc| add_invoice(doc, money, ) end commit("transactions/#{}/capture.xml", request) end |
#purchase(money, payment_method, options = {}) ⇒ Object
Public: Run a purchase transaction.
money - The monetary amount of the transaction in cents. payment_method - The CreditCard or the Spreedly Core payment method
token.
options - A standard ActiveMerchant options hash
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/active_merchant/billing/gateways/spreedly_core.rb', line 41 def purchase(money, payment_method, = {}) if payment_method.is_a?(String) purchase_with_token(money, payment_method, ) else MultiResponse.run do |r| r.process { save_card(false, payment_method, ) } r.process { purchase_with_token(money, r., ) } end end end |
#refund(money, authorization, options = {}) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/active_merchant/billing/gateways/spreedly_core.rb', line 77 def refund(money, , ={}) request = build_xml_request('transaction') do |doc| add_invoice(doc, money, ) end commit("transactions/#{}/credit.xml", request) end |
#store(credit_card, options = {}) ⇒ Object
Public: Store a credit card in the Spreedly Core vault and retain it.
credit_card - The CreditCard to store options - A standard ActiveMerchant options hash
93 94 95 |
# File 'lib/active_merchant/billing/gateways/spreedly_core.rb', line 93 def store(credit_card, ={}) save_card(true, credit_card, ) end |
#unstore(authorization, options = {}) ⇒ Object
Public: Redact the CreditCard in Spreedly Core. This wipes the sensitive payment information from the card.
credit_card - The CreditCard to store options - A standard ActiveMerchant options hash
102 103 104 |
# File 'lib/active_merchant/billing/gateways/spreedly_core.rb', line 102 def unstore(, ={}) commit("payment_methods/#{}/redact.xml", '', :put) end |
#void(authorization, options = {}) ⇒ Object
85 86 87 |
# File 'lib/active_merchant/billing/gateways/spreedly_core.rb', line 85 def void(, ={}) commit("transactions/#{}/void.xml", '') end |