Class: Nimbleshop::PaymentTransactionRecorder
- Inherits:
-
Object
- Object
- Nimbleshop::PaymentTransactionRecorder
- Defined in:
- lib/nimbleshop/nimbleshop/payment_transaction_recorder.rb
Overview
This class is responsible for recording the payment transaction.
Note that even the unsuccessful transactions are recorded for reporting and analysis purpose.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PaymentTransactionRecorder
constructor
A new instance of PaymentTransactionRecorder.
- #record ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PaymentTransactionRecorder
Returns a new instance of PaymentTransactionRecorder.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nimbleshop/nimbleshop/payment_transaction_recorder.rb', line 10 def initialize( = {}) .symbolize_keys! .assert_valid_keys :order, :response, :operation, :transaction_gid, :metadata, :params .reverse_merge! metadata: {} @order = .fetch :order @response = .fetch :response @operation = .fetch :operation @metadata = .fetch :metadata @transaction_gid = .fetch :transaction_gid end |
Instance Method Details
#record ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nimbleshop/nimbleshop/payment_transaction_recorder.rb', line 22 def record h = { operation: @operation.to_s, params: @response.params, amount: @order.total_amount_in_cents, metadata: @metadata, transaction_gid: @transaction_gid } @order.payment_transactions.create!(h) end |