<?php

namespace App\Domain\PaymentGateway\Services;

use UnitPay;
use CashItem;

class UnitpayService
{
    public static function payments_link($amount, $order_id)
    {

        // Project Data
        $domain = 'unitpay.ru';// Your working domain: unitpay.ru or address provided by unitpay support service
        $secretKey  = '72449d551500fb99bb66499203ed1ccb';// Project secret key
        $publicId   = 'demo';
        // $publicId   = '438925-9eafe';

        // My item Info
        $itemName = 'Пополнение баланса';

        // My Order Data
        $orderId        =  $order_id;
        $orderSum       = $amount;
        $orderDesc      = 'Payment for item "' . $itemName . '"';
        $orderCurrency  = 'RUB';

        $unitpay = new UnitPay($domain, $secretKey);

        // ->setCustomerEmail('customer@domain.com')
        // ->setCustomerPhone('79001235555')


        $unitpay
        ->setBackUrl('https://teeaseer.com')
        ->setCashItems([
           new CashItem($itemName, 1, $orderSum)
        ]);

        $redirectUrl = $unitpay->form(
            $publicId,
            $orderSum,
            $orderId,
            $orderDesc,
            $orderCurrency
        );
        return $redirectUrl;


        // $configuration = new \Interkassa\Helper\Config();
        // $configuration->setCheckoutSecretKey(env('INTERKASSA_SECRET_KEY'));
        // $configuration->setAuthorizationKey(env('INTERKASSA_AUTH_KEY'));
        // $configuration->setAccountId(env('INTERKASSA_ACCOUNT_ID'));
        // $SDKClient = new \Interkassa\Interkassa($configuration);

        // $invoiceRequest = new \Interkassa\Request\GetInvoiceRequest();
        // $invoiceRequest
        //     ->setCheckoutId(env('INTERKASSA_ID'))
        //     ->setPaymentNumber($order_id)
        //     ->setAmount($amount)
        //     ->setCurrency('RUB')
        //     ->setDescription('Пополнение баланса');

        // return $SDKClient->makeInvoiceSciLink($invoiceRequest);
    }
}
