Selamlar,
Laravel ile iyzico entegrasyonu yaparken garip bir şekilde ödeme formundan sonra success sayfası 404 olarak geliyor. Benim Local'de çalışıyor ancak sunucuya deploy edip test ettiğimde bu 404 hatasını alıyorum.
Sebebi sizce nedir?
CheckoutController.php
public function creditCardProcess($request)
{
$customer = $this->customerProcess($request);
$address = $customer->addresses()->first();
$request->session()->put(['customer' => $customer, 'address' => $address]);
$products = $this->cartRepo->getCartItems();
$options = new \Iyzipay\Options();
$options->setApiKey(env('IYZICO_API_KEY'));
$options->setSecretKey(env('IYZICO_SECRET_KEY'));
$options->setBaseUrl(env('IYZICO_API_URL'));
$iyzicoReq = new \Iyzipay\Request\CreateCheckoutFormInitializeRequest();
if(app()->getLocale() === "tr") {
$iyzicoReq->setLocale(\Iyzipay\Model\Locale::TR);
} else {
$iyzicoReq->setLocale(\Iyzipay\Model\Locale::EN);
}
$iyzicoReq->setConversationId("123456789");
$iyzicoReq->setPrice(__exchange($this->cartRepo->getSubTotal()));
$iyzicoReq->setPaidPrice(__exchange($this->cartRepo->getTotal()));
if(session()->has('currency')) {
if(session()->get('currency') === "TRY") {
$iyzicoReq->setCurrency(\Iyzipay\Model\Currency::TL);
} elseif(session()->get('currency') === "USD") {
$iyzicoReq->setCurrency(\Iyzipay\Model\Currency::USD);
} else {
$iyzicoReq->setCurrency(\Iyzipay\Model\Currency::EUR);
}
}else {
$iyzicoReq->setCurrency(\Iyzipay\Model\Currency::EUR);
}
$iyzicoReq->setBasketId(Uuid::uuid4()->toString());
$iyzicoReq->setPaymentGroup(\Iyzipay\Model\PaymentGroup::PRODUCT);
$iyzicoReq->setCallbackUrl(route('checkout.success'));
$buyer = new \Iyzipay\Model\Buyer();
$buyer->setId($customer->id);
$buyer->setName($customer->first_name);
$buyer->setSurname($customer->last_name);
$buyer->setGsmNumber($customer->phone);
$buyer->setEmail($customer->email);
$buyer->setIdentityNumber($customer->identity_number ?? "11111111111");
$buyer->setRegistrationAddress($address->address_1);
$buyer->setIp($request->ip());
$buyer->setCity($address->city);
$buyer->setCountry($address->country);
$buyer->setZipCode($address->zip);
$iyzicoReq->setBuyer($buyer);
$shippingAddress = new \Iyzipay\Model\Address();
$shippingAddress->setContactName($customer->fullName());
$shippingAddress->setCity($address->city);
$shippingAddress->setCountry($address->country);
$shippingAddress->setAddress($address->address_1);
$shippingAddress->setZipCode($address->zip);
$iyzicoReq->setShippingAddress($shippingAddress);
$billingAddress = new \Iyzipay\Model\Address();
$billingAddress->setContactName($customer->fullName());
$billingAddress->setCity($address->city);
$billingAddress->setCountry($address->country);
$billingAddress->setAddress($address->address_1);
$billingAddress->setZipCode($address->zip);
$iyzicoReq->setBillingAddress($billingAddress);
$piece = 0;
$total = 0;
foreach ($products as $product) {
$BasketItem = new \Iyzipay\Model\BasketItem();
$BasketItem->setId($product->id);
$BasketItem->setName($product->name);
$BasketItem->setCategory1("Product");
$BasketItem->setItemType(\Iyzipay\Model\BasketItemType::PHYSICAL);
$BasketItem->setPrice($product->price);
$basketItems[$piece] = $BasketItem;
$piece++;
$total += $product->price;
}
$iyzicoReq->setBasketItems($basketItems);
$checkoutFormInitialize = \Iyzipay\Model\CheckoutFormInitialize::create($iyzicoReq, $options);
$paymentinput = $checkoutFormInitialize->getCheckoutFormContent();
return view('front.payments.iyzico', compact('paymentinput'));
}
Bu fonksiyonda aynı controller içinde success route'una iyzico'dan gelen post isteğini karşılıyor;
public function success(Request $request)
{
$customer = $request->session()->get('customer');
$address = $request->session()->get('address');
$order = $this->createOrder($customer, $address, 'credit_card');
return view('front.checkout-success', compact('order'));
}
routes/web.php
Route::prefix('checkout')->group(function() {
Route::get('/', 'CheckoutController@index')->name('checkout.index');
Route::post('/', 'CheckoutController@store')->name('checkout.store');
Route::any('/success', 'CheckoutController@success')->name('checkout.success');
Route::get('/success/{reference}', 'CheckoutController@orderSuccess')->name('checkout.success.bank.transfer');
Route::get('/cancel', 'CheckoutController@cancel')->name('checkout.cancel');
});