Class: Transbank::Onepay::TransactionCommitResponse

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

Overview

Serializes the response to a TransactionCommitRequest

Constant Summary collapse

SIGNATURE_PARAMS =
[:occ,
:authorization_code,
:issued_at,
:amount,
:installments_amount,
:installments_number,
:buy_order].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) ⇒ TransactionCommitResponse

Returns a new instance of TransactionCommitResponse.

Raises:

  • (KeyError)

    upon missing a response parameter



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/transbank/sdk/onepay/responses/transaction_commit_response.rb', line 19

def initialize(json)
  result = json.fetch('result')
  @response_code = json.fetch('responseCode')
  @description = json.fetch('description')
  @occ = result.fetch('occ')
  @authorization_code = result.fetch('authorizationCode')
  @signature = result.fetch('signature')
  @transaction_desc = result.fetch('transactionDesc')
  @buy_order = result.fetch('buyOrder')
  @issued_at = result.fetch('issuedAt')
  @amount = result.fetch('amount')
  @installments_amount = result.fetch('installmentsAmount')
  @installments_number = result.fetch('installmentsNumber')
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

#authorization_codeObject

Returns the value of attribute authorization_code.



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

def authorization_code
  @authorization_code
end

#buy_orderObject

Returns the value of attribute buy_order.



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

def buy_order
  @buy_order
end

#installments_amountObject

Returns the value of attribute installments_amount.



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

def installments_amount
  @installments_amount
end

#installments_numberObject

Returns the value of attribute installments_number.



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

def installments_number
  @installments_number
end

#issued_atObject

Returns the value of attribute issued_at.



7
8
9
# File 'lib/transbank/sdk/onepay/responses/transaction_commit_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_commit_response.rb', line 7

def occ
  @occ
end

#signatureObject

Returns the value of attribute signature.



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

def signature
  @signature
end

#transaction_descObject

Returns the value of attribute transaction_desc.



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

def transaction_desc
  @transaction_desc
end

Instance Method Details

#sign(secret) ⇒ Object



34
35
36
# File 'lib/transbank/sdk/onepay/responses/transaction_commit_response.rb', line 34

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