VivaPayments / API

Index of Viva Wallet open source projects on GitHub.
139 stars 163 forks source link

PHP Webhook Example ? #2479

Closed nsiatras closed 7 months ago

nsiatras commented 8 months ago

Hello,

I am trying to create a webook for the "Transaction Payment Created" event.

Do you have any example code written in PHP ?

nsiatras commented 8 months ago

I used the ASP .NET code you have available and I wrote a PHP code in order to read the WebHook incoming data.

You can now close this issue.

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
    $strData = file_get_contents('php://input');
    //file_put_contents('log.txt', "$strData", FILE_APPEND | LOCK_EX);

    // This array holds the incoming data
    $json = json_decode($strData);

    $eventTypeID = $json->EventTypeId;
    $amount = $json->EventData->Amount)
    $orderCode = $json->EventData->OrderCode;

    // Payment Received Event
    if ($eventTypeID == 1796)
    {
        // Order is now paid !
        // Mark your order as paid to your database and send email to your client
    }
}
VivaWalletCustomerSupport commented 7 months ago

Hello @nsiatras,

Thank you for your message. This ticket will close for now. Please don't hesitate to raise a new ticket if you need further assistance.

Kind regards, Viva Wallet E-commerce Support Team