lib/active_merchant/billing/gateways/qvalent.rb in activemerchant-1.64.0 vs lib/active_merchant/billing/gateways/qvalent.rb in activemerchant-1.65.0
- old
+ new
@@ -11,34 +11,67 @@
self.default_currency = "AUD"
self.money_format = :cents
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners]
def initialize(options={})
- requires!(options, :username, :password, :merchant)
+ requires!(options, :username, :password, :merchant, :pem, :pem_password)
super
end
def purchase(amount, payment_method, options={})
post = {}
add_invoice(post, amount, options)
add_order_number(post, options)
add_payment_method(post, payment_method)
add_verification_value(post, payment_method)
add_customer_data(post, options)
+ add_soft_descriptors(post, options)
commit("capture", post)
end
+ def authorize(amount, payment_method, options={})
+ post = {}
+ add_invoice(post, amount, options)
+ add_order_number(post, options)
+ add_payment_method(post, payment_method)
+ add_verification_value(post, payment_method)
+ add_customer_data(post, options)
+ add_soft_descriptors(post, options)
+
+ commit("preauth", post)
+ end
+
+ def capture(amount, authorization, options={})
+ post = {}
+ add_invoice(post, amount, options)
+ add_reference(post, authorization, options)
+ add_customer_data(post, options)
+ add_soft_descriptors(post, options)
+
+ commit("captureWithoutAuth", post)
+ end
+
def refund(amount, authorization, options={})
post = {}
add_invoice(post, amount, options)
add_reference(post, authorization, options)
add_customer_data(post, options)
+ add_soft_descriptors(post, options)
commit("refund", post)
end
+ def void(authorization, options={})
+ post = {}
+ add_reference(post, authorization, options)
+ add_customer_data(post, options)
+ add_soft_descriptors(post, options)
+
+ commit("reversal", post)
+ end
+
def store(payment_method, options = {})
post = {}
add_payment_method(post, payment_method)
add_card_reference(post)
@@ -59,9 +92,19 @@
private
CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
CURRENCY_CODES["AUD"] = "AUD"
CURRENCY_CODES["INR"] = "INR"
+
+ def add_soft_descriptors(post, options)
+ post["customer.merchantName"] = options[:customer_merchant_name] if options[:customer_merchant_name]
+ post["customer.merchantStreetAddress"] = options[:customer_merchant_street_address] if options[:customer_merchant_street_address]
+ post["customer.merchantLocation"] = options[:customer_merchant_location] if options[:customer_merchant_location]
+ post["customer.merchantState"] = options[:customer_merchant_state] if options[:customer_merchant_state]
+ post["customer.merchantCountry"] = options[:customer_merchant_country] if options[:customer_merchant_country]
+ post["customer.merchantPostCode"] = options[:customer_merchant_post_code] if options[:customer_merchant_post_code]
+ post["customer.subMerchantId"] = options[:customer_sub_merchant_id] if options[:customer_sub_merchant_id]
+ end
def add_invoice(post, money, options)
post["order.amount"] = amount(money)
post["card.currency"] = CURRENCY_CODES[options[:currency] || currency(money)]
post["order.ECI"] = "SSL"