lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.3.2 vs lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.4.0
- old
+ new
@@ -124,12 +124,17 @@
commit(build_purchase_request(money, creditcard, options), options)
end
def void(identification, options = {})
commit(build_void_request(identification, options), options)
- end
+ end
+ def credit(money, identification, options = {})
+ commit(build_credit_request(money, identification, options), options)
+ end
+
+
# CyberSource requires that you provide line item information for tax calculations
# If you do not have prices for each item or want to simplify the situation then pass in one fake line item that costs the subtotal of the order
#
# The line_item hash goes in the options hash and should look like
#
@@ -214,10 +219,21 @@
xml = Builder::XmlMarkup.new :indent => 2
add_void_service(xml, request_id, request_token)
xml.target!
end
+ def build_credit_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 add_business_rules_data(xml)
xml.tag! 'businessRules' do
xml.tag!('ignoreAVSResult', 'true') if @options[:ignore_avs]
xml.tag!('ignoreCVResult', 'true') if @options[:ignore_cvv]
end
@@ -301,10 +317,18 @@
xml.tag! 'voidService', {'run' => 'true'} do
xml.tag! 'voidRequestID', request_id
xml.tag! 'voidRequestToken', request_token
end
end
+
+ def add_credit_service(xml, request_id, request_token)
+ xml.tag! 'ccCreditService', {'run' => 'true'} do
+ xml.tag! 'captureRequestID', request_id
+ xml.tag! 'captureRequestToken', request_token
+ end
+ end
+
# Where we actually build the full SOAP request using builder
def build_request(body, options)
xml = Builder::XmlMarkup.new :indent => 2
xml.instruct!
@@ -316,10 +340,10 @@
xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'
end
end
end
xml.tag! 's:Body', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
- xml.tag! 'requestMessage', {'xmlns' => 'urn:schemas-cybersource-com:transaction-data-1.26'} do
+ xml.tag! 'requestMessage', {'xmlns' => 'urn:schemas-cybersource-com:transaction-data-1.32'} do
add_merchant_data(xml, options)
xml << body
end
end
end