Class: QiwiPay::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/qiwi-pay/credentials.rb

Overview

QiwiPay access credentials

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret:, cert: nil, key: nil, key_pass: nil, p12: nil) ⇒ Credentials

Returns a new instance of Credentials.

Parameters:

  • secret (String)

    Secret for signature calculation

  • cert (String;OpenSSL::X509::Certificate) (defaults to: nil)

    Certificate for API auth

  • key (String;OpenSSL::PKey::RSA) (defaults to: nil)

    Private key for certificate for API auth

  • key_pass (String) (defaults to: nil)

    Private key passphrase

  • p12 (String;OpenSSL::PKCS12) (defaults to: nil)

    Container with key and certificate



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/qiwi-pay/credentials.rb', line 22

def initialize(secret:,
               cert: nil,
               key: nil,
               key_pass: nil,
               p12: nil)
  @secret = secret
  if p12
    @certificate, @key = load_p12(p12)
  else
    @certificate = create_cert(cert) if cert
    @key = create_key(key, key_pass) if key
  end
end

Instance Attribute Details

#certificateOpenSSL::X509::Certificate (readonly)

Returns:

  • (OpenSSL::X509::Certificate)


12
13
14
# File 'lib/qiwi-pay/credentials.rb', line 12

def certificate
  @certificate
end

#keyOpenSSL::PKey::RSA (readonly)

Returns:

  • (OpenSSL::PKey::RSA)


15
16
17
# File 'lib/qiwi-pay/credentials.rb', line 15

def key
  @key
end

#secretString (readonly)

Returns:

  • (String)


9
10
11
# File 'lib/qiwi-pay/credentials.rb', line 9

def secret
  @secret
end