class Bitpesa::TransactionsApi
Attributes
Public Class Methods
# File lib/bitpesa-sdk/api/transactions_api.rb, line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end
Public Instance Methods
Calculates transaction amounts for a transaction payload Calculates the input, output and fee amounts for the recipients in a transaction payload @param transaction_request @param [Hash] opts the optional parameters @return [TransactionResponse]
# File lib/bitpesa-sdk/api/transactions_api.rb, line 29 def calculate_transactions(transaction_request, opts = {}) data, _status_code, _headers = calculate_transactions_with_http_info(transaction_request, opts) data end
Calculates transaction amounts for a transaction payload Calculates the input, output and fee amounts for the recipients in a transaction payload @param transaction_request @param [Hash] opts the optional parameters @return [Array<(TransactionResponse
, Fixnum, Hash)>] TransactionResponse
data, response status code and response headers
# File lib/bitpesa-sdk/api/transactions_api.rb, line 39 def calculate_transactions_with_http_info(transaction_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TransactionsApi.calculate_transactions ...' end # verify the required parameter 'transaction_request' is set if @api_client.config.client_side_validation && transaction_request.nil? fail ArgumentError, "Missing the required parameter 'transaction_request' when calling TransactionsApi.calculate_transactions" end # resource path local_var_path = '/transactions/calculate' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(transaction_request) auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'TransactionResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#calculate_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Fetch a single transaction Finds and returns a Transaction
created by the requesting API key, using the provided Transaction
ID. @param transaction_id ID of the transaction. Example: `/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670` @param [Hash] opts the optional parameters @return [TransactionResponse]
# File lib/bitpesa-sdk/api/transactions_api.rb, line 85 def get_transaction(transaction_id, opts = {}) data, _status_code, _headers = get_transaction_with_http_info(transaction_id, opts) data end
Fetch a single transaction Finds and returns a Transaction
created by the requesting API key, using the provided Transaction
ID. @param transaction_id ID of the transaction. Example: `/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670` @param [Hash] opts the optional parameters @return [Array<(TransactionResponse
, Fixnum, Hash)>] TransactionResponse
data, response status code and response headers
# File lib/bitpesa-sdk/api/transactions_api.rb, line 95 def get_transaction_with_http_info(transaction_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TransactionsApi.get_transaction ...' end # verify the required parameter 'transaction_id' is set if @api_client.config.client_side_validation && transaction_id.nil? fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.get_transaction" end # resource path local_var_path = '/transactions/{Transaction ID}'.sub('{' + 'Transaction ID' + '}', transaction_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'TransactionResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#get_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Get a list of transactions Retrieves a paginated list of the Transactions created by your API key. @param [Hash] opts the optional parameters @option opts [Integer] :page The page number to request (defaults to 1) @option opts [Integer] :per The number of results to load per page (defaults to 10) @option opts [String] :external_id Allows filtering results by `external_id`. Example: `/v1/senders?external_id=26ec8517-2f0d-48c0-b74f-0bccb9ab3a87` @return [TransactionListResponse]
# File lib/bitpesa-sdk/api/transactions_api.rb, line 151 def get_transactions(opts = {}) data, _status_code, _headers = get_transactions_with_http_info(opts) data end
# File lib/bitpesa-sdk/api/transactions_api.rb, line 133 def get_transactions_all(opts = {}) result = [] response = get_transactions(opts) result += response["object"] while next_page = response["meta"]["pagination"]["next_page"] response = get_transactions(opts.merge(page: next_page)) result += response["object"] end result end
Get a list of transactions Retrieves a paginated list of the Transactions created by your API key. @param [Hash] opts the optional parameters @option opts [Integer] :page The page number to request (defaults to 1) @option opts [Integer] :per The number of results to load per page (defaults to 10) @option opts [String] :external_id Allows filtering results by `external_id`. Example: `/v1/senders?external_id=26ec8517-2f0d-48c0-b74f-0bccb9ab3a87` @return [Array<(TransactionListResponse
, Fixnum, Hash)>] TransactionListResponse
data, response status code and response headers
# File lib/bitpesa-sdk/api/transactions_api.rb, line 163 def get_transactions_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TransactionsApi.get_transactions ...' end # resource path local_var_path = '/transactions' # query parameters query_params = {} query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'per'] = opts[:'per'] if !opts[:'per'].nil? query_params[:'external_id'] = opts[:'external_id'] if !opts[:'external_id'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'TransactionListResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#get_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Creates a fake payin for transaction This method is available only in sandbox environment and is supposed to be used only for testing integration. It allows you to emulate a payin without paying actual money. @param transaction_id ID of the transaction to payin. Example: `/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670/payin` @param payin_method_request @param [Hash] opts the optional parameters @return [TransactionResponse]
# File lib/bitpesa-sdk/api/transactions_api.rb, line 207 def payin_transaction(transaction_id, payin_method_request, opts = {}) data, _status_code, _headers = payin_transaction_with_http_info(transaction_id, payin_method_request, opts) data end
Creates a fake payin for transaction This method is available only in sandbox environment and is supposed to be used only for testing integration. It allows you to emulate a payin without paying actual money. @param transaction_id ID of the transaction to payin. Example: `/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670/payin` @param payin_method_request @param [Hash] opts the optional parameters @return [Array<(TransactionResponse
, Fixnum, Hash)>] TransactionResponse
data, response status code and response headers
# File lib/bitpesa-sdk/api/transactions_api.rb, line 218 def payin_transaction_with_http_info(transaction_id, payin_method_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TransactionsApi.payin_transaction ...' end # verify the required parameter 'transaction_id' is set if @api_client.config.client_side_validation && transaction_id.nil? fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.payin_transaction" end # verify the required parameter 'payin_method_request' is set if @api_client.config.client_side_validation && payin_method_request.nil? fail ArgumentError, "Missing the required parameter 'payin_method_request' when calling TransactionsApi.payin_transaction" end # resource path local_var_path = '/transactions/{Transaction ID}/payin'.sub('{' + 'Transaction ID' + '}', transaction_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(payin_method_request) auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'TransactionResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#payin_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Creates a fake payout for transaction This method is available only in sandbox environment and is supposed to be used only for testing. It allows you to emulate the payout of a transaction after payin. @param transaction_id ID of the transaction to payout. Example: `/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670/payout` @param [Hash] opts the optional parameters @return [TransactionResponse]
# File lib/bitpesa-sdk/api/transactions_api.rb, line 268 def payout_transaction(transaction_id, opts = {}) data, _status_code, _headers = payout_transaction_with_http_info(transaction_id, opts) data end
Creates a fake payout for transaction This method is available only in sandbox environment and is supposed to be used only for testing. It allows you to emulate the payout of a transaction after payin. @param transaction_id ID of the transaction to payout. Example: `/v1/transactions/bf9ff782-e182-45ac-abea-5bce83ad6670/payout` @param [Hash] opts the optional parameters @return [Array<(TransactionResponse
, Fixnum, Hash)>] TransactionResponse
data, response status code and response headers
# File lib/bitpesa-sdk/api/transactions_api.rb, line 278 def payout_transaction_with_http_info(transaction_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TransactionsApi.payout_transaction ...' end # verify the required parameter 'transaction_id' is set if @api_client.config.client_side_validation && transaction_id.nil? fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.payout_transaction" end # resource path local_var_path = '/transactions/{Transaction ID}/payout'.sub('{' + 'Transaction ID' + '}', transaction_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'TransactionResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#payout_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Creates a new transaction Transactions are the main objects in the BitPesa API, so it's important to understand how to create and manage them. Transactions facilitate money movement from one Sender
in a specific currency to one or multiple Recipients in another currency. The main flow of a successful transaction flow is the following - - Transaction
is created linking the Sender
to the Recipient(s) with the requested amounts. - Once the sender is KYC'd and approved the transaction can be funded. - Once the transaction is funded, we will initiate the payout to the recipient(s). - After the recipient (or all recipients) has received the money, the transaction is finished. @param transaction_request @param [Hash] opts the optional parameters @return [TransactionResponse]
# File lib/bitpesa-sdk/api/transactions_api.rb, line 322 def post_transactions(transaction_request, opts = {}) data, _status_code, _headers = post_transactions_with_http_info(transaction_request, opts) data end
Creates a new transaction Transactions are the main objects in the BitPesa API, so it's important to understand how to create and manage them. Transactions facilitate money movement from one Sender
in a specific currency to one or multiple Recipients in another currency. The main flow of a successful transaction flow is the following - - Transaction
is created linking the Sender
to the Recipient(s) with the requested amounts. - Once the sender is KYC'd and approved the transaction can be funded. - Once the transaction is funded, we will initiate the payout to the recipient(s). - After the recipient (or all recipients) has received the money, the transaction is finished. @param transaction_request @param [Hash] opts the optional parameters @return [Array<(TransactionResponse
, Fixnum, Hash)>] TransactionResponse
data, response status code and response headers
# File lib/bitpesa-sdk/api/transactions_api.rb, line 332 def post_transactions_with_http_info(transaction_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TransactionsApi.post_transactions ...' end # verify the required parameter 'transaction_request' is set if @api_client.config.client_side_validation && transaction_request.nil? fail ArgumentError, "Missing the required parameter 'transaction_request' when calling TransactionsApi.post_transactions" end # resource path local_var_path = '/transactions' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(transaction_request) auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'TransactionResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#post_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
Validates a transaction payload Validates fields in a transaction payload and displays invalid or missing fields @param transaction_request @param [Hash] opts the optional parameters @return [TransactionResponse]
# File lib/bitpesa-sdk/api/transactions_api.rb, line 378 def validate_transactions(transaction_request, opts = {}) data, _status_code, _headers = validate_transactions_with_http_info(transaction_request, opts) data end
Validates a transaction payload Validates fields in a transaction payload and displays invalid or missing fields @param transaction_request @param [Hash] opts the optional parameters @return [Array<(TransactionResponse
, Fixnum, Hash)>] TransactionResponse
data, response status code and response headers
# File lib/bitpesa-sdk/api/transactions_api.rb, line 388 def validate_transactions_with_http_info(transaction_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TransactionsApi.validate_transactions ...' end # verify the required parameter 'transaction_request' is set if @api_client.config.client_side_validation && transaction_request.nil? fail ArgumentError, "Missing the required parameter 'transaction_request' when calling TransactionsApi.validate_transactions" end # resource path local_var_path = '/transactions/validate' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(transaction_request) auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'TransactionResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: TransactionsApi#validate_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end