Class: MpesaStk::StkPushQuery
- Defined in:
- lib/mpesa_stk/stk_push_query.rb
Overview
Query the status of an STK Push checkout request.
Constant Summary
Constants inherited from Client
Instance Attribute Summary collapse
-
#checkout_request_id ⇒ Object
readonly
Returns the value of attribute checkout_request_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(checkout_request_id, **options) ⇒ StkPushQuery
constructor
A new instance of StkPushQuery.
- #query_status ⇒ Object
Methods inherited from Client
extract_auth_options, #json_headers, #option, #optional_option, #post, #random_reference, #stk_password, #stk_timestamp, #token
Constructor Details
#initialize(checkout_request_id, **options) ⇒ StkPushQuery
Returns a new instance of StkPushQuery.
16 17 18 19 |
# File 'lib/mpesa_stk/stk_push_query.rb', line 16 def initialize(checkout_request_id, **) super(**) @checkout_request_id = checkout_request_id end |
Instance Attribute Details
#checkout_request_id ⇒ Object (readonly)
Returns the value of attribute checkout_request_id.
14 15 16 |
# File 'lib/mpesa_stk/stk_push_query.rb', line 14 def checkout_request_id @checkout_request_id end |
Class Method Details
.call(checkout_request_id, **options) ⇒ Object
9 10 11 |
# File 'lib/mpesa_stk/stk_push_query.rb', line 9 def call(checkout_request_id, **) new(checkout_request_id, **).query_status end |
Instance Method Details
#query_status ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mpesa_stk/stk_push_query.rb', line 21 def query_status short_code = option('business_short_code') passkey = option('business_passkey') = post( 'stk_push_query_url', { BusinessShortCode: short_code, Password: stk_password(short_code, passkey, ), Timestamp: .to_s, CheckoutRequestID: checkout_request_id }, error_message: 'Failed to query STK push status' ) end |