A very very very simple library that performs online payments with unicredit. This is more an example than an actual library.
User: UNIBO
Password: UniBo2014
The original library can be found in the Backoffice under the following path:
PROFILO ESERCENTE >> Documentazione e Supporto >> API Pack
$ composer require railken/unicredit
<?php
use Railken\Unicredit\Unicredit;
$uc = new Unicredit([
'terminal_id' => 'UNI_ECOM',
'api_key' => 'UNI_TESTKEY',
'currency' => 'EUR',
'lang' => 'IT',
'base_url' => 'https://testuni.netsw.it',
'verify_url' => 'http://localhost/verify.php',
'error_url' => 'http://localhost/error.php'
]);
<?php
use Railken\Unicredit\Unicredit;
# Make a new instance
$uc = new Unicredit();
# Create a random ID for an order
$order_id = md5(time());
# Make a payment for 10,00 EUR
# Return the Payment ID
$response = $uc->payment($order_id, 'email@customer.com', 10);
if (!$response->error) {
# IMPORTANT !!!
# Save $order_id and $transaction_id in DB or Cookie in order to retrieve in the next page
# Redirect to the checkout
$uc->redirect_url;
}else{
# Get error
$error = $response->error->message;
}
<?php
use Railken\Unicredit\Unicredit;
# Retrieve $transaction_id and $order_id from DB/Cookie
# Make a new instance
$uc = new Unicredit();
$response = $uc->verify($order_id, $transaction_id);
if (!$response->error) {
# Success
} else {
# Get error
$error = $response->error->message;
}