首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >codeigniter mollie支付网关集成问题

codeigniter mollie支付网关集成问题
EN

Stack Overflow用户
提问于 2020-10-22 18:20:24
回答 1查看 277关注 0票数 0

我正在尝试应用莫莉支付网关在codeIgniter使用https://github.com/mollie/mollie-api-php的引用。但它在其中并不起作用。我已经在laravel中使用了这个库,它正在那里工作。当我尝试在codeIgniter中使用时,它直接将我重定向到redirectUrl,当我在mollie支付仪表板中签到时,没有付款。我不明白我做错了什么。有谁可以帮我?我已经在composer.json中使用了它,并更新了composer

"mollie/mollie-api-php": "^2.0"

在我的控制器文件中

代码语言:javascript
复制
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';
    }
}
EN

回答 1

Stack Overflow用户

发布于 2020-10-23 03:43:53

使用重定向将设置一个新的标头,并实际重定向用户。在您的示例中,您需要使用site_url。

所以你的代码应该是这样的:

代码语言:javascript
复制
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的资产上。

代码语言:javascript
复制
<img src="<?php echo base_url('foo/bar.jpg') ?>"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64480219

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档