Class: Newebpay::Donation::Form
- Inherits:
-
Object
- Object
- Newebpay::Donation::Form
- Defined in:
- lib/newebpay/donation/form.rb
Constant Summary collapse
- REQUIRED_ATTRS =
%i[order_number description price].freeze
- PAYMENT_METHODS =
%i[credit webatm vacc cvs barcode].freeze
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Returns the value of attribute attrs.
-
#donation_url ⇒ Object
Returns the value of attribute donation_url.
-
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
Instance Method Summary collapse
- #check_value ⇒ Object
- #check_value_raw ⇒ Object
- #form_attrs ⇒ Object
-
#initialize(donation_url, options) ⇒ Form
constructor
A new instance of Form.
- #version ⇒ Object
Constructor Details
#initialize(donation_url, options) ⇒ Form
Returns a new instance of Form.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/newebpay/donation/form.rb', line 9 def initialize(donation_url, ) @attrs = {} @merchant_id = [:merchant_id] || Newebpay.config.merchant_id @donation_url = donation_url check_valid() parse_attr() @attrs['Version'] = version @attrs['TimeStamp'] = Time.now.to_i @attrs['RespondType'] = 'JSON' @attrs['CheckValue'] = check_value end |
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs.
5 6 7 |
# File 'lib/newebpay/donation/form.rb', line 5 def attrs @attrs end |
#donation_url ⇒ Object
Returns the value of attribute donation_url.
5 6 7 |
# File 'lib/newebpay/donation/form.rb', line 5 def donation_url @donation_url end |
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
5 6 7 |
# File 'lib/newebpay/donation/form.rb', line 5 def merchant_id @merchant_id end |
Instance Method Details
#check_value ⇒ Object
27 28 29 |
# File 'lib/newebpay/donation/form.rb', line 27 def check_value @check_value ||= Newebpay::NewebpayHelper.sha256_encode(Newebpay.config.hash_key, Newebpay.config.hash_iv, check_value_raw) end |
#check_value_raw ⇒ Object
31 32 33 |
# File 'lib/newebpay/donation/form.rb', line 31 def check_value_raw URI.encode_www_form(attrs.slice('Amt', 'MerchantID', 'MerchantOrderNo', 'TimeStamp', 'Version').sort) end |
#form_attrs ⇒ Object
23 24 25 |
# File 'lib/newebpay/donation/form.rb', line 23 def form_attrs @form_attrs ||= @attrs end |
#version ⇒ Object
35 36 37 |
# File 'lib/newebpay/donation/form.rb', line 35 def version '1.0' end |