<?php
namespace App\Http\Controllers\Web;
use Iyzipay\Options;
class IndexController extends Controller
{
.
.
.
public function iyzico(Request $request){
$name = $request->get('name');
$card_no = $request->get('card_no');
$expire_month = $request->get('expire_month');
$expire_year = $request->get('expire_year');
$cvc = $request->get('cvc');
$user = Auth::user();
//options
$options = new Options();
$options->setApiKey("***");
$options->setSecretKey("***");
$options->setBaseUrl("***");
}
.
.
.
}
I'm doing something like this on controller.But I get the error Class 'Iyzipay\Options' not found
. I checked the file path and it is correct. No matter what I did I couldn't fix the error
CodePudding user response:
If you want to use iyzipay package, you should add to your composer:
composer require iyzico/iyzipay-php
Edit For Manual Usage:
If you want to use manual you can create Library folder under app directory. And paste iyzipay folder here.
Then create a file such as Iyzipay.php in Library folder.
app
-Library
--iyzipay-php
--Iyzipay.php
And Iyzipay.php (i recommend, don't use transaction process in your controller
<?php
namespace App\Library;
require_once dirname ( __FILE__ ) . '/iyzipay-php/IyzipayBootstrap.php';
class Iyzipay
{
public static function boot ()
{
\IyzipayBootstrap::init ();
}
public static function pay ( $apiInfo, $cartInfo, $price, $shippingTaxPrice = 0 )
{
....
....
}
}
and use in your controller like this:
<?php
...
...
use App\Library\Iyzipay;
...
...
Iyzipay::boot ();
$payment = Iyzipay::pay ( $apiResources, $cartInfo, $price) );