lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.28.0 vs lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.29.0

- old
+ new

@@ -105,19 +105,13 @@ # # :ignore_cvv => true don't want to use CVV so continue processing even # if CVV would have failed def initialize(options = {}) requires!(options, :login, :password) - @options = options super end - # Should run against the test servers or not? - def test? - @options[:test] || Base.gateway_mode == :test - end - # Request an authorization for an amount from CyberSource # # You must supply an :order_id in the options hash def authorize(money, creditcard_or_reference, options = {}) requires!(options, :order_id) @@ -146,16 +140,17 @@ def void(identification, options = {}) commit(build_void_request(identification, options), options) end def refund(money, identification, options = {}) - commit(build_credit_request(money, identification, options), options) + commit(build_refund_request(money, identification, options), options) end - def credit(money, identification, options = {}) - deprecated CREDIT_DEPRECATION_MESSAGE - refund(money, identification, options) + # Adds credit to a subscription (stand alone credit). + def credit(money, reference, options = {}) + requires!(options, :order_id) + commit(build_credit_request(money, reference, options), options) end # Stores a customer subscription/profile with type "on-demand". # To charge the card while creating a profile, pass # options[:setup_fee] => money @@ -279,21 +274,31 @@ add_purchase_data(xml, money, true, options) add_auth_reversal_service(xml, request_id, request_token) xml.target! end - def build_credit_request(money, identification, options) + def build_refund_request(money, identification, options) order_id, request_id, request_token = identification.split(";") options[:order_id] = order_id xml = Builder::XmlMarkup.new :indent => 2 add_purchase_data(xml, money, true, options) add_credit_service(xml, request_id, request_token) xml.target! end + def build_credit_request(money, reference, options) + xml = Builder::XmlMarkup.new :indent => 2 + + add_purchase_data(xml, money, true, options) + add_subscription(xml, options, reference) + add_credit_service(xml) + + xml.target! + end + def build_create_subscription_request(creditcard, options) options[:subscription] = (options[:subscription] || {}).merge(:frequency => "on-demand", :amount => 0, :automatic_renew => false) xml = Builder::XmlMarkup.new :indent => 2 add_address(xml, creditcard, options[:billing_address], options) @@ -433,13 +438,13 @@ xml.tag! 'authRequestID', request_id xml.tag! 'authRequestToken', request_token end end - def add_credit_service(xml, request_id, request_token) + def add_credit_service(xml, request_id = nil, request_token = nil) xml.tag! 'ccCreditService', {'run' => 'true'} do - xml.tag! 'captureRequestID', request_id - xml.tag! 'captureRequestToken', request_token + xml.tag! 'captureRequestID', request_id if request_id + xml.tag! 'captureRequestToken', request_token if request_token end end def add_subscription_create_service(xml, options) xml.tag! 'paySubscriptionCreateService', {'run' => 'true'}