Sha256: 3770b2431b3165e4ef9fa0f24e93c95a2508040fe5d2e02719d4bec688d5ceea

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 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': 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

1 entries across 1 versions & 1 rubygems

Version Path
mpesarb-0.3.2 lib/mpesa/resources/payout.rb