Merge pull request #6886 from turbo124/v5-stable

v5.3.26
This commit is contained in:
David Bomba 2021-10-23 16:04:50 +11:00 committed by GitHub
commit ad83badea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
140 changed files with 648003 additions and 406777 deletions

View File

@ -1 +1 @@
5.3.25 5.3.26

View File

@ -0,0 +1,91 @@
<?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\Console\Commands;
use App\Libraries\MultiDB;
use App\Models\Backup;
use App\Models\Design;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
use stdClass;
class BackupUpdate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ninja:backup-update';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Shift backups from DB to storage';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//always return state to first DB
$current_db = config('database.default');
if (! config('ninja.db.multi_db_enabled')) {
$this->handleOnDb();
} else {
//multiDB environment, need to
foreach (MultiDB::$dbs as $db) {
MultiDB::setDB($db);
$this->handleOnDb();
}
MultiDB::setDB($current_db);
}
}
private function handleOnDb()
{
Backup::whereHas('activity')->whereNotNull('html_backup')->cursor()->each(function($backup){
if($backup->activity->client()->exists()){
$client = $backup->activity->client;
$backup->storeRemotely($backup->html_backup, $client);
}
});
}
}

View File

@ -90,6 +90,10 @@ class CreateSingleAccount extends Command
*/ */
public function handle() public function handle()
{ {
if(config('ninja.is_docker'))
return;
MultiDB::setDb($this->option('database')); MultiDB::setDb($this->option('database'));
$this->info(date('r').' Create Single Sample Account...'); $this->info(date('r').' Create Single Sample Account...');

View File

@ -78,6 +78,9 @@ class CreateTestData extends Command
*/ */
public function handle() public function handle()
{ {
if(config('ninja.is_docker'))
return;
$this->info(date('r').' Running CreateTestData...'); $this->info(date('r').' Running CreateTestData...');
$this->count = $this->argument('count'); $this->count = $this->argument('count');

View File

@ -86,6 +86,9 @@ class DemoMode extends Command
{ {
set_time_limit(0); set_time_limit(0);
if(config('ninja.is_docker'))
return;
$cached_tables = config('ninja.cached_tables'); $cached_tables = config('ninja.cached_tables');
foreach ($cached_tables as $name => $class) { foreach ($cached_tables as $name => $class) {

View File

@ -59,37 +59,6 @@ class SubdomainFill extends Command
}); });
// $db1 = Company::on('db-ninja-01')->get();
// $db1->each(function ($company){
// $db2 = Company::on('db-ninja-02a')->find($company->id);
// if($db2)
// {
// $db2->subdomain = $company->subdomain;
// $db2->save();
// }
// });
// $db1 = null;
// $db2 = null;
// $db2 = Company::on('db-ninja-02')->get();
// $db2->each(function ($company){
// $db1 = Company::on('db-ninja-01a')->find($company->id);
// if($db1)
// {
// $db1->subdomain = $company->subdomain;
// $db1->save();
// }
// });
} }
} }

View File

@ -32,7 +32,7 @@ class ClientRegistrationFields
], ],
[ [
'key' => 'phone', 'key' => 'phone',
'required' => true 'required' => false
], ],
[ [
'key' => 'password', 'key' => 'password',

View File

@ -126,15 +126,13 @@ class CompanySettings extends BaseSettings
public $auto_bill = 'off'; //off,always,optin,optout //@implemented public $auto_bill = 'off'; //off,always,optin,optout //@implemented
public $auto_bill_date = 'on_due_date'; // on_due_date , on_send_date //@implemented public $auto_bill_date = 'on_due_date'; // on_due_date , on_send_date //@implemented
//public $design = 'views/pdf/design1.blade.php'; //@deprecated - never used
public $invoice_terms = ''; //@implemented public $invoice_terms = ''; //@implemented
public $quote_terms = ''; //@implemented public $quote_terms = ''; //@implemented
public $invoice_taxes = 0; // ? used in AP only? public $invoice_taxes = 0; // ? used in AP only?
// public $enabled_item_tax_rates = 0;
public $invoice_design_id = 'VolejRejNm'; //@implemented public $invoice_design_id = 'Wpmbk5ezJn'; //@implemented
public $quote_design_id = 'VolejRejNm'; //@implemented public $quote_design_id = 'Wpmbk5ezJn'; //@implemented
public $credit_design_id = 'VolejRejNm'; //@implemented public $credit_design_id = 'Wpmbk5ezJn'; //@implemented
public $invoice_footer = ''; //@implemented public $invoice_footer = ''; //@implemented
public $credit_footer = ''; //@implemented public $credit_footer = ''; //@implemented
public $credit_terms = ''; //@implemented public $credit_terms = ''; //@implemented
@ -146,7 +144,6 @@ class CompanySettings extends BaseSettings
public $tax_name3 = ''; //@TODO where do we use this? public $tax_name3 = ''; //@TODO where do we use this?
public $tax_rate3 = 0; //@TODO where do we use this? public $tax_rate3 = 0; //@TODO where do we use this?
public $payment_type_id = '0'; //@TODO where do we use this? public $payment_type_id = '0'; //@TODO where do we use this?
// public $invoice_fields = ''; //@TODO is this redundant, we store this in the custom_fields on the company?
public $valid_until = ''; //@implemented public $valid_until = ''; //@implemented

View File

@ -0,0 +1,144 @@
<?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\Helpers\Invoice;
use App\Models\Invoice;
use App\Models\RecurringInvoice;
use Carbon\Exceptions\InvalidFormatException;
use Exception;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Carbon;
class ProRata
{
/**
* Returns the amount to refund based on
* the time interval and the frequency duration
*
* @param float $amount
* @param Carbon $from_date
* @param Carbon $to_date
* @param int $frequency
* @return float
*/
public function refund(float $amount, Carbon $from_date, Carbon $to_date, int $frequency) :float
{
$days = $from_date->copy()->diffInDays($to_date);
$days_in_frequency = $this->getDaysInFrequency($frequency);
return round( (($days/$days_in_frequency) * $amount),2);
}
/**
* Returns the amount to charge based on
* the time interval and the frequency duration
*
* @param float $amount
* @param Carbon $from_date
* @param Carbon $to_date
* @param int $frequency
* @return float
*/
public function charge(float $amount, Carbon $from_date, Carbon $to_date, int $frequency) :float
{
$days = $from_date->copy()->diffInDays($to_date);
$days_in_frequency = $this->getDaysInFrequency($frequency);
nlog($from_date->format('Y-m-d'));
nlog($days);
nlog($days_in_frequency);
nlog($amount);
return round( (($days/$days_in_frequency) * $amount),2);
}
/**
* Prepares the line items of an invoice
* to be pro rata refunded.
*
* @param Invoice $invoice
* @param bool $is_credit
* @return array
* @throws Exception
*/
public function refundItems(Invoice $invoice, $is_credit = false) :array
{
if(!$invoice)
return [];
$recurring_invoice = RecurringInvoice::find($invoice->recurring_id)->first();
if(!$recurring_invoice)
throw new \Exception("Invoice isn't attached to a recurring invoice");
/* depending on whether we are creating an invoice or a credit*/
$multiplier = $is_credit ? 1 : -1;
$start_date = Carbon::parse($invoice->date);
$line_items = [];
foreach($invoice->line_items as $item)
{
if($item->product_key != ctrans('texts.refund'))
{
$item->quantity = 1;
$item->cost = $this->refund($item->cost*$multiplier, $start_date, now(), $recurring_invoice->frequency_id);
$item->product_key = ctrans('texts.refund');
$item->notes = ctrans('texts.refund') . ": ". $item->notes;
$line_items[] = $item;
}
}
return $line_items;
}
private function getDaysInFrequency($frequency)
{
switch ($frequency) {
case RecurringInvoice::FREQUENCY_DAILY:
return 1;
case RecurringInvoice::FREQUENCY_WEEKLY:
return 7;
case RecurringInvoice::FREQUENCY_TWO_WEEKS:
return 14;
case RecurringInvoice::FREQUENCY_FOUR_WEEKS:
return now()->diffInDays(now()->addWeeks(4));
case RecurringInvoice::FREQUENCY_MONTHLY:
return now()->diffInDays(now()->addMonthNoOverflow());
case RecurringInvoice::FREQUENCY_TWO_MONTHS:
return now()->diffInDays(now()->addMonthNoOverflow(2));
case RecurringInvoice::FREQUENCY_THREE_MONTHS:
return now()->diffInDays(now()->addMonthNoOverflow(3));
case RecurringInvoice::FREQUENCY_FOUR_MONTHS:
return now()->diffInDays(now()->addMonthNoOverflow(4));
case RecurringInvoice::FREQUENCY_SIX_MONTHS:
return now()->diffInDays(now()->addMonthNoOverflow(6));
case RecurringInvoice::FREQUENCY_ANNUALLY:
return now()->diffInDays(now()->addYear());
case RecurringInvoice::FREQUENCY_TWO_YEARS:
return now()->diffInDays(now()->addYears(2));
case RecurringInvoice::FREQUENCY_THREE_YEARS:
return now()->diffInDays(now()->addYears(3));
default:
return 0;
}
}
}

View File

@ -0,0 +1,102 @@
<?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\Helpers\Subscription;
use App\Helpers\Invoice\ProRata;
use App\Models\Invoice;
use App\Models\RecurringInvoice;
use App\Models\Subscription;
use Illuminate\Support\Carbon;
/**
* SubscriptionCalculator.
*/
class SubscriptionCalculator
{
public Subscription $target_subscription;
public Invoice $invoice;
public function __construct(Subscription $target_subscription, Invoice $invoice)
{
$this->target_subscription = $target_subscription;
$this->invoice = $invoice;
}
/**
* Tests if the user is currently up
* to date with their payments for
* a given recurring invoice
*
* @return bool
*/
public function isPaidUp() :bool
{
$outstanding_invoices_exist = Invoice::whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
->where('subscription_id', $this->invoice->subscription_id)
->where('client_id', $this->invoice->client_id)
->where('balance', '>', 0)
->exists();
return ! $outstanding_invoices_exist;
}
public function calcUpgradePlan()
{
//set the starting refund amount
$refund_amount = 0;
$refund_invoice = false;
//are they paid up to date.
//yes - calculate refund
if($this->isPaidUp())
$refund_invoice = $this->getRefundInvoice();
if($refund_invoice)
{
$subscription = Subscription::find($this->invoice->subscription_id);
$pro_rata = new ProRata;
$to_date = $subscription->service()->getNextDateForFrequency(Carbon::parse($refund_invoice->date), $subscription->frequency_id);
$refund_amount = $pro_rata->refund($refund_invoice->amount, now(), $to_date, $subscription->frequency_id);
$charge_amount = $pro_rata->charge($this->target_subscription->price, now(), $to_date, $this->target_subscription->frequency_id);
return ($charge_amount - $refund_amount);
}
//no - return full freight charge.
return $this->target_subscription->price;
}
public function executeUpgradePlan()
{
}
private function getRefundInvoice()
{
return Invoice::where('subscription_id', $this->invoice->subscription_id)
->where('client_id', $this->invoice->client_id)
->where('is_deleted', 0)
->orderBy('id', 'desc')
->first();
}
}

View File

@ -20,6 +20,7 @@ use App\Utils\Traits\Pdf\PdfMaker;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpFoundation\StreamedResponse;
use stdClass; use stdClass;
@ -136,19 +137,33 @@ class ActivityController extends BaseController
public function downloadHistoricalEntity(DownloadHistoricalEntityRequest $request, Activity $activity) public function downloadHistoricalEntity(DownloadHistoricalEntityRequest $request, Activity $activity)
{ {
$backup = $activity->backup; $backup = $activity->backup;
$html_backup = '';
if (! $backup || ! $backup->html_backup) { /* Refactor 20-10-2021
*
* We have moved the backups out of the database and into object storage.
* In order to handle edge cases, we still check for the database backup
* in case the file no longer exists
*/
if($backup && $backup->filename && Storage::disk(config('filesystems.default'))->exists($backup->filename)){ //disk
$html_backup = file_get_contents(Storage::disk(config('filesystems.default'))->path($backup->filename));
}
elseif($backup && $backup->html_backup){ //db
$html_backup = $backup->html_backup;
}
elseif (! $backup || ! $backup->html_backup) { //failed
return response()->json(['message'=> ctrans('texts.no_backup_exists'), 'errors' => new stdClass], 404); return response()->json(['message'=> ctrans('texts.no_backup_exists'), 'errors' => new stdClass], 404);
} }
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') { if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
$pdf = (new Phantom)->convertHtmlToPdf($backup->html_backup); $pdf = (new Phantom)->convertHtmlToPdf($html_backup);
} }
elseif(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){ elseif(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
$pdf = (new NinjaPdf())->build($backup->html_backup); $pdf = (new NinjaPdf())->build($html_backup);
} }
else { else {
$pdf = $this->makePdf(null, null, $backup->html_backup); $pdf = $this->makePdf(null, null, $html_backup);
} }
if (isset($activity->invoice_id)) { if (isset($activity->invoice_id)) {

View File

@ -15,12 +15,15 @@ use App\Http\Controllers\Controller;
use App\Http\Requests\ClientPortal\Contact\ContactPasswordResetRequest; use App\Http\Requests\ClientPortal\Contact\ContactPasswordResetRequest;
use App\Libraries\MultiDB; use App\Libraries\MultiDB;
use App\Models\Account; use App\Models\Account;
use App\Models\ClientContact;
use App\Models\Company;
use App\Utils\Ninja; use App\Utils\Ninja;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails; use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\View\View; use Illuminate\View\View;
class ContactForgotPasswordController extends Controller class ContactForgotPasswordController extends Controller
@ -80,19 +83,35 @@ class ContactForgotPasswordController extends Controller
public function sendResetLinkEmail(ContactPasswordResetRequest $request) public function sendResetLinkEmail(ContactPasswordResetRequest $request)
{ {
if(Ninja::isHosted() && $request->has('db')) if(Ninja::isHosted() && $request->has('company_key'))
MultiDB::setDb($request->input('db')); MultiDB::findAndSetDbByCompanyKey($request->input('company_key'));
// $user = MultiDB::hasContact($request->input('email'));
$this->validateEmail($request); $this->validateEmail($request);
// $user = MultiDB::hasContact($request->input('email'));
$company = Company::where('company_key', $request->input('company_key'))->first();
$contact = MultiDB::findContact(['company_id' => $company->id, 'email' => $request->input('email')]);
$response = false;
if($contact){
/* Update all instances of the client */
$token = Str::random(60);
ClientContact::where('email', $contact->email)->update(['token' => $token]);
$contact->sendPasswordResetNotification($token);
$response = Password::RESET_LINK_SENT;
}
else
return $this->sendResetLinkFailedResponse($request, Password::INVALID_USER);
// We will send the password reset link to this user. Once we have attempted // We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we // to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response. // need to show to the user. Finally, we'll send out a proper response.
$response = $this->broker()->sendResetLink( // $response = $this->broker()->sendResetLink(
$this->credentials($request) // $this->credentials($request)
); // );
if ($request->ajax()) { if ($request->ajax()) {

View File

@ -14,11 +14,15 @@ namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Libraries\MultiDB; use App\Libraries\MultiDB;
use App\Models\Account; use App\Models\Account;
use App\Models\ClientContact;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Foundation\Auth\ResetsPasswords; use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\View\View; use Illuminate\View\View;
class ContactResetPasswordController extends Controller class ContactResetPasswordController extends Controller
@ -76,19 +80,28 @@ class ContactResetPasswordController extends Controller
public function reset(Request $request) public function reset(Request $request)
{ {
if($request->has('db')) if($request->has('company_key'))
MultiDB::setDb($request->input('db')); MultiDB::findAndSetDbByCompanyKey($request->input('company_key'));
$request->validate($this->rules(), $this->validationErrorMessages()); $request->validate($this->rules(), $this->validationErrorMessages());
// Here we will attempt to reset the user's password. If it is successful we $user = ClientContact::where($request->only(['email','token']))->first();
// will update the password on an actual user model and persist it to the
// database. Otherwise we will parse the error and return the response. if(!$user)
$response = $this->broker()->reset( return $this->sendResetFailedResponse($request, PASSWORD::INVALID_USER);
$this->credentials($request), function ($user, $password) {
$this->resetPassword($user, $password); $hashed_password = Hash::make($request->input('password'));
}
); ClientContact::where('email', $user->email)->update([
'password' => $hashed_password,
'remember_token' => Str::random(60)
]);
event(new PasswordReset($user));
auth()->login($user, true);
$response = Password::PASSWORD_RESET;
// Added this because it collides the session between // Added this because it collides the session between
// client & main portal giving unlimited redirects. // client & main portal giving unlimited redirects.

View File

@ -260,14 +260,14 @@ class LoginController extends BaseController
->increment() ->increment()
->batch(); ->batch();
SystemLogger::dispatch( // SystemLogger::dispatch(
json_encode(['ip' => request()->getClientIp()]), // json_encode(['ip' => request()->getClientIp()]),
SystemLog::CATEGORY_SECURITY, // SystemLog::CATEGORY_SECURITY,
SystemLog::EVENT_USER, // SystemLog::EVENT_USER,
SystemLog::TYPE_LOGIN_FAILURE, // SystemLog::TYPE_LOGIN_FAILURE,
null, // null,
Company::first(), // Company::first(),
); // );
$this->incrementLoginAttempts($request); $this->incrementLoginAttempts($request);

View File

@ -738,6 +738,10 @@ class BaseController extends Controller
return redirect()->secure(request()->getRequestUri()); return redirect()->secure(request()->getRequestUri());
} }
/* Clean up URLs and remove query parameters from the URL*/
if(request()->has('login') && request()->input('login') == 'true')
return redirect('/')->with(['login' => "true"]);
$data = []; $data = [];
//pass report errors bool to front end //pass report errors bool to front end
@ -748,6 +752,9 @@ class BaseController extends Controller
$data['build'] = request()->has('build') ? request()->input('build') : ''; $data['build'] = request()->has('build') ? request()->input('build') : '';
$data['login'] = request()->has('login') ? request()->input('login') : "false"; $data['login'] = request()->has('login') ? request()->input('login') : "false";
if(request()->session()->has('login'))
$data['login'] = "true";
$data['user_agent'] = request()->server('HTTP_USER_AGENT'); $data['user_agent'] = request()->server('HTTP_USER_AGENT');
$data['path'] = $this->setBuild(); $data['path'] = $this->setBuild();
@ -782,6 +789,8 @@ class BaseController extends Controller
return 'main.next.dart.js'; return 'main.next.dart.js';
case 'profile': case 'profile':
return 'main.profile.dart.js'; return 'main.profile.dart.js';
case 'html':
return 'main.html.dart.js';
default: default:
return 'main.foss.dart.js'; return 'main.foss.dart.js';

View File

@ -2,10 +2,13 @@
namespace App\Http\Controllers\ClientPortal; namespace App\Http\Controllers\ClientPortal;
use App\Events\Credit\CreditWasViewed;
use App\Events\Misc\InvitationWasViewed;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\ClientPortal\Credits\ShowCreditRequest; use App\Http\Requests\ClientPortal\Credits\ShowCreditRequest;
use App\Http\Requests\ClientPortal\Credits\ShowCreditsRequest; use App\Http\Requests\ClientPortal\Credits\ShowCreditsRequest;
use App\Models\Credit; use App\Models\Credit;
use App\Utils\Ninja;
class CreditController extends Controller class CreditController extends Controller
{ {
@ -20,6 +23,16 @@ class CreditController extends Controller
$data = ['credit' => $credit]; $data = ['credit' => $credit];
$invitation = $credit->invitations()->where('client_contact_id', auth()->user()->id)->first();
if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {
$invitation->markViewed();
event(new InvitationWasViewed($credit, $invitation, $credit->company, Ninja::eventVars()));
event(new CreditWasViewed($invitation, $invitation->company, Ninja::eventVars()));
}
if ($request->query('mode') === 'fullscreen') { if ($request->query('mode') === 'fullscreen') {
return render('credits.show-fullscreen', $data); return render('credits.show-fullscreen', $data);

View File

@ -11,11 +11,14 @@
namespace App\Http\Controllers\ClientPortal; namespace App\Http\Controllers\ClientPortal;
use App\Events\Invoice\InvoiceWasViewed;
use App\Events\Misc\InvitationWasViewed;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\ClientPortal\Invoices\ShowInvoicesRequest;
use App\Http\Requests\ClientPortal\Invoices\ProcessInvoicesInBulkRequest; use App\Http\Requests\ClientPortal\Invoices\ProcessInvoicesInBulkRequest;
use App\Http\Requests\ClientPortal\Invoices\ShowInvoiceRequest; use App\Http\Requests\ClientPortal\Invoices\ShowInvoiceRequest;
use App\Http\Requests\ClientPortal\Invoices\ShowInvoicesRequest;
use App\Models\Invoice; use App\Models\Invoice;
use App\Utils\Ninja;
use App\Utils\Number; use App\Utils\Number;
use App\Utils\TempFile; use App\Utils\TempFile;
use App\Utils\Traits\MakesDates; use App\Utils\Traits\MakesDates;
@ -23,10 +26,10 @@ use App\Utils\Traits\MakesHash;
use Illuminate\Contracts\Container\BindingResolutionException; use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View; use Illuminate\View\View;
use ZipStream\Option\Archive; use ZipStream\Option\Archive;
use ZipStream\ZipStream; use ZipStream\ZipStream;
use Illuminate\Support\Facades\Storage;
class InvoiceController extends Controller class InvoiceController extends Controller
{ {
@ -56,6 +59,18 @@ class InvoiceController extends Controller
$invoice->service()->removeUnpaidGatewayFees()->save(); $invoice->service()->removeUnpaidGatewayFees()->save();
$invitation = $invoice->invitations()->where('client_contact_id', auth()->user()->id)->first();
if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {
$invitation->markViewed();
event(new InvitationWasViewed($invoice, $invitation, $invoice->company, Ninja::eventVars()));
event(new InvoiceWasViewed($invitation, $invitation->company, Ninja::eventVars()));
}
$data = [ $data = [
'invoice' => $invoice, 'invoice' => $invoice,
]; ];

View File

@ -39,7 +39,6 @@ class NinjaPlanController extends Controller
else else
$account = $company->account; $account = $company->account;
if (MultiDB::findAndSetDbByContactKey($contact_key) && $client_contact = ClientContact::where('contact_key', $contact_key)->first()) if (MultiDB::findAndSetDbByContactKey($contact_key) && $client_contact = ClientContact::where('contact_key', $contact_key)->first())
{ {
@ -49,7 +48,7 @@ class NinjaPlanController extends Controller
/* Current paid users get pushed straight to subscription overview page*/ /* Current paid users get pushed straight to subscription overview page*/
if($account->isPaidHostedClient()) if($account->isPaidHostedClient())
return redirect('/client/subscriptions'); return redirect('/client/dashboard');
/* Users that are not paid get pushed to a custom purchase page */ /* Users that are not paid get pushed to a custom purchase page */
return $this->render('subscriptions.ninja_plan', ['settings' => $client_contact->company->settings]); return $this->render('subscriptions.ninja_plan', ['settings' => $client_contact->company->settings]);

View File

@ -149,11 +149,11 @@ class PaymentMethodController extends Controller
private function getClientGateway() private function getClientGateway()
{ {
if (request()->query('method') == GatewayType::CREDIT_CARD) { if (request()->query('method') == GatewayType::CREDIT_CARD) {
return $gateway = auth()->user()->client->getCreditCardGateway(); return auth()->user()->client->getCreditCardGateway();
} }
if (request()->query('method') == GatewayType::BANK_TRANSFER) { if (in_array(request()->query('method'), [GatewayType::BANK_TRANSFER, GatewayType::DIRECT_DEBIT, GatewayType::SEPA])) {
return $gateway = auth()->user()->client->getBankTransferGateway(); return auth()->user()->client->getBankTransferGateway();
} }
abort(404, 'Gateway not found.'); abort(404, 'Gateway not found.');

View File

@ -12,22 +12,24 @@
namespace App\Http\Controllers\ClientPortal; namespace App\Http\Controllers\ClientPortal;
use App\Events\Misc\InvitationWasViewed;
use App\Events\Quote\QuoteWasApproved; use App\Events\Quote\QuoteWasApproved;
use App\Events\Quote\QuoteWasViewed;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\ClientPortal\Quotes\ProcessQuotesInBulkRequest; use App\Http\Requests\ClientPortal\Quotes\ProcessQuotesInBulkRequest;
use App\Http\Requests\ClientPortal\Quotes\ShowQuotesRequest;
use App\Http\Requests\ClientPortal\Quotes\ShowQuoteRequest; use App\Http\Requests\ClientPortal\Quotes\ShowQuoteRequest;
use App\Http\Requests\ClientPortal\Quotes\ShowQuotesRequest;
use App\Jobs\Invoice\InjectSignature; use App\Jobs\Invoice\InjectSignature;
use App\Models\Quote; use App\Models\Quote;
use App\Utils\Ninja; use App\Utils\Ninja;
use App\Utils\TempFile; use App\Utils\TempFile;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View; use Illuminate\View\View;
use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\BinaryFileResponse;
use ZipStream\Option\Archive; use ZipStream\Option\Archive;
use ZipStream\ZipStream; use ZipStream\ZipStream;
use Illuminate\Support\Facades\Storage;
class QuoteController extends Controller class QuoteController extends Controller
{ {
@ -56,6 +58,18 @@ class QuoteController extends Controller
'quote' => $quote, 'quote' => $quote,
]; ];
$invitation = $quote->invitations()->where('client_contact_id', auth()->user()->id)->first();
if ($invitation && auth()->guard('contact') && ! request()->has('silent') && ! $invitation->viewed_date) {
$invitation->markViewed();
event(new InvitationWasViewed($quote, $invitation, $quote->company, Ninja::eventVars()));
event(new QuoteWasViewed($invitation, $invitation->company, Ninja::eventVars()));
}
if ($request->query('mode') === 'fullscreen') { if ($request->query('mode') === 'fullscreen') {
return render('quotes.show-fullscreen', $data); return render('quotes.show-fullscreen', $data);
} }

View File

@ -27,7 +27,7 @@ class SwitchCompanyController extends Controller
->where('id', $this->transformKeys($contact)) ->where('id', $this->transformKeys($contact))
->first(); ->first();
Auth::guard('contact')->login($client_contact, true); auth()->guard('contact')->user()->login($client_contact, true);
return redirect('/client/dashboard'); return redirect('/client/dashboard');
} }

View File

@ -499,7 +499,7 @@ class CompanyController extends BaseController
$account->delete(); $account->delete();
if(Ninja::isHosted() && $request->has('cancellation_message') && strlen($request->input('cancellation_message')) > 1) if(Ninja::isHosted())
\Modules\Admin\Jobs\Account\NinjaDeletedAccount::dispatch($account_key, $request->all()); \Modules\Admin\Jobs\Account\NinjaDeletedAccount::dispatch($account_key, $request->all());
LightLogs::create(new AccountDeleted()) LightLogs::create(new AccountDeleted())

View File

@ -18,6 +18,8 @@ use App\Http\Requests\GroupSetting\EditGroupSettingRequest;
use App\Http\Requests\GroupSetting\ShowGroupSettingRequest; use App\Http\Requests\GroupSetting\ShowGroupSettingRequest;
use App\Http\Requests\GroupSetting\StoreGroupSettingRequest; use App\Http\Requests\GroupSetting\StoreGroupSettingRequest;
use App\Http\Requests\GroupSetting\UpdateGroupSettingRequest; use App\Http\Requests\GroupSetting\UpdateGroupSettingRequest;
use App\Http\Requests\GroupSetting\UploadGroupSettingRequest;
use App\Models\Account;
use App\Models\GroupSetting; use App\Models\GroupSetting;
use App\Repositories\GroupSettingRepository; use App\Repositories\GroupSettingRepository;
use App\Transformers\GroupSettingTransformer; use App\Transformers\GroupSettingTransformer;
@ -497,4 +499,68 @@ class GroupSettingController extends BaseController
return $this->listResponse(GroupSetting::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()); return $this->listResponse(GroupSetting::withTrashed()->whereIn('id', $this->transformKeys($ids))->company());
} }
/**
* Update the specified resource in storage.
*
* @param UploadGroupSettingRequest $request
* @param GroupSetting $group_setting
* @return Response
*
*
*
* @OA\Put(
* path="/api/v1/group_settings/{id}/upload",
* operationId="uploadGroupSetting",
* tags={"group_settings"},
* summary="Uploads a document to a group setting",
* description="Handles the uploading of a document to a group setting",
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
* @OA\Parameter(ref="#/components/parameters/include"),
* @OA\Parameter(
* name="id",
* in="path",
* description="The Group Setting Hashed ID",
* example="D2J234DFA",
* required=true,
* @OA\Schema(
* type="string",
* format="string",
* ),
* ),
* @OA\Response(
* response=200,
* description="Returns the Group Setting object",
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
* @OA\JsonContent(ref="#/components/schemas/Invoice"),
* ),
* @OA\Response(
* response=422,
* description="Validation error",
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
*
* ),
* @OA\Response(
* response="default",
* description="Unexpected Error",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* ),
* )
*/
public function upload(UploadGroupSettingRequest $request, GroupSetting $group_setting)
{
if(!$this->checkFeature(Account::FEATURE_DOCUMENTS))
return $this->featureFailure();
if ($request->has('documents'))
$this->saveDocuments($request->file('documents'), $group_setting);
return $this->itemResponse($group_setting->fresh());
}
} }

View File

@ -185,6 +185,10 @@ class InvoiceController extends BaseController
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"), * @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"), * @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
* @OA\Parameter(ref="#/components/parameters/include"), * @OA\Parameter(ref="#/components/parameters/include"),
* @OA\RequestBody(
* required=true,
* @OA\JsonContent(ref="#/components/schemas/FillableInvoice")
* ),
* @OA\Response( * @OA\Response(
* response=200, * response=200,
* description="Returns the saved invoice object", * description="Returns the saved invoice object",

View File

@ -180,6 +180,25 @@ class MigrationController extends BaseController
$company->vendors()->forceDelete(); $company->vendors()->forceDelete();
$company->expenses()->forceDelete(); $company->expenses()->forceDelete();
$settings = $company->settings;
/* Reset all counters to 1 after a purge */
$settings->recurring_invoice_number_counter = 1;
$settings->invoice_number_counter = 1;
$settings->quote_number_counter = 1;
$settings->client_number_counter = 1;
$settings->credit_number_counter = 1;
$settings->task_number_counter = 1;
$settings->expense_number_counter = 1;
$settings->recurring_expense_number_counter = 1;
$settings->recurring_quote_number_counter = 1;
$settings->vendor_number_counter = 1;
$settings->ticket_number_counter = 1;
$settings->payment_number_counter = 1;
$settings->project_number_counter = 1;
$company->settings = $settings;
$company->save(); $company->save();
return response()->json(['message' => 'Settings preserved'], 200); return response()->json(['message' => 'Settings preserved'], 200);

View File

@ -0,0 +1,37 @@
<?php
/**
* @OA\Schema(
* schema="FillableInvoice",
* type="object",
* @OA\Property(property="assigned_user_id", type="string", example="", description="__________"),
* @OA\Property(property="client_id", type="string", example="", description="________"),
* @OA\Property(property="number", type="string", example="INV_101", description="The invoice number - is a unique alpha numeric number per invoice per company"),
* @OA\Property(property="po_number", type="string", example="", description="________"),
* @OA\Property(property="terms", type="string", example="", description="________"),
* @OA\Property(property="public_notes", type="string", example="", description="________"),
* @OA\Property(property="private_notes", type="string", example="", description="________"),
* @OA\Property(property="footer", type="string", example="", description="________"),
* @OA\Property(property="custom_value1", type="string", example="", description="________"),
* @OA\Property(property="custom_value2", type="string", example="", description="________"),
* @OA\Property(property="custom_value3", type="string", example="", description="________"),
* @OA\Property(property="custom_value4", type="string", example="", description="________"),
* @OA\Property(property="tax_name1", type="string", example="", description="________"),
* @OA\Property(property="tax_name2", type="string", example="", description="________"),
* @OA\Property(property="tax_rate1", type="number", example="10.00", description="_________"),
* @OA\Property(property="tax_rate2", type="number", example="10.00", description="_________"),
* @OA\Property(property="tax_name3", type="string", example="", description="________"),
* @OA\Property(property="tax_rate3", type="number", example="10.00", description="_________"),
* @OA\Property(property="line_items", type="object", example="", description="_________"),
* @OA\Property(property="discount", type="number", example="10.00", description="_________"),
* @OA\Property(property="partial", type="number", example="10.00", description="_________"),
* @OA\Property(property="is_amount_discount", type="boolean", example="1", description="_________"),
* @OA\Property(property="uses_inclusive_taxes", type="boolean", example="1", description="Defines the type of taxes used as either inclusive or exclusive"),
* @OA\Property(property="date", type="string", example="1994-07-30", description="The Invoice Date"),
* @OA\Property(property="partial_due_date", type="string", example="1994-07-30", description="_________"),
* @OA\Property(property="due_date", type="string", example="1994-07-30", description="_________"),
* @OA\Property(property="custom_surcharge1", type="number", example="10.00", description="First Custom Surcharge"),
* @OA\Property(property="custom_surcharge2", type="number", example="10.00", description="Second Custom Surcharge"),
* @OA\Property(property="custom_surcharge3", type="number", example="10.00", description="Third Custom Surcharge"),
* @OA\Property(property="custom_surcharge4", type="number", example="10.00", description="Fourth Custom Surcharge")
* )
*/

View File

@ -0,0 +1,47 @@
<?php
/**
* @OA\Schema(
* schema="RecurringExpense",
* type="object",
* @OA\Property(property="id", type="string", example="Opnel5aKBz", description="_________"),
* @OA\Property(property="user_id", type="string", example="", description="__________"),
* @OA\Property(property="assigned_user_id", type="string", example="", description="__________"),
* @OA\Property(property="company_id", type="string", example="", description="________"),
* @OA\Property(property="client_id", type="string", example="", description="________"),
* @OA\Property(property="invoice_id", type="string", example="", description="________"),
* @OA\Property(property="bank_id", type="string", example="", description="________"),
* @OA\Property(property="invoice_currency_id", type="string", example="", description="________"),
* @OA\Property(property="expense_currency_id", type="string", example="", description="________"),
* @OA\Property(property="invoice_category_id", type="string", example="", description="________"),
* @OA\Property(property="payment_type_id", type="string", example="", description="________"),
* @OA\Property(property="recurring_expense_id", type="string", example="", description="________"),
* @OA\Property(property="private_notes", type="string", example="", description="________"),
* @OA\Property(property="public_notes", type="string", example="", description="________"),
* @OA\Property(property="transaction_reference", type="string", example="", description="________"),
* @OA\Property(property="transcation_id", type="string", example="", description="________"),
* @OA\Property(property="custom_value1", type="string", example="", description="________"),
* @OA\Property(property="custom_value2", type="string", example="", description="________"),
* @OA\Property(property="custom_value3", type="string", example="", description="________"),
* @OA\Property(property="custom_value4", type="string", example="", description="________"),
* @OA\Property(property="tax_name1", type="string", example="", description="________"),
* @OA\Property(property="tax_name2", type="string", example="", description="________"),
* @OA\Property(property="tax_rate1", type="number", format="float", example="10.00", description="_________"),
* @OA\Property(property="tax_rate2", type="number", format="float", example="10.00", description="_________"),
* @OA\Property(property="tax_name3", type="string", example="", description="________"),
* @OA\Property(property="tax_rate3", type="number", format="float", example="10.00", description="_________"),
* @OA\Property(property="amount", type="number", format="float", example="10.00", description="_________"),
* @OA\Property(property="frequency_id", type="number", format="int", example="1", description="_________"),
* @OA\Property(property="remaining_cycles", type="number", format="int", example="1", description="_________"),
* @OA\Property(property="foreign_amount", type="number", format="float", example="10.00", description="_________"),
* @OA\Property(property="exchange_rate", type="number", format="float", example="0.80", description="_________"),
* @OA\Property(property="date", type="string", example="", description="________"),
* @OA\Property(property="payment_date", type="string", example="", description="________"),
* @OA\Property(property="should_be_invoiced", type="boolean", example=true, description="_________"),
* @OA\Property(property="is_deleted", type="boolean", example=true, description="_________"),
* @OA\Property(property="last_sent_date", type="string", format="date", example="1994-07-30", description="The Date it was sent last"),
* @OA\Property(property="next_send_date", type="string", format="date", example="1994-07-30", description="The next send date"),
* @OA\Property(property="invoice_documents", type="boolean", example=true, description=""),
* @OA\Property(property="updated_at", type="number", format="integer", example="1434342123", description="Timestamp"),
* @OA\Property(property="archived_at", type="number", format="integer", example="1434342123", description="Timestamp"),
* )
*/

View File

@ -10,8 +10,8 @@
* email="contact@invoiceninja.com" * email="contact@invoiceninja.com"
* ), * ),
* @OA\License( * @OA\License(
* name="Attribution Assurance License", * name="Elastic License",
* url="https://opensource.org/licenses/AAL" * url="https://www.elastic.co/licensing/elastic-license"
* ), * ),
* ), * ),
* @OA\Server( * @OA\Server(

View File

@ -20,6 +20,7 @@ use App\Jobs\Util\SchedulerCheck;
use App\Jobs\Util\VersionCheck; use App\Jobs\Util\VersionCheck;
use App\Models\Account; use App\Models\Account;
use App\Utils\CurlUtils; use App\Utils\CurlUtils;
use App\Utils\HostedPDF\NinjaPdf;
use App\Utils\Ninja; use App\Utils\Ninja;
use App\Utils\SystemHealth; use App\Utils\SystemHealth;
use App\Utils\Traits\AppSetup; use App\Utils\Traits\AppSetup;
@ -245,7 +246,7 @@ class SetupController extends Controller
public function checkPdf(Request $request) public function checkPdf(Request $request)
{ {
try { try {
if (config('ninja.phantomjs_pdf_generation')) { if (config('ninja.pdf_generator') == 'phantom') {
return $this->testPhantom(); return $this->testPhantom();
} }

View File

@ -0,0 +1,39 @@
<?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\Http\Requests\GroupSetting;
use App\Http\Requests\Request;
class UploadGroupSettingRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() : bool
{
return auth()->user()->can('edit', $this->group_setting);
}
public function rules()
{
$rules = [];
if($this->input('documents'))
$rules['documents'] = 'file|mimes:html,csv,png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx|max:2000000';
return $rules;
}
}

View File

@ -70,6 +70,13 @@ class StoreInvoiceRequest extends Request
$input['amount'] = 0; $input['amount'] = 0;
$input['balance'] = 0; $input['balance'] = 0;
if(array_key_exists('tax_rate1', $input) && is_null($input['tax_rate1']))
$input['tax_rate1'] = 0;
if(array_key_exists('tax_rate2', $input) && is_null($input['tax_rate2']))
$input['tax_rate2'] = 0;
if(array_key_exists('tax_rate3', $input) && is_null($input['tax_rate3']))
$input['tax_rate3'] = 0;
$this->replace($input); $this->replace($input);
} }
} }

View File

@ -48,7 +48,7 @@ class StoreUserRequest extends Request
} }
if (Ninja::isHosted()) { if (Ninja::isHosted()) {
$rules['hosted_users'] = new CanAddUserRule(auth()->user()->company()->account); $rules['id'] = new CanAddUserRule();
} }
return $rules; return $rules;

View File

@ -18,11 +18,9 @@ use Illuminate\Contracts\Validation\Rule;
*/ */
class CanAddUserRule implements Rule class CanAddUserRule implements Rule
{ {
public $account;
public function __construct($account) public function __construct()
{ {
$this->account = $account;
} }
/** /**
@ -32,7 +30,7 @@ class CanAddUserRule implements Rule
*/ */
public function passes($attribute, $value) public function passes($attribute, $value)
{ {
return $this->account->users->count() < $this->account->num_users; return auth()->user()->company()->account->users->count() < auth()->user()->company()->account->num_users;
} }
/** /**
@ -40,6 +38,6 @@ class CanAddUserRule implements Rule
*/ */
public function message() public function message()
{ {
return ctrans('texts.limit_users', ['limit' => $this->account->num_users]); return ctrans('texts.limit_users', ['limit' => auth()->user()->company()->account->num_users]);
} }
} }

View File

@ -0,0 +1,40 @@
<?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\Http\ValidationRules;
use App\Libraries\MultiDB;
use Illuminate\Contracts\Validation\Rule;
/**
* Class ValidAmount.
*/
class ValidAmount implements Rule
{
/**
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
return trim($value, '-1234567890.,') === '';
}
/**
* @return string
*/
public function message()
{
return ctrans('texts.invalid_amount');
}
}

View File

@ -887,6 +887,7 @@ class CompanyImport implements ShouldQueue
[ [
'hashed_id', 'hashed_id',
'company_id', 'company_id',
'backup',
], ],
[ [
['users' => 'user_id'], ['users' => 'user_id'],
@ -1192,6 +1193,10 @@ class CompanyImport implements ShouldQueue
} }
if(array_key_exists('deleted_at', $obj_array) && $obj_array['deleted_at'] > 1){
$obj_array['deleted_at'] = now();
}
$activity_invitation_key = false; $activity_invitation_key = false;
if($class == 'App\Models\Activity'){ if($class == 'App\Models\Activity'){
@ -1270,6 +1275,10 @@ class CompanyImport implements ShouldQueue
} }
} }
if(array_key_exists('deleted_at', $obj_array) && $obj_array['deleted_at'] > 1){
$obj_array['deleted_at'] = now();
}
/* New to convert product ids from old hashes to new hashes*/ /* New to convert product ids from old hashes to new hashes*/
if($class == 'App\Models\Subscription'){ if($class == 'App\Models\Subscription'){
$obj_array['product_ids'] = $this->recordProductIds($obj_array['product_ids']); $obj_array['product_ids'] = $this->recordProductIds($obj_array['product_ids']);
@ -1320,6 +1329,10 @@ class CompanyImport implements ShouldQueue
} }
} }
if(array_key_exists('deleted_at', $obj_array) && $obj_array['deleted_at'] > 1){
$obj_array['deleted_at'] = now();
}
/* New to convert product ids from old hashes to new hashes*/ /* New to convert product ids from old hashes to new hashes*/
if($class == 'App\Models\Subscription'){ if($class == 'App\Models\Subscription'){
//$obj_array['product_ids'] = $this->recordProductIds($obj_array['product_ids']); //$obj_array['product_ids'] = $this->recordProductIds($obj_array['product_ids']);

View File

@ -13,12 +13,14 @@ namespace App\Jobs\RecurringInvoice;
use App\DataMapper\Analytics\SendRecurringFailure; use App\DataMapper\Analytics\SendRecurringFailure;
use App\Events\Invoice\InvoiceWasEmailed; use App\Events\Invoice\InvoiceWasEmailed;
use App\Factory\InvoiceInvitationFactory;
use App\Factory\RecurringInvoiceToInvoiceFactory; use App\Factory\RecurringInvoiceToInvoiceFactory;
use App\Jobs\Entity\EmailEntity; use App\Jobs\Entity\EmailEntity;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\RecurringInvoice; use App\Models\RecurringInvoice;
use App\Utils\Ninja; use App\Utils\Ninja;
use App\Utils\Traits\GeneratesCounter; use App\Utils\Traits\GeneratesCounter;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\MakesInvoiceValues; use App\Utils\Traits\MakesInvoiceValues;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
@ -32,6 +34,7 @@ class SendRecurring implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use GeneratesCounter; use GeneratesCounter;
use MakesHash;
public $recurring_invoice; public $recurring_invoice;
@ -58,16 +61,6 @@ class SendRecurring implements ShouldQueue
*/ */
public function handle() : void public function handle() : void
{ {
//reset all contacts here
// $this->recurring_invoice->client->contacts()->update(['send_email' => false]);
// $this->recurring_invoice->invitations->each(function ($invitation){
// $contact = $invitation->contact;
// $contact->send_email = true;
// $contact->save();
// });
// Generate Standard Invoice // Generate Standard Invoice
$invoice = RecurringInvoiceToInvoiceFactory::create($this->recurring_invoice, $this->recurring_invoice->client); $invoice = RecurringInvoiceToInvoiceFactory::create($this->recurring_invoice, $this->recurring_invoice->client);
@ -86,10 +79,12 @@ class SendRecurring implements ShouldQueue
$invoice = $invoice->service() $invoice = $invoice->service()
->markSent() ->markSent()
->applyNumber() ->applyNumber()
->createInvitations() //need to only link invitations to those in the recurring invoice // ->createInvitations() //need to only link invitations to those in the recurring invoice
->fillDefaults() ->fillDefaults()
->save(); ->save();
$invoice = $this->createRecurringInvitations($invoice);
} }
else{ else{
@ -115,6 +110,16 @@ class SendRecurring implements ShouldQueue
$this->recurring_invoice->save(); $this->recurring_invoice->save();
/*
if ($this->recurring_invoice->company->pause_recurring_until_paid){
$this->recurring_invoice->service()
->stop();
}
*/
//Admin notification for recurring invoice sent. //Admin notification for recurring invoice sent.
if ($invoice->invitations->count() >= 1 ) { if ($invoice->invitations->count() >= 1 ) {
$invoice->entityEmailEvent($invoice->invitations->first(), 'invoice', 'email_template_invoice'); $invoice->entityEmailEvent($invoice->invitations->first(), 'invoice', 'email_template_invoice');
@ -154,6 +159,28 @@ class SendRecurring implements ShouldQueue
} }
/**
* Only create the invitations that are defined on the recurring invoice.
* @param Invoice $invoice
* @return Invoice $invoice
*/
private function createRecurringInvitations($invoice) :Invoice
{
$this->recurring_invoice->invitations->each(function ($recurring_invitation) use($invoice){
$ii = InvoiceInvitationFactory::create($invoice->company_id, $invoice->user_id);
$ii->key = $this->createDbHash(config('database.default'));
$ii->invoice_id = $invoice->id;
$ii->client_contact_id = $recurring_invitation->client_contact_id;
$ii->save();
});
return $invoice->fresh();
}
public function failed($exception = null) public function failed($exception = null)
{ {
nlog('the job failed'); nlog('the job failed');

View File

@ -174,6 +174,32 @@ class MultiDB
return null; return null;
} }
/**
* @param array $data
* @return User|null
*/
public static function findContact(array $search) : ?ClientContact
{
if (! config('ninja.db.multi_db_enabled'))
return ClientContact::where($search)->first();
$current_db = config('database.default');
foreach (self::$dbs as $db) {
$user = ClientContact::on($db)->where($search)->first();
if ($user) {
self::setDb($db);
return $user;
}
}
self::setDB($current_db);
return null;
}
public static function contactFindAndSetDb($token) :bool public static function contactFindAndSetDb($token) :bool
{ {
$current_db = config('database.default'); $current_db = config('database.default');

View File

@ -42,6 +42,9 @@ class EntityViewedObject
public function build() public function build()
{ {
if(!$this->entity)
return;
App::forgetInstance('translator'); App::forgetInstance('translator');
/* Init a new copy of the translator*/ /* Init a new copy of the translator*/
$t = app('translator'); $t = app('translator');

View File

@ -69,7 +69,7 @@ class SupportMessageSent extends Mailable
if(Ninja::isHosted()) if(Ninja::isHosted())
$subject = "{$priority}Hosted-{$db}-{$is_large}{$platform}{$migrated} :: {$plan} :: ".date('M jS, g:ia'); $subject = "{$priority}Hosted-{$db}-{$is_large}{$platform}{$migrated} :: {$plan} :: ".date('M jS, g:ia');
else else
$subject = "{$priority}Self Hosted :: {$plan} :: {$platform} :: ".date('M jS, g:ia'); $subject = "{$priority}Self Hosted :: {$plan} :: {$is_large}{$platform}{$migrated} :: ".date('M jS, g:ia');
return $this->from(config('mail.from.address'), $user->present()->name()) return $this->from(config('mail.from.address'), $user->present()->name())
->replyTo($user->email, $user->present()->name()) ->replyTo($user->email, $user->present()->name())

View File

@ -11,6 +11,9 @@
namespace App\Models; namespace App\Models;
use App\Models\Client;
use Illuminate\Support\Facades\Storage;
class Backup extends BaseModel class Backup extends BaseModel
{ {
public function getEntityType() public function getEntityType()
@ -22,4 +25,26 @@ class Backup extends BaseModel
{ {
return $this->belongsTo(Activity::class); return $this->belongsTo(Activity::class);
} }
public function storeRemotely(string $html, Client $client)
{
if(strlen($html) == 0)
return;
$path = $client->backup_path() . "/";
$filename = now()->format('Y_m_d'). "_" . md5(time()) . ".html";
$file_path = $path . $filename;
Storage::disk(config('filesystems.default'))->makeDirectory($path, 0775);
Storage::disk(config('filesystems.default'))->put($file_path, $html);
if(Storage::disk(config('filesystems.default'))->exists($file_path)){
$this->html_backup = '';
$this->filename = $file_path;
$this->save();
}
}
} }

View File

@ -518,6 +518,30 @@ class Client extends BaseModel implements HasLocalePreference
} }
if ($this->currency()->code == 'EUR' && in_array(GatewayType::SEPA, array_column($pms, 'gateway_type_id'))) {
foreach ($pms as $pm) {
if ($pm['gateway_type_id'] == GatewayType::SEPA) {
$cg = CompanyGateway::find($pm['company_gateway_id']);
if ($cg && $cg->fees_and_limits->{GatewayType::SEPA}->is_enabled) {
return $cg;
}
}
}
}
if ($this->country->iso_3166_3 == 'GBR' && in_array(GatewayType::DIRECT_DEBIT, array_column($pms, 'gateway_type_id'))) {
foreach ($pms as $pm) {
if ($pm['gateway_type_id'] == GatewayType::DIRECT_DEBIT) {
$cg = CompanyGateway::find($pm['company_gateway_id']);
if ($cg && $cg->fees_and_limits->{GatewayType::DIRECT_DEBIT}->is_enabled) {
return $cg;
}
}
}
}
return null; return null;
} }
@ -532,6 +556,10 @@ class Client extends BaseModel implements HasLocalePreference
if ($this->currency()->code == 'EUR') { if ($this->currency()->code == 'EUR') {
return GatewayType::SEPA; return GatewayType::SEPA;
} }
if ($this->currency()->code == 'GBP') {
return GatewayType::DIRECT_DEBIT;
}
} }
public function getCurrencyCode() public function getCurrencyCode()
@ -717,6 +745,12 @@ class Client extends BaseModel implements HasLocalePreference
})->first()->locale; })->first()->locale;
} }
public function backup_path()
{
return $this->company->company_key.'/'.$this->client_hash.'/backups';
}
public function invoice_filepath($invitation) public function invoice_filepath($invitation)
{ {
$contact_key = $invitation->contact->contact_key; $contact_key = $invitation->contact->contact_key;

View File

@ -112,9 +112,9 @@ class Gateway extends StaticModel
GatewayType::GIROPAY => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']], GatewayType::GIROPAY => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
GatewayType::EPS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']], GatewayType::EPS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
GatewayType::BANCONTACT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']], GatewayType::BANCONTACT => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
GatewayType::BECS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
GatewayType::IDEAL => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']], GatewayType::IDEAL => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']],
]; GatewayType::ACSS => ['refund' => true, 'token_billing' => true, 'webhooks' => ['source.chargeable', 'charge.succeeded']]];
case 39: case 39:
return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']]]; //Checkout return [GatewayType::CREDIT_CARD => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']]]; //Checkout
break; break;
@ -155,7 +155,9 @@ class Gateway extends StaticModel
break; break;
case 52: case 52:
return [ return [
GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']] // GoCardless GatewayType::BANK_TRANSFER => ['refund' => true, 'token_billing' => true, 'webhooks' => [' ']], // GoCardless
GatewayType::DIRECT_DEBIT => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']],
GatewayType::SEPA => ['refund' => false, 'token_billing' => true, 'webhooks' => [' ']]
]; ];
break; break;
case 58: case 58:

View File

@ -11,6 +11,8 @@
namespace App\Models; namespace App\Models;
use function Symfony\Component\String\s;
class GatewayType extends StaticModel class GatewayType extends StaticModel
{ {
public $timestamps = false; public $timestamps = false;
@ -32,6 +34,9 @@ class GatewayType extends StaticModel
const GIROPAY = 15; const GIROPAY = 15;
const PRZELEWY24 = 16; const PRZELEWY24 = 16;
const EPS = 17; const EPS = 17;
const DIRECT_DEBIT = 18;
const ACSS = 19;
const BECS = 20;
public function gateway() public function gateway()
{ {
@ -78,6 +83,12 @@ class GatewayType extends StaticModel
return ctrans('texts.giropay'); return ctrans('texts.giropay');
case self::EPS: case self::EPS:
return ctrans('texts.eps'); return ctrans('texts.eps');
case self::BECS:
return ctrans('tets.becs');
case self::ACSS:
return ctrans('texts.acss');
case self::DIRECT_DEBIT:
return ctrans('texts.payment_type_direct_debit');
default: default:
return 'Undefined.'; return 'Undefined.';
break; break;

View File

@ -50,6 +50,9 @@ class PaymentType extends StaticModel
const GIROPAY = 39; const GIROPAY = 39;
const PRZELEWY24 = 40; const PRZELEWY24 = 40;
const EPS = 41; const EPS = 41;
const DIRECT_DEBIT = 42;
const BECS = 43;
const ACSS = 44;
public static function parseCardType($cardName) public static function parseCardType($cardName)
{ {

View File

@ -308,7 +308,7 @@ class BaseDriver extends AbstractPaymentDriver
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->get(); $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->get();
$invoices->each(function ($invoice) { $invoices->each(function ($invoice) {
$invoice->service()->removeUnpaidGatewayFees(); $invoice->service()->removeUnpaidGatewayFees()->save();
}); });
} }

View File

@ -140,7 +140,8 @@ class PayPal
SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_BRAINTREE, SystemLog::TYPE_BRAINTREE,
$this->braintree->client $this->braintree->client,
$this->braintree->client->company,
); );
return redirect()->route('client.payments.show', ['payment' => $this->braintree->encodePrimaryKey($payment->id)]); return redirect()->route('client.payments.show', ['payment' => $this->braintree->encodePrimaryKey($payment->id)]);

View File

@ -56,6 +56,7 @@ class ACH implements MethodInterface
try { try {
$redirect = $this->go_cardless->gateway->redirectFlows()->create([ $redirect = $this->go_cardless->gateway->redirectFlows()->create([
"params" => [ "params" => [
"scheme" => "ach",
"session_token" => $session_token, "session_token" => $session_token,
"success_redirect_url" => route('client.payment_methods.confirm', [ "success_redirect_url" => route('client.payment_methods.confirm', [
'method' => GatewayType::BANK_TRANSFER, 'method' => GatewayType::BANK_TRANSFER,

View File

@ -0,0 +1,248 @@
<?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://opensource.org/licenses/AAL
*/
namespace App\PaymentDrivers\GoCardless;
use App\Exceptions\PaymentFailed;
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use App\Http\Requests\Request;
use App\Jobs\Mail\PaymentFailureMailer;
use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\Models\Payment;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\Common\MethodInterface;
use App\PaymentDrivers\GoCardlessPaymentDriver;
use App\Utils\Traits\MakesHash;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Redirector;
use Illuminate\View\View;
class DirectDebit implements MethodInterface
{
use MakesHash;
protected GoCardlessPaymentDriver $go_cardless;
public function __construct(GoCardlessPaymentDriver $go_cardless)
{
$this->go_cardless = $go_cardless;
$this->go_cardless->init();
}
/**
* Handle authorization for Direct Debit.
*
* @param array $data
* @return Redirector|RedirectResponse|void
*/
public function authorizeView(array $data)
{
$session_token = \Illuminate\Support\Str::uuid()->toString();
try {
$redirect = $this->go_cardless->gateway->redirectFlows()->create([
'params' => [
'session_token' => $session_token,
'success_redirect_url' => route('client.payment_methods.confirm', [
'method' => GatewayType::DIRECT_DEBIT,
'session_token' => $session_token,
]),
'prefilled_customer' => [
'given_name' => auth('contact')->user()->first_name,
'family_name' => auth('contact')->user()->last_name,
'email' => auth('contact')->user()->email,
'address_line1' => auth('contact')->user()->client->address1,
'city' => auth('contact')->user()->client->city,
'postal_code' => auth('contact')->user()->client->postal_code,
],
],
]);
return redirect(
$redirect->redirect_url
);
} catch (\Exception $exception) {
return $this->processUnsuccessfulAuthorization($exception);
}
}
/**
* Handle unsuccessful authorization.
*
* @param Exception $exception
* @throws PaymentFailed
* @return void
*/
public function processUnsuccessfulAuthorization(\Exception $exception): void
{
SystemLogger::dispatch(
$exception->getMessage(),
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_GOCARDLESS,
$this->go_cardless->client,
$this->go_cardless->client->company,
);
throw new PaymentFailed($exception->getMessage(), $exception->getCode());
}
/**
* Handle authorization response for Direct Debit.
*
* @param Request $request
* @return RedirectResponse|void
*/
public function authorizeResponse(Request $request)
{
try {
$redirect_flow = $this->go_cardless->gateway->redirectFlows()->complete(
$request->redirect_flow_id,
['params' => [
'session_token' => $request->session_token
]],
);
$payment_meta = new \stdClass;
$payment_meta->brand = ctrans('texts.payment_type_direct_debit');
$payment_meta->type = GatewayType::DIRECT_DEBIT;
$payment_meta->state = 'authorized';
$data = [
'payment_meta' => $payment_meta,
'token' => $redirect_flow->links->mandate,
'payment_method_id' => GatewayType::DIRECT_DEBIT,
];
$payment_method = $this->go_cardless->storeGatewayToken($data, ['gateway_customer_reference' => $redirect_flow->links->customer]);
return redirect()->route('client.payment_methods.show', $payment_method->hashed_id);
} catch (\Exception $exception) {
return $this->processUnsuccessfulAuthorization($exception);
}
}
/**
* Payment view for Direct Debit.
*
* @param array $data
* @return View
*/
public function paymentView(array $data): View
{
$data['gateway'] = $this->go_cardless;
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
return render('gateways.gocardless.direct_debit.pay', $data);
}
public function paymentResponse(PaymentResponseRequest $request)
{
$token = ClientGatewayToken::find(
$this->decodePrimaryKey($request->source)
)->firstOrFail();
try {
$payment = $this->go_cardless->gateway->payments()->create([
'params' => [
'amount' => $request->amount,
'currency' => $request->currency,
'metadata' => [
'payment_hash' => $this->go_cardless->payment_hash->hash,
],
'links' => [
'mandate' => $token->token,
],
],
]);
if ($payment->status === 'pending_submission') {
return $this->processPendingPayment($payment, ['token' => $token->hashed_id]);
}
return $this->processUnsuccessfulPayment($payment);
} catch (\Exception $exception) {
throw new PaymentFailed($exception->getMessage(), $exception->getCode());
}
}
/**
* Handle pending payments for Direct Debit.
*
* @param ResourcesPayment $payment
* @param array $data
* @return RedirectResponse
*/
public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = [])
{
$data = [
'payment_method' => $data['token'],
'payment_type' => PaymentType::DIRECT_DEBIT,
'amount' => $this->go_cardless->payment_hash->data->amount_with_fee,
'transaction_reference' => $payment->id,
'gateway_type_id' => GatewayType::DIRECT_DEBIT,
];
$payment = $this->go_cardless->createPayment($data, Payment::STATUS_PENDING);
SystemLogger::dispatch(
['response' => $payment, 'data' => $data],
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_GOCARDLESS,
$this->go_cardless->client,
$this->go_cardless->client->company,
);
return redirect()->route('client.payments.show', ['payment' => $this->go_cardless->encodePrimaryKey($payment->id)]);
}
/**
* Process unsuccessful payments for Direct Debit.
*
* @param ResourcesPayment $payment
* @return never
*/
public function processUnsuccessfulPayment(\GoCardlessPro\Resources\Payment $payment)
{
PaymentFailureMailer::dispatch($this->go_cardless->client, $payment->status, $this->go_cardless->client->company, $this->go_cardless->payment_hash->data->amount_with_fee);
PaymentFailureMailer::dispatch(
$this->go_cardless->client,
$payment,
$this->go_cardless->client->company,
$payment->amount
);
$message = [
'server_response' => $payment,
'data' => $this->go_cardless->payment_hash->data,
];
SystemLogger::dispatch(
$message,
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_GOCARDLESS,
$this->go_cardless->client,
$this->go_cardless->client->company,
);
throw new PaymentFailed('Failed to process the payment.', 500);
}
}

View File

@ -0,0 +1,250 @@
<?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://opensource.org/licenses/AAL
*/
namespace App\PaymentDrivers\GoCardless;
use App\Exceptions\PaymentFailed;
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use App\Http\Requests\Request;
use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\Models\Payment;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\Common\MethodInterface;
use App\PaymentDrivers\GoCardlessPaymentDriver;
use App\Utils\Traits\MakesHash;
use Exception;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Redirector;
use Illuminate\View\View;
class SEPA implements MethodInterface
{
use MakesHash;
protected GoCardlessPaymentDriver $go_cardless;
public function __construct(GoCardlessPaymentDriver $go_cardless)
{
$this->go_cardless = $go_cardless;
$this->go_cardless->init();
}
/**
* Handle authorization for SEPA.
*
* @param array $data
* @return Redirector|RedirectResponse|void
*/
public function authorizeView(array $data)
{
$session_token = \Illuminate\Support\Str::uuid()->toString();
try {
$redirect = $this->go_cardless->gateway->redirectFlows()->create([
'params' => [
'scheme' => 'sepa_core',
'session_token' => $session_token,
'success_redirect_url' => route('client.payment_methods.confirm', [
'method' => GatewayType::SEPA,
'session_token' => $session_token,
]),
'prefilled_customer' => [
'given_name' => auth('contact')->user()->first_name,
'family_name' => auth('contact')->user()->last_name,
'email' => auth('contact')->user()->email,
'address_line1' => auth('contact')->user()->client->address1,
'city' => auth('contact')->user()->client->city,
'postal_code' => auth('contact')->user()->client->postal_code,
],
],
]);
return redirect(
$redirect->redirect_url
);
} catch (\Exception $exception) {
return $this->processUnsuccessfulAuthorization($exception);
}
}
/**
* Handle unsuccessful authorization for SEPA.
*
* @param Exception $exception
* @return void
*/
public function processUnsuccessfulAuthorization(\Exception $exception): void
{
$this->go_cardless->sendFailureMail($exception->getMessage());
SystemLogger::dispatch(
$exception->getMessage(),
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_GOCARDLESS,
$this->go_cardless->client,
$this->go_cardless->client->company,
);
throw new PaymentFailed($exception->getMessage(), $exception->getCode());
}
/**
* Handle authorization response for SEPA.
*
* @param Request $request
* @return RedirectResponse|void
*/
public function authorizeResponse(Request $request)
{
try {
$redirect_flow = $this->go_cardless->gateway->redirectFlows()->complete(
$request->redirect_flow_id,
['params' => [
'session_token' => $request->session_token
]],
);
$payment_meta = new \stdClass;
$payment_meta->brand = ctrans('texts.sepa');
$payment_meta->type = GatewayType::SEPA;
$payment_meta->state = 'authorized';
$data = [
'payment_meta' => $payment_meta,
'token' => $redirect_flow->links->mandate,
'payment_method_id' => GatewayType::SEPA,
];
$payment_method = $this->go_cardless->storeGatewayToken($data, ['gateway_customer_reference' => $redirect_flow->links->customer]);
return redirect()->route('client.payment_methods.show', $payment_method->hashed_id);
} catch (\Exception $exception) {
return $this->processUnsuccessfulAuthorization($exception);
}
}
/**
* Payment view for SEPA.
*
* @param array $data
* @return View
*/
public function paymentView(array $data): View
{
$data['gateway'] = $this->go_cardless;
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
return render('gateways.gocardless.sepa.pay', $data);
}
/**
* Handle the payment page for SEPA.
*
* @param PaymentResponseRequest $request
* @return RedirectResponse|App\PaymentDrivers\GoCardless\never|void
*/
public function paymentResponse(PaymentResponseRequest $request)
{
$token = ClientGatewayToken::find(
$this->decodePrimaryKey($request->source)
)->firstOrFail();
try {
$payment = $this->go_cardless->gateway->payments()->create([
'params' => [
'amount' => $request->amount,
'currency' => $request->currency,
'metadata' => [
'payment_hash' => $this->go_cardless->payment_hash->hash,
],
'links' => [
'mandate' => $token->token,
],
],
]);
if ($payment->status === 'pending_submission') {
return $this->processPendingPayment($payment, ['token' => $token->hashed_id]);
}
return $this->processUnsuccessfulPayment($payment);
} catch (\Exception $exception) {
throw new PaymentFailed($exception->getMessage(), $exception->getCode());
}
}
/**
* Handle pending payments for Direct Debit.
*
* @param ResourcesPayment $payment
* @param array $data
* @return RedirectResponse
*/
public function processPendingPayment(\GoCardlessPro\Resources\Payment $payment, array $data = [])
{
$data = [
'payment_method' => $data['token'],
'payment_type' => PaymentType::SEPA,
'amount' => $this->go_cardless->payment_hash->data->amount_with_fee,
'transaction_reference' => $payment->id,
'gateway_type_id' => GatewayType::SEPA,
];
$payment = $this->go_cardless->createPayment($data, Payment::STATUS_PENDING);
SystemLogger::dispatch(
['response' => $payment, 'data' => $data],
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_GOCARDLESS,
$this->go_cardless->client,
$this->go_cardless->client->company,
);
return redirect()->route('client.payments.show', ['payment' => $this->go_cardless->encodePrimaryKey($payment->id)]);
}
/**
* Process unsuccessful payments for Direct Debit.
*
* @param ResourcesPayment $payment
* @return never
*/
public function processUnsuccessfulPayment(\GoCardlessPro\Resources\Payment $payment)
{
$this->go_cardless->sendFailureMail(
$payment->status
);
$message = [
'server_response' => $payment,
'data' => $this->go_cardless->payment_hash->data,
];
SystemLogger::dispatch(
$message,
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_GOCARDLESS,
$this->go_cardless->client,
$this->go_cardless->client->company,
);
throw new PaymentFailed('Failed to process the payment.', 500);
}
}

View File

@ -37,6 +37,8 @@ class GoCardlessPaymentDriver extends BaseDriver
public static $methods = [ public static $methods = [
GatewayType::BANK_TRANSFER => \App\PaymentDrivers\GoCardless\ACH::class, GatewayType::BANK_TRANSFER => \App\PaymentDrivers\GoCardless\ACH::class,
GatewayType::DIRECT_DEBIT => \App\PaymentDrivers\GoCardless\DirectDebit::class,
GatewayType::SEPA => \App\PaymentDrivers\GoCardless\SEPA::class,
]; ];
const SYSTEM_LOG_TYPE = SystemLog::TYPE_GOCARDLESS; const SYSTEM_LOG_TYPE = SystemLog::TYPE_GOCARDLESS;
@ -62,6 +64,18 @@ class GoCardlessPaymentDriver extends BaseDriver
$types[] = GatewayType::BANK_TRANSFER; $types[] = GatewayType::BANK_TRANSFER;
} }
if (
$this->client
&& isset($this->client->country)
&& in_array($this->client->country->iso_3166_3, ['GBR'])
) {
$types[] = GatewayType::DIRECT_DEBIT;
}
if ($this->client->currency()->code === 'EUR') {
$types[] = GatewayType::SEPA;
}
return $types; return $types;
} }

View File

@ -11,6 +11,7 @@
namespace App\PaymentDrivers; namespace App\PaymentDrivers;
use App\Exceptions\SystemError;
use App\Jobs\Util\SystemLogger; use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken; use App\Models\ClientGatewayToken;
use App\Models\GatewayType; use App\Models\GatewayType;
@ -191,6 +192,9 @@ class PaytracePaymentDriver extends BaseDriver
$auth_data = json_decode($response); $auth_data = json_decode($response);
if(!property_exists($auth_data, 'access_token'))
throw new SystemError('Error authenticating with PayTrace');
$headers = []; $headers = [];
$headers[] = 'Content-type: application/json'; $headers[] = 'Content-type: application/json';
$headers[] = 'Authorization: Bearer '.$auth_data->access_token; $headers[] = 'Authorization: Bearer '.$auth_data->access_token;

View File

@ -0,0 +1,261 @@
<?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\PaymentDrivers\Stripe;
use App\Exceptions\PaymentFailed;
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use App\Http\Requests\Request;
use App\Jobs\Mail\NinjaMailerJob;
use App\Jobs\Mail\NinjaMailerObject;
use App\Jobs\Mail\PaymentFailureMailer;
use App\Jobs\Util\SystemLogger;
use App\Mail\Gateways\ACHVerificationNotification;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\Models\Payment;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\StripePaymentDriver;
use Stripe\Customer;
use Stripe\Exception\CardException;
use Stripe\Exception\InvalidRequestException;
class ACSS
{
/** @var StripePaymentDriver */
public StripePaymentDriver $stripe;
public function __construct(StripePaymentDriver $stripe)
{
$this->stripe = $stripe;
$this->stripe->init();
}
public function authorizeView($data)
{
$data['gateway'] = $this->stripe;
return render('gateways.stripe.acss.authorize', array_merge($data));
}
public function authorizeResponse(Request $request)
{
$stripe_response = json_decode($request->input('gateway_response'));
$customer = $this->stripe->findOrCreateCustomer();
try {
$source = Customer::createSource($customer->id, ['source' => $stripe_response->token->id], $this->stripe->stripe_connect_auth);
} catch (InvalidRequestException $e) {
throw new PaymentFailed($e->getMessage(), $e->getCode());
}
$client_gateway_token = $this->storePaymentMethod($source, $request->input('method'), $customer);
$verification = route('client.payment_methods.verification', ['payment_method' => $client_gateway_token->hashed_id, 'method' => GatewayType::ACSS], false);
$mailer = new NinjaMailerObject();
$mailer->mailable = new ACHVerificationNotification(
auth('contact')->user()->client->company,
route('client.contact_login', ['contact_key' => auth('contact')->user()->contact_key, 'next' => $verification])
);
$mailer->company = auth('contact')->user()->client->company;
$mailer->settings = auth('contact')->user()->client->company->settings;
$mailer->to_user = auth('contact')->user();
NinjaMailerJob::dispatch($mailer);
return redirect()->route('client.payment_methods.verification', ['payment_method' => $client_gateway_token->hashed_id, 'method' => GatewayType::ACSS]);
}
public function verificationView(ClientGatewayToken $token)
{
if (isset($token->meta->state) && $token->meta->state === 'authorized') {
return redirect()
->route('client.payment_methods.show', $token->hashed_id)
->with('message', __('texts.payment_method_verified'));
}
$data = [
'token' => $token,
'gateway' => $this->stripe,
];
return render('gateways.stripe.acss.verify', $data);
}
public function processVerification(Request $request, ClientGatewayToken $token)
{
$request->validate([
'transactions.*' => ['integer', 'min:1'],
]);
if (isset($token->meta->state) && $token->meta->state === 'authorized') {
return redirect()
->route('client.payment_methods.show', $token->hashed_id)
->with('message', __('texts.payment_method_verified'));
}
$bank_account = Customer::retrieveSource($request->customer, $request->source, [], $this->stripe->stripe_connect_auth);
try {
$bank_account->verify(['amounts' => request()->transactions]);
$meta = $token->meta;
$meta->state = 'authorized';
$token->meta = $meta;
$token->save();
return redirect()
->route('client.payment_methods.show', $token->hashed_id)
->with('message', __('texts.payment_method_verified'));
} catch (CardException $e) {
return back()->with('error', $e->getMessage());
}
}
public function paymentView(array $data)
{
$data['gateway'] = $this->stripe;
$data['return_url'] = $this->buildReturnUrl();
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
$data['client'] = $this->stripe->client;
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
$data['country'] = $this->stripe->client->country->iso_3166_2;
$intent = \Stripe\PaymentIntent::create([
'amount' => $data['stripe_amount'],
'currency' => $this->stripe->client->currency()->code,
'setup_future_usage' => 'off_session',
'payment_method_types' => ['acss_debit'],
'customer' => $this->stripe->findOrCreateCustomer(),
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
'payment_method_options' => [
'acss_debit' => [
'mandate_options' => [
'payment_schedule' => 'combined',
'interval_description' => 'when any invoice becomes due',
'transaction_type' => 'personal' // TODO: check if is company or personal https://stripe.com/docs/payments/acss-debit
],
'currency' => $this->stripe->client->currency()->code,
]
]
]);
$data['pi_client_secret'] = $intent->client_secret;
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
$this->stripe->payment_hash->save();
return render('gateways.stripe.acss.pay', $data);
}
private function buildReturnUrl(): string
{
return route('client.payments.response', [
'company_gateway_id' => $this->stripe->company_gateway->id,
'payment_hash' => $this->stripe->payment_hash->hash,
'payment_method_id' => GatewayType::ACSS,
]);
}
public function paymentResponse(PaymentResponseRequest $request)
{
$gateway_response = json_decode($request->gateway_response);
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();
if (property_exists($gateway_response, 'status') && $gateway_response->status == 'processing') {
$this->storePaymentMethod($gateway_response);
return $this->processSuccessfulPayment($gateway_response->id);
}
return $this->processUnsuccessfulPayment();
}
public function processSuccessfulPayment(string $payment_intent): \Illuminate\Http\RedirectResponse
{
$data = [
'payment_method' => $payment_intent,
'payment_type' => PaymentType::ACSS,
'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()),
'transaction_reference' => $payment_intent,
'gateway_type_id' => GatewayType::ACSS,
];
$payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING);
SystemLogger::dispatch(
['response' => $this->stripe->payment_hash->data, 'data' => $data],
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_STRIPE,
$this->stripe->client,
$this->stripe->client->company,
);
return redirect()->route('client.payments.show', $payment->hashed_id);
}
public function processUnsuccessfulPayment()
{
$server_response = $this->stripe->payment_hash->data;
PaymentFailureMailer::dispatch(
$this->stripe->client,
$server_response,
$this->stripe->client->company,
$this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency())
);
$message = [
'server_response' => $server_response,
'data' => $this->stripe->payment_hash->data,
];
SystemLogger::dispatch(
$message,
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_STRIPE,
$this->stripe->client,
$this->stripe->client->company,
);
throw new PaymentFailed('Failed to process the payment.', 500);
}
private function storePaymentMethod($intent)
{
try {
$method = $this->stripe->getStripePaymentMethod($intent->payment_method);
$payment_meta = new \stdClass;
$payment_meta->brand = (string) \sprintf('%s (%s)', $method->au_becs_debit->bank_code, ctrans('texts.acss'));
$payment_meta->last4 = (string) $method->au_becs_debit->last4;
$payment_meta->state = 'authorized';
$payment_meta->type = GatewayType::ACSS;
$data = [
'payment_meta' => $payment_meta,
'token' => $intent->payment_method,
'payment_method_id' => GatewayType::ACSS,
];
$this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $method->customer]);
} catch (\Exception $e) {
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
}
}
}

View File

@ -0,0 +1,160 @@
<?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\PaymentDrivers\Stripe;
use App\Exceptions\PaymentFailed;
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use App\Jobs\Mail\PaymentFailureMailer;
use App\Jobs\Util\SystemLogger;
use App\Models\GatewayType;
use App\Models\Payment;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\StripePaymentDriver;
class BECS
{
/** @var StripePaymentDriver */
public StripePaymentDriver $stripe;
public function __construct(StripePaymentDriver $stripe)
{
$this->stripe = $stripe;
$this->stripe->init();
}
public function authorizeView($data)
{
return render('gateways.stripe.becs.authorize', $data);
}
public function paymentView(array $data)
{
$data['gateway'] = $this->stripe;
$data['payment_method_id'] = GatewayType::BECS;
$data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency());
$data['client'] = $this->stripe->client;
$data['customer'] = $this->stripe->findOrCreateCustomer()->id;
$data['country'] = $this->stripe->client->country->iso_3166_2;
$data['payment_hash'] = $this->stripe->payment_hash->hash;
$intent = \Stripe\PaymentIntent::create([
'amount' => $data['stripe_amount'],
'currency' => $this->stripe->client->currency()->code,
'payment_method_types' => ['au_becs_debit'],
'setup_future_usage' => 'off_session',
'customer' => $this->stripe->findOrCreateCustomer(),
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
]);
$data['pi_client_secret'] = $intent->client_secret;
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
$this->stripe->payment_hash->save();
return render('gateways.stripe.becs.pay', $data);
}
public function paymentResponse(PaymentResponseRequest $request)
{
$gateway_response = json_decode($request->gateway_response);
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();
if (property_exists($gateway_response, 'status') && $gateway_response->status == 'processing') {
$this->stripe->init();
$this->storePaymentMethod($gateway_response);
return $this->processSuccessfulPayment($gateway_response->id);
}
return $this->processUnsuccessfulPayment();
}
public function processSuccessfulPayment(string $payment_intent): \Illuminate\Http\RedirectResponse
{
$data = [
'payment_method' => $payment_intent,
'payment_type' => PaymentType::BECS,
'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()),
'transaction_reference' => $payment_intent,
'gateway_type_id' => GatewayType::BECS,
];
$payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING);
SystemLogger::dispatch(
['response' => $this->stripe->payment_hash->data, 'data' => $data],
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_SUCCESS,
SystemLog::TYPE_STRIPE,
$this->stripe->client,
$this->stripe->client->company,
);
return redirect()->route('client.payments.show', $payment->hashed_id);
}
public function processUnsuccessfulPayment()
{
$server_response = $this->stripe->payment_hash->data;
PaymentFailureMailer::dispatch(
$this->stripe->client,
$server_response,
$this->stripe->client->company,
$this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency())
);
$message = [
'server_response' => $server_response,
'data' => $this->stripe->payment_hash->data,
];
SystemLogger::dispatch(
$message,
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_STRIPE,
$this->stripe->client,
$this->stripe->client->company,
);
throw new PaymentFailed('Failed to process the payment.', 500);
}
private function storePaymentMethod($intent)
{
try {
$method = $this->stripe->getStripePaymentMethod($intent->payment_method);
$payment_meta = new \stdClass;
$payment_meta->brand = (string) \sprintf('%s (%s)', $method->sepa_debit->bank_code, ctrans('texts.becs'));
$payment_meta->last4 = (string) $method->sepa_debit->last4;
$payment_meta->state = 'authorized';
$payment_meta->type = GatewayType::BECS;
$data = [
'payment_meta' => $payment_meta,
'token' => $intent->payment_method,
'payment_method_id' => GatewayType::BECS,
];
$this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $method->customer]);
} catch (\Exception $e) {
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
}
}
}

View File

@ -87,8 +87,9 @@ class Bancontact
/* @todo: https://github.com/invoiceninja/invoiceninja/pull/3789/files#r436175798 */ /* @todo: https://github.com/invoiceninja/invoiceninja/pull/3789/files#r436175798 */
//catch duplicate submissions. //catch duplicate submissions.
if(Payment::where('transaction_reference', $payment_intent)->exists()) if (Payment::where('transaction_reference', $payment_intent)->exists()) {
return redirect()->route('client.payments.index'); return redirect()->route('client.payments.index');
}
$this->stripe->init(); $this->stripe->init();

View File

@ -89,8 +89,9 @@ class EPS
$this->stripe->init(); $this->stripe->init();
//catch duplicate submissions. //catch duplicate submissions.
if(Payment::where('transaction_reference', $payment_intent)->exists()) if (Payment::where('transaction_reference', $payment_intent)->exists()) {
return redirect()->route('client.payments.index'); return redirect()->route('client.payments.index');
}
$data = [ $data = [
'payment_method' => $payment_intent, 'payment_method' => $payment_intent,

View File

@ -89,8 +89,9 @@ class GIROPAY
$this->stripe->init(); $this->stripe->init();
//catch duplicate submissions. //catch duplicate submissions.
if(Payment::where('transaction_reference', $payment_intent)->exists()) if (Payment::where('transaction_reference', $payment_intent)->exists()) {
return redirect()->route('client.payments.index'); return redirect()->route('client.payments.index');
}
$data = [ $data = [
'payment_method' => $payment_intent, 'payment_method' => $payment_intent,

View File

@ -89,8 +89,9 @@ class PRZELEWY24
$this->stripe->init(); $this->stripe->init();
//catch duplicate submissions. //catch duplicate submissions.
if(Payment::where('transaction_reference', $payment_intent)->exists()) if (Payment::where('transaction_reference', $payment_intent)->exists()) {
return redirect()->route('client.payments.index'); return redirect()->route('client.payments.index');
}
$data = [ $data = [
'payment_method' => $payment_intent, 'payment_method' => $payment_intent,

View File

@ -89,8 +89,9 @@ class iDeal
$this->stripe->init(); $this->stripe->init();
//catch duplicate submissions. //catch duplicate submissions.
if(Payment::where('transaction_reference', $payment_intent)->exists()) if (Payment::where('transaction_reference', $payment_intent)->exists()) {
return redirect()->route('client.payments.index'); return redirect()->route('client.payments.index');
}
$data = [ $data = [
'payment_method' => $payment_intent, 'payment_method' => $payment_intent,

View File

@ -38,6 +38,8 @@ use App\PaymentDrivers\Stripe\GIROPAY;
use App\PaymentDrivers\Stripe\iDeal; use App\PaymentDrivers\Stripe\iDeal;
use App\PaymentDrivers\Stripe\EPS; use App\PaymentDrivers\Stripe\EPS;
use App\PaymentDrivers\Stripe\Bancontact; use App\PaymentDrivers\Stripe\Bancontact;
use App\PaymentDrivers\Stripe\BECS;
use App\PaymentDrivers\Stripe\ACSS;
use App\PaymentDrivers\Stripe\UpdatePaymentMethods; use App\PaymentDrivers\Stripe\UpdatePaymentMethods;
use App\PaymentDrivers\Stripe\Utilities; use App\PaymentDrivers\Stripe\Utilities;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
@ -87,6 +89,8 @@ class StripePaymentDriver extends BaseDriver
GatewayType::IDEAL => iDeal::class, GatewayType::IDEAL => iDeal::class,
GatewayType::EPS => EPS::class, GatewayType::EPS => EPS::class,
GatewayType::BANCONTACT => Bancontact::class, GatewayType::BANCONTACT => Bancontact::class,
GatewayType::BECS => BECS::class,
GatewayType::ACSS => ACSS::class,
]; ];
const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE; const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE;
@ -200,6 +204,20 @@ class StripePaymentDriver extends BaseDriver
&& in_array($this->client->country->iso_3166_3, ["BEL"])) && in_array($this->client->country->iso_3166_3, ["BEL"]))
$types[] = GatewayType::BANCONTACT; $types[] = GatewayType::BANCONTACT;
if ($this->client
&& $this->client->currency()
&& ($this->client->currency()->code == 'AUD')
&& isset($this->client->country)
&& in_array($this->client->country->iso_3166_3, ["AUS", "DEU"]))
$types[] = GatewayType::BECS;
if ($this->client
&& $this->client->currency()
&& in_array($this->client->currency()->code, ['CAD', 'USD'])
&& isset($this->client->country)
&& in_array($this->client->country->iso_3166_3, ["CAN", "USA"]))
$types[] = GatewayType::ACSS;
return $types; return $types;
} }
@ -235,6 +253,10 @@ class StripePaymentDriver extends BaseDriver
return 'gateways.stripe.eps'; return 'gateways.stripe.eps';
case GatewayType::BANCONTACT: case GatewayType::BANCONTACT:
return 'gateways.stripe.bancontact'; return 'gateways.stripe.bancontact';
case GatewayType::BECS:
return 'gateways.stripe.becs';
case GatewayType::ACSS:
return 'gateways.stripe.acss';
default: default:
break; break;
} }

View File

@ -73,24 +73,25 @@ class ActivityRepository extends BaseRepository
if ($entity instanceof User || $entity->company->is_disabled) if ($entity instanceof User || $entity->company->is_disabled)
return; return;
$backup = new Backup();
if (get_class($entity) == Invoice::class if (get_class($entity) == Invoice::class
|| get_class($entity) == Quote::class || get_class($entity) == Quote::class
|| get_class($entity) == Credit::class || get_class($entity) == Credit::class
|| get_class($entity) == RecurringInvoice::class || get_class($entity) == RecurringInvoice::class
) { ) {
$backup = new Backup();
$entity->load('client'); $entity->load('client');
$contact = $entity->client->primary_contact()->first(); $contact = $entity->client->primary_contact()->first();
$backup->html_backup = $this->generateHtml($entity); $backup->html_backup = $this->generateHtml($entity);
$backup->amount = $entity->amount; $backup->amount = $entity->amount;
}
$backup->activity_id = $activity->id; $backup->activity_id = $activity->id;
$backup->json_backup = ''; $backup->json_backup = '';
$backup->save(); $backup->save();
$backup->storeRemotely($this->generateHtml($entity), $entity->client);
}
} }
public function getTokenId(array $event_vars) public function getTokenId(array $event_vars)
@ -126,7 +127,7 @@ class ActivityRepository extends BaseRepository
if(!$entity->invitations()->exists() || !$design){ if(!$entity->invitations()->exists() || !$design){
nlog("No invitations for entity {$entity->id} - {$entity->number}"); nlog("No invitations for entity {$entity->id} - {$entity->number}");
return; return '';
} }
$entity->load('client.company', 'invitations'); $entity->load('client.company', 'invitations');

View File

@ -222,15 +222,15 @@ class BaseRepository
$this->saveDocuments($data['documents'], $model); $this->saveDocuments($data['documents'], $model);
/* Marks whether the client contact should receive emails based on the send_email property */ /* Marks whether the client contact should receive emails based on the send_email property */
if (isset($data['client_contacts'])) { // if (isset($data['client_contacts'])) {
foreach ($data['client_contacts'] as $contact) { // foreach ($data['client_contacts'] as $contact) {
if ($contact['send_email'] == 1 && is_string($contact['id'])) { // if ($contact['send_email'] == 1 && is_string($contact['id'])) {
$client_contact = ClientContact::find($this->decodePrimaryKey($contact['id'])); // $client_contact = ClientContact::find($this->decodePrimaryKey($contact['id']));
$client_contact->send_email = true; // $client_contact->send_email = true;
$client_contact->save(); // $client_contact->save();
} // }
} // }
} // }
/* If invitations are present we need to filter existing invitations with the new ones */ /* If invitations are present we need to filter existing invitations with the new ones */
if (isset($data['invitations'])) { if (isset($data['invitations'])) {
@ -285,10 +285,8 @@ class BaseRepository
} }
} }
$model->load('invitations');
/* If no invitations have been created, this is our fail safe to maintain state*/ /* If no invitations have been created, this is our fail safe to maintain state*/
if ($model->invitations->count() == 0) if ($model->invitations()->count() == 0)
$model->service()->createInvitations(); $model->service()->createInvitations();
/* Recalculate invoice amounts */ /* Recalculate invoice amounts */

View File

@ -70,7 +70,10 @@ class InstantPayment
$invoices = Invoice::whereIn('id', $this->transformKeys($payable_invoices->pluck('invoice_id')->toArray()))->withTrashed()->get(); $invoices = Invoice::whereIn('id', $this->transformKeys($payable_invoices->pluck('invoice_id')->toArray()))->withTrashed()->get();
$invoices->each(function($invoice){ $invoices->each(function($invoice){
$invoice->service()->removeUnpaidGatewayFees()->save(); $invoice->service()
->markSent()
->removeUnpaidGatewayFees()
->save();
}); });
/* pop non payable invoice from the $payable_invoices array */ /* pop non payable invoice from the $payable_invoices array */

View File

@ -483,6 +483,30 @@ class InvoiceService
} }
/*
//if paid invoice is attached to a recurring invoice - check if we need to unpause the recurring invoice
if ($this->invoice->status_id == Invoice::STATUS_PAID &&
$this->invoice->recurring_id &&
$this->invoice->company->pause_recurring_until_paid &&
($this->invoice->recurring_invoice->status_id != RecurringInvoice::STATUS_ACTIVE || $this->invoice->recurring_invoice->status_id != RecurringInvoice::STATUS_COMPLETED))
{
$recurring_invoice = $this->invoice->recurring_invoice;
// Check next_send_date if it is in the past - calculate
$next_send_date = Carbon::parse($recurring_invoice->next_send_date)->startOfDay();
if(next_send_date->lt(now())){
$recurring_invoice->next_send_date = $recurring_invoice->nextDateByFrequency(now()->format('Y-m-d'));
$recurring_invoice->save();
}
// Start the recurring invoice
$recurring_invoice->service()
->start();
}
*/
return $this; return $this;
} }
@ -494,6 +518,6 @@ class InvoiceService
{ {
$this->invoice->saveQuietly(); $this->invoice->saveQuietly();
return $this->invoice; return $this->invoice->fresh();
} }
} }

View File

@ -39,7 +39,7 @@ class MarkPaid extends AbstractService
public function run() public function run()
{ {
if ($this->invoice->status_id == Invoice::STATUS_DRAFT) { if ($this->invoice->status_id == Invoice::STATUS_DRAFT) {
$this->invoice->service()->markSent(); $this->invoice->service()->markSent()->save();
} }
/*Don't double pay*/ /*Don't double pay*/
@ -77,17 +77,22 @@ class MarkPaid extends AbstractService
$this->invoice->next_send_date = null; $this->invoice->next_send_date = null;
$this->invoice->service() $this->invoice
->service()
->setExchangeRate() ->setExchangeRate()
->updateBalance($payment->amount * -1) ->updateBalance($payment->amount * -1)
->updatePaidToDate($payment->amount) ->updatePaidToDate($payment->amount)
->setStatus(Invoice::STATUS_PAID) ->setStatus(Invoice::STATUS_PAID)
->save();
$this->invoice
->service()
->applyNumber() ->applyNumber()
->deletePdf() ->deletePdf()
->save(); ->save();
if ($this->invoice->client->getSetting('client_manual_payment_notification')) // if ($this->invoice->client->getSetting('client_manual_payment_notification'))
$payment->service()->sendEmail(); // $payment->service()->sendEmail();
/* Update Invoice balance */ /* Update Invoice balance */
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
@ -103,7 +108,10 @@ class MarkPaid extends AbstractService
->updatePaidToDate($payment->amount) ->updatePaidToDate($payment->amount)
->save(); ->save();
$this->invoice->service()->workFlow()->save(); $this->invoice
->service()
->workFlow()
->save();
return $this->invoice; return $this->invoice;
} }

View File

@ -33,15 +33,18 @@ class MarkSent extends AbstractService
{ {
/* Return immediately if status is not draft */ /* Return immediately if status is not draft */
if ($this->invoice->status_id != Invoice::STATUS_DRAFT) { if ($this->invoice->fresh()->status_id != Invoice::STATUS_DRAFT) {
return $this->invoice; return $this->invoice;
} }
$this->invoice->markInvitationsSent(); /*Set status*/
$this->invoice $this->invoice
->service() ->service()
->setStatus(Invoice::STATUS_SENT) ->setStatus(Invoice::STATUS_SENT)
->save();
$this->invoice
->service()
->applyNumber() ->applyNumber()
->setDueDate() ->setDueDate()
->updateBalance($this->invoice->amount) ->updateBalance($this->invoice->amount)
@ -49,9 +52,18 @@ class MarkSent extends AbstractService
->setReminder() ->setReminder()
->save(); ->save();
$this->client->service()->updateBalance($this->invoice->balance)->save(); $this->invoice->markInvitationsSent();
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance, "Invoice {$this->invoice->number} marked as sent."); /*Adjust client balance*/
$this->client
->service()
->updateBalance($this->invoice->balance)
->save();
/*Update ledger*/
$this->invoice
->ledger()
->updateInvoiceBalance($this->invoice->balance, "Invoice {$this->invoice->number} marked as sent.");
event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));

View File

@ -13,6 +13,8 @@
namespace App\Services\Quote; namespace App\Services\Quote;
use App\Factory\CloneQuoteToInvoiceFactory; use App\Factory\CloneQuoteToInvoiceFactory;
use App\Factory\InvoiceInvitationFactory;
use App\Models\Invoice;
use App\Models\Quote; use App\Models\Quote;
use App\Repositories\InvoiceRepository; use App\Repositories\InvoiceRepository;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
@ -39,14 +41,20 @@ class ConvertQuote
{ {
$invoice = CloneQuoteToInvoiceFactory::create($quote, $quote->user_id); $invoice = CloneQuoteToInvoiceFactory::create($quote, $quote->user_id);
$invoice->design_id = $this->decodePrimaryKey($this->client->getSetting('invoice_design_id')); $invoice->design_id = $this->decodePrimaryKey($this->client->getSetting('invoice_design_id'));
$invoice = $this->invoice_repo->save($invoice->toArray(), $invoice);
//create invitations here before the repo save()
//we need to do this here otherwise the repo_save will create
//invitations for ALL contacts
$invites = $this->createConversionInvitations($invoice, $quote);
$invoice_array = $invoice->toArray();
$invoice_array['invitations'] = $invites;
$invoice = $this->invoice_repo->save($invoice_array, $invoice);
$invoice->fresh(); $invoice->fresh();
$invoice->service() $invoice->service()
->fillDefaults() ->fillDefaults()
// ->markSent()
// ->createInvitations()
->save(); ->save();
$quote->invoice_id = $invoice->id; $quote->invoice_id = $invoice->id;
@ -56,4 +64,26 @@ class ConvertQuote
// maybe should return invoice here // maybe should return invoice here
return $invoice; return $invoice;
} }
/**
* Only create the invitations that are defined on the quote.
*
* @return Invoice $invoice
*/
private function createConversionInvitations($invoice, $quote)
{
$invites = [];
foreach($quote->invitations as $quote_invitation){
$ii = InvoiceInvitationFactory::create($invoice->company_id, $invoice->user_id);
$ii->key = $this->createDbHash(config('database.default'));
$ii->client_contact_id = $quote_invitation->client_contact_id;
$invites[] = $ii;
}
return $invites;
}
} }

View File

@ -12,6 +12,7 @@
namespace App\Services\Quote; namespace App\Services\Quote;
use App\Events\Quote\QuoteWasApproved; use App\Events\Quote\QuoteWasApproved;
use App\Factory\InvoiceInvitationFactory;
use App\Jobs\Util\UnlinkFile; use App\Jobs\Util\UnlinkFile;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Quote; use App\Models\Quote;
@ -117,7 +118,6 @@ class QuoteService
$this->invoice $this->invoice
->service() ->service()
->markSent() ->markSent()
->createInvitations()
->deletePdf() ->deletePdf()
->save(); ->save();

View File

@ -54,8 +54,6 @@ class RecurringService
return $this; return $this;
} }
// $this->createInvitations()->setStatus(RecurringInvoice::STATUS_ACTIVE);
$this->setStatus(RecurringInvoice::STATUS_ACTIVE); $this->setStatus(RecurringInvoice::STATUS_ACTIVE);
return $this; return $this;

View File

@ -223,6 +223,7 @@ class SubscriptionService
->first(); ->first();
} }
if ($outstanding->count() == 0){ if ($outstanding->count() == 0){
//nothing outstanding //nothing outstanding
return $target->price - $this->calculateProRataRefundForSubscription($outstanding_invoice); return $target->price - $this->calculateProRataRefundForSubscription($outstanding_invoice);
@ -426,6 +427,8 @@ class SubscriptionService
nlog("total payable = {$total_payable}"); nlog("total payable = {$total_payable}");
/* Only generate a credit if the previous invoice was paid in full. */
if($last_invoice->balance == 0)
$credit = $this->createCredit($last_invoice, $target_subscription, $is_credit); $credit = $this->createCredit($last_invoice, $target_subscription, $is_credit);
$new_recurring_invoice = $this->createNewRecurringInvoice($recurring_invoice); $new_recurring_invoice = $this->createNewRecurringInvoice($recurring_invoice);
@ -575,7 +578,7 @@ class SubscriptionService
$old_recurring_invoice->service()->stop()->save(); $old_recurring_invoice->service()->stop()->save();
$recurring_invoice_repo = new RecurringInvoiceRepository(); $recurring_invoice_repo = new RecurringInvoiceRepository();
$recurring_invoice_repo->archive($old_recurring_invoice); $recurring_invoice_repo->delete($old_recurring_invoice);
$recurring_invoice = $this->convertInvoiceToRecurring($old_recurring_invoice->client_id); $recurring_invoice = $this->convertInvoiceToRecurring($old_recurring_invoice->client_id);
$recurring_invoice = $recurring_invoice_repo->save([], $recurring_invoice); $recurring_invoice = $recurring_invoice_repo->save([], $recurring_invoice);
@ -934,6 +937,38 @@ class SubscriptionService
} }
public function getNextDateForFrequency($date, $frequency)
{
switch ($frequency) {
case RecurringInvoice::FREQUENCY_DAILY:
return $date->addDay();
case RecurringInvoice::FREQUENCY_WEEKLY:
return $date->addDays(7);
case RecurringInvoice::FREQUENCY_TWO_WEEKS:
return $date->addDays(13);
case RecurringInvoice::FREQUENCY_FOUR_WEEKS:
return $date->addWeeks(4);
case RecurringInvoice::FREQUENCY_MONTHLY:
return $date->addMonthNoOverflow();
case RecurringInvoice::FREQUENCY_TWO_MONTHS:
return $date->addMonthNoOverflow(2);
case RecurringInvoice::FREQUENCY_THREE_MONTHS:
return $date->addMonthNoOverflow(3);
case RecurringInvoice::FREQUENCY_FOUR_MONTHS:
return $date->addMonthNoOverflow(4);
case RecurringInvoice::FREQUENCY_SIX_MONTHS:
return $date->addMonthNoOverflow(6);
case RecurringInvoice::FREQUENCY_ANNUALLY:
return $date->addYear();
case RecurringInvoice::FREQUENCY_TWO_YEARS:
return $date->addYears(2);
case RecurringInvoice::FREQUENCY_THREE_YEARS:
return $date->addYears(3);
default:
return 0;
}
}
/** /**
* 'email' => $this->email ?? $this->contact->email, * 'email' => $this->email ?? $this->contact->email,

View File

@ -25,17 +25,13 @@ use Illuminate\Support\Facades\Queue;
class SystemHealth class SystemHealth
{ {
private static $extensions = [ private static $extensions = [
// 'mysqli',
'gd', 'gd',
'curl', 'curl',
'zip', 'zip',
// 'gmp',
'openssl', 'openssl',
'mbstring', 'mbstring',
'xml', 'xml',
'bcmath', 'bcmath',
// 'mysqlnd',
//'intl', //todo double check whether we need this for email dns validation
]; ];
private static $php_version = 7.4; private static $php_version = 7.4;
@ -84,9 +80,19 @@ class SystemHealth
'jobs_pending' => (int) Queue::size(), 'jobs_pending' => (int) Queue::size(),
'pdf_engine' => (string) self::getPdfEngine(), 'pdf_engine' => (string) self::getPdfEngine(),
'queue' => (string) config('queue.default'), 'queue' => (string) config('queue.default'),
'trailing_slash' => (bool) self::checkUrlState(),
]; ];
} }
public static function checkUrlState()
{
if (env('APP_URL') && substr(env('APP_URL'), -1) == '/')
return true;
return false;
}
public static function getPdfEngine() public static function getPdfEngine()
{ {
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja') if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja')

View File

@ -13,7 +13,7 @@
"tasks", "tasks",
"freelancer" "freelancer"
], ],
"license": "Attribution Assurance License", "license": "Elastic License",
"authors": [ "authors": [
{ {
"name": "Hillel Coren", "name": "Hillel Coren",

View File

@ -14,8 +14,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true), 'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => '5.3.25', 'app_version' => '5.3.26',
'app_tag' => '5.3.25', 'app_tag' => '5.3.26',
'minimum_client_version' => '5.0.16', 'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1', 'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''), 'api_secret' => env('API_SECRET', ''),

View File

@ -12,6 +12,7 @@
namespace Database\Factories; namespace Database\Factories;
use App\Models\RecurringInvoice;
use App\Models\Subscription; use App\Models\Subscription;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
@ -32,7 +33,8 @@ class SubscriptionFactory extends Factory
public function definition() public function definition()
{ {
return [ return [
'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY,
'name' => $this->faker->company(),
]; ];
} }
} }

View File

@ -0,0 +1,52 @@
<?php
use App\Models\GatewayType;
use App\Models\PaymentType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class StripePaymentGateways extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('payment_types', function (Blueprint $table) {
$type = new PaymentType();
$type2 = new PaymentType();
$type3 = new PaymentType();
$type4 = new PaymentType();
$type5 = new PaymentType();
$type->id = 44;
$type->name = 'ACSS';
$type->gateway_type_id = GatewayType::ACSS;
$type2->id = 43;
$type2->name = 'BECS';
$type2->gateway_type_id = GatewayType::BECS;
$type3->id = 39;
$type3->name = 'GiroPay';
$type3->gateway_type_id = GatewayType::GIROPAY;
$type4->id = 40;
$type4->name = 'Przelewy24';
$type4->gateway_type_id = GatewayType::PRZELEWY24;
$type5->id = 41;
$type5->name = 'EPS';
$type5->gateway_type_id = GatewayType::EPS;
$type->save();
$type2->save();
$type3->save();
$type4->save();
$type5->save();
});
}
}

View File

@ -0,0 +1,28 @@
<?php
use App\Models\GatewayType;
use App\Models\PaymentType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddDirectDebitToPaymentTypes extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('payment_types', function (Blueprint $table) {
$type = new PaymentType();
$type->id = 42;
$type->name = 'Direct Debit';
$type->gateway_type_id = GatewayType::DIRECT_DEBIT;
$type->save();
});
}
}

View File

@ -0,0 +1,23 @@
<?php
use App\Models\GatewayType;
use Illuminate\Database\Migrations\Migration;
class AddGatewayTypeForDirectDebit extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$type = new GatewayType();
$type->id = 18;
$type->alias = 'direct_debit';
$type->name = 'Direct Debit';
$type->save();
}
}

View File

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

View File

@ -3,7 +3,7 @@ const MANIFEST = 'flutter-app-manifest';
const TEMP = 'flutter-temp-cache'; const TEMP = 'flutter-temp-cache';
const CACHE_NAME = 'flutter-app-cache'; const CACHE_NAME = 'flutter-app-cache';
const RESOURCES = { const RESOURCES = {
"version.json": "07a43895b172742ab22bb808918b117a", "version.json": "27abc97e9c76cf112b697fa080c304b5",
"favicon.ico": "51636d3a390451561744c42188ccd628", "favicon.ico": "51636d3a390451561744c42188ccd628",
"favicon.png": "dca91c54388f52eded692718d5a98b8b", "favicon.png": "dca91c54388f52eded692718d5a98b8b",
"assets/fonts/MaterialIcons-Regular.otf": "4e6447691c9509f7acdbf8a931a85ca1", "assets/fonts/MaterialIcons-Regular.otf": "4e6447691c9509f7acdbf8a931a85ca1",
@ -32,9 +32,9 @@ const RESOURCES = {
"assets/packages/material_design_icons_flutter/lib/fonts/materialdesignicons-webfont.ttf": "174c02fc4609e8fc4389f5d21f16a296", "assets/packages/material_design_icons_flutter/lib/fonts/materialdesignicons-webfont.ttf": "174c02fc4609e8fc4389f5d21f16a296",
"icons/Icon-192.png": "bb1cf5f6982006952211c7c8404ffbed", "icons/Icon-192.png": "bb1cf5f6982006952211c7c8404ffbed",
"icons/Icon-512.png": "0f9aff01367f0a0c69773d25ca16ef35", "icons/Icon-512.png": "0f9aff01367f0a0c69773d25ca16ef35",
"main.dart.js": "6d7015b94cf66c9fd426081b7bfb5b97", "main.dart.js": "4b982138f175597df211146084e39b66",
"manifest.json": "ef43d90e57aa7682d7e2cfba2f484a40", "manifest.json": "ef43d90e57aa7682d7e2cfba2f484a40",
"/": "4da4247bb7f072054c574b10e7370438" "/": "3debb9cbb687369f006a776cc7ab525b"
}; };
// The application shell files that are downloaded before a service worker can // The application shell files that are downloaded before a service worker can

View File

@ -0,0 +1,2 @@
/*! For license information please see stripe-acss.js.LICENSE.txt */
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=31)}({31:function(e,t,n){e.exports=n("RyUd")},RyUd:function(e,t){var n,r,o,a;function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=function(){function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,"setupStripe",(function(){return r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=l),r})),i(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");return""===document.getElementById("acss-name").value?(document.getElementById("acss-name").focus(),t.textContent=document.querySelector("meta[name=translation-name-required]").content,void(t.hidden=!1)):""===document.getElementById("acss-email-address").value?(document.getElementById("acss-email-address").focus(),t.textContent=document.querySelector("meta[name=translation-email-required]").content,void(t.hidden=!1)):(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void r.stripe.confirmAcssDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("acss-name").value,email:document.getElementById("acss-email-address").value}}}).then((function(e){return e.error?r.handleFailure(e.error.message):r.handleSuccess(e)})))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}var t,n,r;return t=e,(n=[{key:"handleSuccess",value:function(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),document.getElementById("server-response").submit()}},{key:"handleFailure",value:function(e){var t=document.getElementById("errors");t.textContent="",t.textContent=e,t.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}])&&u(t.prototype,n),r&&u(t,r),e}(),d=null!==(n=null===(r=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"",l=null!==(o=null===(a=document.querySelector('meta[name="stripe-account-id"]'))||void 0===a?void 0:a.content)&&void 0!==o?o:"";new c(d,l).setupStripe().handle()}});

View File

@ -0,0 +1,9 @@
/**
* 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://opensource.org/licenses/AAL
*/

View File

@ -1 +1,2 @@
!function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/",o(o.s=6)}({6:function(e,t,n){e.exports=n("RFiP")},RFiP:function(e,t){var n;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r=null!==(n=null===(r=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"",i=null!==(n=null===(n=document.querySelector('meta[name="stripe-account-id"]'))||void 0===n?void 0:n.content)&&void 0!==n?n:"";new function t(e,n){var r=this;!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),o(this,"setupStripe",function(){return r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=i),r}),o(this,"handle",function(){document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors");if(!document.getElementById("bancontact-name").value)return t.textContent="Enter name",t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmBancontactPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("bancontact-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})}),this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=n}(r,i).setupStripe().handle()}}); /*! For license information please see stripe-bancontact.js.LICENSE.txt */
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=32)}({32:function(e,t,n){e.exports=n("9g3I")},"9g3I":function(e,t){var n,r,o,u;function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=null!==(n=null===(r=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"",a=null!==(o=null===(u=document.querySelector('meta[name="stripe-account-id"]'))||void 0===u?void 0:u.content)&&void 0!==o?o:"";new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,"setupStripe",(function(){return r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=a),r})),i(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("bancontact-name").value)return t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmBancontactPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("bancontact-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(c,a).setupStripe().handle()}});

View File

@ -0,0 +1,2 @@
/*! For license information please see stripe-becs.js.LICENSE.txt */
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=33)}({33:function(e,t,n){e.exports=n("v79X")},v79X:function(e,t){var n,o,r,a;function c(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=function(){function e(t,n){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),u(this,"setupStripe",(function(){o.stripe=Stripe(o.key),o.stripeConnect&&(o.stripe.stripeAccount=d);var e=o.stripe.elements(),t={style:{base:{color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"},":-webkit-autofill":{color:"#32325d"}},invalid:{color:"#fa755a",iconColor:"#fa755a",":-webkit-autofill":{color:"#fa755a"}}},disabled:!1,hideIcon:!1,iconStyle:"default"};return o.auBankAccount=e.create("auBankAccount",t),o.auBankAccount.mount("#becs-iban"),o})),u(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");return""===document.getElementById("becs-name").value?(document.getElementById("becs-name").focus(),t.textContent=document.querySelector("meta[name=translation-name-required]").content,void(t.hidden=!1)):""===document.getElementById("becs-email-address").value?(document.getElementById("becs-email-address").focus(),t.textContent=document.querySelector("meta[name=translation-email-required]").content,void(t.hidden=!1)):document.getElementById("becs-mandate-acceptance").checked?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void o.stripe.confirmAuBecsDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{au_becs_debit:o.auBankAccount,billing_details:{name:document.getElementById("becs-name").value,email:document.getElementById("becs-email-address").value}}}).then((function(e){return e.error?o.handleFailure(e.error.message):o.handleSuccess(e)}))):(document.getElementById("becs-mandate-acceptance").focus(),t.textContent=document.querySelector("meta[name=translation-terms-required]").content,t.hidden=!1,void console.log("Terms"))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}var t,n,o;return t=e,(n=[{key:"handleSuccess",value:function(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),document.getElementById("server-response").submit()}},{key:"handleFailure",value:function(e){var t=document.getElementById("errors");t.textContent="",t.textContent=e,t.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}])&&c(t.prototype,n),o&&c(t,o),e}(),l=null!==(n=null===(o=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"",d=null!==(r=null===(a=document.querySelector('meta[name="stripe-account-id"]'))||void 0===a?void 0:a.content)&&void 0!==r?r:"";new i(l,d).setupStripe().handle()}});

View File

@ -0,0 +1,9 @@
/**
* 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://opensource.org/licenses/AAL
*/

View File

@ -1 +1,2 @@
!function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/",o(o.s=6)}({6:function(e,t,n){e.exports=n("RFiP")},RFiP:function(e,t){var n;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r=null!==(n=null===(r=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"",i=null!==(n=null===(n=document.querySelector('meta[name="stripe-account-id"]'))||void 0===n?void 0:n.content)&&void 0!==n?n:"";new function t(e,n){var r=this;!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),o(this,"setupStripe",function(){r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=i);let e=r.stripe.elements();return r.eps=e.create("epsBank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),r.eps.mount("#eps-bank-element"),r}),o(this,"handle",function(){document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors");if(!document.getElementById("eps-name").value)return t.textContent="Enter name",t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmEpsPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{eps:r.eps,billing_details:{name:document.getElementById("eps-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})}),this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=n}(r,i).setupStripe().handle()}}); /*! For license information please see stripe-eps.js.LICENSE.txt */
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=34)}({34:function(e,t,n){e.exports=n("Gn/6")},"Gn/6":function(e,t){var n,r,o,i;function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=null!==(n=null===(r=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"",c=null!==(o=null===(i=document.querySelector('meta[name="stripe-account-id"]'))||void 0===i?void 0:i.content)&&void 0!==o?o:"";new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),u(this,"setupStripe",(function(){r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=c);var e=r.stripe.elements();return r.eps=e.create("epsBank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),r.eps.mount("#eps-bank-element"),r})),u(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("eps-name").value)return t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmEpsPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{eps:r.eps,billing_details:{name:document.getElementById("ideal-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(a,c).setupStripe().handle()}});

View File

@ -1 +1,2 @@
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=6)}({6:function(e,t,n){e.exports=n("RFiP")},RFiP:function(e,t){var n,r,o,i;function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=null!==(n=null===(r=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"",l=null!==(o=null===(i=document.querySelector('meta[name="stripe-account-id"]'))||void 0===i?void 0:i.content)&&void 0!==o?o:"";new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),u(this,"setupStripe",function(){return r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=l),r}),u(this,"handle",function(){document.getElementById("pay-now").addEventListener("click",function(e){let t=document.getElementById("errors");if(!document.getElementById("giropay-mandate-acceptance").checked)return t.textContent="Accept Terms",t.hidden=!1,void console.log("Terms");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmGiropayPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("giropay-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})}),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(c,l).setupStripe().handle()}}); /*! For license information please see stripe-giropay.js.LICENSE.txt */
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=30)}({30:function(e,t,n){e.exports=n("5IXF")},"5IXF":function(e,t){var n,r,o,i;function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=null!==(n=null===(r=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"",a=null!==(o=null===(i=document.querySelector('meta[name="stripe-account-id"]'))||void 0===i?void 0:i.content)&&void 0!==o?o:"";new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),u(this,"setupStripe",(function(){return r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=a),r})),u(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("giropay-mandate-acceptance").checked)return t.textContent=document.querySelector("meta[name=translation-terms-required]").content,t.hidden=!1,void console.log("Terms");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmGiropayPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.getElementById("giropay-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(c,a).setupStripe().handle()}});

View File

@ -1 +1,2 @@
!function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/",o(o.s=6)}({6:function(e,t,n){e.exports=n("RFiP")},RFiP:function(e,t){var n;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var r=null!==(n=null===(r=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"",i=null!==(n=null===(n=document.querySelector('meta[name="stripe-account-id"]'))||void 0===n?void 0:n.content)&&void 0!==n?n:"";new function t(e,n){var r=this;!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),o(this,"setupStripe",function(){r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=i);let e=r.stripe.elements();return this.ideal=e.create("idealBank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),this.ideal.mount("#ideal-bank-element"),r}),o(this,"handle",function(){document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors");if(!document.getElementById("ideal-name").value)return t.textContent="Enter name",t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),this.stripe.confirmIdealPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{ideal:this.ideal,billing_details:{name:document.getElementById("ideal-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})})}),this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=n}(r,i).setupStripe().handle()}}); /*! For license information please see stripe-ideal.js.LICENSE.txt */
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=35)}({35:function(e,t,n){e.exports=n("T01t")},T01t:function(e,t){var n,r,o,i;function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=null!==(n=null===(r=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"",u=null!==(o=null===(i=document.querySelector('meta[name="stripe-account-id"]'))||void 0===i?void 0:i.content)&&void 0!==o?o:"";new function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),a(this,"setupStripe",(function(){r.stripe=Stripe(r.key),r.stripeConnect&&(r.stripe.stripeAccount=u);var e=r.stripe.elements();return r.ideal=e.create("idealBank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),r.ideal.mount("#ideal-bank-element"),r})),a(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");if(!document.getElementById("ideal-name").value)return t.textContent=document.querySelector("meta[name=translation-name-required]").content,t.hidden=!1,void console.log("name");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmIdealPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{ideal:r.ideal,billing_details:{name:document.getElementById("ideal-name").value}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(l,u).setupStripe().handle()}});

View File

@ -1 +1,2 @@
!function(n){var o={};function r(e){if(o[e])return o[e].exports;var t=o[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,r),t.l=!0,t.exports}r.m=n,r.c=o,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.s=6)}({6:function(e,t,n){e.exports=n("RFiP")},RFiP:function(e,t){var n;function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=null!==(n=null===(o=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"",a=null!==(n=null===(n=document.querySelector('meta[name="stripe-account-id"]'))||void 0===n?void 0:n.content)&&void 0!==n?n:"";new function t(e,n){var o=this;!function(e){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),r(this,"setupStripe",function(){o.stripe=Stripe(o.key),o.stripeConnect&&(o.stripe.stripeAccount=a);let e=o.stripe.elements();return o.p24bank=e.create("p24Bank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),o.p24bank.mount("#p24-bank-element"),o}),r(this,"handle",function(){document.getElementById("pay-now").addEventListener("click",function(e){let t=document.getElementById("errors");return""===document.getElementById("p24-name").value?(document.getElementById("p24-name").focus(),t.textContent="Name required.",void(t.hidden=!1)):""===document.getElementById("p24-email-address").value?(document.getElementById("p24-email-address").focus(),t.textContent="Email required.",void(t.hidden=!1)):document.getElementById("p24-mandate-acceptance").checked?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void o.stripe.confirmP24Payment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{p24:o.p24bank,billing_details:{name:document.getElementById("p24-name").value,email:document.getElementById("p24-email-address").value}},payment_method_options:{p24:{tos_shown_and_accepted:document.getElementById("p24-mandate-acceptance").checked}},return_url:document.querySelector('meta[name="return-url"]').content})):(document.getElementById("p24-mandate-acceptance").focus(),t.textContent="Accept Terms.",void(t.hidden=!1))})}),this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=n}(o,a).setupStripe().handle()}}),a; /*! For license information please see stripe-przelewy24.js.LICENSE.txt */
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=36)}({36:function(e,t,n){e.exports=n("Btf5")},Btf5:function(e,t){var n,o,r,a;function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var d=null!==(n=null===(o=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"",u=null!==(r=null===(a=document.querySelector('meta[name="stripe-account-id"]'))||void 0===a?void 0:a.content)&&void 0!==r?r:"";new function e(t,n){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c(this,"setupStripe",(function(){o.stripe=Stripe(o.key),o.stripeConnect&&(o.stripe.stripeAccount=u);var e=o.stripe.elements();return o.p24bank=e.create("p24Bank",{style:{base:{padding:"10px 12px",color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"}}}}),o.p24bank.mount("#p24-bank-element"),o})),c(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors");return""===document.getElementById("p24-name").value?(document.getElementById("p24-name").focus(),t.textContent=document.querySelector("meta[name=translation-name-required]").content,void(t.hidden=!1)):""===document.getElementById("p24-email-address").value?(document.getElementById("p24-email-address").focus(),t.textContent=document.querySelector("meta[name=translation-email-required]").content,void(t.hidden=!1)):document.getElementById("p24-mandate-acceptance").checked?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void o.stripe.confirmP24Payment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{p24:o.p24bank,billing_details:{name:document.getElementById("p24-name").value,email:document.getElementById("p24-email-address").value}},payment_method_options:{p24:{tos_shown_and_accepted:document.getElementById("p24-mandate-acceptance").checked}},return_url:document.querySelector('meta[name="return-url"]').content})):(document.getElementById("p24-mandate-acceptance").focus(),t.textContent=document.querySelector("meta[name=translation-terms-required]").content,void(t.hidden=!1))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}(d,u).setupStripe().handle()}});

221742
public/main.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

223944
public/main.foss.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

237180
public/main.html.dart.js vendored Normal file

File diff suppressed because one or more lines are too long

358286
public/main.next.dart.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"/js/app.js": "/js/app.js?id=696e8203d5e8e7cf5ff5", "/js/app.js": "/js/app.js?id=019831a9b0c0aff43c7f",
"/css/app.css": "/css/app.css?id=f7f7b35aa3f417a3eca3", "/css/app.css": "/css/app.css?id=df1ea83ea621533ac837",
"/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4", "/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4",
"/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1", "/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1",
"/js/clients/linkify-urls.js": "/js/clients/linkify-urls.js?id=0dc8c34010d09195d2f7", "/js/clients/linkify-urls.js": "/js/clients/linkify-urls.js?id=0dc8c34010d09195d2f7",
@ -19,8 +19,15 @@
"/js/clients/payments/razorpay-aio.js": "/js/clients/payments/razorpay-aio.js?id=817ab3b2b94ee37b14eb", "/js/clients/payments/razorpay-aio.js": "/js/clients/payments/razorpay-aio.js?id=817ab3b2b94ee37b14eb",
"/js/clients/payments/square-credit-card.js": "/js/clients/payments/square-credit-card.js?id=070c86b293b532c5a56c", "/js/clients/payments/square-credit-card.js": "/js/clients/payments/square-credit-card.js?id=070c86b293b532c5a56c",
"/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=81c2623fc1e5769b51c7", "/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=81c2623fc1e5769b51c7",
"/js/clients/payments/stripe-acss.js": "/js/clients/payments/stripe-acss.js?id=4a85142c085723991d28",
"/js/clients/payments/stripe-alipay.js": "/js/clients/payments/stripe-alipay.js?id=665ddf663500767f1a17", "/js/clients/payments/stripe-alipay.js": "/js/clients/payments/stripe-alipay.js?id=665ddf663500767f1a17",
"/js/clients/payments/stripe-bancontact.js": "/js/clients/payments/stripe-bancontact.js?id=d803da4574a36e8472d5",
"/js/clients/payments/stripe-becs.js": "/js/clients/payments/stripe-becs.js?id=fdc4defaeded2312eac2",
"/js/clients/payments/stripe-credit-card.js": "/js/clients/payments/stripe-credit-card.js?id=a30464874dee84678344", "/js/clients/payments/stripe-credit-card.js": "/js/clients/payments/stripe-credit-card.js?id=a30464874dee84678344",
"/js/clients/payments/stripe-eps.js": "/js/clients/payments/stripe-eps.js?id=ea3deb74233cfe4abd13",
"/js/clients/payments/stripe-giropay.js": "/js/clients/payments/stripe-giropay.js?id=51ff0603d109eb5487c2",
"/js/clients/payments/stripe-ideal.js": "/js/clients/payments/stripe-ideal.js?id=cd8299e9f3df07f25144",
"/js/clients/payments/stripe-przelewy24.js": "/js/clients/payments/stripe-przelewy24.js?id=693e8e5ac5ada09c597a",
"/js/clients/payments/stripe-sepa.js": "/js/clients/payments/stripe-sepa.js?id=3f2fa0857dc804a85dcb", "/js/clients/payments/stripe-sepa.js": "/js/clients/payments/stripe-sepa.js?id=3f2fa0857dc804a85dcb",
"/js/clients/payments/stripe-sofort.js": "/js/clients/payments/stripe-sofort.js?id=231571942310348aa616", "/js/clients/payments/stripe-sofort.js": "/js/clients/payments/stripe-sofort.js?id=231571942310348aa616",
"/js/clients/payments/wepay-credit-card.js": "/js/clients/payments/wepay-credit-card.js?id=f51400e03c5fdb6cdabe", "/js/clients/payments/wepay-credit-card.js": "/js/clients/payments/wepay-credit-card.js?id=f51400e03c5fdb6cdabe",
@ -29,6 +36,6 @@
"/js/clients/shared/multiple-downloads.js": "/js/clients/shared/multiple-downloads.js?id=5c35d28cf0a3286e7c45", "/js/clients/shared/multiple-downloads.js": "/js/clients/shared/multiple-downloads.js?id=5c35d28cf0a3286e7c45",
"/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=2a99d83305ba87bfa6cc", "/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=2a99d83305ba87bfa6cc",
"/js/clients/statements/view.js": "/js/clients/statements/view.js?id=ca3ec4cea0de824f3a36", "/js/clients/statements/view.js": "/js/clients/statements/view.js?id=ca3ec4cea0de824f3a36",
"/js/setup/setup.js": "/js/setup/setup.js?id=8d454e7090f119552a6c", "/js/setup/setup.js": "/js/setup/setup.js?id=03ea88a737e59eb2bd5a",
"/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ad" "/css/card-js.min.css": "/css/card-js.min.css?id=62afeb675235451543ad"
} }

View File

@ -1 +1 @@
{"app_name":"invoiceninja_flutter","version":"5.0.60","build_number":"60"} {"app_name":"invoiceninja_flutter","version":"5.0.62","build_number":"62"}

View File

@ -88,11 +88,7 @@ class SquareCreditCard {
} }
catch(typeError){ catch(typeError){
console.log(typeError); console.log(typeError);
die("failed in the catch");
} }
// console.log(" verification tokem = " + verificationToken.token);
// verificationToken = verificationResults.token;
console.debug('Verification Token:', verificationToken); console.debug('Verification Token:', verificationToken);

View File

@ -0,0 +1,97 @@
/**
* 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://opensource.org/licenses/AAL
*/
class ProcessACSS {
constructor(key, stripeConnect) {
this.key = key;
this.errors = document.getElementById('errors');
this.stripeConnect = stripeConnect;
}
setupStripe = () => {
this.stripe = Stripe(this.key);
if(this.stripeConnect)
this.stripe.stripeAccount = stripeConnect;
return this;
};
handle = () => {
document.getElementById('pay-now').addEventListener('click', (e) => {
let errors = document.getElementById('errors');
if (document.getElementById('acss-name').value === "") {
document.getElementById('acss-name').focus();
errors.textContent = document.querySelector('meta[name=translation-name-required]').content;
errors.hidden = false;
return;
}
if (document.getElementById('acss-email-address').value === "") {
document.getElementById('acss-email-address').focus();
errors.textContent = document.querySelector('meta[name=translation-email-required]').content;
errors.hidden = false;
return ;
}
document.getElementById('pay-now').disabled = true;
document.querySelector('#pay-now > svg').classList.remove('hidden');
document.querySelector('#pay-now > span').classList.add('hidden');
this.stripe.confirmAcssDebitPayment(
document.querySelector('meta[name=pi-client-secret').content,
{
payment_method: {
billing_details: {
name: document.getElementById("acss-name").value,
email: document.getElementById("acss-email-address").value,
},
},
}
).then((result) => {
if (result.error) {
return this.handleFailure(result.error.message);
}
return this.handleSuccess(result);
});
});
};
handleSuccess(result) {
document.querySelector(
'input[name="gateway_response"]'
).value = JSON.stringify(result.paymentIntent);
document.getElementById('server-response').submit();
}
handleFailure(message) {
let errors = document.getElementById('errors');
errors.textContent = '';
errors.textContent = message;
errors.hidden = false;
document.getElementById('pay-now').disabled = false;
document.querySelector('#pay-now > svg').classList.add('hidden');
document.querySelector('#pay-now > span').classList.remove('hidden');
}
}
const publishableKey = document.querySelector(
'meta[name="stripe-publishable-key"]'
)?.content ?? '';
const stripeConnect =
document.querySelector('meta[name="stripe-account-id"]')?.content ?? '';
new ProcessACSS(publishableKey, stripeConnect).setupStripe().handle();

View File

@ -28,7 +28,7 @@ class ProcessBANCONTACTPay {
let errors = document.getElementById('errors'); let errors = document.getElementById('errors');
if (!document.getElementById('bancontact-name').value) { if (!document.getElementById('bancontact-name').value) {
errors.textContent = "Enter name"; errors.textContent = document.querySelector('meta[name=translation-name-required]').content;
errors.hidden = false; errors.hidden = false;
console.log("name"); console.log("name");
return ; return ;

View File

@ -0,0 +1,136 @@
/**
* 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://opensource.org/licenses/AAL
*/
class ProcessBECS {
constructor(key, stripeConnect) {
this.key = key;
this.errors = document.getElementById('errors');
this.stripeConnect = stripeConnect;
}
setupStripe = () => {
this.stripe = Stripe(this.key);
if(this.stripeConnect)
this.stripe.stripeAccount = stripeConnect;
const elements = this.stripe.elements();
const style = {
base: {
color: '#32325d',
fontSize: '16px',
'::placeholder': {
color: '#aab7c4'
},
':-webkit-autofill': {
color: '#32325d',
},
},
invalid: {
color: '#fa755a',
iconColor: '#fa755a',
':-webkit-autofill': {
color: '#fa755a',
},
}
};
const options = {
style: style,
disabled: false,
hideIcon: false,
iconStyle: "default", // or "solid"
};
this.auBankAccount = elements.create("auBankAccount", options);
this.auBankAccount.mount("#becs-iban");
return this;
};
handle = () => {
document.getElementById('pay-now').addEventListener('click', (e) => {
let errors = document.getElementById('errors');
if (document.getElementById('becs-name').value === "") {
document.getElementById('becs-name').focus();
errors.textContent = document.querySelector('meta[name=translation-name-required]').content;
errors.hidden = false;
return;
}
if (document.getElementById('becs-email-address').value === "") {
document.getElementById('becs-email-address').focus();
errors.textContent = document.querySelector('meta[name=translation-email-required]').content;
errors.hidden = false;
return ;
}
if (!document.getElementById('becs-mandate-acceptance').checked) {
document.getElementById('becs-mandate-acceptance').focus();
errors.textContent = document.querySelector('meta[name=translation-terms-required]').content;
errors.hidden = false;
console.log("Terms");
return ;
}
document.getElementById('pay-now').disabled = true;
document.querySelector('#pay-now > svg').classList.remove('hidden');
document.querySelector('#pay-now > span').classList.add('hidden');
this.stripe.confirmAuBecsDebitPayment(
document.querySelector('meta[name=pi-client-secret').content,
{
payment_method: {
au_becs_debit: this.auBankAccount,
billing_details: {
name: document.getElementById("becs-name").value,
email: document.getElementById("becs-email-address").value,
},
},
}
).then((result) => {
if (result.error) {
return this.handleFailure(result.error.message);
}
return this.handleSuccess(result);
});
});
};
handleSuccess(result) {
document.querySelector(
'input[name="gateway_response"]'
).value = JSON.stringify(result.paymentIntent);
document.getElementById('server-response').submit();
}
handleFailure(message) {
let errors = document.getElementById('errors');
errors.textContent = '';
errors.textContent = message;
errors.hidden = false;
document.getElementById('pay-now').disabled = false;
document.querySelector('#pay-now > svg').classList.add('hidden');
document.querySelector('#pay-now > span').classList.remove('hidden');
}
}
const publishableKey = document.querySelector(
'meta[name="stripe-publishable-key"]'
)?.content ?? '';
const stripeConnect =
document.querySelector('meta[name="stripe-account-id"]')?.content ?? '';
new ProcessBECS(publishableKey, stripeConnect).setupStripe().handle();

Some files were not shown because too many files have changed in this diff Show More