Class: ActiveMerchant::Billing::FatZebraGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/fat_zebra.rb

Constant Summary collapse

LIVE_URL =
"https://gateway.fatzebra.com.au/v1.0"
SANDBOX_URL =
"https://gateway.sandbox.fatzebra.com.au/v1.0"

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FatZebraGateway

Setup a new instance of the gateway.

The options hash should include :username and :token You can find your username and token at dashboard.fatzebra.com.au Under the Your Account section



22
23
24
25
26
27
28
# File 'lib/active_merchant/billing/gateways/fat_zebra.rb', line 22

def initialize(options = {})
  requires!(options, :username)
  requires!(options, :token)
  @username = options[:username]
  @token    = options[:token]
  super
end

Instance Method Details

#purchase(money, creditcard, options = {}) ⇒ Object

To create a purchase on a credit card use:

purchase(money, creditcard , { ... })

To charge a tokenized card

purchase(money, {:token => "abzy87u", :cvv => "123"}, { ... }})


37
38
39
40
41
42
43
44
45
46
# File 'lib/active_merchant/billing/gateways/fat_zebra.rb', line 37

def purchase(money, creditcard, options = {})
  post = {}

  add_amount(post, money, options)
  add_creditcard(post, creditcard, options)
  post[:reference] = options[:order_id]
  post[:customer_ip] = options[:ip]

  commit(:post, 'purchases', post)
end

#refund(money, txn_id, reference) ⇒ Object

Refund a transaction

amount - Integer - the amount to refund txn_id - String - the original transaction to be refunded reference - String - your transaction reference



53
54
55
56
57
58
59
60
61
# File 'lib/active_merchant/billing/gateways/fat_zebra.rb', line 53

def refund(money, txn_id, reference)
  post = {}

  post[:amount] = money
  post[:transaction_id] = txn_id
  post[:reference] = reference

  commit(:post, "refunds", post)
end

#store(creditcard) ⇒ Object

Tokenize a credit card



64
65
66
67
68
69
# File 'lib/active_merchant/billing/gateways/fat_zebra.rb', line 64

def store(creditcard)
  post = {}
  add_creditcard(post, creditcard)

  commit(:post, "credit_cards", post)
end