PHP code example of yorchi / laravel-conekta-webhooks

1. Go to this page and download the library: Download yorchi/laravel-conekta-webhooks 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/ */

    

yorchi / laravel-conekta-webhooks example snippets

 php
Route::conektaWebhooks('webhook-route-configured-at-the-conekta-dashboard');
 php
protected $except = [
    'webhook-route-configured-at-the-conekta-dashboard',
];
 php
namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Yorchi\LaravelConektaWebhooks\ConektaWebhookCall;

class HandleCreatedCharge implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    /** @var  \Yorchi\LaravelConektaWebhooks\ConektaWebhookCalll */
    public $webhookCall;

    public function __construct(ConektaWebhookCalll $webhookCall)
    {
        $this->webhookCall = $webhookCall;
    }

    public function handle()
    {
        // do your work here

        // you can access the payload of the webhook call with $this->webhookCall->payload
    }
}
 php
// config/conekta-webhooks.php

'jobs' => [
    'chargeCreated' => \App\Jobs\ConektaWebhooks\HandleCreatedCharge::class,
],
 php
/**
 * The event listener mappings for the application.
 *
 * @var  array
 */
protected $listen = [
    'conekta-webhooks::chargeCreated' => [
        App\Listeners\MailOperators::class,
    ],
];
 php
namespace App\Listeners;

use Illuminate\Contracts\Queue\ShouldQueue;
use Yorchi\LaravelConektaWebhooks\ConektaWebhookCall;

class MailOperators implements ShouldQueue
{
    public function handle(ConektaWebhookCalll $webhookCall)
    {
        // do your work here

        // you can access the payload of the webhook call with `$webhookCall->payload`
    }
}
 php
$webhookCall->payload; // returns an array;