Class: Twoctwop::Response
- Inherits:
-
Object
- Object
- Twoctwop::Response
- Defined in:
- lib/twoctwop/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#certificate ⇒ Object
Returns the value of attribute certificate.
-
#private_key ⇒ Object
Returns the value of attribute private_key.
Instance Method Summary collapse
- #decrypt_body ⇒ Object
-
#initialize(body) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(body) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 16 17 18 |
# File 'lib/twoctwop/response.rb', line 10 def initialize(body) raise "No private key defined" if Twoctwop::Config.private_key.nil? raise "No certificate defined" if Twoctwop::Config.certificate.nil? @certificate = OpenSSL::X509::Certificate.new(Twoctwop::Config.certificate) @private_key = OpenSSL::PKey::RSA.new(Twoctwop::Config.private_key, Twoctwop::Config.passphrase) @body = OpenSSL::PKCS7.new(Base64.strict_decode64(body)) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
8 9 10 |
# File 'lib/twoctwop/response.rb', line 8 def body @body end |
#certificate ⇒ Object
Returns the value of attribute certificate.
8 9 10 |
# File 'lib/twoctwop/response.rb', line 8 def certificate @certificate end |
#private_key ⇒ Object
Returns the value of attribute private_key.
8 9 10 |
# File 'lib/twoctwop/response.rb', line 8 def private_key @private_key end |
Instance Method Details
#decrypt_body ⇒ Object
20 21 22 |
# File 'lib/twoctwop/response.rb', line 20 def decrypt_body Hashie::Mash.new(Hash.from_xml(body.decrypt(private_key, certificate))['PaymentResponse']) end |