1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Update defaults

This commit is contained in:
David Bomba 2021-03-21 16:35:09 +11:00
parent ae8942b187
commit c7d7916b04
4 changed files with 43 additions and 0 deletions

View File

@ -101,6 +101,7 @@ class CreateSingleAccount extends Command
$company = Company::factory()->create([
'account_id' => $account->id,
'slack_webhook_url' => config('ninja.notification.slack'),
'default_password_timeout' => 30*60000,
]);
$account->default_company_id = $company->id;

View File

@ -35,12 +35,18 @@ class WebhookConfiguration
*/
public $post_purchase_body = '';
/**
* @var string
*/
public $post_purchase_rest_method = 'POST';
/**
* @var array
*/
public static $casts = [
'return_url' => 'string',
'post_purchase_url' => 'string',
'post_purchase_rest_method' => 'string',
'post_purchase_headers' => 'array',
'post_purchase_body' => 'object',
];

View File

@ -13,17 +13,25 @@ namespace App\Services\BillingSubscription;
use App\DataMapper\InvoiceItem;
use App\Factory\InvoiceFactory;
use App\Jobs\Util\SystemLogger;
use App\Models\BillingSubscription;
use App\Models\ClientSubscription;
use App\Models\PaymentHash;
use App\Models\Product;
use App\Models\SystemLog;
use App\Repositories\InvoiceRepository;
use App\Utils\Traits\MakesHash;
use GuzzleHttp\RequestOptions;
class BillingSubscriptionService
{
use MakesHash;
/** @var BillingSubscription */
private $billing_subscription;
private $client_subscription;
public function __construct(BillingSubscription $billing_subscription)
{
$this->billing_subscription = $billing_subscription;
@ -158,11 +166,38 @@ class BillingSubscriptionService
// client_id
$cs->save();
$this->client_subscription = $cs;
}
public function triggerWebhook($payment_hash)
{
//hit the webhook to after a successful onboarding
//$client = xxxxxxx
//todo webhook
$body = [
'billing_subscription' => $this->billing_subscription,
'client_subscription' => $this->client_subscription,
// 'client' => $client->toArray(),
];
$client = new \GuzzleHttp\Client(['headers' => $this->billing_subscription->webhook_configuration->post_purchase_headers]);
$response = $client->{$this->billing_subscription->webhook_configuration->post_purchase_rest_method}($this->billing_subscription->post_purchase_url,[
RequestOptions::JSON => ['body' => $body]
]);
SystemLogger::dispatch(
$body,
SystemLog::CATEGORY_WEBHOOK,
SystemLog::EVENT_WEBHOOK_RESPONSE,
SystemLog::TYPE_WEBHOOK_RESPONSE,
//$client,
);
}
public function fireNotifications()

View File

@ -37,6 +37,7 @@ class CompanyFactory extends Factory
'db' => config('database.default'),
'settings' => CompanySettings::defaults(),
'is_large' => false,
'default_password_timeout' => 30*60000,
'enabled_modules' => config('ninja.enabled_modules'),
'custom_fields' => (object) [
//'invoice1' => 'Custom Date|date',