mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Fixes for tests
This commit is contained in:
parent
e9d9b8a137
commit
a30941bdb8
@ -24,8 +24,6 @@ class ApplePayDomainController extends Controller
|
|||||||
|
|
||||||
private array $stripe_keys = ['d14dd26a47cecc30fdd65700bfb67b34', 'd14dd26a37cecc30fdd65700bfb55b23'];
|
private array $stripe_keys = ['d14dd26a47cecc30fdd65700bfb67b34', 'd14dd26a37cecc30fdd65700bfb55b23'];
|
||||||
|
|
||||||
private ?Company $company = null;
|
|
||||||
|
|
||||||
public function showAppleMerchantId(Request $request)
|
public function showAppleMerchantId(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ use App\Http\Requests\CompanyGateway\EditCompanyGatewayRequest;
|
|||||||
use App\Http\Requests\CompanyGateway\ShowCompanyGatewayRequest;
|
use App\Http\Requests\CompanyGateway\ShowCompanyGatewayRequest;
|
||||||
use App\Http\Requests\CompanyGateway\StoreCompanyGatewayRequest;
|
use App\Http\Requests\CompanyGateway\StoreCompanyGatewayRequest;
|
||||||
use App\Http\Requests\CompanyGateway\UpdateCompanyGatewayRequest;
|
use App\Http\Requests\CompanyGateway\UpdateCompanyGatewayRequest;
|
||||||
|
use App\Jobs\Util\ApplePayDomain;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\CompanyGateway;
|
use App\Models\CompanyGateway;
|
||||||
use App\Repositories\CompanyRepository;
|
use App\Repositories\CompanyRepository;
|
||||||
@ -45,6 +46,9 @@ class CompanyGatewayController extends BaseController
|
|||||||
|
|
||||||
public $forced_includes = [];
|
public $forced_includes = [];
|
||||||
|
|
||||||
|
private array $stripe_keys = ['d14dd26a47cecc30fdd65700bfb67b34', 'd14dd26a37cecc30fdd65700bfb55b23'];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CompanyGatewayController constructor.
|
* CompanyGatewayController constructor.
|
||||||
* @param CompanyRepository $company_repo
|
* @param CompanyRepository $company_repo
|
||||||
@ -379,6 +383,8 @@ class CompanyGatewayController extends BaseController
|
|||||||
|
|
||||||
$company_gateway->save();
|
$company_gateway->save();
|
||||||
|
|
||||||
|
ApplePayDomain::dispatch($company_gateway, $company_gateway->company->db);
|
||||||
|
|
||||||
return $this->itemResponse($company_gateway);
|
return $this->itemResponse($company_gateway);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
93
app/Jobs/Util/ApplePayDomain.php
Normal file
93
app/Jobs/Util/ApplePayDomain.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Jobs\Util;
|
||||||
|
|
||||||
|
use App\Jobs\Util\UnlinkFile;
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Account;
|
||||||
|
use App\Models\CompanyGateway;
|
||||||
|
use App\Utils\Ninja;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class ApplePayDomain implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
private CompanyGateway $company_gateway;
|
||||||
|
|
||||||
|
private string $db;
|
||||||
|
|
||||||
|
private array $stripe_keys = ['d14dd26a47cecc30fdd65700bfb67b34', 'd14dd26a37cecc30fdd65700bfb55b23'];
|
||||||
|
|
||||||
|
public $tries = 1;
|
||||||
|
|
||||||
|
public function __construct(CompanyGateway $company_gateway, string $db)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->db = $db;
|
||||||
|
|
||||||
|
$this->company_gateway = $company_gateway;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
MultiDB::setDB($this->db);
|
||||||
|
|
||||||
|
if(in_array($this->company_gateway->gateway_key, $this->stripe_keys))
|
||||||
|
{
|
||||||
|
$domain = $this->getDomain();
|
||||||
|
|
||||||
|
$this->company_gateway->driver()->setApplePayDomain($domain);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDomain()
|
||||||
|
{
|
||||||
|
|
||||||
|
$domain = '';
|
||||||
|
|
||||||
|
if(Ninja::isHosted())
|
||||||
|
{
|
||||||
|
|
||||||
|
if($this->company->portal_mode == 'domain'){
|
||||||
|
$domain = $this->company->portal_domain;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$domain = $this->company->subdomain . '.' . config('ninja.app_domain');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
$domain = config('ninja.app_url');
|
||||||
|
}
|
||||||
|
|
||||||
|
$parsed_url = parse_url($domain);
|
||||||
|
|
||||||
|
return $parsed_url['host'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -725,13 +725,15 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
return (new Verify($this))->run();
|
return (new Verify($this))->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDomain()
|
public function setApplePayDomain($domain)
|
||||||
{
|
{
|
||||||
// \Stripe\ApplePayDomain::create([
|
|
||||||
// 'domain_name' => 'example.com',
|
$this->init();
|
||||||
// ],[
|
|
||||||
// 'stripe_account' => '{{CONNECTED_ACCOUNT_ID}}',
|
\Stripe\ApplePayDomain::create([
|
||||||
// ]);
|
'domain_name' => $domain,
|
||||||
|
],$this->stripe_connect_auth);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disconnect()
|
public function disconnect()
|
||||||
|
@ -38,6 +38,11 @@ class ApplePayDomainMerchantUrlTest extends TestCase
|
|||||||
|
|
||||||
public function testMerchantFieldGet()
|
public function testMerchantFieldGet()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (! config('ninja.testvars.stripe')) {
|
||||||
|
$this->markTestSkipped('Skip test no company gateways installed');
|
||||||
|
}
|
||||||
|
|
||||||
$config = new \stdClass;
|
$config = new \stdClass;
|
||||||
$config->publishableKey = "pk_test";
|
$config->publishableKey = "pk_test";
|
||||||
$config->apiKey = "sk_test";
|
$config->apiKey = "sk_test";
|
||||||
@ -61,4 +66,27 @@ class ApplePayDomainMerchantUrlTest extends TestCase
|
|||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
$this->assertEquals("merchant_id", $arr);
|
$this->assertEquals("merchant_id", $arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDomainParsing()
|
||||||
|
{
|
||||||
|
$domain = 'http://ninja.test:8000';
|
||||||
|
|
||||||
|
$parsed = parse_url($domain);
|
||||||
|
|
||||||
|
$this->assertEquals('ninja.test', $parsed['host']);
|
||||||
|
|
||||||
|
$domain = 'ninja.test:8000';
|
||||||
|
|
||||||
|
$parsed = parse_url($domain);
|
||||||
|
|
||||||
|
$this->assertEquals('ninja.test', $parsed['host']);
|
||||||
|
|
||||||
|
$domain = 'http://ninja.test:8000/afadf/dfdfdf/dfdfasf';
|
||||||
|
|
||||||
|
$parsed = parse_url($domain);
|
||||||
|
|
||||||
|
$this->assertEquals('ninja.test', $parsed['host']);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user