üstad cevabın için teşekkür ederim. Tüm gün uğraştım sanırım kafam durmuştu. senin de dediğin gibi dönen cevabı yakaladıktan sonra if ile hallettim. Callback sayfasında yakalamayı başardım geri dönüşleri. kodları buraya bırakıyorum. Belki birisinin işine yarayabilir.
public function index(){
$data = request()->only('setPaidPrice','setId','setName','setSurname','setGsmNumber','setEmail','setRegistrationDate','setRegistrationAddress','setCity','setCountry','setZipCode','setIdentityNumber');
$clientIP = \Request::getClientIp(true);
$string = str_random(15);
$options = new Options();
$options->setApiKey('sandbox-******');
$options->setSecretKey('sandbox-*******');
$options->setBaseUrl('https://sandbox-api.iyzipay.com');
$request = new CreateCheckoutFormInitializeRequest();
$request->setLocale(Locale::TR);
$request->setConversationId($string);
$request->setPrice("1");
$request->setPaidPrice($data['setPaidPrice']);
$request->setCurrency(Currency::TL);
$request->setBasketId($data['setPaidPrice']);
$request->setPaymentGroup(PaymentGroup::PRODUCT);
$request->setCallbackUrl("http://***.test/admin/callback");
$request->setEnabledInstallments(array(1));
$buyer = new Buyer();
$buyer->setId($data['setId']);
$buyer->setName($data['setName']);
$buyer->setSurname($data['setSurname']);
$buyer->setGsmNumber($data['setGsmNumber']);
$buyer->setEmail($data['setEmail']);
$buyer->setIdentityNumber($data['setIdentityNumber']);
$buyer->setLastLoginDate("2015-10-05 12:43:35");
$buyer->setRegistrationDate($data['setRegistrationDate']);
$buyer->setRegistrationAddress($data['setRegistrationAddress']);
$buyer->setIp($clientIP);
$buyer->setCity($data['setCity']);
$buyer->setCountry($data['setCountry']);
$buyer->setZipCode($data['setZipCode']);
$request->setBuyer($buyer);
$shippingAddress = new Address();
$shippingAddress->setContactName($data['setName'].' '.$data['setSurname']);
$shippingAddress->setCity($data['setCity']);
$shippingAddress->setCountry($data['setCountry']);
$shippingAddress->setAddress($data['setRegistrationAddress']);
$shippingAddress->setZipCode($data['setZipCode']);
$request->setShippingAddress($shippingAddress);
$billingAddress = new Address();
$billingAddress->setContactName($data['setName'].' '.$data['setSurname']);
$billingAddress->setCity($data['setCity']);
$billingAddress->setCountry($data['setCountry']);
$billingAddress->setAddress($data['setRegistrationAddress']);
$billingAddress->setZipCode($data['setZipCode']);
$request->setBillingAddress($billingAddress);
$basketItems = array();
$firstBasketItem = new BasketItem();
$firstBasketItem->setId($data['setId']);
$firstBasketItem->setName("***.com Kredi İşlemi");
$firstBasketItem->setCategory1("***.com Kredi İşlemi");
$firstBasketItem->setCategory2("***.com Kredi İşlemi");
$firstBasketItem->setItemType(BasketItemType::PHYSICAL);
$firstBasketItem->setPrice("0.3");
$basketItems[0] = $firstBasketItem;
$secondBasketItem = new BasketItem();
$secondBasketItem->setId($data['setId']);
$secondBasketItem->setName("***.com Kredi İşlemi");
$secondBasketItem->setCategory1("***.com Kredi İşlemi");
$secondBasketItem->setCategory2("***.com Kredi İşlemi");
$secondBasketItem->setItemType(BasketItemType::VIRTUAL);
$secondBasketItem->setPrice("0.5");
$basketItems[1] = $secondBasketItem;
$thirdBasketItem = new BasketItem();
$thirdBasketItem->setId($data['setId']);
$thirdBasketItem->setName("***.com Kredi İşlemi");
$thirdBasketItem->setCategory1("***.com Kredi İşlemi");
$thirdBasketItem->setCategory2("***.com Kredi İşlemi");
$thirdBasketItem->setItemType(BasketItemType::PHYSICAL);
$thirdBasketItem->setPrice("0.2");
$basketItems[2] = $thirdBasketItem;
$request->setBasketItems($basketItems);
$checkoutFormInitialize = CheckoutFormInitialize::create($request, $options);
print_r($checkoutFormInitialize->getErrorMessage());
print_r($checkoutFormInitialize->getCheckoutFormContent());
}
public function callback()
{
$options = new Options();
$options->setApiKey('sandbox-*****');
$options->setSecretKey('sandbox-******');
$options->setBaseUrl('https://sandbox-api.iyzipay.com');
$token=$_POST['token'];
$request = new \Iyzipay\Request\RetrieveCheckoutFormRequest();
$request->setLocale(\Iyzipay\Model\Locale::TR);
$request->setConversationId("123456789");
$request->setToken("$token");
$checkoutForm = \Iyzipay\Model\CheckoutForm::retrieve($request, $options);
echo $odeme_durum= $checkoutForm->getPaymentStatus();
echo "<br>";
$islem_no= $checkoutForm->getPaymentId();
$price= $checkoutForm->getPaidPrice();
if ($odeme_durum == "FAILURE"){
echo "Başarısız Ödeme. 5 saniye sonra anasayfaya yönlendirileceksiniz";
} elseif (($odeme_durum == "SUCCESS"))
{
echo "Başarılı Ödeme ".$islem_no;
echo "<br>";
echo "5 saniye sonra anasayfaya yönlendirileceksiniz";
$user = User::where('id', auth()->user()->id)->firstOrFail();
$array = [
'userCredit' => $user->userCredit + $price,
];
$entry = User::where('id', $user->id)->update($array);
return view('admin.callback')->with('message','Successful')
->with('message_type', 'success');;
}
}
}