lib/active_merchant/billing/gateways/cashnet.rb in activemerchant-1.44.1 vs lib/active_merchant/billing/gateways/cashnet.rb in activemerchant-1.45.0
- old
+ new
@@ -16,11 +16,14 @@
# * <tt>:merchant</tt> -- Gateway Merchant (REQUIRED)
# * <tt>:operator</tt> -- Operator (REQUIRED)
# * <tt>:password</tt> -- Password (REQUIRED)
# * <tt>:merchant_gateway_name</tt> -- Site name (REQUIRED)
# * <tt>:station</tt> -- Station (defaults to "WEB")
- # * <tt>:default_item_code</tt> -- Item code (defaults to "FEE")
+ # * <tt>:custcode</tt> -- Customer code (defaults to
+ # "ActiveMerchant/#{ActiveMerchant::VERSION}")
+ # * <tt>:default_item_code</tt> -- Default item code (defaults to "FEE",
+ # can be overridden on a per-transaction basis with options[:item_code])
def initialize(options = {})
requires!(
options,
:merchant,
:operator,
@@ -29,22 +32,24 @@
)
options[:default_item_code] ||= "FEE"
super
end
- def purchase(money, payment_object, fields = {})
+ def purchase(money, payment_object, options = {})
post = {}
add_creditcard(post, payment_object)
- add_invoice(post, fields)
- add_address(post, fields)
- add_customer_data(post, fields)
+ add_invoice(post, options)
+ add_address(post, options)
+ add_customer_data(post, options)
commit('SALE', money, post)
end
- def refund(money, identification, fields = {})
- fields[:origtx] = identification
- commit('REFUND', money, fields)
+ def refund(money, identification, options = {})
+ post = {}
+ post[:origtx] = identification
+ add_invoice(post, options)
+ commit('REFUND', money, post)
end
private
def commit(action, money, fields)
@@ -67,23 +72,25 @@
post[:command] = action
post[:merchant] = @options[:merchant]
post[:operator] = @options[:operator]
post[:password] = @options[:password]
post[:station] = (@options[:station] || "WEB")
- post[:itemcode] = (options[:item_code] || @options[:default_item_code])
- post[:custcode] = "ActiveMerchant/#{ActiveMerchant::VERSION}"
+ post[:custcode] = (@options[:custcode] || "ActiveMerchant/#{ActiveMerchant::VERSION}")
post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
end
def add_creditcard(post, creditcard)
post[:cardno] = creditcard.number
post[:cid] = creditcard.verification_value
post[:expdate] = expdate(creditcard)
post[:card_name_g] = creditcard.name
+ post[:fname] = creditcard.first_name
+ post[:lname] = creditcard.last_name
end
def add_invoice(post, options)
post[:order_number] = options[:order_id] if options[:order_id].present?
+ post[:itemcode] = (options[:item_code] || @options[:default_item_code])
end
def add_address(post, options)
if address = (options[:shipping_address] || options[:billing_address] || options[:address])
post[:addr_g] = String(address[:address1]) + ',' + String(address[:address2])