Class: ActiveMerchant::Billing::BalancedGateway
- Defined in:
- lib/active_merchant/billing/gateways/balanced.rb
Overview
For more information on Balanced visit www.balancedpayments.com or visit #balanced on irc.freenode.net
Instantiate a instance of BalancedGateway by passing through your Balanced API key secret.
To obtain an API key of your own
-
Visit www.balancedpayments.com
-
Click “Get started”
-
The next screen will give you a test API key of your own
-
When you’re ready to generate a production API key click the “Go live” button on the Balanced dashboard and fill in your marketplace details.
Constant Summary collapse
- VERSION =
"2.0.0"
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
- #authorize(money, payment_method, options = {}) ⇒ Object
- #capture(money, identifier, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ BalancedGateway
constructor
Creates a new BalancedGateway.
- #purchase(money, payment_method, options = {}) ⇒ Object
- #refund(money, identifier, options = {}) ⇒ Object
- #store(credit_card, options = {}) ⇒ Object
- #void(identifier, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #test?
Methods included from CreditCardFormatting
Constructor Details
#initialize(options = {}) ⇒ BalancedGateway
Creates a new BalancedGateway
Options
-
:login
– The Balanced API Secret (REQUIRED)
35 36 37 38 |
# File 'lib/active_merchant/billing/gateways/balanced.rb', line 35 def initialize( = {}) requires!(, :login) super end |
Instance Method Details
#authorize(money, payment_method, options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/active_merchant/billing/gateways/balanced.rb', line 57 def (money, payment_method, = {}) post = {} add_amount(post, money) post[:description] = [:description] add_common_params(post, ) MultiResponse.run do |r| identifier = if(payment_method.respond_to?(:number)) r.process{store(payment_method, )} r. else payment_method end r.process{commit("card_holds", "cards/#{card_identifier_from(identifier)}/card_holds", post)} end end |
#capture(money, identifier, options = {}) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/active_merchant/billing/gateways/balanced.rb', line 74 def capture(money, identifier, = {}) post = {} add_amount(post, money) post[:description] = [:description] if [:description] add_common_params(post, ) commit("debits", "card_holds/#{reference_identifier_from(identifier)}/debits", post) end |
#purchase(money, payment_method, options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/active_merchant/billing/gateways/balanced.rb', line 40 def purchase(money, payment_method, = {}) post = {} add_amount(post, money) post[:description] = [:description] add_common_params(post, ) MultiResponse.run do |r| identifier = if(payment_method.respond_to?(:number)) r.process{store(payment_method, )} r. else payment_method end r.process{commit("debits", "cards/#{card_identifier_from(identifier)}/debits", post)} end end |
#refund(money, identifier, options = {}) ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'lib/active_merchant/billing/gateways/balanced.rb', line 91 def refund(money, identifier, = {}) post = {} add_amount(post, money) post[:description] = [:description] add_common_params(post, ) commit("refunds", "debits/#{reference_identifier_from(identifier)}/refunds", post) end |
#store(credit_card, options = {}) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/active_merchant/billing/gateways/balanced.rb', line 100 def store(credit_card, ={}) post = {} post[:number] = credit_card.number post[:expiration_month] = credit_card.month post[:expiration_year] = credit_card.year post[:cvv] = credit_card.verification_value if credit_card.verification_value? post[:name] = credit_card.name if credit_card.name add_address(post, ) commit("cards", "cards", post) end |
#void(identifier, options = {}) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/active_merchant/billing/gateways/balanced.rb', line 83 def void(identifier, = {}) post = {} post[:is_void] = true add_common_params(post, ) commit("card_holds", "card_holds/#{reference_identifier_from(identifier)}", post, :put) end |