lib/active_merchant/billing/gateways/fat_zebra.rb in activemerchant-1.47.0 vs lib/active_merchant/billing/gateways/fat_zebra.rb in activemerchant-1.48.0
- old
+ new
@@ -36,24 +36,48 @@
def purchase(money, creditcard, options = {})
post = {}
add_amount(post, money, options)
add_creditcard(post, creditcard, options)
+ add_extra_options(post, options)
post[:reference] = options[:order_id]
post[:customer_ip] = options[:ip]
commit(:post, 'purchases', post)
end
+ def authorize(money, creditcard, options = {})
+ post = {}
+
+ add_amount(post, money, options)
+ add_creditcard(post, creditcard, options)
+ add_extra_options(post, options)
+ post[:capture] = false
+ post[:reference] = options[:order_id]
+ post[:customer_ip] = options[:ip]
+
+ commit(:post, 'purchases', post)
+ end
+
+ def capture(money, authorization, options = {})
+ post = {}
+ add_amount(post, money, options)
+ add_extra_options(post, options)
+
+
+ commit(:post, "purchases/#{CGI.escape(authorization)}/capture", post)
+ end
+
# Refund a transaction
#
# amount - Integer - the amount to refund
# txn_id - String - the original transaction to be refunded
# reference - String - your transaction reference
def refund(money, txn_id, reference)
post = {}
+ add_extra_options(post, options)
post[:amount] = money
post[:transaction_id] = txn_id
post[:reference] = reference
commit(:post, "refunds", post)
@@ -71,10 +95,12 @@
private
# Add the money details to the request
def add_amount(post, money, options)
+ post[:currency] = (options[:currency] || currency(money))
+ post[:currency] = post[:currency].upcase if post[:currency]
post[:amount] = money
end
# Add the credit card details to the request
def add_creditcard(post, creditcard, options = {})
@@ -91,9 +117,16 @@
post[:card_token] = creditcard[:token]
post[:cvv] = creditcard[:cvv]
else
raise ArgumentError.new("Unknown credit card format #{creditcard.inspect}")
end
+ end
+
+ def add_extra_options(post, options)
+ extra = {}
+ extra[:name] = options[:merchant] if options[:merchant]
+ extra[:location] = options[:merchant_location] if options[:merchant_location]
+ post[:extra] = extra if extra.any?
end
# Post the data to the gateway
def commit(method, uri, parameters=nil)
response = begin