lib/active_merchant/billing/gateways/payment_express.rb in activemerchant-1.35.1 vs lib/active_merchant/billing/gateways/payment_express.rb in activemerchant-1.36.0

- old
+ new

@@ -283,13 +283,13 @@ # Parse the XML response response = parse( ssl_post(self.live_url, request.to_s) ) # Return a response - PaymentExpressResponse.new(response[:success] == APPROVED, response[:card_holder_help_text], response, + PaymentExpressResponse.new(response[:success] == APPROVED, message_from(response), response, :test => response[:test_mode] == '1', - :authorization => response[:dps_txn_ref] + :authorization => authorization_from(action, response) ) end # Response XML documentation: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#XMLTxnOutput def parse(xml_string) @@ -308,9 +308,22 @@ xml.elements.each('Txn/Transaction/*') do |element| response[element.name.underscore.to_sym] = element.text end response + end + + def message_from(response) + (response[:card_holder_help_text] || response[:response_text]) + end + + def authorization_from(action, response) + case action + when :validate + (response[:billing_id] || response[:dps_billing_id]) + else + response[:dps_txn_ref] + end end def format_date(month, year) "#{format(month, :two_digits)}#{format(year, :two_digits)}" end