Download the PHP package barion/barion-web-php without Composer

On this page you can find all versions of the php package barion/barion-web-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package barion-web-php

# Barion Web PHP Library

version Total Downloads License

A compact PHP library to manage online e-money and card payments via the Barion Smart Gateway.
It allows you to accept credit card, e-money, and wire transfer payments in just a few lines of code.

This library will help you

All with just a few simple pieces of code!

System requirements

Legacy version support

If you are using PHP versions 8.1 or lower, download our library version 1.4.11.
Please note that the use of End-Of-Support and End-Of-Life software during integration is highly discouraged.

Supported API versions

BarionClient method Endpoint description Current API version
PreparePayment Prepares a new payment in the Barion system v2
PaymentState Requests the full current state of a payment v4
FinishReservation Finishes a previously reserved Reservation payment v2
Capture Captures the final amount of a Delayed Capture payment v2
CancelAuthorization Cancels the authorization on a Delayed Capture payment v2
Complete3DSPayment Completes a previously 3D-Secure authenticated payment v2
RefundPayment Refunds a previously completed payment v2
GetPaymentState Requests the full current state of a payment (deprecated) v2
GetPaymentQRImage Requests a QR code image for a payment (deprecated) v1

Installation

Composer

You can install the library via Composer. Run the following command:

Then generate the necessary autoload files using Composer.
The library automatically detects Composer-generated autoload files and uses them for autoloading.

Manual installation

If you do not wish to use Composer, just copy the contents of the barion library into the desired folder.
The library will use its own autoloading mechanism if no Composer-generated files are detected.

Note
Be sure to set the necessary access to the path when running your PHP script.

Basic usage

Include the BarionClient class in your PHP script:

Note
BarionClient will autoload everything for you, regardless of whether you used Composer ot not.

Then instantiate a Barion client. To achieve this, you must supply three key parameters:

1. The secret key of the online store registered in Barion (called POSKey)

2. The target Barion API version number (2 by default)

3. The environment to connect to. This can be the test/sandbox system, or the production environment.

With these parameters you can create an instance of the BarionClient class:

Note
Only set useBundledRootCerts to true as a last resort if you are having SSL connection problems. It is your own responsibility to use up-to-date software that includes the latest international trusted CA certificate chains. The authors take no responsibility for loss of service resulting from the use of the certificate chain bundled with the library.

Base flow

Using the library, managing a payment process consists of two steps:

1. Starting the payment

1.1. Creating the request object

To start an online payment, you have to create one or more Payment Transaction objects, add transaction Items to them, then group these transactions together in a Payment object.

First, create an ItemModel:

Then create a PaymentTransactionModel and add the Item mentioned above to it:

Finally, create a PreparePaymentRequestModel and add the PaymentTransactionModel mentioned above to it:

Note
The secret POSKey used for authentication is not part of the request object.
The Barion client class automatically injects this value into every request sent to the Barion API.

1.2. Calling the Barion API

Now you can call the PreparePayment method of the Barion client with the request model you just created:

The Barion API now prepares a payment entity that can be paid by anyone.

The $myPayment variable holds the response received from the Barion API, which is an instance of a PreparePaymentResponseModel object.

1.3. Redirecting the user to the Barion Smart Gateway

You can use the PaymentId value in the response to redirect the user to the Barion Smart Gateway. You have to supply this identifier in the ID query string parameter.
The complete redirect URL looks like this:

The user can now complete the payment at the Barion Smart Gateway.

2. Getting information about a payment

In this example we are going to get detailed information about the payment we just created above.

2.1. Creating the request object

To request details about a payment, you only need one parameter: the payment identifier. This is the PaymentId we have used earlier to redirect the user.

2.2. Calling the Barion API

To request payment details, we call the PaymentState method of the Barion client class with the identifier above.

Note
The PaymentState API is available in API version 4. The v2 GetPaymentState API is now deprecated.

Based on the payment status and parameters received in the response, the shop can now decide whether the payment was successful or not.

API documentation

It is essential to get a basic understanding of the various statuses and errors returned by the Barion API during HTTP calls.
Please refer to the official Barion API Documentation to learn more about the various API endpoints and their responses.

Basic troubleshooting

Here are a few common mistakes you might want to double-check for before reaching out to our support:

1. I get a "User authentication failed" error when sending my request

2. I get a "Shop is closed" error message in the TEST environment

3. I get SSL errors about invalid certificates when trying to call the API

Getting help

If you have any questions or need help with usage of this plugin, join our Discord server and ask the developer community!

License

This repository is available under the Apache 2.0 License.

Contributing

How to contribute to the Barion API library

  1. Fork the barion/barion-php-web repository.
  2. Create a new branch in your fork, make the desired changes, then push the changes to your fork.
  3. Create a pull request to the barion/barion-php-web repository.
    In the pull request, please describe the functionality you developed or the problem you solved in detail.

We will try to review your pull request as soon as possible.

Version history

For details about version changes, please refer to the changelog.md file.

Further examples

To view more examples about the usage of the Barion library, refer to the docs and examples folders of the repository.

© 2024 Barion Payment Inc.


All versions of barion-web-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package barion/barion-web-php contains the following files

Loading the files please wait ....