Class: MpesaStk::PushPayment
- Inherits:
-
Object
- Object
- MpesaStk::PushPayment
- Defined in:
- lib/mpesa_stk/push_payment.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#phone_number ⇒ Object
readonly
Returns the value of attribute phone_number.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(amount, phone_number) ⇒ PushPayment
constructor
A new instance of PushPayment.
- #push_payment ⇒ Object
Constructor Details
#initialize(amount, phone_number) ⇒ PushPayment
Returns a new instance of PushPayment.
13 14 15 16 17 |
# File 'lib/mpesa_stk/push_payment.rb', line 13 def initialize(amount, phone_number) @token = MpesaStk::AccessToken.call @amount = amount @phone_number = phone_number end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
11 12 13 |
# File 'lib/mpesa_stk/push_payment.rb', line 11 def amount @amount end |
#phone_number ⇒ Object (readonly)
Returns the value of attribute phone_number.
11 12 13 |
# File 'lib/mpesa_stk/push_payment.rb', line 11 def phone_number @phone_number end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
11 12 13 |
# File 'lib/mpesa_stk/push_payment.rb', line 11 def token @token end |
Class Method Details
.call(amount, phone_number) ⇒ Object
6 7 8 |
# File 'lib/mpesa_stk/push_payment.rb', line 6 def call(amount, phone_number) new(amount, phone_number).push_payment end |
Instance Method Details
#push_payment ⇒ Object
19 20 21 22 |
# File 'lib/mpesa_stk/push_payment.rb', line 19 def push_payment response = HTTParty.post(url, headers: headers, body: body) JSON.parse(response.body) end |