PHP code example of eren-seyfi / php-iyzico

1. Go to this page and download the library: Download eren-seyfi/php-iyzico 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/ */

    

eren-seyfi / php-iyzico example snippets




use Eren\PhpIyzico\Config;
use Eren\PhpIyzico\Iyzico;

// 1) Temel yapılandırma
$cfg = new Config(
  apiKey: 'sandbox-xxxxx',
  secretKey: 'sandbox-xxxxx',
  baseUrl: 'https://sandbox-api.iyzipay.com',
  locale: \Iyzipay\Model\Locale::TR,
  conversationId: 'order-123' // benzersiz üret
);

// 2) Facade üzerinden servisler
$iyz = new Iyzico($cfg);

// Örnek: Non-3D ödeme
$payment = $iyz->non3ds()->pay(
  order: ['price'=>'1.00','paidPrice'=>'1.20','basketId'=>'B67832'],
  card: (new \Iyzipay\Model\PaymentCard())
          ->setCardHolderName('John Doe')
          ->setCardNumber('5528790000000008')
          ->setExpireMonth('12')
          ->setExpireYear('2030')
          ->setCvc('123'),
  buyer: $buyerArray,
  shipAddress: $shipAddressArray,
  billAddress: $billingAddressArray,
  basketItems: $basketItemsArray
);

$ok = \Eren\PhpIyzico\Security\Signature::verifyPayment(
  $payment,
  \Eren\PhpIyzico\OptionsFactory::create($cfg)
);

$resp = $iyz->non3ds()->payAndVerify($order, $card, $buyer, $ship, $bill, $basketItems);
if (!$resp['verified']) { /* alarm/log */ }

$init = $iyz->checkout()->initialize(
  $order, $buyer, $ship, $bill, $basketItems, 'https://merchant/cb'
);
$valid = $iyz->checkout()->verifyInitializeSignature($init);

$result = $iyz->checkout()->retrieve($_POST['token'] ?? '');
list('verified'=>$ok) = $iyz->checkout()->retrieveAndVerify($_POST['token'] ?? '');
bash
composer