Handle webhook

All things event

When a payment occurs, Bani sends a webhook event to the webhook URL that you saved on your dashboard.

It is highly recommended that you use webhooks or verify the payment transaction status before delivering value to your customers.

We advise you to verify the response before carrying out any further action.

Please note: if the payout_status value is 'system_closed', kindly wait until the status change to either 'failed' or 'completed' before taking action on your end.

To verify the response, you will have to form the signature and compare your result with the value of 'BANI-HOOK-SIGNATURE' sent to you. The signature is a combination of your merchant_private_key and request payload.

import hmac
import hashlib
import six

my_hook_signature = hmac.new(six.b(merchant_private_key), msg=str(request_payload).encode('utf-8'), digestmod=hashlib.sha256).hexdigest()
if not hmac.compare_digest(my_hook_signature, bani-hook-signature):
    content = {"message":"Invalid signature"}
    return JsonResponse(content, status=400)
Event
Description

payin_mobile_money

Payment made via mobile money

payin_bank_transfer

Payment made via bank transfer

payin_ewallet

Payment made via third party wallet

coin_payment_incoming

An incoming crypto payment

coin_payment_received

Payment made via crypto

payout

A successful transfer to a bank account or mobile money wallet has been completed

payout_reversal

A transfer to a bank account or mobile money wallet you attempted has been reversed

payout_crypto

A successful transfer to a crypto wallet has been completed

payout_crypto_reversal

A transfer to a crypto wallet you attempted has been reversed

collection_service_status

This is sent whenever a payment method/provider is active or inactive. It's just a way of giving you heads-up on when to activate or deactivate the payment method/provider

vas_completed

This will be sent after a successful bill payment transaction

vas_failed

This will be sent after a failed bill payment transaction

Find sample request payload below.

{
  "event": "payin_mobile_money",
  "data": {
    "pay_ref": "BNPay-j6bva8xcesc2vrhhh4w1vs51t9xj96",
    "pay_ext_ref": "",
    "holder_first_name": "Star",
    "holder_last_name": "Lord",
    "custom_data": {
      "me": "userr"
    },
    "pay_amount": "30.88",
    "pay_method": "mobile_money",
    "holder_phone": "+254713674757",
    "holder_phone_carrier": "safke",
    "order_details": null,
    "holder_currency": "KES",
    "holder_country_code": "KE",
    "pay_status": "paid",
    "holder_account_number": "",
    "pub_date": "2022-04-07T11:32:24.084772Z",
    "modified_date": "2022-04-07T11:32:33.166011Z",
    "holder_bank_name": "",
    "merch_currency": "NGN",
    "merch_amount": "150.00"
  }
}

Last updated