Sha256: 90be4e96e35ffa989f7e79822986ba336c4d51ea49f2579dd78c3c02ef6493a0

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

# frozen_string_literal: true

module Mpesa
  class Payout < Resource
    PATH = 'mpesa/b2c/v1/paymentrequest'

    def call
      Object.new post_request(url: PATH, body: body).body
    end

    def body
      {
        'InitiatorName': args[:initiator_username],
        'SecurityCredential': credentials,
        'CommandID': args[:command_id],
        'Amount': args[:amount],
        'PartyA': client.shortcode || args[:shortcode],
        'PartyB': format_phone(args[:phone]),
        'Remarks': args[:remarks],
        'QueueTimeOutURL': args[:timeout_url],
        'ResultURL': args[:result_url],
        'Occasion': args[:occasion]
      }
    end

    def credentials
      SecurityCred.new(args[:initiator_password], client.env).password_credential
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mpesarb-0.3.5 lib/mpesa/resources/payout.rb
mpesarb-0.3.4 lib/mpesa/resources/payout.rb
mpesarb-0.3.3 lib/mpesa/resources/payout.rb