PHP code example of avpet979 / payment-laravel

1. Go to this page and download the library: Download avpet979/payment-laravel 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/ */

    

avpet979 / payment-laravel example snippets




return [
    "api_key" => env('INVOICE_API_KEY',"Ваш API ключ"),
    "login" => env('INVOICE_LOGIN',"логин от личного кабинета Invoice"),
    "default_terminal_name" => env('INVOICE_TERMINAL_NAME',"Название терминала"),
    "terminal_id" => env('INVOICE_TERMINAL_ID', "terminal_id"),
];



class InvoiceController extends AbstractNotificationController {

        //orderID - ID заказа в вашей системе

        function onPay($orderId, $amount)
        {
             //При успешной оплате
        }
    
        function onFail($orderId)
        {
            //При неудачной оплате
        }
    
        function onRefund($orderId)
        {
            //При возврате средств
        }
}



use \invoice\payment\InvoicePaymentManager;

$invoice = new InvoicePaymentManager();

$items = [
    //Название, цена за 1шт, кол-во, итоговая цена
    new ITEM('Какой-то предмет', 110 , 2, 220)
];
//ID заказа, цена, товары
$payment = $invoice->createPayment('ID заказа в вашей системе', 220, $items);

echo($payment->payment_url);



$invoice = new InvoicePaymentManager();

$payment = $invoice->getPayment('ID заказа в вашей системе');

echo($payment->payment_url);



$invoice = new InvoicePaymentManager();

//ID заказа в вашей системе, сумма возврата, причина
$refundInfo = $invoice->createRefund('ID заказа в вашей системе', 10, 'Причина');