lib/active_merchant/billing/gateways/fat_zebra.rb in activemerchant-1.90.0 vs lib/active_merchant/billing/gateways/fat_zebra.rb in activemerchant-1.91.0
- old
+ new
@@ -44,30 +44,40 @@
commit(:post, 'purchases', post)
end
def capture(money, authorization, options = {})
+ txn_id, _ = authorization.to_s.split('|')
post = {}
+
add_amount(post, money, options)
add_extra_options(post, options)
- commit(:post, "purchases/#{CGI.escape(authorization)}/capture", post)
+ commit(:post, "purchases/#{CGI.escape(txn_id)}/capture", post)
end
- def refund(money, txn_id, options={})
+ def refund(money, authorization, options={})
+ txn_id, _ = authorization.to_s.split('|')
post = {}
add_extra_options(post, options)
add_amount(post, money, options)
post[:transaction_id] = txn_id
add_order_id(post, options)
commit(:post, 'refunds', post)
end
+ def void(authorization, options={})
+ txn_id, endpoint = authorization.to_s.split('|')
+
+ commit(:post, "#{endpoint}/void?id=#{txn_id}", {})
+ end
+
def store(creditcard, options={})
post = {}
+
add_creditcard(post, creditcard)
commit(:post, 'credit_cards', post)
end
@@ -95,11 +105,12 @@
post[:card_number] = creditcard.number
post[:card_expiry] = "#{creditcard.month}/#{creditcard.year}"
post[:cvv] = creditcard.verification_value if creditcard.verification_value?
post[:card_holder] = creditcard.name if creditcard.name
elsif creditcard.is_a?(String)
- post[:card_token] = creditcard
+ id, _ = creditcard.to_s.split('|')
+ post[:card_token] = id
post[:cvv] = options[:cvv]
elsif creditcard.is_a?(Hash)
ActiveMerchant.deprecated 'Passing the credit card as a Hash is deprecated. Use a String and put the (optional) CVV in the options hash instead.'
post[:card_token] = creditcard[:token]
post[:cvv] = creditcard[:cvv]
@@ -139,24 +150,26 @@
Response.new(
success,
message_from(response),
response,
:test => response['test'],
- :authorization => authorization_from(response, success)
+ :authorization => authorization_from(response, success, uri)
)
end
def success_from(response)
(
response['successful'] &&
response['response'] &&
- (response['response']['successful'] || response['response']['token'])
+ (response['response']['successful'] || response['response']['token'] || response['response']['response_code'] == '00')
)
end
- def authorization_from(response, success)
+ def authorization_from(response, success, uri)
+ endpoint = uri.split('/')[0]
if success
- (response['response']['id'] || response['response']['token'])
+ id = response['response']['id'] || response['response']['token']
+ "#{id}|#{endpoint}"
else
nil
end
end