class Wechatpay::Api::V3::Cert

Attributes

cert[RW]
certificate[RW]
expires_at[RW]
serial_no[RW]

Public Instance Methods

load() click to toggle source
# File lib/wechatpay/api/v3/cert.rb, line 25
def load
  return false if cert.nil? || expires_at < DateTime.now

  self
end
update(json) { |ec, ec, ec| ... } click to toggle source
# File lib/wechatpay/api/v3/cert.rb, line 13
def update(json)
  Wechatpay::Api.client.logger.debug { "Cert JSON: #{json}" }
  expire_time = DateTime.parse(json[:expire_time])
  return unless expires_at.nil? || expire_time > expires_at

  @serial_no = json[:serial_no]
  @expires_at = expire_time
  ec = json[:encrypt_certificate]
  @cert = yield(ec[:ciphertext], ec[:nonce], ec[:associated_data])
  @certificate = OpenSSL::X509::Certificate.new @cert
end