<?php

/*
*  Barion PHP library usage example
*  
*  Starting an immediate payment with two payee transactions
*  
*  � 2015 Barion Payment Inc.
*/
require_once '../library/BarionClient.php';
$myPosKey = "11111111-1111-1111-1111-111111111111";
// <-- Replace this with your POSKey!
$myEmailAddress = "*****@*****.**";
// <-- Replace this with your e-mail address in Barion!
// Barion Client that connects to the TEST environment
$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test);
// create the item model
$item = new ItemModel();
$item->Name = "ExpensiveTestItem";
// no more than 250 characters
$item->Description = "An expensive test item for payment";
// no more than 500 characters
$item->Quantity = 1;
$item->Unit = "piece";
// no more than 50 characters
$item->UnitPrice = 50000;
$item->ItemTotal = 50000;
$item->SKU = "ITEM-03";
// no more than 100 characters
// create the payee transactions
$ptrans1 = new PayeeTransactionModel();
<?php

/*
*  Barion PHP library usage example
*  
*  Refunding a payment partially (refunding 100 Ft from a payment)
*  
*  © 2015 Barion Payment Inc.
*/
require_once '../library/BarionClient.php';
$myPosKey = "11111111-1111-1111-1111-111111111111";
// <-- Replace this with your POSKey!
$paymentId = "22222222-2222-2222-2222-222222222222";
// <-- Replace this with the ID of the payment!
// Barion Client that connects to the TEST environment
$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test);
// create the refund transaction model
$trans = new TransactionToRefundModel();
$trans->TransactionId = "33333333-3333-3333-3333-333333333333";
// <-- Replace this with the original transaction ID!
$trans->POSTransactionId = "TRANS-04";
// <-- Replace this with the original POS transaction ID!
$trans->AmountToRefund = 100;
$trans->Comment = "Refund because of complaint";
// no more than 640 characters
$rr = new RefundRequestModel($paymentId);
$rr->AddTransaction($trans);
$refundResult = $BC->RefundPayment($rr);
if ($refundResult->RequestSuccessful) {
    // TODO: process the information contained in $refundResult
}
<?php

/*
*  Barion PHP library usage example
*  
*  Starting a reservation payment with two products
*  
*  � 2015 Barion Payment Inc.
*/
require_once '../library/BarionClient.php';
$myPosKey = "11111111-1111-1111-1111-111111111111";
// <-- Replace this with your POSKey!
$paymentId = "22222222-2222-2222-2222-222222222222";
// <-- Replace this with the ID of the payment!
// Barion Client that connects to the TEST environment
$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test);
// create the item models
$item1 = new ItemModel();
$item1->Name = "TestItem";
// no more than 250 characters
$item1->Description = "A test item for payment";
// no more than 500 characters
$item1->Quantity = 1;
$item1->Unit = "piece";
// no more than 50 characters
$item1->UnitPrice = 1000;
$item1->ItemTotal = 1000;
$item1->SKU = "ITEM-01";
// no more than 100 characters
$item2 = new ItemModel();
$item2->Name = "AnotherTestItem";
<?php

/*
*  Barion PHP library usage example
*  
*  Getting detailed information about a payment
*  
*  © 2015 Barion Payment Inc.
*/
require_once '../library/BarionClient.php';
$myPosKey = "11111111-1111-1111-1111-111111111111";
// <-- Replace this with your POSKey!
$paymentId = "22222222-2222-2222-2222-222222222222";
// <-- Replace this with the ID of the payment!
// Barion Client that connects to the TEST environment
$BC = new BarionClient($myPosKey, 2, BarionEnvironment::Test);
// send the request
$paymentDetails = $BC->GetPaymentState($paymentId);
// TODO: process the information contained in $paymentDetails