Skip to content
Products
Docs
Pricing
Blog
Log In
Sign Up
Docs
Docs
CODE
On this page

Payment Provider Integration

How to add a custom payment provider class in UNA 15, covering the interface, SQL registration, checkout hooks, and webhook URLs.
Android
iOS
Web
Core
~15.0
Source
Copy Page
Note
Important
interface iBxBaseModPaymentProvider
{
    public function initializeCheckout($iPendingId, $aCartInfo);
    public function finalizeCheckout(&$aData);
    public function finalizedCheckout();
}
INSERT INTO `bx_payment_providers`(
  `name`, `caption`, `description`, `option_prefix`,
  `for_visitor`, `for_single`, `for_recurring`, `single_seller`, `time_tracker`,
  `active`, `order`, `class_name`, `class_file`
) VALUES (
  'mygate', '_bx_payment_mygate_cpt', '_bx_payment_mygate_dsc', 'mygate_',
  1, 1, 0, 0, 0,
  1, 80, 'BxPaymentProviderMygate', ''
);
SET @iProviderId = LAST_INSERT_ID();

INSERT INTO `bx_payment_providers_options`(
  `provider_id`, `name`, `type`, `caption`, `description`,
  `extra`, `check_type`, `check_params`, `check_error`, `order`
) VALUES
(@iProviderId, 'mygate_active', 'checkbox', '_bx_payment_mygate_active_cpt', '_bx_payment_mygate_active_dsc', '', '', '', '', 1),
(@iProviderId, 'mygate_api_key', 'secret', '_bx_payment_mygate_api_key_cpt', '_bx_payment_mygate_api_key_dsc', '', '', '', '', 2),
(@iProviderId, 'mygate_return_data_url', 'value', '_bx_payment_mygate_return_data_url_cpt', '', '', '', '', '', 3),
(@iProviderId, 'mygate_notify_url', 'value', '_bx_payment_mygate_notify_url_cpt', '', '', '', '', '', 4);
class BxPaymentProviderOffline extends BxBaseModPaymentProvider implements iBxBaseModPaymentProvider
{
    function __construct($aConfig)
    {
        $this->MODULE = 'bx_payment';
        parent::__construct($aConfig);
    }

    public function initializeCheckout($iPendingId, $aCartInfo, $sRedirect = '')
    {
        $aPending = $this->_oModule->_oDb->getOrderPending(array('type' => 'id', 'id' => $iPendingId));
        if(!empty($aPending['order']) || (int)$aPending['processed'] != 0)
            return $this->_sLangsPrefix . 'err_already_processed';

        // Build form / redirect for BX_PAYMENT_TYPE_SINGLE; reject recurring.
        $this->_oModule->_oTemplate->displayPageCodeRedirect($this->getCheckoutUrl(), $aFormData);
        exit;
    }

    public function finalizeCheckout(&$aData)
    {
        return array('code' => 1, 'message' => $this->_sLangsPrefix . 'cdt_err_not_available');
    }

    public function finalizedCheckout()
    {
        return array('code' => 1, 'message' => $this->_sLangsPrefix . 'cdt_err_not_available');
    }
}
6d
On this page
Where it livesContractRegister the providerCheckout flowfinalizeCheckout resultMinimal class shapeBuilt-in providers (master)ChecklistRelated
Auto
Introduction
Getting Started
Configuration
Apps
CODE
Developer Architecture
Code Convention
Code Quality
Directory Structure
How to Add an App
Storage System
Common Mistakes
Payment Provider Integration
Module API
iOS Client
NEO Developer
Android Client
Web Client
Contributing
REST API
Analytics Developer
Auth
Connect
INSERT INTO `bx_payment_providers`(
  `name`, `caption`, `description`, `option_prefix`,
  `for_visitor`, `for_single`, `for_recurring`, `single_seller`, `time_tracker`,
  `active`, `order`, `class_name`, `class_file`
) VALUES (
  'mygate', '_bx_payment_mygate_cpt', '_bx_payment_mygate_dsc', 'mygate_',
  1, 1, 0, 0, 0,
  1, 80, 'BxPaymentProviderMygate', ''
);
SET @iProviderId = LAST_INSERT_ID();

INSERT INTO `bx_payment_providers_options`(
  `provider_id`, `name`, `type`, `caption`, `description`,
  `extra`, `check_type`, `check_params`, `check_error`, `order`
) VALUES
(@iProviderId, 'mygate_active', 'checkbox', '_bx_payment_mygate_active_cpt', '_bx_payment_mygate_active_dsc', '', '', '', '', 1),
(@iProviderId, 'mygate_api_key', 'secret', '_bx_payment_mygate_api_key_cpt', '_bx_payment_mygate_api_key_dsc', '', '', '', '', 2),
(@iProviderId, 'mygate_return_data_url', 'value', '_bx_payment_mygate_return_data_url_cpt', '', '', '', '', '', 3),
(@iProviderId, 'mygate_notify_url', 'value', '_bx_payment_mygate_notify_url_cpt', '', '', '', '', '', 4);
class BxPaymentProviderOffline extends BxBaseModPaymentProvider implements iBxBaseModPaymentProvider
{
    function __construct($aConfig)
    {
        $this->MODULE = 'bx_payment';
        parent::__construct($aConfig);
    }

    public function initializeCheckout($iPendingId, $aCartInfo, $sRedirect = '')
    {
        $aPending = $this->_oModule->_oDb->getOrderPending(array('type' => 'id', 'id' => $iPendingId));
        if(!empty($aPending['order']) || (int)$aPending['processed'] != 0)
            return $this->_sLangsPrefix . 'err_already_processed';

        // Build form / redirect for BX_PAYMENT_TYPE_SINGLE; reject recurring.
        $this->_oModule->_oTemplate->displayPageCodeRedirect($this->getCheckoutUrl(), $aFormData);
        exit;
    }

    public function finalizeCheckout(&$aData)
    {
        return array('code' => 1, 'message' => $this->_sLangsPrefix . 'cdt_err_not_available');
    }

    public function finalizedCheckout()
    {
        return array('code' => 1, 'message' => $this->_sLangsPrefix . 'cdt_err_not_available');
    }
}