codeigniter莫利支付网关集成问题

7gs2gvoe  于 2022-12-07  发布在  其他
关注(0)|答案(2)|浏览(155)

我尝试使用https://github.com/mollie/mollie-api-php的ref在codeIgniter中应用mollie支付网关。但它不在其中工作。我已经在laravel中使用了这个库,它在那里工作。当我尝试在codeIgniter中使用时,它直接将我重定向到redirectUrl,当我在mollie支付 Jmeter 板中检查时,没有付款。我不明白我做错了什么。有人能帮助我吗?我已经在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';
    }
}
jgovgodb

jgovgodb1#

使用重定向将设置一个新的头并实际重定向用户。在您的情况下,您需要使用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。
网站url也会将index.php添加到你的url中,以防你使用它。如果你的url中没有index.php,你不必担心它也会起作用。
基础url应该用在你不想让index.php出现的资产上。

<img src="<?php echo base_url('foo/bar.jpg') ?>"
pgvzfuti

pgvzfuti2#

这可能对你有帮助
https://github.com/mollie/mollie-api-php
$payment-〉getCheckoutUrl()对象返回到您结帐URL,您需要重定向此URL

相关问题