Sha256: c1d63e3d70cc916875d91b1d336d32757964b995d1cb70446dc68d2d71af9758
Contents?: true
Size: 905 Bytes
Versions: 2
Compression:
Stored size: 905 Bytes
Contents
require 'base64' module Mpesa class Stk < Resource PATH = 'mpesa/stkpush/v1/processrequest' def call Object.new post_request(url: PATH, body: body).body end def body { 'BusinessShortCode': args[:shortcode] || client.shortcode, 'Password': password, 'Timestamp': timestamp.to_s, 'TransactionType': 'CustomerPayBillOnline', 'Amount': args[:amount], 'PartyA': args[:phone], 'PartyB': args[:shortcode] || client.shortcode, 'PhoneNumber': args[:phone], 'CallBackURL': args[:callback_url], 'AccountReference': args[:reference], 'TransactionDesc': args[:trans_desc] } end def password Base64.strict_encode64("#{args[:shortcode]}#{client.pass_key || args[:pass_key]}#{timestamp}") end def timestamp Time.now.strftime('%Y%m%d%H%M%S').to_i end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mpesarb-0.3.1 | lib/mpesa/resources/stk.rb |
mpesarb-0.3.0 | lib/mpesa/resources/stk.rb |