Skip to content
Products
Resources
Solutions
Pricing
Contact
Log In
Sign Up
Docs
Getting Started
Configuration
Apps
CODE
Developer Architecture
Code Convention
Code Quality
Directory Structure
Storage System
Common Mistakes
Payment Provider Integration
How to Add an App
Auth
Docs
CODE
Payment Provider Integration
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');For a real gateway, copy patterns from `BxPaymentProviderPayPal` (HTML redirect + PDT/IPN) or `BxPaymentProviderStripeV3` (SCA). Call `$this->log(...)` while integrating.

## Built-in providers (master)

| `name` | Class | Single | Recurring | Notes |
| --- | --- | --- | --- | --- |
| `generic` | `BxPaymentProviderGeneric` | No | No | Shared seller options only. Does not charge |
| `offline` | `BxPaymentProviderOffline` | Yes | No | Cash / etransfer style |
| `credits` | `BxPaymentProviderCredits` | Yes | Yes | Needs Credits app |
| `paypal` | `BxPaymentProviderPayPal` | Yes | No | Classic HTML checkout |
| `paypal_api` | `BxPaymentProviderPayPalApi` | Yes | Yes | API + notify |
| `chargebee` | `BxPaymentProviderChargebee` | No | Yes | Hosted |
| `chargebee_v3` | `BxPaymentProviderChargebeeV3` | Yes | Yes | Drop-in |
| `stripe` | `BxPaymentProviderStripe` | Yes | Yes | Without SCA |
| `stripe_v3` | `BxPaymentProviderStripeV3` | Yes | Yes | 3D Secure / SCA |
| `stripe_connect` | `BxPaymentProviderStripeConnect` | Yes | Yes | Delegates to `bx_stripe_connect` |
| `apple_in_app` | `BxPaymentProviderAppleInApp` | Yes | Yes | Owner only; App Store notifications |

Studio captions can repeat (two Stri1. Class extends `BxBaseModPaymentProvider`, implements `iBxBaseModPaymentProvider`, sets `MODULE` to `bx_payment`.
2. File is loadable via empty `class_file` (payment `classes/`) or an explicit `class_file`.
3. `bx_payment_providers` row with unique `name` and `option_prefix`.
4. Options include `{prefix}active` when sellers must enable the provider, plus keys / mode / URLs as needed.
5. `initializeCheckout` creates or continues the gateway session for the pending id; guard against already-processed pendings.
6. `finalizeCheckout` returns `code` `0`, `pending_id`, and `paid` / subscription fields; update pending order metadata.
7. Webhook providers implement `notify()` and document the notify URL for sellers.
8. Lang keys exist; uninstall SQL removes provider rows and options.
9. Test with Studio Providers enabled and seller Active on Main seller (and any Market seller).

## Related

[Payments](wiki/Payments) · [Paid Levels](wiki/Paid-Levels-App) · [How to Add an App](wiki/how-to-add-an-app) · [Developer Architecture](wiki/developer-architecture) · [Module API](wiki/module-api) · [Common Mistakes](wiki/common-mistakes)pe rows, two Chargebee rows). Distinguish by Description and by `name`.

## Checklist


    }
}
6d
On this page
Where it livesContractCheckout flowfinalizeCheckout resultMinimal class shapeRegister the provider
Auto
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');For a real gateway, copy patterns from `BxPaymentProviderPayPal` (HTML redirect + PDT/IPN) or `BxPaymentProviderStripeV3` (SCA). Call `$this->log(...)` while integrating.

## Built-in providers (master)

| `name` | Class | Single | Recurring | Notes |
| --- | --- | --- | --- | --- |
| `generic` | `BxPaymentProviderGeneric` | No | No | Shared seller options only. Does not charge |
| `offline` | `BxPaymentProviderOffline` | Yes | No | Cash / etransfer style |
| `credits` | `BxPaymentProviderCredits` | Yes | Yes | Needs Credits app |
| `paypal` | `BxPaymentProviderPayPal` | Yes | No | Classic HTML checkout |
| `paypal_api` | `BxPaymentProviderPayPalApi` | Yes | Yes | API + notify |
| `chargebee` | `BxPaymentProviderChargebee` | No | Yes | Hosted |
| `chargebee_v3` | `BxPaymentProviderChargebeeV3` | Yes | Yes | Drop-in |
| `stripe` | `BxPaymentProviderStripe` | Yes | Yes | Without SCA |
| `stripe_v3` | `BxPaymentProviderStripeV3` | Yes | Yes | 3D Secure / SCA |
| `stripe_connect` | `BxPaymentProviderStripeConnect` | Yes | Yes | Delegates to `bx_stripe_connect` |
| `apple_in_app` | `BxPaymentProviderAppleInApp` | Yes | Yes | Owner only; App Store notifications |

Studio captions can repeat (two Stri1. Class extends `BxBaseModPaymentProvider`, implements `iBxBaseModPaymentProvider`, sets `MODULE` to `bx_payment`.
2. File is loadable via empty `class_file` (payment `classes/`) or an explicit `class_file`.
3. `bx_payment_providers` row with unique `name` and `option_prefix`.
4. Options include `{prefix}active` when sellers must enable the provider, plus keys / mode / URLs as needed.
5. `initializeCheckout` creates or continues the gateway session for the pending id; guard against already-processed pendings.
6. `finalizeCheckout` returns `code` `0`, `pending_id`, and `paid` / subscription fields; update pending order metadata.
7. Webhook providers implement `notify()` and document the notify URL for sellers.
8. Lang keys exist; uninstall SQL removes provider rows and options.
9. Test with Studio Providers enabled and seller Active on Main seller (and any Market seller).

## Related

[Payments](wiki/Payments) · [Paid Levels](wiki/Paid-Levels-App) · [How to Add an App](wiki/how-to-add-an-app) · [Developer Architecture](wiki/developer-architecture) · [Module API](wiki/module-api) · [Common Mistakes](wiki/common-mistakes)pe rows, two Chargebee rows). Distinguish by Description and by `name`.

## Checklist


    }
}