Class: MpesaStk::B2B

Inherits:
Client show all
Defined in:
lib/mpesa_stk/b2b.rb

Overview

Business-to-business payments via Daraja B2B API.

Constant Summary

Constants inherited from Client

Client::AUTH_KEYS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

extract_auth_options, #json_headers, #option, #optional_option, #post, #random_reference, #stk_password, #stk_timestamp, #token

Constructor Details

#initialize(amount, receiver_party, **options) ⇒ B2B

Returns a new instance of B2B.



16
17
18
19
20
# File 'lib/mpesa_stk/b2b.rb', line 16

def initialize(amount, receiver_party, **options)
  super(**options)
  @amount = amount
  @receiver_party = receiver_party
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



14
15
16
# File 'lib/mpesa_stk/b2b.rb', line 14

def amount
  @amount
end

#receiver_partyObject (readonly)

Returns the value of attribute receiver_party.



14
15
16
# File 'lib/mpesa_stk/b2b.rb', line 14

def receiver_party
  @receiver_party
end

Class Method Details

.call(amount, receiver_party, **options) ⇒ Object



9
10
11
# File 'lib/mpesa_stk/b2b.rb', line 9

def call(amount, receiver_party, **options)
  new(amount, receiver_party, **options).send_payment
end

Instance Method Details

#send_paymentObject



22
23
24
# File 'lib/mpesa_stk/b2b.rb', line 22

def send_payment
  post('b2b_url', b2b_payload, error_message: 'Failed to send B2B payment')
end