Module: PaystackGateway::TransactionResponse

Overview

Common helpers for responses from transaction endpoints

Instance Method Summary collapse

Instance Method Details

#failure_reasonObject



29
30
31
32
33
# File 'lib/paystack_gateway/transaction_response.rb', line 29

def failure_reason
  return if !transaction_failed? && !transaction_abandoned?

  data.gateway_response || transaction_status || message
end

#subaccount_amountObject



23
24
25
26
27
# File 'lib/paystack_gateway/transaction_response.rb', line 23

def subaccount_amount
  return if !subaccount || !fees_split

  fees_split.subaccount / BigDecimal('100')
end

#transaction_abandoned?Boolean

Returns:

  • (Boolean)


15
# File 'lib/paystack_gateway/transaction_response.rb', line 15

def transaction_abandoned? = transaction_status == :abandoned

#transaction_amountObject



20
# File 'lib/paystack_gateway/transaction_response.rb', line 20

def transaction_amount = amount / BigDecimal('100')

#transaction_completed_atObject



21
# File 'lib/paystack_gateway/transaction_response.rb', line 21

def transaction_completed_at = data[:updatedAt] || @completed_at

#transaction_failed?Boolean

Returns:

  • (Boolean)


16
# File 'lib/paystack_gateway/transaction_response.rb', line 16

def transaction_failed? = transaction_status == :failed

#transaction_pending?Boolean

Returns:

  • (Boolean)


17
# File 'lib/paystack_gateway/transaction_response.rb', line 17

def transaction_pending? = transaction_status.in?(%i[pending ongoing])

#transaction_statusObject



19
# File 'lib/paystack_gateway/transaction_response.rb', line 19

def transaction_status = data.status.to_sym

#transaction_success?Boolean

Returns:

  • (Boolean)


14
# File 'lib/paystack_gateway/transaction_response.rb', line 14

def transaction_success? = transaction_status.in?(%i[success reversed reversal_pending])