Class: PedicelPay::Client
- Inherits:
-
Object
- Object
- PedicelPay::Client
- Defined in:
- lib/pedicel-pay/client.rb
Instance Attribute Summary collapse
-
#ca_certificate_pem ⇒ Object
Returns the value of attribute ca_certificate_pem.
-
#certificate ⇒ Object
Returns the value of attribute certificate.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
- #decrypt(token, ca_certificate_pem: @ca_certificate_pem, now: Time.now) ⇒ Object
- #generate_csr(subject: PedicelPay.config[:subject][:csr]) ⇒ Object
- #generate_key ⇒ Object
-
#initialize(key: nil, certificate: nil, ca_certificate_pem: nil) ⇒ Client
constructor
A new instance of Client.
- #merchant_id ⇒ Object
- #symmetric_key(token) ⇒ Object
Constructor Details
#initialize(key: nil, certificate: nil, ca_certificate_pem: nil) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/pedicel-pay/client.rb', line 9 def initialize(key: nil, certificate: nil, ca_certificate_pem: nil) @key = key @certificate = certificate @ca_certificate_pem = ca_certificate_pem end |
Instance Attribute Details
#ca_certificate_pem ⇒ Object
Returns the value of attribute ca_certificate_pem.
7 8 9 |
# File 'lib/pedicel-pay/client.rb', line 7 def ca_certificate_pem @ca_certificate_pem end |
#certificate ⇒ Object
Returns the value of attribute certificate.
7 8 9 |
# File 'lib/pedicel-pay/client.rb', line 7 def certificate @certificate end |
#key ⇒ Object
Returns the value of attribute key.
7 8 9 |
# File 'lib/pedicel-pay/client.rb', line 7 def key @key end |
Instance Method Details
#decrypt(token, ca_certificate_pem: @ca_certificate_pem, now: Time.now) ⇒ Object
36 37 38 39 40 |
# File 'lib/pedicel-pay/client.rb', line 36 def decrypt(token, ca_certificate_pem: @ca_certificate_pem, now: Time.now) Pedicel::EC. new(token). decrypt(private_key: key, certificate: certificate, ca_certificate_pem: ca_certificate_pem, now: now) end |
#generate_csr(subject: PedicelPay.config[:subject][:csr]) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/pedicel-pay/client.rb', line 22 def generate_csr(subject: PedicelPay.config[:subject][:csr]) req = OpenSSL::X509::Request.new req.version = 0 req.subject = subject req.public_key = PedicelPay::Helper.ec_key_to_pkey_public_key(key) req.sign(key, OpenSSL::Digest::SHA256.new) req end |
#generate_key ⇒ Object
15 16 17 18 19 20 |
# File 'lib/pedicel-pay/client.rb', line 15 def generate_key @key = OpenSSL::PKey::EC.new(PedicelPay::EC_CURVE) @key.generate_key @key end |
#merchant_id ⇒ Object
32 33 34 |
# File 'lib/pedicel-pay/client.rb', line 32 def merchant_id Pedicel::EC.merchant_id(certificate: certificate) end |
#symmetric_key(token) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/pedicel-pay/client.rb', line 42 def symmetric_key(token) Pedicel::EC. new(token). symmetric_key(private_key: key, certificate: certificate). unpack('H*') end |