A
A
alexgodman2021-05-05 15:19:44
1C-Bitrix
alexgodman, 2021-05-05 15:19:44

How to write a payment handler in Bitrix?

I am writing a payment processor for lending. I found links on how to write it.
course
documentation
So I realized that the old version of
d7

handlers As a result, I wrote such a canoe

<?php

namespace Sale\Handlers\PaySystem;

use Bitrix\Main\Request;
use Bitrix\Sale\PaySystem;
use Bitrix\Sale\Payment;
use Bitrix\Sale;
use Bitrix\Sale\PaySystem\ServiceResult;

class tcreditHandler extends PaySystem\ServiceHandler
{
    public function initiatePay(Payment $payment, Request $request = null)
    {
        AddMessage2Log('TcreditHandler initiatePay()');
        $params = array('URL' => $this->getUrl($payment, 'pay'));
        $this->setExtraParams($params);

        return $this->showTemplate($payment, "template");
    }

    public static function getIndicativeFields()
    {
        AddMessage2Log('TcreditHandler getIndicativeFields()');
        return array('BX_HANDLER' => 'CREDIT');
    }

    public function getCurrencyList()
    {
        AddMessage2Log('TcreditHandler getCurrencyList()');
    }

    public function processRequest(Payment $payment, Request $request)
    {
        AddMessage2Log('TcreditHandler processRequest()');
    }

    public function getPaymentIdFromRequest(Request $request)
    {
        AddMessage2Log('TcreditHandler  getPaymentIdFromRequest()');
    }
}

threw this structure into bitrix/php_interface/include/sale_payment
609289e843f82480427283.png

As far as I understand, after creating an order on the page, the initiatePay method should be processed and html should be returned from the template.php template, but for some reason this does not happen. According to the logs, only getCurrencyList() works;
60928afa541a9137270463.png

I looked at how it was done with the acquiring module from tinkoff, there the handler is in payment.php and other files are connected to it from everywhere, however, if you copy the structure and simply rename the folder and classes, it still does not work.
Can the handler be registered somehow?

Thank you in advance for your help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question