subscriptions

This commit is contained in:
David Bomba 2021-04-05 22:37:25 +10:00
parent 8d4fa8cb42
commit 660dca561b
4 changed files with 53 additions and 22 deletions

View File

@ -600,6 +600,7 @@ class CompanySettings extends BaseSettings
'$client.city_state_postal',
'$client.country',
'$contact.email',
'$client.phone',
],
'company_details' => [
'$company.name',

View File

@ -11,12 +11,12 @@
namespace App\Jobs\Mail;
use App\Jobs\Mail\NinjaMailer;
use App\Jobs\Mail\NinjaMailerJob;
use App\Jobs\Mail\NinjaMailerObject;
use App\Libraries\MultiDB;
use App\Mail\Admin\EntityNotificationMailer;
use App\Mail\Admin\PaymentFailureObject;
use App\Mail\NinjaMailer;
use App\Models\User;
use App\Utils\Traits\Notifications\UserNotifies;
use Illuminate\Bus\Queueable;

View File

@ -15,7 +15,9 @@ use App\DataMapper\InvoiceItem;
use App\Factory\InvoiceFactory;
use App\Factory\InvoiceToRecurringInvoiceFactory;
use App\Factory\RecurringInvoiceFactory;
use App\Jobs\Util\SubscriptionWebhookHandler;
use App\Jobs\Util\SystemLogger;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\ClientSubscription;
use App\Models\Invoice;
@ -243,38 +245,36 @@ class SubscriptionService
'db' => $this->subscription->company->db,
]);
$headers = [
'Content-Type' => 'application/json',
'X-Requested-With' => 'XMLHttpRequest',
];
//$this->subscription->webhook_configuration['post_purchase_headers']
$client = new \GuzzleHttp\Client(
[
'headers' => $headers,
]);
$headers = [
'Content-Type' => 'application/json',
'X-Requested-With' => 'XMLHttpRequest',
];
try{
$client = new \GuzzleHttp\Client(
[
'headers' => $headers,
]);
try {
$response = $client->{$this->subscription->webhook_configuration['post_purchase_rest_method']}($this->subscription->webhook_configuration['post_purchase_url'],[
RequestOptions::JSON => ['body' => $body], RequestOptions::ALLOW_REDIRECTS => false
]);
}
catch(\Exception $e)
{
nlog($e->getMessage());
}
// $response = $client->post('http://ninja.test:8000/api/admin/plan',[RequestOptions::JSON => ['body' => $body]]);
$client = \App\Models\Client::find($this->decodePrimaryKey($body['client']));
// SystemLogger::dispatch(
// $body,
// SystemLog::CATEGORY_WEBHOOK,
// SystemLog::EVENT_WEBHOOK_RESPONSE,
// SystemLog::TYPE_WEBHOOK_RESPONSE,
// $this->client_subscription->client,
// );
SystemLogger::dispatch(
$body,
SystemLog::CATEGORY_WEBHOOK,
SystemLog::EVENT_WEBHOOK_RESPONSE,
SystemLog::TYPE_WEBHOOK_RESPONSE,
$client,
);
}

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTrialDurationToAccountsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('accounts', function (Blueprint $table) {
$table->unsignedInteger('trial_duration')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}