否';访问控制允许原点';标题出现在请求的资源上-Mollie payment ajax
我正在尝试使用以下两个库创建mollie付款:否';访问控制允许原点';标题出现在请求的资源上-Mollie payment ajax,ajax,laravel,cross-domain,omnipay,mollie,Ajax,Laravel,Cross Domain,Omnipay,Mollie,我正在尝试使用以下两个库创建mollie付款: 当客户端填写表单并提交ajax请求时,将向my laravel应用程序中的函数发出请求 在我的Laravel函数中,我尝试执行以下操作: $gateway = Omnipay\Omnipay::create('Mollie'); $gateway->setApiKey('test_gSDS4xNA96AfNmmdwB3fAA47zS84KN'); $params = [ 'amount' => $ticket_ord
$gateway = Omnipay\Omnipay::create('Mollie');
$gateway->setApiKey('test_gSDS4xNA96AfNmmdwB3fAA47zS84KN');
$params = [
'amount' => $ticket_order['order_total'] + $ticket_order['organiser_booking_fee'],
'description' => 'Kapelhoek wijkfeesten',
'returnUrl' => URL::action('EventCheckoutController@fallback'),
];
$response = $gateway->purchase($params)->send();
if ($response->isSuccessful()) {
// payment was successful: update database
print_r($response); die;
} elseif ($response->isRedirect()) {
// redirect to offsite payment gateway
return $response->getRedirectResponse(); die;
} else {
// payment failed: display message to customer
echo $response->getMessage(); die;
}
但我得到的回应是:
无法加载XMLHttpRequest。请求的资源上不存在“Access Control Allow Origin”标头。因此,不允许访问源“”
如何解决此问题?我认为问题在于Api仪表板。在发出POST请求之前,您必须将域列入白名单。行
return$response->getRedirectResponse()
正在重定向到消费者应该发送到的支付URL。但是,AJAX调用中不允许此重定向
相反,您的脚本应该使用
$response->getRedirectUrl()
打印此支付URL,您的网页应该使用javascript重定向消费者。如果您从其他域请求API,您必须实现CORS-我更喜欢此包