Developer / API
Plugin API
yui\barion\Plugin implements yStore's
yui\craft\base\collector\PaymentMethodRegistryInterface and registers itself
with the store's PaymentMethodRegistry once all plugins have loaded
(Plugins::EVENT_AFTER_LOAD_PLUGINS). The methods below are the contract
yStore calls into; they are not normally called directly from custom code, but
are useful to know when debugging a checkout integration.
use yui\barion\Plugin;
$details = Plugin::$plugin->getDetails();
| Method | Purpose |
|---|---|
getDetails(): array | Returns the payment method descriptor yStore uses to list Barion at checkout: name, code/handle (barion), type (online), instructions, price, enabled, plus url, logo, and description for the CP/checkout UI. Returns [] and logs on error. |
placeOrder(array $data, array $items, ?string $code = null): array | Builds and sends the Barion payment request for an order. Returns ['extra' => [...], 'redirectUrl' => ...] on success (see below), or [] if the order data/items are invalid or Barion returned an error. |
postValidate(?array $params): array | Called on the checkout return/callback. Reads paymentId from the current request, fetches the Barion payment state, and returns ['success' => bool, 'paid' => float, 'status' => string]. success is only true when Barion's status is Succeeded. |
getPaymentRetryUrl(array $order, array $items): ?string | Always returns null in this plugin version — Barion payment retry is not implemented as a distinct URL; the customer restarts checkout instead. |
getApi(): ApiService | Returns the plugin's ApiService component (Plugin::$plugin->get('api')). |
getLicense(): LicenseService | Returns the plugin's license service component, shared with the CP License page. |
placeOrder() success payload
[
'extra' => [
'paymentId' => $results->PaymentId,
'paymentRequestId' => $results->PaymentRequestId,
'paymentStatus' => $results->Status,
'qUrl' => $results->QRUrl,
'resurrectedResults' => $results->RecurrenceResult,
'paymentRedirectUrl' => $results->PaymentRedirectUrl,
],
'redirectUrl' => $results->PaymentRedirectUrl,
];
redirectUrl is what the storefront sends the customer's browser to — Barion's
hosted payment page.
ApiService
yui\barion\services\ApiService (Plugin::$plugin->get('api') /
Plugin::$plugin->getApi()) wraps the barion/barion-web-php SDK
(BarionClient). It's only instantiated with a live BarionClient when the
plugin is enabled; the environment (BarionEnvironment::Prod vs ::Test) is
chosen from Enable SandboxMode at construction time.
| Method | Purpose |
|---|---|
prepare(array $data, array $items): self | Builds the Barion transaction + payment request models from raw order $data (via DataHelper::extractOrderData()) and $items (via DataHelper::extractOrderItems()). Chainable — call ->send() next. Throws if $data or $items is empty. |
send() | Sends the prepared payment request to Barion (BarionClient::PreparePayment) and returns the PreparePaymentResponseModel, or logs and returns nothing on error. |
getPaymentDetails(?string $identifier) | Calls BarionClient::GetPaymentState($identifier) and returns the PaymentStateResponseModel, or false on error. |
testCredentials(): bool | Calls getPaymentDetails('test') and checks whether Barion responds with an AuthenticationFailed error — used by the settings page's Test Credentials action. |
BARION_API_VERSION is fixed at 2.
DataHelper
yui\barion\helpers\DataHelper prepares data for ApiService::prepare() and
is not normally called directly, but its output shape is useful for
integration debugging:
extractOrderData(array $data): array— validatesorder_id,increment_id,email, andgrand_totalare present, then returns the normalized order array (total,comment,transaction_id,payment_request_id,redirectUrl,callbackUrl, …) consumed byApiService. Throwsyii\db\Exceptionwhen required order fields are missing.extractOrderItems(array $items): array— maps yStore order line items (Craft element objects withtoArray()) to thename/description/qty/unit/price/rowTotal/handleshape Barion'sItemModelexpects. Prices are divided by 100 (yStore stores minor units) and formatted to two decimal places.generateTransactionId()/generatePaymentRequestId()— build aTRANSACTION-{site_id}-{order_id}-{random}/PAYMENT-{site_id}-{order_id}-{random}string and AES-256-ECB encrypt it (keyed by the plugin handle) before it's sent to Barion asPOSTransactionId/PaymentRequestId.getPaymentStatusList(): array— returns the full list of Barion payment statuses with human-readable labels and descriptions; see Payment statuses below.
Payment statuses
DataHelper::getPaymentStatusList() documents every status Barion can return
for a payment (PaymentStateResponseModel->Status):
| Status | Meaning |
|---|---|
Prepared | Payment is prepared; can still be completed unless the payment time window expires. |
Started | Payer has started the payment with a funding source. |
InProgress | Barion is currently communicating with the bank card processing system; the payment cannot be altered. |
Waiting | Paid by bank transfer, result not yet known (Payment Buttons scenarios). |
Reserved | Completed by the payer but the amount is still reserved; must be finished before the reservation period expires. |
Authorized | Completed by the payer but not yet charged; must be finished before the authorization period expires. |
Canceled | Explicitly cancelled/rejected by the payer. Final. |
Succeeded | Fully completed. Final. This is the only status Plugin::postValidate() treats as a successful, paid order. |
Failed | Failed for unknown reasons (bank-transfer scenarios). |
PartiallySucceeded | Some transactions in a complex reservation payment finished, others didn't; becomes Succeeded once all finish. |
Expired | The payment expired. |
Only Succeeded marks an order as paid in this plugin version — if you
build custom logic that needs to react to Reserved/Authorized
(delayed-capture-style flows), call ApiService::getPaymentDetails() directly
rather than relying on postValidate().
Control panel routes
Registered on UrlManager::EVENT_REGISTER_CP_URL_RULES, all under barion/*:
barion/settings— settings page (SettingsController::actionIndex).barion/settings/test— runsApiService::testCredentials()and redirects back with a success/error flash (SettingsController::actionTest).barion/license,barion/license/redeem,barion/license/activate,barion/license/revoke,barion/license/delete,barion/license/copy-token— license management, sharedAbstractLicenseControllerflow used by other YUI plugins.
There are no anonymous/site-facing routes registered by this plugin directly —
the checkout redirect to Barion and the return callback are driven through
yStore's own checkout controllers calling Plugin::placeOrder() /
Plugin::postValidate(), not through Barion-specific URLs.
Extensibility
This plugin version does not register its own Craft events, permissions, or
MCP tools — extension points are the public Plugin/ApiService methods
above. To react to a Barion payment outside the standard checkout flow (for
example, a delayed-capture reconciliation job), call
Plugin::$plugin->getApi()->getPaymentDetails($paymentId) directly and branch
on the status table above.