Class: RocketGate::Response
- Inherits:
-
Object
- Object
- RocketGate::Response
- Defined in:
- lib/rocketgate/response.rb
Instance Attribute Summary collapse
-
#authorization ⇒ Object
Returns the value of attribute authorization.
-
#response_code ⇒ Object
Returns the value of attribute response_code.
-
#xml_document ⇒ Object
Returns the value of attribute xml_document.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#authorization ⇒ Object
Returns the value of attribute authorization.
5 6 7 |
# File 'lib/rocketgate/response.rb', line 5 def end |
#response_code ⇒ Object
Returns the value of attribute response_code.
5 6 7 |
# File 'lib/rocketgate/response.rb', line 5 def response_code @response_code end |
#xml_document ⇒ Object
Returns the value of attribute xml_document.
5 6 7 |
# File 'lib/rocketgate/response.rb', line 5 def xml_document @xml_document end |
Class Method Details
.from_xml(xml) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/rocketgate/response.rb', line 7 def self.from_xml(xml) response = self.new.tap do |r| r.xml_document = Nokogiri.parse(xml) r.build! end end |
Instance Method Details
#authorized? ⇒ Boolean
63 64 65 |
# File 'lib/rocketgate/response.rb', line 63 def !!( && .success?) end |
#build! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rocketgate/response.rb', line 14 def build! @response_code = RocketGate::ResponseCode::RESPONSE[find_value('responseCode')] card_type = RocketGate::ResponseCode::CARD_TYPE[find_value('cardDebitCredit')] pay_type = find_value('payType').downcase.to_sym rescue :credit = RocketGate::Authorization.new.tap do |auth| auth.avs_response = RocketGate::ResponseCode::AVS[find_value('avsResponse')] auth.cvv_response = RocketGate::ResponseCode::CVV[find_value('cvv2Code')] auth.reason_code = RocketGate::ResponseCode::REASON[find_value('reasonCode')] auth.card_type = card_type || pay_type auth.issuer_network = RocketGate::ResponseCode::CARD_BRAND[find_value('cardType')] auth.issuer_name = find_value('cardIssuerName') auth.issuer_phone = find_value('cardIssuerPhone') auth.issuer_url = find_value('cardIssuerURL') auth.auth_code = find_value('authNo') auth.reference_id = find_value('guidNo') auth.approved_amount = find_value('approvedAmount').to_f auth.approved_currency = find_value('approvedCurrency') auth.customer_id = find_value('merchantCustomerID') auth.card_hash = find_value('cardHash') auth.card_expiration = find_value('cardExpiration') auth.card_last_four = find_value('cardLastFour') auth.card_description = find_value('cardDescription') auth.card_country = find_value('cardCountry') end end |
#confirm! ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rocketgate/response.rb', line 45 def confirm! if success? confirmation = RocketGate::Transaction.new.tap do |tx| tx.reference_id = self..reference_id tx.type = RocketGate::Transaction::TYPE[:confirmation] end confirmation_response = RocketGate.send_request!(RocketGate::Request.new(confirmation)) if confirmation_response.success? return self # return self instead of the empty confirmation response else raise RocketGate::AuthorizationError.new("Unable to confirm transaction: #{confirmation_response.response_code}") end else raise RocketGate::AuthorizationError.new('Unable to confirm unauthorized transaction') end end |
#success? ⇒ Boolean
67 68 69 |
# File 'lib/rocketgate/response.rb', line 67 def success? && response_code == :success end |