module UnionpayOpen
Constants
- Base
- ENDPOINT_DEV
- ENDPOINT_PRO
- VERSION
Public Class Methods
config() { |self| ... }
click to toggle source
# File lib/unionpay_open.rb, line 20 def config yield(self) if block_given? @@endpoint = ENDPOINT_PRO if @@env == "production" @@x509_certificate = OpenSSL::X509::Certificate.new(File.read(@@ca_file)) if @@ca_file if @@pfx_file and @@pfx_file_password @@pkcs12 = OpenSSL::PKCS12.new( File.read(@@pfx_file), @@pfx_file_password ) end end
fen2yuan(amount)
click to toggle source
# File lib/unionpay_open.rb, line 30 def fen2yuan(amount) # 10fen = 0.1yuan; 100fen = 1.0yuan value = "00" + amount.to_s [ value[0..-3], value[-2..-1] ].join('.').to_f end
yuan2fen(amount)
click to toggle source
# File lib/unionpay_open.rb, line 35 def yuan2fen(amount) # 100yuan = 10000fen value = amount.to_s.split('.') return (value.first + "00").to_i if value.size == 1 a, b = value.first, value.last (b += "0") if b.size == 1 (a + b[0..1]).to_i end