Webhook
Pix Cash In response
You can create webhook subscriptions to receive events whenever a new log is created. We send the event by making a POST request to your endpoint URL. The event sent to the endpoint URL has the structure shown below. Structure in JSON.
When informing your Webhook URL to the support team, it is important to keep in mind some points:
- The Webhook URL must be a valid and active URL that can receive HTTP POST requests.
By informing your Webhook URL to the support team, you will enable the receipt of important notifications directly into your system, allowing you to monitor and respond to events more efficiently. It is important to be aware of the mentioned points to ensure that your Webhook URL is valid, secure, and configured correctly.
{
"event_type" : "pix_cash_in",
"pix_id" : 941256257,
"amount" : 600,
"expiration" : 3600,
"tags" : "teste",
"status" : "pending_deposit",
"id_pix_copia_cola" : ".....kinfra.com/v4234a3f403ccb0...",
"uuid" : "fee8037cb34e4234a3f403ccb0a016f2",
"currency" : "BRL",
"createdAt" : 2023-05-03,
"payment_type" : "pix",
"client_ip" : 177.52.30.90,
"link_token" : "f43651a3af3195a69e40524e3630322c"
}
Example
You should create security handling by confirming your SECRET TOKEN, which only you should know.
Below we have created an example using the PHP language:
<?php
$data = $_POST;
$token_key = $data['token_key'];
$event_type = $data['event_type'];
if($token_key == 'b9526feaf.....ff7eec86'){
// Implement the logic in this body.
if($event_type == 'card_transaction'){
$event_type = $data['event_type'];
$event_type = $data['event_type'];
$event_id = $data['event_id'];
$invoice_id = $data['invoice_id'];
$metadata = $data['metadata'];
$link_token = $data['link_token'];
$status = $data['status'];
$message = $data['message'];
$card_brand = $data['card_brand'];
$holder_name = $data['holder_name'];
$amount = $data['amount'];
$currency = $data['currency'];
$split = $data['split'];
$payment_type = $data['payment_type'];
$date = $data['date'];
$client_ip = $data['client_ip'];
$data = [
'event_type' => $event_type,
'EVENT ID' => $event_id,
'INVOICE ID' => $invoice_id,
'EVENT TYPE' => $event_type,
'METADATA' => $metadata,
'LINK TOKEN' => $link_token,
'STATUS' => $status,
'MESSAGE' => $message,
'CARD BRAND' => $card_brand,
'HOLDER NAME' => $holder_name,
'AMOUNT' => $amount,
'CURRENCY' => $currency,
'SPLIT' => $split,
'PAYMENT TYPE' => $payment_type,
'DATE' => $date,
'CLI. IP' => $client_ip,
];
file_put_contents('webhook_log.txt', print_r($data, true));
} else if($event_type == 'pix_cash_in'){
$event_type = $data['event_type'];
$pix_id = $data['pix_id'];
$amount = $data['amount'];
$expiration = $data['expiration'];
$tags = $data['tags'];
$status = $data['status'];
$id_pix_copia_cola = $data['id_pix_copia_cola'];
$uuid = $data['uuid'];
$currency = $data['currency'];
$createdAt = $data['createdAt'];
$payment_type = $data['payment_type'];
$date = $data['date'];
$client_ip = $data['client_ip'];
$link_token = $data['link_token'];
$data = [
'event_type' => $event_type,
'pix_id' => $pix_id,
'amount' => $amount,
'expiration' => $expiration,
'tags' => $tags,
'status' => $status,
'id_pix_copia_cola' => $id_pix_copia_cola,
'uuid' => $uuid,
'currency' => $currency,
'createdAt' => $createdAt,
'payment_type' => $payment_type,
'client_ip' => $client_ip,
'link_token' => $link_token,
];
file_put_contents('webhook_log.txt', print_r($data, true));
}
} else {
file_put_contents('webhook_log.txt', 'ERROR!');
}
Last updated