mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add CORS support for buy now buttons
This commit is contained in:
parent
f73959e6bc
commit
b6dab2bc13
@ -34,5 +34,6 @@ class Kernel extends HttpKernel
|
|||||||
'permissions.required' => 'App\Http\Middleware\PermissionsRequired',
|
'permissions.required' => 'App\Http\Middleware\PermissionsRequired',
|
||||||
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
|
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
|
||||||
'api' => 'App\Http\Middleware\ApiCheck',
|
'api' => 'App\Http\Middleware\ApiCheck',
|
||||||
|
'cors' => '\App\Http\Middleware\Cors',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
22
app/Http/Middleware/Cors.php
Normal file
22
app/Http/Middleware/Cors.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
|
||||||
|
class Cors
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
return $next($request)
|
||||||
|
->header('Access-Control-Allow-Origin', '*')
|
||||||
|
->header('Access-Control-Allow-Methods', 'GET, POST');
|
||||||
|
}
|
||||||
|
}
|
@ -71,7 +71,10 @@ Route::post('signup/submit', 'AccountController@submitSignup');
|
|||||||
|
|
||||||
Route::get('/auth/{provider}', 'Auth\AuthController@authLogin');
|
Route::get('/auth/{provider}', 'Auth\AuthController@authLogin');
|
||||||
Route::get('/auth_unlink', 'Auth\AuthController@authUnlink');
|
Route::get('/auth_unlink', 'Auth\AuthController@authUnlink');
|
||||||
Route::match(['GET', 'POST'], '/buy_now/{gateway_type?}', 'OnlinePaymentController@handleBuyNow');
|
|
||||||
|
Route::group(['middleware' => 'cors'], function () {
|
||||||
|
Route::match(['GET', 'POST'], '/buy_now/{gateway_type?}', 'OnlinePaymentController@handleBuyNow');
|
||||||
|
});
|
||||||
|
|
||||||
Route::post('/hook/email_bounced', 'AppController@emailBounced');
|
Route::post('/hook/email_bounced', 'AppController@emailBounced');
|
||||||
Route::post('/hook/email_opened', 'AppController@emailOpened');
|
Route::post('/hook/email_opened', 'AppController@emailOpened');
|
||||||
|
@ -85,6 +85,23 @@
|
|||||||
|
|
||||||
function buyProduct(affiliateKey, productId) {
|
function buyProduct(affiliateKey, productId) {
|
||||||
window.open('{{ Utils::isNinjaDev() ? '' : NINJA_APP_URL }}/buy_now/?account_key={{ NINJA_LICENSE_ACCOUNT_KEY }}&product_id=' + productId + '&contact_key={{ Auth::user()->primaryAccount()->account_key }}' + '&redirect_url=' + window.location);
|
window.open('{{ Utils::isNinjaDev() ? '' : NINJA_APP_URL }}/buy_now/?account_key={{ NINJA_LICENSE_ACCOUNT_KEY }}&product_id=' + productId + '&contact_key={{ Auth::user()->primaryAccount()->account_key }}' + '&redirect_url=' + window.location);
|
||||||
|
/*
|
||||||
|
var url = '{{ Utils::isNinjaDev() ? '' : NINJA_APP_URL }}/buy_now/';
|
||||||
|
var data = {
|
||||||
|
'account_key': '{{ NINJA_LICENSE_ACCOUNT_KEY }}',
|
||||||
|
'contact_key': '{{ Auth::user()->primaryAccount()->account_key }}',
|
||||||
|
'product_id': productId,
|
||||||
|
'redirect_url': window.location,
|
||||||
|
'first_name': '{{ Auth::user()->first_name }}',
|
||||||
|
'last_name': '{{ Auth::user()->last_name }}',
|
||||||
|
'email': '{{ Auth::user()->email }}',
|
||||||
|
};
|
||||||
|
$.post(url, function (data) {
|
||||||
|
var w = window.open();
|
||||||
|
w.document.write(data);
|
||||||
|
w.document.close();
|
||||||
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
function showApplyLicense() {
|
function showApplyLicense() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user