#Problem redirect to mollie checkout.

1 messages · Page 1 of 1 (latest)

warm hamlet
#

We are experiencing the following problem:

- create payment is ok
- webhook gets called (in this case only when the payment expires)
- The redirect to the Mollie checkout fails (CORS)
    in PHP: header("Location: " . $payment->getCheckoutUrl(), true, 303);
    
- The browser responds with:
        Access to XMLHttpRequest at 'https://www.mollie.com/checkout/select-method/HRSYvFuVBa' (redirected from 'https://bellohwriting.com/index7VWiw_75uQR.php') from origin 'https://bellohwriting.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
        GET https://www.mollie.com/checkout/select-method/HRSYvFuVBa net::ERR_FAILED

Can someone please help 🙂

chrome chasm
#

Hi there,

Welcome to the community!

Do you maybe have some code samples to indicate what you are doing?

warm hamlet
#

thx.. we are implementing the mollie checkout on our website. Backend is PHP.

#

relevant code is :

#

$payment = $mollie->payment($_POST);

            [$mollie->payment() doet het volgende:

                $this->mollie = new \Mollie\Api\MollieApiClient();
                $this->mollie->setApiKey(C::MOLLIE_API_KEY); // test API key

                $protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
                $hostname = $_SERVER['HTTP_HOST'];
                $path = str_replace('/bat', '', dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']));        
            
                $payment = $this->mollie->payments->create(array(
                    'amount' => array(
                        'currency' => 'EUR',
                        'value' => $amount
                    ),
                    'description' => 'Donatie Stichting Liberian In Action Nederland - Hartelijk Dank!',
                    'redirectUrl' => "{$protocol}://{$hostname}{$path}/php/return.php?order={$order_id}",
                    'webhookUrl' => "{$protocol}://{$hostname}{$path}/php/webhook.php"
                ));
                return $payment;
            ]

    if ($payment) {
        header("Location: " . $payment->getCheckoutUrl(), true, 303);
        exit;
        
    } else {
        logError('geen payment info');
    }
chrome chasm
#

When does this call get fired?

#

What triggers it?

warm hamlet
#

When placing the order on the website

chrome chasm
#

Yes, it seems you posting the data to the class via Javascript (XMLHttpRequest). Via that method, you can not redirect to us

#

Because with you current setup, you post the data also to us and that's blocked for security reasons

warm hamlet
#

thx. we think the problem is with existing javascript libaries on the site. Payment link did work with a blank php page form the domain.

#

yhx for the time we will investigate further. 🙏