mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 06:32:40 +01:00
commit
6c6a142f36
@ -17,8 +17,8 @@ Currently the client portal and API are of alpha quality, to get started:
|
||||
git clone https://github.com/invoiceninja/invoiceninja.git
|
||||
git checkout v5-stable
|
||||
cp .env.example .env
|
||||
php artisan key:generate
|
||||
composer update
|
||||
php artisan key:generate
|
||||
```
|
||||
|
||||
Please Note: Your APP_KEY in the .env file is used to encrypt data, if you lose this you will not be able to run the application.
|
||||
@ -91,4 +91,4 @@ To manage our workflow we will be creating separate branches for the client (Flu
|
||||
|
||||
## License
|
||||
Invoice Ninja is released under the Attribution Assurance License.
|
||||
See [LICENSE](LICENSE) for details.
|
||||
See [LICENSE](LICENSE) for details.
|
||||
|
@ -1 +1 @@
|
||||
5.1.34
|
||||
5.1.35
|
@ -38,7 +38,7 @@ class PaymentFailureMailer implements ShouldQueue
|
||||
|
||||
public $company;
|
||||
|
||||
public $payment_hash;
|
||||
public $amount;
|
||||
|
||||
public $settings;
|
||||
|
||||
@ -50,7 +50,7 @@ class PaymentFailureMailer implements ShouldQueue
|
||||
* @param $company
|
||||
* @param $amount
|
||||
*/
|
||||
public function __construct($client, $error, $company, $payment_hash)
|
||||
public function __construct($client, $error, $company, $amount)
|
||||
{
|
||||
$this->company = $company;
|
||||
|
||||
@ -58,7 +58,7 @@ class PaymentFailureMailer implements ShouldQueue
|
||||
|
||||
$this->client = $client;
|
||||
|
||||
$this->payment_hash = $payment_hash;
|
||||
$this->amount = $amount;
|
||||
|
||||
$this->company = $company;
|
||||
|
||||
@ -86,7 +86,7 @@ class PaymentFailureMailer implements ShouldQueue
|
||||
if (($key = array_search('mail', $methods)) !== false) {
|
||||
unset($methods[$key]);
|
||||
|
||||
$mail_obj = (new PaymentFailureObject($this->client, $this->error, $this->company, $this->payment_hash))->build();
|
||||
$mail_obj = (new PaymentFailureObject($this->client, $this->error, $this->company, $this->amount))->build();
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer($mail_obj);
|
||||
|
@ -26,9 +26,9 @@ class PaymentFailureObject
|
||||
|
||||
public $company;
|
||||
|
||||
public $payment_hash;
|
||||
public $amount;
|
||||
|
||||
private $invoices;
|
||||
// private $invoices;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
@ -38,7 +38,7 @@ class PaymentFailureObject
|
||||
* @param $company
|
||||
* @param $amount
|
||||
*/
|
||||
public function __construct($client, $error, $company, $payment_hash)
|
||||
public function __construct($client, $error, $company, $amount)
|
||||
{
|
||||
$this->client = $client;
|
||||
|
||||
@ -46,7 +46,7 @@ class PaymentFailureObject
|
||||
|
||||
$this->company = $company;
|
||||
|
||||
$this->payment_hash = $payment_hash;
|
||||
$this->amount = $amount;
|
||||
|
||||
$this->company = $company;
|
||||
|
||||
@ -55,7 +55,7 @@ class PaymentFailureObject
|
||||
public function build()
|
||||
{
|
||||
|
||||
$this->invoices = Invoice::whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->get();
|
||||
// $this->invoices = Invoice::whereIn('id', $this->transformKeys(array_column($this->payment_hash->invoices(), 'invoice_id')))->get();
|
||||
|
||||
$mail_obj = new stdClass;
|
||||
$mail_obj->amount = $this->getAmount();
|
||||
@ -70,7 +70,7 @@ class PaymentFailureObject
|
||||
private function getAmount()
|
||||
{
|
||||
|
||||
return array_sum(array_column($this->payment_hash->invoices(), 'amount')) + $this->payment_hash->fee_total;
|
||||
return $this->amount;
|
||||
|
||||
}
|
||||
|
||||
|
@ -111,11 +111,27 @@ class SubscriptionService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
'email' => $this->email ?? $this->contact->email,
|
||||
'quantity' => $this->quantity,
|
||||
'contact_id' => $this->contact->id,
|
||||
*/
|
||||
/* Hits the client endpoint to determine whether the user is able to access this subscription */
|
||||
public function isEligible($contact)
|
||||
{
|
||||
|
||||
$context = [
|
||||
'context' => 'is_eligible',
|
||||
'subscription' => $this->subscription->hashed_id,
|
||||
'contact' => $contact->hashed_id,
|
||||
'contact_email' => $contact->email
|
||||
];
|
||||
|
||||
$response = $this->triggerWebhook($context);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Starts the process to create a trial
|
||||
- we create a recurring invoice, which is has its next_send_date as now() + trial_duration
|
||||
- we then hit the client API end point to advise the trial payload
|
||||
- we then return the user to either a predefined user endpoint, OR we return the user to the recurring invoice page.
|
||||
*/
|
||||
public function startTrial(array $data)
|
||||
{
|
||||
// Redirects from here work just fine. Livewire will respect it.
|
||||
@ -152,7 +168,7 @@ class SubscriptionService
|
||||
];
|
||||
|
||||
//execute any webhooks
|
||||
$this->triggerWebhook($context);
|
||||
$response = $this->triggerWebhook($context);
|
||||
|
||||
if(array_key_exists('return_url', $this->subscription->webhook_configuration) && strlen($this->subscription->webhook_configuration['return_url']) >=1){
|
||||
return redirect($this->subscription->webhook_configuration['return_url']);
|
||||
@ -199,45 +215,14 @@ class SubscriptionService
|
||||
return $recurring_invoice;
|
||||
}
|
||||
|
||||
// @deprecated due to change in architecture
|
||||
|
||||
// public function createClientSubscription($payment_hash)
|
||||
// {
|
||||
|
||||
// //is this a recurring or one off subscription.
|
||||
|
||||
// $cs = new ClientSubscription();
|
||||
// $cs->subscription_id = $this->subscription->id;
|
||||
// $cs->company_id = $this->subscription->company_id;
|
||||
|
||||
// $cs->invoice_id = $payment_hash->billing_context->invoice_id;
|
||||
// $cs->client_id = $payment_hash->billing_context->client_id;
|
||||
// $cs->quantity = $payment_hash->billing_context->quantity;
|
||||
|
||||
// //if is_recurring
|
||||
// //create recurring invoice from invoice
|
||||
// if($this->subscription->is_recurring)
|
||||
// {
|
||||
// $recurring_invoice = $this->convertInvoiceToRecurring($payment_hash);
|
||||
// $recurring_invoice->frequency_id = $this->subscription->frequency_id;
|
||||
// $recurring_invoice->next_send_date = $recurring_invoice->nextDateByFrequency(now()->format('Y-m-d'));
|
||||
// $recurring_invoice->save();
|
||||
// $cs->recurring_invoice_id = $recurring_invoice->id;
|
||||
|
||||
// //?set the recurring invoice as active - set the date here also based on the frequency?
|
||||
// $recurring_invoice->service()->start();
|
||||
// }
|
||||
|
||||
|
||||
// $cs->save();
|
||||
|
||||
// $this->client_subscription = $cs;
|
||||
|
||||
// }
|
||||
|
||||
//@todo - need refactor
|
||||
public function triggerWebhook($context)
|
||||
{
|
||||
/* If no webhooks have been set, then just return gracefully */
|
||||
if(!array_key_exists('post_purchase_url', $this->subscription->webhook_configuration) || !array_key_exists('post_purchase_rest_method', $this->subscription->webhook_configuration)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$response = false;
|
||||
|
||||
$body = array_merge($context, [
|
||||
'company_key' => $this->subscription->company->company_key,
|
||||
@ -263,6 +248,15 @@ class SubscriptionService
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
$body = array_merge($body, ['exception' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
/* Append the response to the system logger body */
|
||||
if($response) {
|
||||
|
||||
$status = $response->getStatusCode();
|
||||
$response_body = $response->getBody();
|
||||
$body = array_merge($body, ['status' => $status, 'response_body' => $response_body]);
|
||||
|
||||
}
|
||||
|
||||
@ -276,6 +270,8 @@ class SubscriptionService
|
||||
$client,
|
||||
);
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
public function fireNotifications()
|
||||
|
@ -14,7 +14,7 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', ''),
|
||||
'app_version' => '5.1.34',
|
||||
'app_version' => '5.1.35',
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', false),
|
||||
|
@ -40,7 +40,7 @@ class PlanTest extends TestCase
|
||||
Model::reguard();
|
||||
}
|
||||
|
||||
public function testTrialPlans()
|
||||
public function testTrialFeatures()
|
||||
{
|
||||
config(['ninja.production' => true]);
|
||||
|
||||
@ -51,8 +51,6 @@ class PlanTest extends TestCase
|
||||
$this->account->trial_duration = 60*60*24*31;
|
||||
$this->account->save();
|
||||
|
||||
nlog($this->account->getPlanDetails());
|
||||
|
||||
$this->assertFalse($this->account->hasFeature(Account::FEATURE_USERS));
|
||||
|
||||
$this->account->trial_plan = 'pro';
|
||||
|
Loading…
Reference in New Issue
Block a user