Exception: Saferpay::TransactionError
- Inherits:
-
StandardError
- Object
- StandardError
- Saferpay::TransactionError
- Defined in:
- lib/ruby-saferpay.rb
Overview
TODO: is there an eleant way of having the error messages “jump” out of here when a Transaction error is raised?
Constant Summary collapse
- ERRORS =
[ {:code => 0, :short_message => 'Authorization Successful', :long_message => ''}, {:code => 5, :short_message => 'Access Denied', :long_message => 'The access to the specified account was denied by Saferpay.'}, {:code => 21, :short_message => 'Invalid Structure', :long_message => 'Invalid structure of request.'}, {:code => 22, :short_message => 'Unknown Action', :long_message => 'Unknown action attribute.'}, {:code => 23, :short_message => 'Invalid Action', :long_message => 'Invalid action attribute or action not possible.'}, {:code => 61, :short_message => 'Invalid Card', :long_message => 'The static checks failed on this card (range check, LUHN check digit).'}, {:code => 62, :short_message => 'Invalid Date', :long_message => 'Invalid expiration date.'}, {:code => 63, :short_message => 'Card Expired', :long_message => 'The card has expired.'}, {:code => 64, :short_message => 'Unknown Card', :long_message => 'The card type is unknown the BIN range could not be assigned to a known card brand.'}, {:code => 65, :short_message => 'Authorization Denied', :long_message => 'The processor has denied the transaction request.'}, {:code => 67, :short_message => 'No Contract', :long_message => '"No contract exists for the card/currency combination specified.'}, {:code => 68, :short_message => 'Ambigous Contract', :long_message => '"More than one contracts exist for the specified card/currency combination.'}, {:code => 75, :short_message => 'Missing Parameter', :long_message => 'One or more mandatory parameters are missing'}, {:code => 76, :short_message => 'Connect Failed', :long_message => 'The connection to the card processor could not be established or was broken during the request. Retry the request.'}, {:code => 77, :short_message => 'No Endpoint', :long_message => 'No endpoint is specified for the processor of the card. This processor may not support online authorization of cards.'}, {:code => 78, :short_message => 'Internal Error', :long_message => 'A system error has occurred during processing the request. Retry the request if possible.'}, {:code => 80, :short_message => 'No Terminal', :long_message => 'Terminal does not exist.'}, {:code => 82, :short_message => 'Not Found', :long_message => 'Transaction not found.'}, {:code => 83, :short_message => 'Invalid Currency', :long_message => 'The specified currency code is invalid.'}, {:code => 84, :short_message => 'Invalid Amount', :long_message => 'The specified amout is invalid or does not match the rules for the currency.'}, {:code => 87, :short_message => 'Prevalidate Denied', :long_message => 'Access denied.'}, {:code => 88, :short_message => 'Reservation Invalid', :long_message => 'Reservation invalid.'}, {:code => 89, :short_message => 'Reservation Overbooked', :long_message => 'Amount of reservation overbooked.'}, {:code => 90, :short_message => 'Contract Disabled', :long_message => 'The contract for this card is currently disabled.'}, {:code => 97, :short_message => 'Already Captured', :long_message => 'Transaction already captured (PayComplete)'}, {:code => 98, :short_message => 'Invalid Signature', :long_message => 'Invalid signature'}, {:code => 102, :short_message => 'Not Supported', :long_message => 'Function not supported by provider.'}, {:code => 104, :short_message => 'Denied Blacklist', :long_message => 'Card number in customer black list.'}, {:code => 105, :short_message => 'Denied Country', :long_message => 'Card number not in country BIN range list.'}, {:code => 151, :short_message => 'Timeout Response', :long_message => 'Timeout waiting on authorization response. Retry the request.'}, {:code => 152, :short_message => 'Unknown Error', :long_message => 'Unknown (system) error.'}, {:code => 301, :short_message => 'Authentication Error', :long_message => 'An error happened during the authentication request. The merchant application could choose to:\n- continue the payment without authentication or\n- ask customer for other payment method or\n- stop the payment.'} ]
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
-
#initialize(saferpay_response) ⇒ TransactionError
constructor
A new instance of TransactionError.
Constructor Details
#initialize(saferpay_response) ⇒ TransactionError
Returns a new instance of TransactionError.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ruby-saferpay.rb', line 58 def initialize(saferpay_response) if saferpay_response.is_a? String result = Hpricot.parse(saferpay_response).at('idp').attributes['result'].to_i rescue 152 elsif saferpay_response.is_a? Hash result = saferpay_response['result'].to_i rescue 152 elsif saferpay_response.is_a? Fixnum result = saferpay_response elsif saferpay_response.is_a? OpenStruct result = saferpay_response.response else result = 152 # Unknown error end @error = ERRORS.any?{|err| err[:code] == result} end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
57 58 59 |
# File 'lib/ruby-saferpay.rb', line 57 def error @error end |