Class: MpesaStk::Reversal
Overview
Reverse a completed M-Pesa transaction.
Constant Summary
Constants inherited from Client
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(transaction_id, amount, **options) ⇒ Reversal
constructor
A new instance of Reversal.
- #reverse_transaction ⇒ Object
Methods inherited from Client
extract_auth_options, #json_headers, #option, #optional_option, #post, #random_reference, #stk_password, #stk_timestamp, #token
Constructor Details
#initialize(transaction_id, amount, **options) ⇒ Reversal
Returns a new instance of Reversal.
16 17 18 19 20 |
# File 'lib/mpesa_stk/reversal.rb', line 16 def initialize(transaction_id, amount, **) super(**) @transaction_id = transaction_id @amount = amount end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
14 15 16 |
# File 'lib/mpesa_stk/reversal.rb', line 14 def amount @amount end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
14 15 16 |
# File 'lib/mpesa_stk/reversal.rb', line 14 def transaction_id @transaction_id end |
Class Method Details
.call(transaction_id, amount, **options) ⇒ Object
9 10 11 |
# File 'lib/mpesa_stk/reversal.rb', line 9 def call(transaction_id, amount, **) new(transaction_id, amount, **).reverse_transaction end |
Instance Method Details
#reverse_transaction ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mpesa_stk/reversal.rb', line 22 def reverse_transaction post( 'reversal_url', { Initiator: option('initiator'), SecurityCredential: option('security_credential'), CommandID: 'TransactionReversal', TransactionID: transaction_id, Amount: amount.to_s, ReceiverParty: option('business_short_code', :receiver_party), RecieverIdentifierType: @options.fetch(:receiver_identifier_type, '4'), ResultURL: option('result_url'), QueueTimeOutURL: option('queue_timeout_url') }, error_message: 'Failed to reverse transaction' ) end |