PHP code example of frain / convoy

1. Go to this page and download the library: Download frain/convoy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

frain / convoy example snippets


use Convoy\Convoy;

$convoy = new Convoy(["api_key" => "your_api_key", "project_id" => "your_project_id"]);

$endpointData = [
    "name" => "Default Endpoint",
    "url" => "https://0d87-102-89-2-172.ngrok.io",
    "description" => "Default Endpoint",
    "secret" => "endpoint-secret",
    "events" => ["*"]
];

$response = $convoy->endpoints()->create($endpointData);

$endpointId = "01GTVFSGBAH8NJTMT5Y1ENE218";

$endpointData = [
    "name" => "Default Endpoint",
    "url" => "https://0d87-102-89-2-172.ngrok.io",
    "description" => "Default Endpoint",
    "secret" => "endpoint-secret",
    "events" => ["*"]
];

$response = $convoy->endpoints()->update($endpointId, $endpointData);

$eventData = [
    "endpoint_id" => $endpointId,
    "event_type" => "payment.success",
    "data" => [
        "event" => "payment.success",
        "data" => [
            "status" => "Completed",
            "description" => "Transaction Successful",
            "userID" => "test_user_id808"
        ]
    ]
];

$response = $convoy->events()->create($eventData);