Class: QiwiPay::Wpf::PaymentOperation

Inherits:
PaymentOperation show all
Defined in:
lib/qiwi-pay/wpf/payment_operation.rb

Overview

WPF payment operation

Generates URL or form parameters which should be used to perform operation

Constant Summary

Constants inherited from PaymentOperation

PaymentOperation::ATTRIBUTES

Instance Method Summary collapse

Methods inherited from PaymentOperation

#amount, #callback_url=, description, #description, #initialize, #opcode, opcode, #order_expire=

Constructor Details

This class inherits a constructor from QiwiPay::PaymentOperation

Instance Method Details

#paramsHash

Returns params for payment form.

Examples:

{
  :method=>:get,
  :url=>"https://pay.qiwi.com/paypage/initial",
  :opcode=>"1",
  :merchant_site=>"111111",
  :currency=>"643",
  :amount=>"1000.00",
  :order_id=>"1234",
  :email=>"[email protected]",
  :country=>"RUS",
  :city=>"Moscow",
  :product_name=>"Оплата тура",
  :merchant_uid=>"432101",
  :callback_url=>"https://example.com/payment/callback",
  :sign=>"...c4dbf..."
}

Returns:

  • (Hash)

    params for payment form



48
49
50
51
52
53
54
55
56
# File 'lib/qiwi-pay/wpf/payment_operation.rb', line 48

def params
  {
    method: :get,
    url: URI::HTTPS.build(
      host: QiwiPay::Wpf::ENDPOINT_HOST,
      path: QiwiPay::Wpf::ENDPOINT_PATH
    ).to_s
  }.merge(request_params)
end

#params_valid?Boolean

Returns:

  • (Boolean)


58
59
60
61
62
# File 'lib/qiwi-pay/wpf/payment_operation.rb', line 58

def params_valid?
  !opcode.nil? &&
    !merchant_site.nil? &&
    !currency.nil?
end

#urlString

Returns payment form redirection URL.

Examples:

https://pay.qiwi.com/paypage/initial?opcode=1&merchant_site=111111
&currency=643&amount=1000.00&order_id=1234&[email protected]
&country=RUS&city=Moscow&product_name=%D0%9E%D0%BF%D0%BB%D0%B0%D1
%82%D0%B0+%D1%82%D1%83%D1%80%D0%B0&merchant_uid=432101
&callback_url=https%3A%2F%example.com%2Fpayment%2Fcallback
&sign=...c4dbf...

Returns:

  • (String)

    payment form redirection URL



19
20
21
22
23
24
25
26
27
28
# File 'lib/qiwi-pay/wpf/payment_operation.rb', line 19

def url
  qry = request_params.map do |k, v|
    "#{k}=#{CGI.escape(v)}" unless v.nil? || v.empty?
  end.compact.join('&')
  URI::HTTPS.build(
    host: QiwiPay::Wpf::ENDPOINT_HOST,
    path: QiwiPay::Wpf::ENDPOINT_PATH,
    query: qry
  ).to_s
end