1. Go to this page and download the library: Download andreighioc/btipay library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andreighioc / btipay example snippets
->withRouting(
web: __DIR__.'/../routes/web.php',
then: function () {
use BtiPay\Laravel\Facades\BtiPay;
use BtiPay\Laravel\Builders\OrderBundle;
// Build orderBundle
$bundle = OrderBundle::make()
->orderCreationDate(now()->format('Y-m-d'))
->email('[email protected]')
->phone('40740123456')
->deliveryInfo('delivery', '642', 'Cluj-Napoca', 'Str. Example 10', '400000')
->billingInfo('642', 'Cluj-Napoca', 'Str. Example 10', '400000');
// Register order
$response = BtiPay::register([
'orderNumber' => 'ORD-' . time(),
'amount' => 1500, // 15.00 RON (in minor units / bani)
'currency' => 946,
'returnUrl' => route('BtiPay.finish'),
'description' => 'Order #123',
'email' => '[email protected]',
'orderBundle' => $bundle->toArray(),
]);
if ($response->isSuccessful()) {
// Redirect to the BT payment page
return redirect($response->getFormUrl());
} else {
// Registration error
echo $response->getErrorMessage();
}
$status = BtiPay::getOrderStatus(orderId: $request->get('orderId'));
if ($status->isPaid()) {
// Payment successful - card, amount, RRN available
$status->getMaskedPan();
$status->getAmountFormatted();
$status->getAuthRefNum();
}
if ($status->isDeclined()) {
$status->getActionCodeMessage(); // message in the configured language
}
use BtiPay\Laravel\Traits\HasBtiPayPayments;
class Order extends Model
{
use HasBtiPayPayments;
}
// Usage
$order = Order::find(1);
$order->BtiPayTransactions; // All transactions
$order->latestBtiPayTransaction; // Latest transaction
$order->isPaidViaBtiPay(); // Is it paid?
$order->getTotalPaidViaBtiPay(); // Total paid (in minor units)
$order->getTotalRefundedViaBtiPay(); // Total refunded
// Deposit with loyalty
$response = BtiPay::deposit(
orderId: 'uuid-ron-order-id',
amount: 3000, // Total amount RON + LOY
depositLoyalty: true
);
// Refund with loyalty
$response = BtiPay::refund(
orderId: 'uuid-ron-order-id',
amount: 4000,
refundLoyalty: true
);
// Reverse with loyalty
$response = BtiPay::reverse(
orderId: 'uuid-ron-order-id',
reverseLoyalty: true
);