Class: Newebpay::CloseFund::Base
- Inherits:
-
Object
- Object
- Newebpay::CloseFund::Base
- Defined in:
- lib/newebpay/close_fund/base.rb
Constant Summary collapse
- REQUIRED_ATTRS =
%i[order_number price].freeze
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Returns the value of attribute attrs.
-
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #encode_url_params ⇒ Object
- #form_attrs ⇒ Object
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
- #trade_info ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/newebpay/close_fund/base.rb', line 8 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' @attrs['CloseType'] = close_type result = HTTP.post(Newebpay.config.close_fund_url, form: form_attrs).body.to_s @response = Response.new(result) end |
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs.
5 6 7 |
# File 'lib/newebpay/close_fund/base.rb', line 5 def attrs @attrs end |
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
5 6 7 |
# File 'lib/newebpay/close_fund/base.rb', line 5 def merchant_id @merchant_id end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/newebpay/close_fund/base.rb', line 5 def response @response end |
Instance Method Details
#encode_url_params ⇒ Object
34 35 36 |
# File 'lib/newebpay/close_fund/base.rb', line 34 def encode_url_params URI.encode_www_form(attrs) end |
#form_attrs ⇒ Object
23 24 25 26 27 28 |
# File 'lib/newebpay/close_fund/base.rb', line 23 def form_attrs @form_attrs ||= { MerchantID_: merchant_id, PostData_: trade_info } end |
#trade_info ⇒ Object
30 31 32 |
# File 'lib/newebpay/close_fund/base.rb', line 30 def trade_info @trade_info ||= Newebpay::NewebpayHelper.encrypt_data(encode_url_params) end |
#version ⇒ Object
38 39 40 |
# File 'lib/newebpay/close_fund/base.rb', line 38 def version '1.1' end |