Class: PaynowQR::Generator
- Inherits:
-
Object
- Object
- PaynowQR::Generator
- Defined in:
- lib/paynow_qr/generator.rb
Overview
Builds an EMVCo-compliant PayNow (SGQR) payload string.
Constant Summary collapse
- PROXY_TYPES =
{ mobile: "0", uen: "2" }.freeze
- DEFAULT_COMPANY =
"NA"- CURRENCY_SGD =
"702"- COUNTRY_SG =
"SG"- CITY_SINGAPORE =
"Singapore"- MCC_UNUSED =
"0000"
Instance Method Summary collapse
-
#initialize(proxy_type:, proxy_value:, amount: nil, editable: false, company: DEFAULT_COMPANY, expiry: nil, reference: nil) ⇒ Generator
constructor
A new instance of Generator.
-
#payload ⇒ String
(also: #to_s)
Complete EMVCo QR payload with CRC.
Constructor Details
#initialize(proxy_type:, proxy_value:, amount: nil, editable: false, company: DEFAULT_COMPANY, expiry: nil, reference: nil) ⇒ Generator
Returns a new instance of Generator.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/paynow_qr/generator.rb', line 32 def initialize(proxy_type:, proxy_value:, amount: nil, editable: false, company: DEFAULT_COMPANY, expiry: nil, reference: nil) @proxy_type = resolve_proxy_type(proxy_type) @proxy_value = require_present(proxy_value, :proxy_value).strip @amount = amount @editable = editable ? true : false @company = (company.to_s.strip.empty? ? DEFAULT_COMPANY : company.to_s.strip) @expiry = normalize_expiry(expiry) @reference = reference&.to_s&.strip @reference = nil if @reference && @reference.empty? end |