| Server IP : 146.59.209.152 / Your IP : 216.73.216.152 Web Server : Apache System : Linux webm009.cluster131.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : monpetu ( 144298) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/monpetu/www/ipprint/extensions/bookly-addon-pro/frontend/modules/square/ |
Upload File : |
<?php
namespace BooklyPro\Frontend\Modules\Square;
use Bookly\Lib as BooklyLib;
use Bookly\Frontend\Modules\Payment;
use BooklyPro\Lib\Payment\SquareGateway;
class Ajax extends BooklyLib\Base\Ajax
{
/**
* @inheritDoc
*/
protected static function permissions()
{
return array( '_default' => 'anonymous' );
}
/**
* Processing Square webhooks
*/
public static function squareWebhooks()
{
$data = json_decode( file_get_contents( 'php://input' ), true );
$response_code = 200;
if ( isset( $data['type'] ) && $data['type'] === 'order.updated' ) {
try {
/** @var BooklyLib\Entities\Payment $payment */
$payment = BooklyLib\Entities\Payment::query()->where( 'ref_id', $data['data']['id'] )->findOne();
if ( $payment && $payment->getStatus() === BooklyLib\Entities\Payment::STATUS_PENDING ) {
$square = new SquareGateway( Payment\Request::getInstance() );
$square->setPayment( $payment )->retrieve();
}
} catch ( \Exception $e ) {
$response_code = 400;
}
}
BooklyLib\Utils\Common::emptyResponse( $response_code );
}
/**
* @inheritDoc
*/
protected static function csrfTokenValid( $action = null )
{
return true;
}
}