Class: Payanyway::Request::Check
- Defined in:
- lib/payanyway/request/check.rb
Constant Summary collapse
- SPECIAL_CODE =
когда в запросе не было суммы, а мы её передает в ответе
100
- RESPONSE_CODE =
{ paid: 200, in_progress: 302, unpaid: 402, canceled: 500 }
- @@_params =
{ 'MNT_COMMAND' => :command, 'MNT_ID' => :moneta_id, 'MNT_TRANSACTION_ID' => :transaction_id, 'MNT_OPERATION_ID' => :operation_id, 'MNT_AMOUNT' => :amount, 'MNT_CURRENCY_CODE' => :currency, 'MNT_SUBSCRIBER_ID' => :subscriber_id, 'MNT_TEST_MODE' => :test_mode, 'MNT_SIGNATURE' => :signature, 'MNT_USER' => :user, 'MNT_CORRACCOUNT' => :corraccount, 'MNT_CUSTOM1' => :custom1, 'MNT_CUSTOM2' => :custom2, 'MNT_CUSTOM3' => :custom3, 'paymentSystem.unitId' => :payment_system_unit_id }.invert.to_settings
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(params) ⇒ Check
constructor
A new instance of Check.
- #response(attr) ⇒ Object
- #success? ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(params) ⇒ Check
Returns a new instance of Check.
34 35 36 37 |
# File 'lib/payanyway/request/check.rb', line 34 def initialize(params) super @valid_signature = (@pretty_params[:signature] == Payanyway::Helpers::SignatureGenerate.for_check(@params)) end |
Instance Method Details
#response(attr) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/payanyway/request/check.rb', line 43 def response(attr) # Возвращает Nokogiri::XML документ # * _attr[:amount] - сумма заказа # * _attr[:state] - статус платежа (см. RESPONSE_CODE) # * _attr[:description] - Произвольное описание заказа (необязятельно) # * _attr[:attributes] - Произвольный атрибуты заказа (необязятельно) validate_status!(attr[:state]) xml = base_xml(attr[:amount], attr[:state], attr[:description]) parent = xml.at_css('MNT_RESPONSE') parent.add_child(signature_node(xml)) parent.add_child(attributes_node(attr[:attributes], xml)) if attr[:attributes].present? add_to_logger(xml) if attr[:logger] xml end |
#success? ⇒ Boolean
39 40 41 |
# File 'lib/payanyway/request/check.rb', line 39 def success? @valid_signature end |