lib/active_merchant/billing/gateways/forte.rb in activemerchant-1.114.0 vs lib/active_merchant/billing/gateways/forte.rb in activemerchant-1.116.0

- old
+ new

@@ -13,79 +13,81 @@ self.supported_cardtypes = %i[visa master american_express discover] self.homepage_url = 'https://www.forte.net' self.display_name = 'Forte' - def initialize(options={}) + def initialize(options = {}) requires!(options, :api_key, :secret, :location_id, :account_id) super end - def purchase(money, payment_method, options={}) + def purchase(money, payment_method, options = {}) post = {} add_amount(post, money, options) + add_service_fee(post, options) add_invoice(post, options) add_payment_method(post, payment_method, options) add_billing_address(post, payment_method, options) add_shipping_address(post, options) post[:action] = 'sale' commit(:post, post) end - def authorize(money, payment_method, options={}) + def authorize(money, payment_method, options = {}) post = {} add_amount(post, money, options) + add_service_fee(post, options) add_invoice(post, options) add_payment_method(post, payment_method, options) add_billing_address(post, payment_method, options) add_shipping_address(post, options) post[:action] = 'authorize' commit(:post, post) end - def capture(money, authorization, options={}) + def capture(money, authorization, options = {}) post = {} post[:transaction_id] = transaction_id_from(authorization) post[:authorization_code] = authorization_code_from(authorization) || '' post[:action] = 'capture' commit(:put, post) end - def credit(money, payment_method, options={}) + def credit(money, payment_method, options = {}) post = {} add_amount(post, money, options) add_invoice(post, options) add_payment_method(post, payment_method, options) add_billing_address(post, payment_method, options) post[:action] = 'disburse' commit(:post, post) end - def refund(money, authorization, options={}) + def refund(money, authorization, options = {}) post = {} add_amount(post, money, options) post[:original_transaction_id] = transaction_id_from(authorization) post[:authorization_code] = authorization_code_from(authorization) post[:action] = 'reverse' commit(:post, post) end - def void(authorization, options={}) + def void(authorization, options = {}) post = {} post[:transaction_id] = transaction_id_from(authorization) post[:authorization_code] = authorization_code_from(authorization) post[:action] = 'void' commit(:put, post) end - def verify(credit_card, options={}) + def verify(credit_card, options = {}) MultiResponse.run(:use_first_response) do |r| r.process { authorize(100, credit_card, options) } r.process(:ignore_result) { void(r.authorization, options) } end end @@ -112,9 +114,13 @@ post[:order_number] = options[:order_id] end def add_amount(post, money, options) post[:authorization_amount] = amount(money) + end + + def add_service_fee(post, options) + post[:service_fee_amount] = options[:service_fee_amount] if options[:service_fee_amount] end def add_billing_address(post, payment, options) post[:billing_address] = {} if address = options[:billing_address] || options[:address]