It looks like you are accessing this page on a mobile device!


Daraza is designed and best optimized for PCs. Please access this page on a desktop or laptop computer or a wider screen at least.

Integrating Your API Key and Managing Transactions

 

After creating your account, business profile, and app, the next steps involve integrating the API key into your system and managing transactions effectively.
 


Step 6: Integrate the API Key
 

The API key enables your application to communicate securely with Daraza’s payment system. Follow these steps to set it up:
 

1. Access Daraza API Documentation
 

  1. Navigate to the "Documentation" section in your Daraza dashboard to get the endpoints.
     
  2. Review the detailed guides for API integration, including examples in popular programming languages like Python, PHP, or JavaScript.
     

2. Add the API Key to Your Application
 

  1. In your application’s code, set the API key as an environment variable for security.

    • Example for Python:


      import os
      DARAZA_API_KEY = os.getenv('DARAZA_API_KEY')

       

    • Add your API key to the .env file:


      DARAZA_API_KEY=your-api-key-here
       

  2. Use the API key in API requests:

    • Example of sending a payment request:

       

      import requests

      headers = {

                  "Authorization": f"Api-Key {DARAZA_API_KEY}",
                  "Content-Type": "application/json"

              }

      payload = {

                   "method": 1,
                   "amount": "5000",
                   "amount": "+2567890000000",
                   "note": "Payment for Order #1234"

               }

      response = requests.post("https://api.daraza.net/api/request_to_pay/", headers=headers, json=payload)

      if response.status_code == 200:

          print("Payment Successful:", response.json())

      else:

          print("Error:", response.text)

       

3. Test Your Integration
 

  1. Use the Daraza Sandbox Environment to simulate payments without affecting real accounts.
     
  2. Verify your API requests and responses to ensure proper integration.
     

Step 7: Manage Transactions
 

Daraza provides tools for tracking and managing payments directly from the dashboard or via API.
 

1. View Transactions in the Dashboard
 

  1. Log in to your Daraza account.
     
  2. Navigate to the App making the request and then  "Funds" section to see a list of all payments processed.

2. Handle Transaction Notifications
 

Daraza supports webhooks to notify you about transaction events:

  1. Set up a Webhook URL in your app settings.
     

  2. Handle the incoming notification payload:

    1. Example webhook handler (Python Flask):


      from flask import Flask, request, jsonify

      app = Flask(__name__)

      @app.route('/webhook', methods=['POST'])
      def webhook():
           data = request.json
           if data['status'] == 'completed':
                print(f"Payment received: {data['amount']} UGX")
           else:
                print(f"Payment failed: {data['reason']}")
           return jsonify({"status": "success"}), 200

      if __name__ == '__main__':
          app.run(port=5000)

       

  3. Test your webhook with the Daraza dashboard to confirm you’re receiving notifications.
     

3. Refund and Reversal Management
 

  1. To initiate a refund, use the Remittance API Endpoint to send money back to a customer.

Step 8: Monitor and Analyze Transactions
 

Daraza’s analytics tools help you understand your payment performance:

A. General Monitor

Your home view gives the general analytics for your business profiles and apps, API request summary and the most recent activity logs
 

B. App Analytics
 

Your app has diffrent analytics scetion to give your different insights. 
 

  1. Visit the Details section on your app to view:
    • App deatils such as client, credentials and important dates such creation
    • Number of request mades i.e. GET, POST and DELETE
       
  2. Visit the Logs section on your app to view the apps activity logs
     
  3. Visit the Funds section on your app to view:
    • Total revenue.
    • Breakdown of of different transaction types.

Session Timeout Warning

You've been inactive for 29 minutes. Your session will expire in:

01:00