Class: Newebpay::Periodical::Form
- Inherits:
-
Object
- Object
- Newebpay::Periodical::Form
- Defined in:
- lib/newebpay/periodical/form.rb
Constant Summary collapse
- REQUIRED_ATTRS =
%i[order_number description price email].freeze
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Returns the value of attribute attrs.
-
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
Instance Method Summary collapse
- #encode_url_params ⇒ Object
- #form_attrs ⇒ Object
-
#initialize(options) ⇒ Form
constructor
A new instance of Form.
- #trade_info ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(options) ⇒ Form
Returns a new instance of Form.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/newebpay/periodical/form.rb', line 9 def initialize() check_valid() @attrs = {} @merchant_id = [:merchant_id] || Newebpay.config.merchant_id parse_attr() @attrs['Version'] = version @attrs['TimeStamp'] = Time.now.to_i @attrs['RespondType'] = 'JSON' end |
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs.
8 9 10 |
# File 'lib/newebpay/periodical/form.rb', line 8 def attrs @attrs end |
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
8 9 10 |
# File 'lib/newebpay/periodical/form.rb', line 8 def merchant_id @merchant_id end |
Instance Method Details
#encode_url_params ⇒ Object
31 32 33 |
# File 'lib/newebpay/periodical/form.rb', line 31 def encode_url_params URI.encode_www_form(attrs) end |
#form_attrs ⇒ Object
20 21 22 23 24 25 |
# File 'lib/newebpay/periodical/form.rb', line 20 def form_attrs @form_attrs ||= { MerchantID_: merchant_id, PostData_: trade_info } end |
#trade_info ⇒ Object
27 28 29 |
# File 'lib/newebpay/periodical/form.rb', line 27 def trade_info @trade_info ||= Newebpay::NewebpayHelper.encrypt_data(encode_url_params) end |
#version ⇒ Object
35 36 37 |
# File 'lib/newebpay/periodical/form.rb', line 35 def version '1.0' end |