如何解决codeigniter mollie付款网关集成问题
我正在尝试使用https://github.com/mollie/mollie-api-php的引用在codeIgniter中应用mollie付款网关。但是它没有用。我已经在laravel中使用了这个库。当我尝试在codeIgniter中使用时,它直接将我重定向到redirectUrl,并且当我签入mollie付款仪表板时,没有付款。我不明白我在做什么错。谁能帮我? 我在composer.json中使用了它并更新了composer
"mollie/mollie-api-PHP": "^2.0"
在我的控制器文件中,
class Mollie_test extends CI_Controller {
public function make_payment()
{
$mollie = new \Mollie\Api\Mollieapiclient();
$mollie->setApiKey("test_key");
$payment = $mollie->payments->create([
'amount' => [
'currency' => 'EUR','value' => '10.00'
],'description' => 'tesst','redirectUrl' => redirect('mollie_test/success')
]);
}
public function success()
{
echo 'payment process completed';
}
}
解决方法
使用重定向将设置新的标头并实际重定向用户。您需要使用site_url。
因此您的代码应类似于:
class Mollie_test extends CI_Controller {
public function make_payment()
{
$mollie = new \Mollie\Api\MollieApiClient();
$mollie->setApiKey("test_key");
$payment = $mollie->payments->create([
'amount' => [
'currency' => 'EUR','value' => '10.00'
],'description' => 'tesst','redirectUrl' => site_url('mollie_test/success')
]);
}
public function success()
{
echo 'payment process completed';
}
}
许多人将site_url与base_url混淆了,在这种情况下不应该使用base_url。
如果您正在使用网站网址,它也会将index.php添加到您的网址中。如果您的网址中没有index.php,则不必担心也会起作用。
应该在不希望使用index.php的资产上使用基本url。
<img src="<?php echo base_url('foo/bar.jpg') ?>"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。