Class: Transbank::Onepay::TransactionCreateResponse

Inherits:
Object
  • Object
show all
Includes:
Response
Defined in:
lib/transbank/sdk/onepay/responses/transaction_create_response.rb

Overview

Serializes the response to a TransactionCreateRequest

Constant Summary collapse

SIGNATURE_PARAMS =
[:occ,
:external_unique_number,
:issued_at].freeze

Instance Attribute Summary collapse

Attributes included from Response

#description, #response_code

Instance Method Summary collapse

Methods included from Response

#full_description, #response_ok?

Methods included from Utils::SignatureUtils

#hmac_sha256, #signature_for, #to_data, #valid_signature?

Methods included from Utils::JSONUtils

included, #jsonify, #transform_hash_keys, #underscore

Constructor Details

#initialize(json) ⇒ TransactionCreateResponse

Returns a new instance of TransactionCreateResponse.

Raises:

  • (KeyError)

    upon trying to fetch a missing key from the response



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/transbank/sdk/onepay/responses/transaction_create_response.rb', line 14

def initialize(json)
  result = json.fetch('result')
  @response_code = json.fetch('responseCode')
  @description = json.fetch('description')
  @occ = result.fetch('occ')
  @ott = result.fetch('ott')
  @external_unique_number = result.fetch('externalUniqueNumber')
  @qr_code_as_base64 = result.fetch('qrCodeAsBase64')
  @issued_at = result.fetch('issuedAt')
  @signature = result.fetch('signature')
end

Instance Attribute Details

#external_unique_numberObject

Returns the value of attribute external_unique_number.



7
8
9
# File 'lib/transbank/sdk/onepay/responses/transaction_create_response.rb', line 7

def external_unique_number
  @external_unique_number
end

#issued_atObject

Returns the value of attribute issued_at.



7
8
9
# File 'lib/transbank/sdk/onepay/responses/transaction_create_response.rb', line 7

def issued_at
  @issued_at
end

#occObject

Returns the value of attribute occ.



7
8
9
# File 'lib/transbank/sdk/onepay/responses/transaction_create_response.rb', line 7

def occ
  @occ
end

#ottObject

Returns the value of attribute ott.



7
8
9
# File 'lib/transbank/sdk/onepay/responses/transaction_create_response.rb', line 7

def ott
  @ott
end

#qr_code_as_base64Object

Returns the value of attribute qr_code_as_base64.



7
8
9
# File 'lib/transbank/sdk/onepay/responses/transaction_create_response.rb', line 7

def qr_code_as_base64
  @qr_code_as_base64
end

#signatureObject

Returns the value of attribute signature.



7
8
9
# File 'lib/transbank/sdk/onepay/responses/transaction_create_response.rb', line 7

def signature
  @signature
end

Instance Method Details

#sign(secret) ⇒ Object



26
27
28
29
# File 'lib/transbank/sdk/onepay/responses/transaction_create_response.rb', line 26

def sign(secret)
  @signature = signature_for(to_data, secret)
  self
end