Registering and receiving webhooks
Info
Once registered, a webhook allows you to receive confirmation or failure of a transaction.
The subscriptions that can be registered for a url are:
Subscriptions:
- "transaction.success"
- "brcode.created"
- "brcode.credited"
- "payment.success"
- "payment.fail"
For more information about authentication and libraries to use see: doc
Example of message signature and verification
//sign
$priv = env('fabank_private');
$privateKey = EllipticCurve\PrivateKey::fromPem($priv);
$message = [
[
"amount" => 10,
"expiration" => 5600,
"tags" => ["teste"]
]
];
$message = json_encode($message);
$signed = EllipticCurve\Ecdsa::sign($message, $privateKey);
$signature = $signed->toBase64();
echo $signature."\n";
//verify
$envPK = env('fabank_public');// get from url: url_api_fabank/api/v1/public-key
$signature2 = \EllipticCurve\Signature::fromBase64($signature);
$publickey = EllipticCurve\PublicKey::fromPem($envPK);
$verify = EllipticCurve\Ecdsa::verify($message, $signature2, $publickey);
return response()->json([
"signature" => $signature,
"verify" => $verify,
]);
Returned objects
{
"event": {
"created": "2023-09-28T13:47:14.000000Z",
"id": 246,
"data": {
"accountNumber": null,
"accountType": null,
"amount": "1.10",
"bankCode": null,
"branchCode": null,
"created": "2023-09-28 13:47:07",
"id": "00020101021226890014br.gov.bcb.pix2567brcode-h.sandbox.starkinfra.com\/v2\/98ec7354d1414e0fbfff215b9503c6c05204000053039865802BR5925Fapay Meios de Pagamento 6012Porto Alegre62070503***630470EB",
"name": null,
"status": "credited",
"tags": [
"my_transaction_id:12345",
"brcodeid:9a3df452-7750-491b-9993-fb86604454d0"
],
"taxId": null,
"type": null,
"updated": "2023-09-28 13:47:07"
},
"subscription": "brcode.credited",
"status": "done",
"errors": [],
"accountNumber": "6288880214999040"
}
}{
"event": {
"created": "2023-09-21T05:46:37.000000Z",
"id": 198,
"data": {
"accountNumber": null,
"accountType": null,
"amount": "0.10",
"bankCode": null,
"branchCode": null,
"created": "2023-09-21 05:46:14",
"id": "00020101021226890014br.gov.bcb.pix2567brcode-h.sandbox.starkinfra.com\/v2\/855331b920ba491aaf02241dd7f404ed5204000053039865802BR5925Fapay Meios de Pagamento 6012Porto Alegre62070503***6304A36B",
"name": null,
"status": "credited",
"tags": [
"meuidunico:21312iu3y2i1u3y21iu3y21i3uy213iu21y31",
"brcodeid:9a2f3373-6405-4a7f-a3e4-d1f72f913b21"
],
"taxId": null,
"type": null,
"updated": "2023-09-21 05:46:16"
},
"subscription": "brcode.created",
"status": "done",
"errors": [],
"accountNumber": "6288880214999040"
}
}{
"event": {
"created": "2023-09-21T05:06:42.000000Z",
"id": 196,
"data": {
"accountNumber": "5550954686447616",
"amount": "7.38",
"bankCode": "20018183",
"branchCode": "0001",
"created": "2023-09-21T05:06:16.000000Z",
"fee": "0.00",
"id": "9a2f2529-f1a6-4d49-9cb2-10dc8b796d46",
"name": "Tarifa out para Fapay Meios de Pagamento S\/A",
"status": "done",
"tags": [
"_tax_transfer_id:9a2ec8fa-04c4-4b02-b37e-68e18a6853dd",
"provedor_transaction_id:6449956218994688"
],
"taxId": "37.885.897\/0001-98",
"type": "pix",
"updated": null
},
"subscription": "transaction.success",
"status": "done",
"errors": [],
"accountNumber": "6288880214999040"
}
}
To validate a message received via webhook, use the "signature" field, sent in the request header.It is HIGHLY RECOMMENDED that you validate the signature before make any action in you application.
