Class: Newebpay::MPG::Form
- Inherits:
-
Object
- Object
- Newebpay::MPG::Form
- Defined in:
- lib/newebpay/mpg/form.rb
Constant Summary collapse
- REQUIRED_ATTRS =
%i[order_number description price email payment_methods].freeze
- PAYMENT_METHODS =
%i[credit credit_red unionpay webatm vacc cvs barcode android_pay samsung_pay p2g].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
- #trade_sha ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(options) ⇒ Form
Returns a new instance of Form.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/newebpay/mpg/form.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' end |
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs.
5 6 7 |
# File 'lib/newebpay/mpg/form.rb', line 5 def attrs @attrs end |
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
5 6 7 |
# File 'lib/newebpay/mpg/form.rb', line 5 def merchant_id @merchant_id end |
Instance Method Details
#encode_url_params ⇒ Object
36 37 38 |
# File 'lib/newebpay/mpg/form.rb', line 36 def encode_url_params URI.encode_www_form(attrs) end |
#form_attrs ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/newebpay/mpg/form.rb', line 19 def form_attrs @form_attrs ||= { MerchantID: merchant_id, TradeInfo: trade_info, TradeSha: trade_sha, Version: version } end |
#trade_info ⇒ Object
28 29 30 |
# File 'lib/newebpay/mpg/form.rb', line 28 def trade_info @trade_info ||= Newebpay::NewebpayHelper.encrypt_data(encode_url_params) end |
#trade_sha ⇒ Object
32 33 34 |
# File 'lib/newebpay/mpg/form.rb', line 32 def trade_sha @trade_sha ||= Newebpay::NewebpayHelper.sha256_encode_trade_info(trade_info) end |
#version ⇒ Object
40 41 42 |
# File 'lib/newebpay/mpg/form.rb', line 40 def version '1.5' end |