php - laravel 8中的iyzico付款方式失败
问题描述
我已经通过 Composer 安装了 Iyzico 付款方式,并按照文档中的每个步骤进行操作,但我正在尝试加载 Iyzico 付款的默认形式,但是当我重新加载页面时,它显示失败状态只是显示
奥德梅赛法
和失败所以我该怎么做这是我在控制器中的代码
public function payment()
{
$iyzico = new Iyzico();
$payment = $iyzico->setForm([
'conversationID' => '123456789',
'price' => '120.0',
])
->paymentForm();
$paymentContent = $payment->getCheckoutFormContent();
$paymentStatus = $payment->getStatus();
return view(
'iyzico',
compact('paymentContent', 'paymentStatus')
);
}
这是 iyzico 类代码
<?php
namespace App\Libraries;
use PhpParser\Node\Expr\Cast\Array_;
class Iyzico
{
protected $options;
protected $request;
protected $basketItems;
public function __construct()
{
$this->options = new \Iyzipay\Options();
$this->options->setApiKey("your api key");
$this->options->setSecretKey("your secret key");
$this->options->setBaseUrl("https://sandbox-api.iyzipay.com");
$this->basketItems = [];
}
public function setForm(array $params)
{
$this->request = new \Iyzipay\Request\CreateCheckoutFormInitializeRequest();
$this->request->setLocale(\Iyzipay\Model\Locale::TR);
$this->request->setConversationId($params['conversationID']);
$this->request->setPrice($params['price']);
return $this;
}
public function setBuyer(array $params)
{
$buyer = new \Iyzipay\Model\Buyer();
$buyer->setId($params['id']);
$buyer->setName($params['name']);
return $this;
}
public function setShipping(array $params)
{
$shippingAddress = new \Iyzipay\Model\Address();
$shippingAddress->setContactName($params['name']);
$this->request->setShippingAddress($shippingAddress);
return $this;
}
public function setBilling(array $params)
{
$billingAddress = new \Iyzipay\Model\Address();
$billingAddress->setContactName($params['name']);
$this->request->setBillingAddress($billingAddress);
return $this;
}
public function setItem(array $items)
{
foreach ($items as $key => $value) {
$basketItem = new \Iyzipay\Model\BasketItem();
$basketItem->setId($value['id']);
$basketItem->setName($value['name']);
array_push($this->basketItems, $basketItem);
}
$this->request->setBasketItems($this->basketItems);
return $this;
}
public function paymentForm()
{
$form = \Iyzipay\Model\CheckoutFormInitialize::create($this->request, $this->options);
return $form;
}
}
这是我的 iyzico.blade.php 页面
<article>
<h1>odeme sayfa</h1>
<div>
{{ $paymentContent }}
{{ $paymentStatus }}
<div id="iyzipay-checkout-form" class="responsive"></div>
</div>
</article>
解决方案
推荐阅读
- python - 使用 python pip 分发可执行文件
- javascript - Javascript - 语法错误:属性列表后缺少 }
- grails3 - 使用 grails3 的 ehcache3 插件的有效 ehcache.xml
- wordpress - 视频飞溅未在移动设备上显示
- r - 将multind与bookdown一起使用?
- postgresql - 如何在 PostgreSQL 上使用模式指定数据库参数的大小?
- python-3.x - Tkinter:使用新背景颜色更新标签(Python 3.5.3)
- macos - 黄瓜:找不到命令(在 Mac OS 中)
- mysql - 我想要一个 sql 查询从聊天中选择唯一结果,其中 senderid=3 或 receiverid=3 order by I'd desc limit 0,10
- c# - 在 .Net Core 控制台应用程序中找不到依赖项 - 启动时显示为缺失