我正在尝试应用莫莉支付网关在codeIgniter使用https://github.com/mollie/mollie-api-php的引用。但它在其中并不起作用。我已经在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';
}
}发布于 2020-10-23 03:43:53
使用重定向将设置一个新的标头,并实际重定向用户。在您的示例中,您需要使用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。
Site url还会将index.php添加到您的url中,以防您正在使用它。如果你的url中没有index.php,你也不用担心这也会起作用。
基本url应该用在你永远不想要index.php的资产上。
<img src="<?php echo base_url('foo/bar.jpg') ?>"https://stackoverflow.com/questions/64480219
复制相似问题