PHP code example of markupagency / kapitalbank-api

1. Go to this page and download the library: Download markupagency/kapitalbank-api 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/ */

    

markupagency / kapitalbank-api example snippets


namespace App\Http\Controllers;

use KapitalBankAPI\Services\PaymentService;

class PaymentController extends Controller
{
    protected $paymentService;

    public function __construct(PaymentService $paymentService)
    {
        $this->paymentService = $paymentService;
    }

    public function createOrder()
    {
        $amount = request('amount');
        $description = request('description');
        $response = $this->paymentService->createOrder($amount, $description);
        return response()->json($response->json());
    }

    public function refund()
    {
        $amount = request('amount');
        $response = $this->paymentService->refund($amount);
        return response()->json($response->json());
    }

    public function reverse()
    {
        $response = $this->paymentService->reverse();
        return response()->json($response->json());
    }

    public function installment()
    {
        $amount = request('amount');
        $description = request('description');
        $response = $this->paymentService->installment($amount, $description);
        return response()->json($response->json());
    }

    public function saveCard()
    {
        $amount = request('amount');
        $description = request('description');
        $response = $this->paymentService->saveCard($amount, $description);
        return response()->json($response->json());
    }
}
bash
php artisan vendor:publish --provider="KapitalBankAPI\Providers\PaymentServiceProvider"