mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 15:44:33 -04:00
Fixes for hosted auto forwarding
This commit is contained in:
parent
d73e56cbb6
commit
53c8f8d6e0
@ -89,14 +89,6 @@ class StepsController extends BaseController
|
|||||||
url('/migration/companies?hosted=true')
|
url('/migration/companies?hosted=true')
|
||||||
);
|
);
|
||||||
|
|
||||||
//old
|
|
||||||
// return redirect(
|
|
||||||
// url('/migration/auth')
|
|
||||||
// );
|
|
||||||
|
|
||||||
// return redirect(
|
|
||||||
// url('/migration/endpoint')
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(
|
return redirect(
|
||||||
@ -153,6 +145,7 @@ class StepsController extends BaseController
|
|||||||
{
|
{
|
||||||
|
|
||||||
$url = 'https://invoicing.co/api/v1/confirm_forwarding';
|
$url = 'https://invoicing.co/api/v1/confirm_forwarding';
|
||||||
|
// $url = 'http://devhosted.test:8000/api/v1/confirm_forwarding';
|
||||||
|
|
||||||
$headers = [
|
$headers = [
|
||||||
'X-API-HOSTED-SECRET' => config('ninja.ninja_hosted_secret'),
|
'X-API-HOSTED-SECRET' => config('ninja.ninja_hosted_secret'),
|
||||||
@ -197,6 +190,7 @@ class StepsController extends BaseController
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if($response->getStatusCode() == 401){
|
if($response->getStatusCode() == 401){
|
||||||
|
info("autoForwardUrl");
|
||||||
info($response->getBody());
|
info($response->getBody());
|
||||||
|
|
||||||
} elseif ($response->getStatusCode() == 200) {
|
} elseif ($response->getStatusCode() == 200) {
|
||||||
@ -217,10 +211,21 @@ class StepsController extends BaseController
|
|||||||
$account_settings->forward_url_for_v5 = rtrim($forwarding_url,'/');
|
$account_settings->forward_url_for_v5 = rtrim($forwarding_url,'/');
|
||||||
$account_settings->save();
|
$account_settings->save();
|
||||||
|
|
||||||
|
$billing_transferred = $message_body['billing_transferred'];
|
||||||
|
|
||||||
|
if($billing_transferred == 'true'){
|
||||||
|
|
||||||
|
$company = $account->company;
|
||||||
|
$company->plan = null;
|
||||||
|
$company->plan_expires = null;
|
||||||
|
$company->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
info("failed to autoforward");
|
||||||
info(json_decode($response->getBody()->getContents()));
|
info(json_decode($response->getBody()->getContents()));
|
||||||
|
// dd('else');
|
||||||
}
|
}
|
||||||
|
|
||||||
return back();
|
return back();
|
||||||
@ -336,7 +341,6 @@ class StepsController extends BaseController
|
|||||||
try {
|
try {
|
||||||
$migrationData = $this->generateMigrationData($request->all());
|
$migrationData = $this->generateMigrationData($request->all());
|
||||||
|
|
||||||
|
|
||||||
$completeService->data($migrationData)
|
$completeService->data($migrationData)
|
||||||
->endpoint(session('MIGRATION_ENDPOINT'))
|
->endpoint(session('MIGRATION_ENDPOINT'))
|
||||||
->start();
|
->start();
|
||||||
@ -436,8 +440,6 @@ class StepsController extends BaseController
|
|||||||
Storage::makeDirectory('migrations');
|
Storage::makeDirectory('migrations');
|
||||||
$file = Storage::path("migrations/{$fileName}.zip");
|
$file = Storage::path("migrations/{$fileName}.zip");
|
||||||
|
|
||||||
//$file = storage_path("migrations/{$fileName}.zip");
|
|
||||||
|
|
||||||
ksort($localMigrationData);
|
ksort($localMigrationData);
|
||||||
|
|
||||||
$zip = new \ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
|
@ -54,15 +54,15 @@ class HostedMigration extends Job
|
|||||||
|
|
||||||
$completeService->data($migrationData)
|
$completeService->data($migrationData)
|
||||||
->endpoint('https://v5-app1.invoicing.co')
|
->endpoint('https://v5-app1.invoicing.co')
|
||||||
// ->endpoint('http://ninja.test:8000')
|
// ->endpoint('http://devhosted.test:8000')
|
||||||
->start();
|
->start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getToken()
|
private function getToken()
|
||||||
{
|
{
|
||||||
$url = 'https://invoicing.co/api/v1/get_migration_account';
|
//$url = 'https://invoicing.co/api/v1/get_migration_account';
|
||||||
// $url = 'http://ninja.test:8000/api/v1/get_migration_account';
|
$url = 'http://devhosted.test:8000/api/v1/get_migration_account';
|
||||||
|
|
||||||
$headers = [
|
$headers = [
|
||||||
'X-API-HOSTED-SECRET' => $this->v4_secret,
|
'X-API-HOSTED-SECRET' => $this->v4_secret,
|
||||||
@ -98,27 +98,10 @@ class HostedMigration extends Job
|
|||||||
$this->migration_token = $message_body['token'];
|
$this->migration_token = $message_body['token'];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
info(json_decode($response->getBody()->getContents()));
|
// info(json_decode($response->getBody()->getContents()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// $body = \Unirest\Request\Body::json($body);
|
|
||||||
|
|
||||||
// $response = Request::post($url, $headers, $body);
|
|
||||||
|
|
||||||
// if (in_array($response->code, [200])) {
|
|
||||||
|
|
||||||
// $data = $response->body;
|
|
||||||
// info(print_r($data,1));
|
|
||||||
// $this->migration_token = $data->token;
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
// info("getting token failed");
|
|
||||||
// info($response->raw_body);
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,12 +75,11 @@ class CompleteService
|
|||||||
'headers' => $this->getHeaders(),
|
'headers' => $this->getHeaders(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$payload_data = [
|
$payload_data = [
|
||||||
'multipart'=> array_merge($files, $payload),
|
'multipart'=> array_merge($files, $payload),
|
||||||
];
|
];
|
||||||
|
|
||||||
info(print_r($payload_data,1));
|
// info(print_r($payload_data,1));
|
||||||
$response = $client->request("POST", $this->getUrl(),$payload_data);
|
$response = $client->request("POST", $this->getUrl(),$payload_data);
|
||||||
|
|
||||||
if($response->getStatusCode() == 200){
|
if($response->getStatusCode() == 200){
|
||||||
@ -88,7 +87,7 @@ class CompleteService
|
|||||||
$this->isSuccessful = true;
|
$this->isSuccessful = true;
|
||||||
return json_decode($response->getBody(),true);
|
return json_decode($response->getBody(),true);
|
||||||
}else {
|
}else {
|
||||||
info($response->raw_body);
|
// info($response->raw_body);
|
||||||
|
|
||||||
$this->isSuccessful = false;
|
$this->isSuccessful = false;
|
||||||
$this->errors = [
|
$this->errors = [
|
||||||
@ -98,25 +97,6 @@ class CompleteService
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// $body = \Unirest\Request\Body::multipart(['companies' => json_encode($data)], $files);
|
|
||||||
|
|
||||||
// $response = Request::post($this->getUrl(), $this->getHeaders(), $body);
|
|
||||||
|
|
||||||
// if (in_array($response->code, [200])) {
|
|
||||||
// $this->isSuccessful = true;
|
|
||||||
// } else {
|
|
||||||
// info($response->raw_body);
|
|
||||||
|
|
||||||
// $this->isSuccessful = false;
|
|
||||||
// $this->errors = [
|
|
||||||
// 'Oops, something went wrong. Migration can\'t be processed at the moment. Please checks the logs.',
|
|
||||||
// ];
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSuccessful()
|
public function isSuccessful()
|
||||||
|
@ -1543,7 +1543,7 @@ trait GenerateMigrationResources
|
|||||||
}
|
}
|
||||||
catch(\Exception $e){
|
catch(\Exception $e){
|
||||||
|
|
||||||
info($config);
|
// info($config);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user