Documentation

Payment system events

Events

EventDescription and parametersAvailable from version
OnSalePsServiceProcessRequestBeforePaid Triggered when method processRequest for payment system handler operated without errors and payment status needs an update.

Parameters
paymentPayment object.
statusStatus (Y/N).
pay_system_idPayment system ID.
OnSaleGetHandlerDescription Triggered on receiving description for payment system. Event handler can add to CODE key value.

Parameters
handlerPayment system handler.
onSalePsInitiatePaySuccessTriggered on successful initializing of payment system. Event handler contains available payment object.

Parameters
paymentPayment object.
onSalePsInitiatePayErrorTriggered on error when initializing payment system. Event handler contains payment object and array with errors.

Parameters
paymentPayment object.
errorsarray with errors, retrieved via getErrorMessages from object ServiceResult.

Examples

OnSalePsServiceProcessRequestBeforePaid

use Bitrix\Main;
use Bitrix\Sale\Payment;

Main\EventManager::getInstance()->addEventHandler(
   'sale',
   'OnSalePsServiceProcessRequestBeforePaid',
   'myFunction'
);

function myFunction(Main\Event $event)
{
   /** @var Payment $payment */
   $payment = $event->getParameter('payment');

   /** @var string $status */
   $status = $event->getParameter('status');

   /** @var string $paySystemId */
   $paySystemId = $event->getParameter('pay_system_id');

   /**
    * Arbitrary code
    * For example, getting payment system $paySystem = $payment->getPaySystem();
    */
}

OnSaleGetHandlerDescription

use Bitrix\Main;
use Bitrix\Sale\Payment;

Main\EventManager::getInstance()->addEventHandler(
   'sale',
   'OnSaleGetHandlerDescription',
   'myFunction'
);

function myFunction(Main\Event $event)
{
   /** @var string $handler */
   $handler = $event->getParameter("handler");

   if ($handler === 'my_handler')
   {
      return array(
         'USER_COLUMNS' => array(
            "NAME" => "User field",
            "SORT" => 6000,
            'GROUP' => 'COLUMN_SETTINGS',
         )
      );
   }

   return array();
}

onSalePsInitiatePaySuccess

use Bitrix\Main;
use Bitrix\Sale\Payment;

Main\EventManager::getInstance()->addEventHandler(
   'sale',
   'onSalePsInitiatePaySuccess',
   'myFunction'
);

function myFunction(Main\Event $event)
{
   /** @var Payment $payment */
   $payment = $event->getParameter('payment');

   /**
    * Arbitrary code
    */
}

onSalePsInitiatePayError

use Bitrix\Main;
use Bitrix\Sale\Payment;

Main\EventManager::getInstance()->addEventHandler(
   'sale',
   'onSalePsInitiatePayError',
   'myFunction'
);

function myFunction(Main\Event $event)
{
   /** @var Payment $payment */
   $payment = $event->getParameter('payment');

   /** @var array $errors array with errors retrieved via getErrorMessages from object ServiceResult */
   $errors = $event->getParameter('errors');

   /**
    * Arbitrary code
    */
}

© «Bitrix24», 2001-2024
Up