Download the PHP package tomise/laravel-barion without Composer
On this page you can find all versions of the php package tomise/laravel-barion. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tomise/laravel-barion
More information about tomise/laravel-barion
Files in tomise/laravel-barion
Package laravel-barion
Short Description A simple Laravel package for Barion payment gateway
License MIT
Informations about the package laravel-barion
A simple Laravel package for Barion Smart Gateway
Tomise/Laravel-Barion provides an easy way to use the Barion API in Laravel applications (10–13): Smart Gateway payments (immediate, reservation, delayed capture, recurring), payment state, refund, and Barion Wallet operations.
Installation
- Install the package using composer:
From a local checkout, add a path repository to the application's composer.json first:
-
The service provider is registered automatically (package discovery). Without discovery, add
Tomise\Barion\Providers\BarionServiceProvider::classto the providers. - Publish the config file (optional):
Configuration
Details in config/barion-gateway.php.
Smart Gateway
Every request method throws:
Tomise\Barion\Exceptions\BarionPaymentExceptionwhen Barion rejects the request. The message is Barion's (Title: Description),getErrors()has every error,getErrorCode()the first error code,getCode()the HTTP status.Tomise\Barion\Exceptions\BarionConnectionExceptionwhen Barion cannot be reached.
Start a payment
startPaymentManual() fills the configured defaults (payment type, periods, payment window, guest checkout, funding
sources, redirect and callback URL, locale, currency). Amounts are rounded to the currency's decimals (HUF: 0).
Usage with models
The models need a $barion_casts property: the keys are given, the values are the model's attributes.
Locale and currency come from the config; to change them: $payment->getPaymentData()->setCurrency(Currency::Eur).
Changing the currency does not convert the amounts.
Callback: the state of a payment
Barion only posts the paymentId to the callback URL; query the state (v4 PaymentState):
Answer the callback with HTTP 200, Barion retries otherwise.
Refund
Full or partial, per transaction (the TransactionId from the start or the state response):
Reservation: charge later, finish with the final amount
The amount is charged at once and held until the payment is finished (BARION_RESERVATION_PERIOD, max. 1 year). A
lower final total refunds the rest, 0 refunds everything. Transactions not finished in time are refunded to the
customer (status Expired, or PartiallySucceeded when some were finished).
Delayed capture: authorize now, capture later
The amount is only blocked on the card (BARION_DELAYED_CAPTURE_PERIOD, max. 7 days, 21 days for Hungarian shops)
and charged on capture. An uncaptured authorization is released when the period expires (status Expired). Card
payments only; the card issuer can release the block earlier, then the capture fails.
Token payments: save the card, charge it later
The first payment is made by the customer on the Barion page and saves the card under your RecurrenceId (3DS
authentication happens here). Later payments with the same RecurrenceId are charged without the customer: the
response is already Succeeded, or Barion's error (e.g. CardExpired) is thrown. A premium feature: it has to be
requested from Barion. Barion does not schedule the charges: call the API when a charge is due (e.g. from a scheduled
command).
RecurrenceType |
When | Amount |
|---|---|---|
MerchantInitiatedPayment |
irregular charges without the customer (e.g. on a date, a no-show fee) | any; the first payment can be 0 (card registration only) |
RecurringPayment |
regular charges without the customer (subscription) | at most the first amount; needs PurchaseInformation RecurringFrequency and RecurringExpiry |
OneClickPayment |
the customer pays again on your site | any; 3DS on every payment |
The customer must clearly consent to the later charges: the Barion page does not show that the card is saved.
When a charge fails, Barion suggests checking FundingInformation->ProcessResult in the payment state: do not retry
LostOrStolenCard, FraudulentTransaction, CardNotSupported or ThreeDsNotEnabled. Retry the others later
(at least a day apart, at most 5 times), then ask the customer to register a card again.
Follow-up requests
The follow-up methods take the PaymentId as a parameter, or use the one set with setPaymentId():
| Method | Endpoint |
|---|---|
sendSinglePayment(?idempotencyKey) |
POST v2/Payment/Start |
sendPaymentState(paymentId) |
GET v4/Payment/{paymentId}/PaymentState |
sendRefund(?paymentId, transactions, ?idempotencyKey) |
POST v2/Payment/Refund |
sendFinishReservation(?paymentId, transactions) |
POST v2/Payment/FinishReservation |
sendCapture(?paymentId, transactions) |
POST v2/Payment/Capture |
sendCancelAuthorization(?paymentId) |
POST v2/Payment/CancelAuthorization |
sendCompletePayment(?paymentId) |
POST v2/Payment/Complete |
Available Locales: https://docs.barion.com/Localisation
Available Currencies: https://docs.barion.com/Supported_currencies
Testing your application
BarionGateway resolves the service from the container, so the HTTP client can be replaced:
Barion Wallet
Barion Wallet documentation
Examples
- Payment example with models
- Manual payment, callback and refund example
License
Laravel-Barion is open source software licensed under the MIT License.
All versions of laravel-barion with dependencies
guzzlehttp/guzzle Version ^7.8|^8.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
ramsey/uuid Version ^4.7