Developer Docs

Webhook

Get notified for every successful/failed transaction that occurs on your AutoSyncNG account

What is a webhook? A webhook is an event triggered HTTP POST call notification.

AutoSyncNG will send you a webhook event that will notify your application of every successful payment that occurs on your account.

How to setup your webhook.
Login to your account to setup your webhook URL.

Step 1

Receiving a webhook notification Creating a webhook endpoint on your server is no different from creating any page on your website.

                                            
                                                
$payload = @file_get_contents('php://input');

if(!$payload) {
exit;
}

$data = json_decode($payload);

//Verify the hash
$hash = hash('sha256', sprint('%s:%s', '1234', $data->transaction->reference));

if (!hash_equals($data->hash,$hash)) {
// webhook not from autosyncng
exit;
}

if ($data->transaction->status === 'successful') {

//Still do more checks to confirm if value has not been given.
//Give value

}
                                            
                                        

Body

{
    "hash": "e050ac4b18449566ab06aa2f2af37cca4f252e8334c8be3b5a7524bb757ffba9",
    "transaction": {
        "id": 883368,
        "reference": "95e813f7-4e33-4363-8481-446e4109473f",
        "user_id": 4,
        "amount": "50.00",
        "discount": "0.00",
        "convenience_fee": "50.00",
        "balance_before": "0.00",
        "balance_after": "50.00",
        "payment_method": "wallet",
        "details": "An AutoSyncNG test payment",
        "status": "completed",
        "type": "qr payment",
        "transact_type": "credit",
        "remarks": null,
        "paid_by": "95e81779-6d6f-4b8b-95bd-557b0d9f84fc",
        "request_ref": null,
        "created_at": "2022-03-25T20:26:39.000000Z",
        "updated_at": "2022-03-25T20:36:27.000000Z",
        "actual_amount": 50,
        "full_actual_amount": 100,
        "is_e_pin": false
    }
}

Parameters

hash The hash value is 'your transaction pin:transaction reference' hash algo = sha256 E.g hash('sha256','1234:95e813f7-4e33-4363-8481-446e4109473f') = e050ac4b18449566ab06aa2f2af37cca4f252e8334c8be3b5a7524bb757ffba9
transaction This the transaction object