Fix white label purchases with PayPal

This commit is contained in:
Hillel Coren 2017-05-09 13:18:03 +03:00
parent a6c100eb47
commit 701f6c3851
4 changed files with 36 additions and 2 deletions

View File

@ -7,6 +7,7 @@ use App\Models\Country;
use App\Models\License;
use App\Ninja\Mailers\ContactMailer;
use App\Ninja\Repositories\AccountRepository;
use App\Libraries\CurlUtils;
use Auth;
use Cache;
use CreditCard;
@ -290,4 +291,31 @@ class NinjaController extends BaseController
return RESULT_SUCCESS;
}
public function purchaseWhiteLabel()
{
if (Utils::isNinja()) {
return redirect('/');
}
$user = Auth::user();
$url = NINJA_APP_URL . '/buy_now';
$contactKey = $user->primaryAccount()->account_key;
$data = [
'account_key' => NINJA_LICENSE_ACCOUNT_KEY,
'contact_key' => $contactKey,
'product_id' => PRODUCT_WHITE_LABEL,
'first_name' => Auth::user()->first_name,
'last_name' => Auth::user()->last_name,
'email' => Auth::user()->email,
'return_link' => true,
];
if ($url = CurlUtils::post($url, $data)) {
return redirect($url);
} else {
return redirect()->back()->withError(trans('texts.error_refresh_page'));
}
}
}

View File

@ -21,7 +21,7 @@ class VerifyCsrfToken extends BaseVerifier
'hook/email_bounced',
'reseller_stats',
'payment_hook/*',
'buy_now/*',
'buy_now*',
'hook/bot/*',
];

View File

@ -235,7 +235,9 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
Route::post('bluevine/signup', 'BlueVineController@signup');
Route::get('bluevine/hide_message', 'BlueVineController@hideMessage');
Route::get('bluevine/completed', 'BlueVineController@handleCompleted');
Route::get('white_label/hide_message', 'NinjaController@hideWhiteLabelMessage');
Route::get('white_label/purchase', 'NinjaController@purchaseWhiteLabel');
Route::get('reports', 'ReportController@showReports');
Route::post('reports', 'ReportController@showReports');

View File

@ -93,7 +93,11 @@
}
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.href);
location.href = "{{ url('white_label/purchase') }}";
//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.href);
/*
var url = '{{ Utils::isNinjaDev() ? '' : NINJA_APP_URL }}/buy_now/';
$.ajax({