igzard/php-unas-webhook

Unas Webhook Processor

v0.1.1 2024-11-29 17:10 UTC

This package is auto-updated.

Last update: 2025-01-10 14:36:34 UTC


README

🛍️ Use this package to process incoming webhooks from Unas.

Tests passed Total Downloads Latest Version

Requires PHP 8.3+

Getting started

Get Hmac Secret from UNAS

1. First step you need to login to your unas webshop admin (https://unas.hu/belepes)
2. Navigate to Settings -> External connections -> API connection (https://shop.unas.hu/admin_config_connect_api.php)
3. Click to "Verify webhook" tab
4. Click to "HMAC key generation"
5. Copy+Paste your Hmac secret code

Installation

composer require igzard/php-unas-webhook

Usage

//Initialize Unas Webhook with your Unas shop HMAC secret and request header UNAS hmac
use Igzard\PhpUnasWebhook\UnasWebhook;

$webhook = new UnasWebhook([
    'hmac' => 'your-unas-shop-hmac-secret',
    'hmac_header' => 'Hmac secret from http header e.g: $_SERVER["HTTP_X_UNAS_HMAC"]'
]);

//Process incoming webhook request
$unasOrder = $webhook->process("{'message':'Unas request json'}");

//Get order data eg. order number
$orderNumber = $unasOrder->getOrderId()->getValue(); //return with unas webshop order number string

//or get customer data
$customer = $unasOrder->getCustomer(); //return with Customer data object

//etc.

//processing Unas Order with your domain logic...

Contributing

We are open to contributions. If you want to fix a bug, implement a new feature or just ask a question, please feel free to open an issue or create a pull request.

🚀 Install dependencies with composer:

make composer-install

✅ Run Code quality check:

make code-quality

👷 Run PHPUnit tests:

make phpunit

🎨 Run cs-fix:

make cs-fix

🔥 Run phpstan:

make phpstan

♻️ Run rector:

make rector

PHP UNAS Webhook processor was created by Gergely Ignácz under the MIT license.