1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Merge remote-tracking branch 'upstream/v2' into v2-2606-payment-webhook

This commit is contained in:
Benjamin Beganović 2020-06-27 15:53:18 +02:00
commit 1e4e482801
29 changed files with 728 additions and 293 deletions

View File

@ -21,6 +21,6 @@ class DashboardController extends Controller
*/
public function index()
{
return $this->render('dashboard.index');
return redirect()->route('client.invoices.index');
}
}

View File

@ -44,8 +44,12 @@ class PaymentMethodController extends Controller
{
$gateway = auth()->user()->client->getCreditCardGateway();
return $gateway->driver(auth()->user()->client)->authorizeView(GatewayType::CREDIT_CARD);
$data['gateway'] = $gateway;
return $gateway
->driver(auth()->user()->client)
->setPaymentMethod(GatewayType::BANK_TRANSFER)
->authorizeView($data);
}
/**
@ -57,9 +61,11 @@ class PaymentMethodController extends Controller
public function store(Request $request)
{
$gateway = auth()->user()->client->getCreditCardGateway();
return $gateway->driver(auth()->user()->client)->authorizeResponseView($request->all());
return $gateway
->driver(auth()->user()->client)
->setPaymentMethod(GatewayType::BANK_TRANSFER)
->authorizeResponse($request);
}
/**
@ -104,7 +110,7 @@ class PaymentMethodController extends Controller
return $gateway
->driver(auth()->user()->client)
->setPaymentMethod('App\\PaymentDrivers\\Stripe\\ACH')
->setPaymentMethod(GatewayType::BANK_TRANSFER)
->verificationView($payment_method);
}
@ -114,7 +120,7 @@ class PaymentMethodController extends Controller
return $gateway
->driver(auth()->user()->client)
->setPaymentMethod('App\\PaymentDrivers\\Stripe\\ACH')
->setPaymentMethod(GatewayType::BANK_TRANSFER)
->processVerification($payment_method);
}

View File

@ -15,6 +15,7 @@ namespace App\Http\Controllers\Traits;
use App\Models\User;
use App\Utils\Traits\UserSessionAttributes;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
/**
* Class VerifiesUserEmail
@ -30,20 +31,49 @@ trait VerifiesUserEmail
*/
public function confirm()
{
if ($user = User::whereRaw("BINARY `confirmation_code`= ?", request()->route('confirmation_code'))->first()) {
$user->email_verified_at = now();
$user->confirmation_code = null;
$user->save();
$user = User::where('confirmation_code', request()->confirmation_code)->first();
// if ($user = User::whereRaw("BINARY `confirmation_code`= ?", request()->input('confirmation_code'))->first()) {
return $this->render('auth.confirmed', [
'root' => 'themes',
'message' => ctrans('texts.security_confirmation'),
]);
if (!$user) {
return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]);
}
if (is_null($user->password) || empty($user->password)) {
return $this->render('auth.confirmation_with_password', ['root' => 'themes']);
}
$user->email_verified_at = now();
$user->confirmation_code = null;
$user->save();
return $this->render('auth.confirmed', [
'root' => 'themes',
'message' => ctrans('texts.wrong_confirmation'),
'message' => ctrans('texts.security_confirmation'),
]);
}
public function confirmWithPassword()
{
$user = User::where('confirmation_code', request()->confirmation_code)->first();
if (!$user) {
return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]);
}
request()->validate([
'password' => ['required', 'min:6', 'confirmed'],
]);
$user->password = Hash::make(request()->password);
$user->email_verified_at = now();
$user->confirmation_code = null;
$user->save();
return $this->render('auth.confirmed', [
'root' => 'themes',
'message' => ctrans('texts.security_confirmation'),
]);
}
}

View File

@ -60,7 +60,7 @@ class PortalComposer
{
$data = [];
$data[] = [ 'title' => ctrans('texts.dashboard'), 'url' => 'client.dashboard', 'icon' => 'activity'];
// $data[] = [ 'title' => ctrans('texts.dashboard'), 'url' => 'client.dashboard', 'icon' => 'activity'];
$data[] = [ 'title' => ctrans('texts.invoices'), 'url' => 'client.invoices.index', 'icon' => 'file-text'];
$data[] = [ 'title' => ctrans('texts.recurring_invoices'), 'url' => 'client.recurring_invoices.index', 'icon' => 'file'];
$data[] = [ 'title' => ctrans('texts.payments'), 'url' => 'client.payments.index', 'icon' => 'credit-card'];

View File

@ -90,6 +90,11 @@ class Payment extends BaseModel
return $this->belongsTo(Client::class)->withTrashed();
}
public function company_gateway()
{
return $this->belongsTo(CompanyGateway::class)->withTrashed();
}
public function company()
{
return $this->belongsTo(Company::class);

View File

@ -120,6 +120,7 @@ class AuthorizeCreditCard
$payment->client_id = $this->authorize->client->id;
$payment->company_gateway_id = $this->authorize->company_gateway->id;
$payment->status_id = Payment::STATUS_COMPLETED;
$payment->gateway_type_id = $this->authorize->payment_method;
$payment->type_id = PaymentType::CREDIT_CARD_OTHER;
$payment->currency_id = $this->authorize->client->getSetting('currency_id');
$payment->date = Carbon::now();
@ -129,7 +130,6 @@ class AuthorizeCreditCard
$payment->client->getNextPaymentNumber($this->authorize->client);
$payment->save();
$this->authorize->attachInvoices($payment, $request->hashed_ids);
$payment->service()->updateInvoicePayment();

View File

@ -64,11 +64,11 @@ class AuthorizePaymentMethod
}
public function authorizeResponseView($payment_method, $data)
public function authorizeResponseView($data)
{
$this->payment_method = $payment_method;
$this->payment_method = $data['payment_method_id'];
switch ($payment_method) {
switch ($this->payment_method) {
case GatewayType::CREDIT_CARD:
return $this->authorizeCreditCardResponse($data);
break;

View File

@ -102,7 +102,7 @@ class AuthorizePaymentDriver extends BaseDriver
public function authorizeResponseView(array $data)
{
return (new AuthorizePaymentMethod($this))->authorizeResponseView($data['gateway_type_id'], $data);
return (new AuthorizePaymentMethod($this))->authorizeResponseView($data);
}
public function authorize($payment_method)

View File

@ -172,7 +172,7 @@ class StripePaymentDriver extends BasePaymentDriver
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function authorizeCreditCardResponse($request)
public function authorizeResponse($request)
{
return $this->payment_method->authorizeResponse($request);
}

View File

@ -44,8 +44,9 @@ class RefundPayment
return $this->calculateTotalRefund() //sets amount for the refund (needed if we are refunding multiple invoices in one payment)
->setStatus() //sets status of payment
->buildCreditNote() //generate the credit note
->buildCreditLineItems() //generate the credit note items
//->reversePayment()
//->buildCreditNote() //generate the credit note
//->buildCreditLineItems() //generate the credit note items
->updateCreditables() //return the credits first
->updatePaymentables() //update the paymentable items
->adjustInvoices()
@ -53,19 +54,23 @@ class RefundPayment
->save();
}
/**
* Process the refund through the gateway
*
* @return $this
*/
private function processGatewayRefund()
{
if ($this->refund_data['gateway_refund'] !== false && $this->total_refund > 0) {
$gateway = CompanyGateway::first();
if ($gateway) {
if ($this->payment->company_gateway) {
$response = $gateway->driver($this->payment->client)->refund($this->payment, $this->total_refund);
if ($response['success']) {
throw new PaymentRefundFailed();
}
$this->payment->refunded = $this->total_refund;
$this->payment->refunded += $this->total_refund;
$this
->createActivity($gateway)
@ -78,20 +83,12 @@ class RefundPayment
return $this;
}
public function updateCreditNoteBalance()
{
$this->credit_note->balance -= $this->total_refund;
$this->credit_note->status_id = Credit::STATUS_APPLIED;
$this->credit_note->balance === 0
? $this->credit_note->status_id = Credit::STATUS_APPLIED
: $this->credit_note->status_id = Credit::STATUS_PARTIAL;
$this->credit_note->save();
return $this;
}
/**
* Create the payment activity
*
* @param json $notes gateway_transaction
* @return $this
*/
private function createActivity($notes)
{
$fields = new \stdClass;
@ -116,90 +113,43 @@ class RefundPayment
return $this;
}
/**
* Determine the amount of refund
*
* @return $this
*/
private function calculateTotalRefund()
{
if (array_key_exists('invoices', $this->refund_data) && count($this->refund_data['invoices']) > 0){
info("array of invoice to refund");
if (array_key_exists('invoices', $this->refund_data) && count($this->refund_data['invoices']) > 0)
$this->total_refund = collect($this->refund_data['invoices'])->sum('amount');
}
else{
info("no invoices found - refunding total.");
else
$this->total_refund = $this->refund_data['amount'];
}
return $this;
}
/**
* Set the payment status
*/
private function setStatus()
{
if ($this->refund_data['amount'] == $this->payment->amount) {
if ($this->refund_data['amount'] == $this->payment->amount)
$this->payment->status_id = Payment::STATUS_REFUNDED;
} else {
else
$this->payment->status_id = Payment::STATUS_PARTIALLY_REFUNDED;
}
return $this;
}
private function buildCreditNote()
{
$this->credit_note = CreditFactory::create($this->payment->company_id, $this->payment->user_id);
$this->credit_note->assigned_user_id = isset($this->payment->assigned_user_id) ?: null;
$this->credit_note->date = $this->refund_data['date'];
$this->credit_note->status_id = Credit::STATUS_SENT;
$this->credit_note->client_id = $this->payment->client->id;
$this->credit_note->amount = $this->total_refund;
$this->credit_note->balance = $this->total_refund;
$this->credit_note->save();
$this->credit_note->number = $this->payment->client->getNextCreditNumber($this->payment->client);
$this->credit_note->save();
return $this;
}
private function buildCreditLineItems()
{
$ledger_string = '';
if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
foreach ($this->refund_data['invoices'] as $invoice) {
$inv = Invoice::find($invoice['invoice_id']);
$credit_line_item = InvoiceItemFactory::create();
$credit_line_item->quantity = 1;
$credit_line_item->cost = $invoice['amount'];
$credit_line_item->product_key = ctrans('texts.invoice');
$credit_line_item->notes = ctrans('texts.refund_body', ['amount' => $invoice['amount'], 'invoice_number' => $inv->number]);
$credit_line_item->line_total = $invoice['amount'];
$credit_line_item->date = $this->refund_data['date'];
$ledger_string .= $credit_line_item->notes . ' ';
$line_items[] = $credit_line_item;
}
} else {
$credit_line_item = InvoiceItemFactory::create();
$credit_line_item->quantity = 1;
$credit_line_item->cost = $this->refund_data['amount'];
$credit_line_item->product_key = ctrans('texts.credit');
$credit_line_item->notes = ctrans('texts.credit_created_by', ['transaction_reference' => $this->payment->number]);
$credit_line_item->line_total = $this->refund_data['amount'];
$credit_line_item->date = $this->refund_data['date'];
$line_items = [];
$line_items[] = $credit_line_item;
}
$this->credit_note->line_items = $line_items;
$this->credit_note->save();
return $this;
}
/**
* Update the paymentable records
*
* @return $this
*/
private function updatePaymentables()
{
if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
@ -218,6 +168,12 @@ class RefundPayment
return $this;
}
/**
* If credits have been bundled in this payment, we
* need to reverse these
*
* @return $this
*/
private function updateCreditables()
{
@ -229,9 +185,9 @@ class RefundPayment
if ($available_credit > $this->total_refund) {
$paymentable_credit->pivot->refunded += $this->total_refund;
$paymentable_credit->pivot->save();
$paymentable_credit->balance += $this->total_refund;
$paymentable_credit->save();
$paymentable_credit->service()->setStatus(Credit::STATUS_SENT)->save();
//$paymentable_credit->save();
$this->total_refund = 0;
} else {
@ -239,7 +195,8 @@ class RefundPayment
$paymentable_credit->pivot->save();
$paymentable_credit->balance += $available_credit;
$paymentable_credit->save();
$paymentable_credit->service()->setStatus(Credit::STATUS_SENT)->save();
// $paymentable_credit->save();
$this->total_refund -= $available_credit;
}
@ -253,50 +210,137 @@ class RefundPayment
return $this;
}
/**
* Reverse the payments made on invoices
*
* @return $this
*/
private function adjustInvoices()
{
$adjustment_amount = 0;
if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
foreach ($this->refund_data['invoices'] as $refunded_invoice) {
foreach ($this->refund_data['invoices'] as $refunded_invoice)
{
$invoice = Invoice::find($refunded_invoice['invoice_id']);
$invoice->service()->updateBalance($refunded_invoice['amount'])->save();
$invoice->ledger()->updateInvoiceBalance($refunded_invoice['amount'], "Refund of payment # {$this->payment->number}")->save();
if ($invoice->amount == $invoice->balance) {
if ($invoice->amount == $invoice->balance)
$invoice->service()->setStatus(Invoice::STATUS_SENT);
} else {
else
$invoice->service()->setStatus(Invoice::STATUS_PARTIAL);
}
$invoice->save();
$client = $invoice->client;
$adjustment_amount += $refunded_invoice['amount'];
$client->balance += $refunded_invoice['amount'];
$client->save();
//todo adjust ledger balance here? or after and reference the credit and its total
}
$ledger_string = ''; //todo
// $ledger_string = "Refund for Invoice {$invoice->number} for amount " . $refunded_invoice['amount']; //todo
$this->credit_note->ledger()->updateCreditBalance($adjustment_amount, $ledger_string);
// $this->credit_note->ledger()->updateCreditBalance($adjustment_amount, $ledger_string);
$this->payment->client->paid_to_date -= $this->refund_data['amount'];
$this->payment->client->save();
$client = $this->payment->client->fresh();
$client->paid_to_date -= $this->total_refund;
$client->save();
}
return $this;
}
/**
* Saves the payment
*
* @return Payment $payment
*/
private function save()
{
$this->payment->save();
return $this->payment;
}
// public function updateCreditNoteBalance()
// {
// $this->credit_note->balance -= $this->total_refund;
// $this->credit_note->status_id = Credit::STATUS_APPLIED;
// $this->credit_note->balance === 0
// ? $this->credit_note->status_id = Credit::STATUS_APPLIED
// : $this->credit_note->status_id = Credit::STATUS_PARTIAL;
// $this->credit_note->save();
// return $this;
// }
// private function buildCreditNote()
// {
// $this->credit_note = CreditFactory::create($this->payment->company_id, $this->payment->user_id);
// $this->credit_note->assigned_user_id = isset($this->payment->assigned_user_id) ?: null;
// $this->credit_note->date = $this->refund_data['date'];
// $this->credit_note->status_id = Credit::STATUS_SENT;
// $this->credit_note->client_id = $this->payment->client->id;
// $this->credit_note->amount = $this->total_refund;
// $this->credit_note->balance = $this->total_refund;
// $this->credit_note->save();
// $this->credit_note->number = $this->payment->client->getNextCreditNumber($this->payment->client);
// $this->credit_note->save();
// return $this;
// }
// private function buildCreditLineItems()
// {
// $ledger_string = '';
// if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
// foreach ($this->refund_data['invoices'] as $invoice) {
// $inv = Invoice::find($invoice['invoice_id']);
// $credit_line_item = InvoiceItemFactory::create();
// $credit_line_item->quantity = 1;
// $credit_line_item->cost = $invoice['amount'];
// $credit_line_item->product_key = ctrans('texts.invoice');
// $credit_line_item->notes = ctrans('texts.refund_body', ['amount' => $invoice['amount'], 'invoice_number' => $inv->number]);
// $credit_line_item->line_total = $invoice['amount'];
// $credit_line_item->date = $this->refund_data['date'];
// $ledger_string .= $credit_line_item->notes . ' ';
// $line_items[] = $credit_line_item;
// }
// } else {
// $credit_line_item = InvoiceItemFactory::create();
// $credit_line_item->quantity = 1;
// $credit_line_item->cost = $this->refund_data['amount'];
// $credit_line_item->product_key = ctrans('texts.credit');
// $credit_line_item->notes = ctrans('texts.credit_created_by', ['transaction_reference' => $this->payment->number]);
// $credit_line_item->line_total = $this->refund_data['amount'];
// $credit_line_item->date = $this->refund_data['date'];
// $line_items = [];
// $line_items[] = $credit_line_item;
// }
// $this->credit_note->line_items = $line_items;
// $this->credit_note->save();
// return $this;
// }
}

View File

@ -0,0 +1,302 @@
<?php
namespace App\Services\Payment;
use App\Exceptions\PaymentRefundFailed;
use App\Factory\CreditFactory;
use App\Factory\InvoiceItemFactory;
use App\Models\Activity;
use App\Models\CompanyGateway;
use App\Models\Credit;
use App\Models\Invoice;
use App\Models\Payment;
use App\Repositories\ActivityRepository;
class RefundPayment
{
public $payment;
public $refund_data;
private $credit_note;
private $total_refund;
private $gateway_refund_status;
private $activity_repository;
public function __construct($payment, $refund_data)
{
$this->payment = $payment;
$this->refund_data = $refund_data;
$this->total_refund = 0;
$this->gateway_refund_status = false;
$this->activity_repository = new ActivityRepository();
}
public function run()
{
return $this->calculateTotalRefund() //sets amount for the refund (needed if we are refunding multiple invoices in one payment)
->setStatus() //sets status of payment
->buildCreditNote() //generate the credit note
->buildCreditLineItems() //generate the credit note items
->updateCreditables() //return the credits first
->updatePaymentables() //update the paymentable items
->adjustInvoices()
->processGatewayRefund() //process the gateway refund if needed
->save();
}
private function processGatewayRefund()
{
if ($this->refund_data['gateway_refund'] !== false && $this->total_refund > 0) {
$gateway = CompanyGateway::first();
if ($gateway) {
$response = $gateway->driver($this->payment->client)->refund($this->payment, $this->total_refund);
if ($response['success']) {
throw new PaymentRefundFailed();
}
$this->payment->refunded = $this->total_refund;
$this
->createActivity($gateway)
->updateCreditNoteBalance();
}
} else {
$this->payment->refunded += $this->total_refund;
}
return $this;
}
public function updateCreditNoteBalance()
{
$this->credit_note->balance -= $this->total_refund;
$this->credit_note->status_id = Credit::STATUS_APPLIED;
$this->credit_note->balance === 0
? $this->credit_note->status_id = Credit::STATUS_APPLIED
: $this->credit_note->status_id = Credit::STATUS_PARTIAL;
$this->credit_note->save();
return $this;
}
private function createActivity($notes)
{
$fields = new \stdClass;
$activity_repo = new ActivityRepository();
$fields->payment_id = $this->payment->id;
$fields->user_id = $this->payment->user_id;
$fields->company_id = $this->payment->company_id;
$fields->activity_type_id = Activity::REFUNDED_PAYMENT;
$fields->credit_id = $this->credit_note->id;
$fields->notes = json_encode($notes);
if (isset($this->refund_data['invoices'])) {
foreach ($this->refund_data['invoices'] as $invoice) {
$fields->invoice_id = $invoice['invoice_id'];
$activity_repo->save($fields, $this->payment);
}
} else {
$activity_repo->save($fields, $this->payment);
}
return $this;
}
private function calculateTotalRefund()
{
if (array_key_exists('invoices', $this->refund_data) && count($this->refund_data['invoices']) > 0){
info("array of invoice to refund");
$this->total_refund = collect($this->refund_data['invoices'])->sum('amount');
}
else{
info("no invoices found - refunding total.");
$this->total_refund = $this->refund_data['amount'];
}
return $this;
}
private function setStatus()
{
if ($this->refund_data['amount'] == $this->payment->amount) {
$this->payment->status_id = Payment::STATUS_REFUNDED;
} else {
$this->payment->status_id = Payment::STATUS_PARTIALLY_REFUNDED;
}
return $this;
}
private function buildCreditNote()
{
$this->credit_note = CreditFactory::create($this->payment->company_id, $this->payment->user_id);
$this->credit_note->assigned_user_id = isset($this->payment->assigned_user_id) ?: null;
$this->credit_note->date = $this->refund_data['date'];
$this->credit_note->status_id = Credit::STATUS_SENT;
$this->credit_note->client_id = $this->payment->client->id;
$this->credit_note->amount = $this->total_refund;
$this->credit_note->balance = $this->total_refund;
$this->credit_note->save();
$this->credit_note->number = $this->payment->client->getNextCreditNumber($this->payment->client);
$this->credit_note->save();
return $this;
}
private function buildCreditLineItems()
{
$ledger_string = '';
if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
foreach ($this->refund_data['invoices'] as $invoice) {
$inv = Invoice::find($invoice['invoice_id']);
$credit_line_item = InvoiceItemFactory::create();
$credit_line_item->quantity = 1;
$credit_line_item->cost = $invoice['amount'];
$credit_line_item->product_key = ctrans('texts.invoice');
$credit_line_item->notes = ctrans('texts.refund_body', ['amount' => $invoice['amount'], 'invoice_number' => $inv->number]);
$credit_line_item->line_total = $invoice['amount'];
$credit_line_item->date = $this->refund_data['date'];
$ledger_string .= $credit_line_item->notes . ' ';
$line_items[] = $credit_line_item;
}
} else {
$credit_line_item = InvoiceItemFactory::create();
$credit_line_item->quantity = 1;
$credit_line_item->cost = $this->refund_data['amount'];
$credit_line_item->product_key = ctrans('texts.credit');
$credit_line_item->notes = ctrans('texts.credit_created_by', ['transaction_reference' => $this->payment->number]);
$credit_line_item->line_total = $this->refund_data['amount'];
$credit_line_item->date = $this->refund_data['date'];
$line_items = [];
$line_items[] = $credit_line_item;
}
$this->credit_note->line_items = $line_items;
$this->credit_note->save();
return $this;
}
private function updatePaymentables()
{
if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
$this->payment->invoices->each(function ($paymentable_invoice) {
collect($this->refund_data['invoices'])->each(function ($refunded_invoice) use ($paymentable_invoice) {
if ($refunded_invoice['invoice_id'] == $paymentable_invoice->id) {
$paymentable_invoice->pivot->refunded += $refunded_invoice['amount'];
$paymentable_invoice->pivot->save();
}
});
});
}
return $this;
}
private function updateCreditables()
{
if ($this->payment->credits()->exists()) {
//Adjust credits first!!!
foreach ($this->payment->credits as $paymentable_credit) {
$available_credit = $paymentable_credit->pivot->amount - $paymentable_credit->pivot->refunded;
if ($available_credit > $this->total_refund) {
$paymentable_credit->pivot->refunded += $this->total_refund;
$paymentable_credit->pivot->save();
$paymentable_credit->balance += $this->total_refund;
$paymentable_credit->save();
$this->total_refund = 0;
} else {
$paymentable_credit->pivot->refunded += $available_credit;
$paymentable_credit->pivot->save();
$paymentable_credit->balance += $available_credit;
$paymentable_credit->save();
$this->total_refund -= $available_credit;
}
if ($this->total_refund == 0) {
break;
}
}
}
return $this;
}
private function adjustInvoices()
{
$adjustment_amount = 0;
if (isset($this->refund_data['invoices']) && count($this->refund_data['invoices']) > 0) {
foreach ($this->refund_data['invoices'] as $refunded_invoice) {
$invoice = Invoice::find($refunded_invoice['invoice_id']);
$invoice->service()->updateBalance($refunded_invoice['amount'])->save();
if ($invoice->amount == $invoice->balance) {
$invoice->service()->setStatus(Invoice::STATUS_SENT);
} else {
$invoice->service()->setStatus(Invoice::STATUS_PARTIAL);
}
$invoice->save();
$client = $invoice->client;
$adjustment_amount += $refunded_invoice['amount'];
$client->balance += $refunded_invoice['amount'];
$client->save();
//todo adjust ledger balance here? or after and reference the credit and its total
}
$ledger_string = ''; //todo
$this->credit_note->ledger()->updateCreditBalance($adjustment_amount, $ledger_string);
$this->payment->client->paid_to_date -= $this->refund_data['amount'];
$this->payment->client->save();
}
return $this;
}
private function save()
{
$this->payment->save();
return $this->payment;
}
}

View File

@ -954,6 +954,7 @@ class CreateUsersTable extends Migration
$t->unsignedInteger('client_contact_id')->nullable();
$t->unsignedInteger('invitation_id')->nullable();
$t->unsignedInteger('company_gateway_id')->nullable();
$t->unsignedInteger('gateway_type_id')->nullable();
$t->unsignedInteger('type_id')->nullable();
$t->unsignedInteger('status_id')->index();
$t->decimal('amount', 16, 4)->default(0);

View File

@ -265,29 +265,29 @@ class RandomDataSeeder extends Seeder
]);
if (config('ninja.testvars.stripe')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.stripe'));
$cg->save();
// if (config('ninja.testvars.stripe')) {
// $cg = new CompanyGateway;
// $cg->company_id = $company->id;
// $cg->user_id = $user->id;
// $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
// $cg->require_cvv = true;
// $cg->show_billing_address = true;
// $cg->show_shipping_address = true;
// $cg->update_details = true;
// $cg->config = encrypt(config('ninja.testvars.stripe'));
// $cg->save();
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.stripe'));
$cg->save();
}
// $cg = new CompanyGateway;
// $cg->company_id = $company->id;
// $cg->user_id = $user->id;
// $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
// $cg->require_cvv = true;
// $cg->show_billing_address = true;
// $cg->show_shipping_address = true;
// $cg->update_details = true;
// $cg->config = encrypt(config('ninja.testvars.stripe'));
// $cg->save();
// }
// if (config('ninja.testvars.paypal')) {
// $cg = new CompanyGateway;
@ -315,18 +315,18 @@ class RandomDataSeeder extends Seeder
// $cg->save();
// }
// if(config('ninja.testvars.authorize')) {
// $cg = new CompanyGateway;
// $cg->company_id = $company->id;
// $cg->user_id = $user->id;
// $cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb';
// $cg->require_cvv = true;
// $cg->show_billing_address = true;
// $cg->show_shipping_address = true;
// $cg->update_details = true;
// $cg->config = encrypt(config('ninja.testvars.authorize'));
// $cg->save();
// }
if(config('ninja.testvars.authorize')) {
$cg = new CompanyGateway;
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '3b6621f970ab18887c4f6dca78d3f8bb';
$cg->require_cvv = true;
$cg->show_billing_address = true;
$cg->show_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.authorize'));
$cg->save();
}
}
}

View File

@ -1,2 +1,2 @@
/*! For license information please see action-selectors.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=5)}({5:function(e,t,n){e.exports=n("Boob")},Boob:function(e,t){function n(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)}}(new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentElement=document.querySelector(".form-check-parent"),this.parentForm=document.getElementById("bulkActions")}var t,r,o;return t=e,(r=[{key:"watchCheckboxes",value:function(e){var t=this;document.querySelectorAll(".form-check-child").forEach((function(n){e.checked?(n.checked=e.checked,t.processChildItem(n,document.getElementById("bulkActions"))):(n.checked=!1,document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()})))}))}},{key:"processChildItem",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n.hasOwnProperty("single")&&document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()}));var r=document.createElement("INPUT");r.setAttribute("name","invoices[]"),r.setAttribute("value",e.dataset.value),r.setAttribute("class","child-hidden-input"),r.hidden=!0,t.append(r)}},{key:"handle",value:function(){var e=this;this.parentElement.addEventListener("click",(function(){e.watchCheckboxes(e.parentElement)}));var t=!0,n=!1,r=void 0;try{for(var o,c=function(){var t=o.value;t.addEventListener("click",(function(){e.processChildItem(t,e.parentForm)}))},u=document.querySelectorAll(".form-check-child")[Symbol.iterator]();!(t=(o=u.next()).done);t=!0)c()}catch(e){n=!0,r=e}finally{try{t||null==u.return||u.return()}finally{if(n)throw r}}}}])&&n(t.prototype,r),o&&n(t,o),e}())).handle()}});
!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=5)}({5:function(e,t,n){e.exports=n("Boob")},Boob:function(e,t){function n(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)}}(new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentElement=document.querySelector(".form-check-parent"),this.parentForm=document.getElementById("bulkActions")}var t,r,o;return t=e,(r=[{key:"watchCheckboxes",value:function(e){var t=this;document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()})),document.querySelectorAll(".form-check-child").forEach((function(n){e.checked?(n.checked=e.checked,t.processChildItem(n,document.getElementById("bulkActions"))):(n.checked=!1,document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()})))}))}},{key:"processChildItem",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(n.hasOwnProperty("single")&&document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()})),!1!==e.checked){var r=document.createElement("INPUT");r.setAttribute("name","invoices[]"),r.setAttribute("value",e.dataset.value),r.setAttribute("class","child-hidden-input"),r.hidden=!0,t.append(r)}else{var o=document.querySelectorAll("input.child-hidden-input"),c=!0,u=!1,l=void 0;try{for(var i,a=o[Symbol.iterator]();!(c=(i=a.next()).done);c=!0){var d=i.value;d.value==e.dataset.value&&d.remove()}}catch(e){u=!0,l=e}finally{try{c||null==a.return||a.return()}finally{if(u)throw l}}}}},{key:"handle",value:function(){var e=this;this.parentElement.addEventListener("click",(function(){e.watchCheckboxes(e.parentElement)}));var t=!0,n=!1,r=void 0;try{for(var o,c=function(){var t=o.value;t.addEventListener("click",(function(){e.processChildItem(t,e.parentForm)}))},u=document.querySelectorAll(".form-check-child")[Symbol.iterator]();!(t=(o=u.next()).done);t=!0)c()}catch(e){n=!0,r=e}finally{try{t||null==u.return||u.return()}finally{if(n)throw r}}}}])&&n(t.prototype,r),o&&n(t,o),e}())).handle()}});

View File

@ -1 +1,2 @@
!function(e){var t={};function n(a){if(t[a])return t[a].exports;var r=t[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},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 a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(a,r,function(t){return e[t]}.bind(null,r));return a},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=2)}({2:function(e,t,n){e.exports=n("6vDv")},"6vDv":function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}new(function(){function e(t,n){var a,r,o,i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o=function(){document.getElementById("card_number").addEventListener("keyup",(function(e){var t=document.getElementById("card_number_errors");valid.number(e.target.value).isValid?(t.hidden=!0,i.form.valid=!0):(t.textContent=i.translations.invalidCard,t.hidden=!1,i.form.valid=!1)})),document.getElementById("expiration_month").addEventListener("keyup",(function(e){var t=document.getElementById("expiration_month_errors");valid.expirationMonth(e.target.value).isValid?(t.hidden=!0,i.form.valid=!0):(t.textContent=i.translations.invalidMonth,t.hidden=!1,i.form.valid=!1)})),document.getElementById("expiration_year").addEventListener("keyup",(function(e){var t=document.getElementById("expiration_year_errors");valid.expirationYear(e.target.value).isValid?(t.hidden=!0,i.form.valid=!0):(t.textContent=i.translations.invalidYear,t.hidden=!1,i.form.valid=!1)}))},(r="handleFormValidation")in(a=this)?Object.defineProperty(a,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):a[r]=o,this.publicKey=t,this.loginId=n,this.cardHolderName=document.getElementById("cardholder_name"),this.cardButton=document.getElementById("card_button"),this.form={valid:!1},this.translations={invalidCard:document.querySelector('meta[name="credit-card-invalid"]').content,invalidMonth:document.querySelector('meta[name="month-invalid"]').content,invalidYear:document.querySelector('meta[name="year-invalid"]').content}}var t,a,r;return t=e,(a=[{key:"handleAuthorization",value:function(){var e={};e.clientKey=this.publicKey,e.apiLoginID=this.loginId;var t={};t.cardNumber=document.getElementById("card_number").value,t.month=document.getElementById("expiration_month").value,t.year=document.getElementById("expiration_year").value,t.cardCode=document.getElementById("cvv").value;var n={};return n.authData=e,n.cardData=t,Accept.dispatchData(n,this.responseHandler),!1}},{key:"responseHandler",value:function(e){if("Error"===e.messages.resultCode)for(var t=0;t<e.messages.message.length;)console.log(e.messages.message[t].code+": "+e.messages.message[t].text),t+=1;else"Ok"===e.messages.resultCode&&(document.getElementById("dataDescriptor").value=e.opaqueData.dataDescriptor,document.getElementById("dataValue").value=e.opaqueData.dataValue,document.getElementById("server_response").submit());return!1}},{key:"handle",value:function(){var e=this;return this.handleFormValidation(),this.cardButton.addEventListener("click",(function(){e.cardButton.disabled=!e.cardButton.disabled})),this}}])&&n(t.prototype,a),r&&n(t,r),e}())(document.querySelector('meta[name="authorize-public-key"]').content,document.querySelector('meta[name="authorize-login-id"]').content).handle()}});
/*! For license information please see authorize-authorize-card.js.LICENSE.txt */
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.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 a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));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=2)}({2:function(e,t,n){e.exports=n("6vDv")},"6vDv":function(e,t){function n(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)}}new(function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.publicKey=t,this.loginId=n,this.cardHolderName=document.getElementById("cardholder_name"),this.cardButton=document.getElementById("card_button")}var t,r,a;return t=e,(r=[{key:"handleAuthorization",value:function(){var e=$("#my-card"),t={};t.clientKey=this.publicKey,t.apiLoginID=this.loginId;var n={};n.cardNumber=e.CardJs("cardNumber"),n.month=e.CardJs("expiryMonth"),n.year=e.CardJs("expiryYear"),n.cardCode=document.getElementById("cvv").value;var r={};return r.authData=t,r.cardData=n,Accept.dispatchData(r,this.responseHandler),!1}},{key:"responseHandler",value:function(e){if("Error"===e.messages.resultCode)for(var t=0;t<e.messages.message.length;)console.log(e.messages.message[t].code+": "+e.messages.message[t].text),t+=1;else"Ok"===e.messages.resultCode&&(document.getElementById("dataDescriptor").value=e.opaqueData.dataDescriptor,document.getElementById("dataValue").value=e.opaqueData.dataValue,document.getElementById("server_response").submit());return!1}},{key:"handle",value:function(){var e=this;return this.cardButton.addEventListener("click",(function(){e.cardButton.disabled=!e.cardButton.disabled,e.handleAuthorization()})),this}}])&&n(t.prototype,r),a&&n(t,a),e}())(document.querySelector('meta[name="authorize-public-key"]').content,document.querySelector('meta[name="authorize-login-id"]').content).handle()}});

View File

@ -1,2 +1,2 @@
/*! For license information please see action-selectors.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=10)}({10:function(e,t,n){e.exports=n("ydWM")},ydWM:function(e,t){function n(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)}}(new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentElement=document.querySelector(".form-check-parent"),this.parentForm=document.getElementById("bulkActions")}var t,r,o;return t=e,(r=[{key:"watchCheckboxes",value:function(e){var t=this;document.querySelectorAll(".form-check-child").forEach((function(n){e.checked?(n.checked=e.checked,t.processChildItem(n,document.getElementById("bulkActions"))):(n.checked=!1,document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()})))}))}},{key:"processChildItem",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n.hasOwnProperty("single")&&document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()}));var r=document.createElement("INPUT");r.setAttribute("name","quotes[]"),r.setAttribute("value",e.dataset.value),r.setAttribute("class","child-hidden-input"),r.hidden=!0,t.append(r)}},{key:"handle",value:function(){var e=this;this.parentElement.addEventListener("click",(function(){e.watchCheckboxes(e.parentElement)}));var t=!0,n=!1,r=void 0;try{for(var o,c=function(){var t=o.value;t.addEventListener("click",(function(){e.processChildItem(t,e.parentForm)}))},u=document.querySelectorAll(".form-check-child")[Symbol.iterator]();!(t=(o=u.next()).done);t=!0)c()}catch(e){n=!0,r=e}finally{try{t||null==u.return||u.return()}finally{if(n)throw r}}}}])&&n(t.prototype,r),o&&n(t,o),e}())).handle()}});
!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=10)}({10:function(e,t,n){e.exports=n("ydWM")},ydWM:function(e,t){function n(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)}}(new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentElement=document.querySelector(".form-check-parent"),this.parentForm=document.getElementById("bulkActions")}var t,r,o;return t=e,(r=[{key:"watchCheckboxes",value:function(e){var t=this;document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()})),document.querySelectorAll(".form-check-child").forEach((function(n){e.checked?(n.checked=e.checked,t.processChildItem(n,document.getElementById("bulkActions"))):(n.checked=!1,document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()})))}))}},{key:"processChildItem",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(n.hasOwnProperty("single")&&document.querySelectorAll(".child-hidden-input").forEach((function(e){return e.remove()})),!1!==e.checked){var r=document.createElement("INPUT");r.setAttribute("name","invoices[]"),r.setAttribute("value",e.dataset.value),r.setAttribute("class","child-hidden-input"),r.hidden=!0,t.append(r)}else{var o=document.querySelectorAll("input.child-hidden-input"),c=!0,u=!1,l=void 0;try{for(var i,a=o[Symbol.iterator]();!(c=(i=a.next()).done);c=!0){var d=i.value;d.value==e.dataset.value&&d.remove()}}catch(e){u=!0,l=e}finally{try{c||null==a.return||a.return()}finally{if(u)throw l}}}}},{key:"handle",value:function(){var e=this;this.parentElement.addEventListener("click",(function(){e.watchCheckboxes(e.parentElement)}));var t=!0,n=!1,r=void 0;try{for(var o,c=function(){var t=o.value;t.addEventListener("click",(function(){e.processChildItem(t,e.parentForm)}))},u=document.querySelectorAll(".form-check-child")[Symbol.iterator]();!(t=(o=u.next()).done);t=!0)c()}catch(e){n=!0,r=e}finally{try{t||null==u.return||u.return()}finally{if(n)throw r}}}}])&&n(t.prototype,r),o&&n(t,o),e}())).handle()}});

View File

@ -1,10 +1,10 @@
{
"/js/app.js": "/js/app.js?id=baf7fef12d5e65c3d9ff",
"/css/app.css": "/css/app.css?id=369c7335c317e8ac0212",
"/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=0632d6281202800e0921",
"/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=d244486b16dc6f94a726",
"/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=d7e708d66a9c769b4c6e",
"/js/clients/payment_methods/authorize-ach.js": "/js/clients/payment_methods/authorize-ach.js?id=9e6495d9ae236b3cb5ad",
"/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=3f6129bf10ff3bf20332",
"/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=83c223814db63f9db590",
"/js/clients/payment_methods/authorize-stripe-card.js": "/js/clients/payment_methods/authorize-stripe-card.js?id=f4c45f0da9868d840799",
"/js/clients/payments/alipay.js": "/js/clients/payments/alipay.js?id=428ac5b81ed722636e8f",
"/js/clients/payments/authorize-credit-card-payment.js": "/js/clients/payments/authorize-credit-card-payment.js?id=3a74587f41c617a7cc81",
@ -12,7 +12,7 @@
"/js/clients/payments/checkout.com.js": "/js/clients/payments/checkout.com.js?id=42d239882b80af83ad22",
"/js/clients/payments/process.js": "/js/clients/payments/process.js?id=49b220081e0d7fa8140b",
"/js/clients/payments/sofort.js": "/js/clients/payments/sofort.js?id=ff4ad07a93bd9fb327c1",
"/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=2fe0ad3e46ead2edb8c3",
"/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=b6b33ab51b58b51e1212",
"/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=1c5d76fb5f98bd49f6c8",
"/js/clients/shared/pdf.js": "/js/clients/shared/pdf.js?id=ba1182244cda0e0ffbeb",
"/js/setup/setup.js": "/js/setup/setup.js?id=87653cfb4084aadea7a2",

View File

@ -10,48 +10,65 @@
class ActionSelectors {
constructor() {
this.parentElement = document.querySelector(".form-check-parent");
this.parentForm = document.getElementById("bulkActions");
this.parentElement = document.querySelector('.form-check-parent');
this.parentForm = document.getElementById('bulkActions');
}
watchCheckboxes(parentElement) {
document.querySelectorAll(".form-check-child").forEach(child => {
document
.querySelectorAll('.child-hidden-input')
.forEach((element) => element.remove());
document.querySelectorAll('.form-check-child').forEach((child) => {
if (parentElement.checked) {
child.checked = parentElement.checked;
this.processChildItem(child, document.getElementById("bulkActions"));
this.processChildItem(
child,
document.getElementById('bulkActions')
);
} else {
child.checked = false;
document
.querySelectorAll(".child-hidden-input")
.forEach(element => element.remove());
.querySelectorAll('.child-hidden-input')
.forEach((element) => element.remove());
}
});
}
processChildItem(element, parent, options = {}) {
if (options.hasOwnProperty("single")) {
if (options.hasOwnProperty('single')) {
document
.querySelectorAll(".child-hidden-input")
.forEach(element => element.remove());
.querySelectorAll('.child-hidden-input')
.forEach((element) => element.remove());
}
let _temp = document.createElement("INPUT");
if (element.checked === false) {
let inputs = document.querySelectorAll('input.child-hidden-input');
_temp.setAttribute("name", "invoices[]");
_temp.setAttribute("value", element.dataset.value);
_temp.setAttribute("class", "child-hidden-input");
for (let i of inputs) {
if (i.value == element.dataset.value) i.remove();
}
return;
}
let _temp = document.createElement('INPUT');
_temp.setAttribute('name', 'invoices[]');
_temp.setAttribute('value', element.dataset.value);
_temp.setAttribute('class', 'child-hidden-input');
_temp.hidden = true;
parent.append(_temp);
}
handle() {
this.parentElement.addEventListener("click", () => {
this.parentElement.addEventListener('click', () => {
this.watchCheckboxes(this.parentElement);
});
for (let child of document.querySelectorAll(".form-check-child")) {
child.addEventListener("click", () => {
for (let child of document.querySelectorAll('.form-check-child')) {
child.addEventListener('click', () => {
this.processChildItem(child, this.parentForm);
});
}

View File

@ -15,34 +15,26 @@ class AuthorizeAuthorizeCard {
this.loginId = loginId;
this.cardHolderName = document.getElementById("cardholder_name");
this.cardButton = document.getElementById("card_button");
this.form = { valid: false };
this.translations = {
invalidCard: document.querySelector('meta[name="credit-card-invalid"]').content,
invalidMonth: document.querySelector('meta[name="month-invalid"]').content,
invalidYear: document.querySelector('meta[name="year-invalid"]').content,
}
}
handleAuthorization() {
var myCard = $('#my-card');
var authData = {};
var authData = {};
authData.clientKey = this.publicKey;
authData.apiLoginID = this.loginId;
var cardData = {};
cardData.cardNumber = document.getElementById("card_number").value;
cardData.month = document.getElementById("expiration_month").value;
cardData.year = document.getElementById("expiration_year").value;
var cardData = {};
cardData.cardNumber = myCard.CardJs('cardNumber');
cardData.month = myCard.CardJs('expiryMonth');
cardData.year = myCard.CardJs('expiryYear');;
cardData.cardCode = document.getElementById("cvv").value;
var secureData = {};
var secureData = {};
secureData.authData = authData;
secureData.cardData = cardData;
// If using banking information instead of card information,
// send the bankData object instead of the cardData object.
//
// secureData.bankData = bankData;
Accept.dispatchData(secureData, this.responseHandler);
return false;
@ -71,53 +63,15 @@ class AuthorizeAuthorizeCard {
return false;
}
handleFormValidation = () => {
document.getElementById("card_number").addEventListener('keyup', (e) => {
let errors = document.getElementById('card_number_errors');
if (valid.number(e.target.value).isValid) {
errors.hidden = true;
this.form.valid = true;
} else {
errors.textContent = this.translations.invalidCard;
errors.hidden = false;
this.form.valid = false;
}
});
document.getElementById("expiration_month").addEventListener('keyup', (e) => {
let errors = document.getElementById('expiration_month_errors');
if (valid.expirationMonth(e.target.value).isValid) {
errors.hidden = true;
this.form.valid = true;
} else {
errors.textContent = this.translations.invalidMonth;
errors.hidden = false;
this.form.valid = false;
}
});
document.getElementById("expiration_year").addEventListener('keyup', (e) => {
let errors = document.getElementById('expiration_year_errors');
if (valid.expirationYear(e.target.value).isValid) {
errors.hidden = true;
this.form.valid = true;
} else {
errors.textContent = this.translations.invalidYear;
errors.hidden = false;
this.form.valid = false;
}
});
}
handle() {
this.handleFormValidation();
//this.handleFormValidation();
// At this point as an small API you can request this.form.valid to check if input elements are valid.
// Note: this.form.valid will not handle empty fields.
this.cardButton.addEventListener("click", () => {
this.cardButton.disabled = !this.cardButton.disabled;
// this.handleAuthorization();
this.handleAuthorization();
});

View File

@ -10,48 +10,65 @@
class ActionSelectors {
constructor() {
this.parentElement = document.querySelector(".form-check-parent");
this.parentForm = document.getElementById("bulkActions");
this.parentElement = document.querySelector('.form-check-parent');
this.parentForm = document.getElementById('bulkActions');
}
watchCheckboxes(parentElement) {
document.querySelectorAll(".form-check-child").forEach(child => {
document
.querySelectorAll('.child-hidden-input')
.forEach((element) => element.remove());
document.querySelectorAll('.form-check-child').forEach((child) => {
if (parentElement.checked) {
child.checked = parentElement.checked;
this.processChildItem(child, document.getElementById("bulkActions"));
this.processChildItem(
child,
document.getElementById('bulkActions')
);
} else {
child.checked = false;
document
.querySelectorAll(".child-hidden-input")
.forEach(element => element.remove());
.querySelectorAll('.child-hidden-input')
.forEach((element) => element.remove());
}
});
}
processChildItem(element, parent, options = {}) {
if (options.hasOwnProperty("single")) {
if (options.hasOwnProperty('single')) {
document
.querySelectorAll(".child-hidden-input")
.forEach(element => element.remove());
.querySelectorAll('.child-hidden-input')
.forEach((element) => element.remove());
}
let _temp = document.createElement("INPUT");
if (element.checked === false) {
let inputs = document.querySelectorAll('input.child-hidden-input');
_temp.setAttribute("name", "quotes[]");
_temp.setAttribute("value", element.dataset.value);
_temp.setAttribute("class", "child-hidden-input");
for (let i of inputs) {
if (i.value == element.dataset.value) i.remove();
}
return;
}
let _temp = document.createElement('INPUT');
_temp.setAttribute('name', 'invoices[]');
_temp.setAttribute('value', element.dataset.value);
_temp.setAttribute('class', 'child-hidden-input');
_temp.hidden = true;
parent.append(_temp);
}
handle() {
this.parentElement.addEventListener("click", () => {
this.parentElement.addEventListener('click', () => {
this.watchCheckboxes(this.parentElement);
});
for (let child of document.querySelectorAll(".form-check-child")) {
child.addEventListener("click", () => {
for (let child of document.querySelectorAll('.form-check-child')) {
child.addEventListener('click', () => {
this.processChildItem(child, this.parentForm);
});
}

View File

@ -3223,5 +3223,9 @@ return [
'month_invalid' => 'Provided month is not valid.',
'year_invalid' => 'Provided year is not valid.',
'if_you_need_help' => 'If you need help you can either post to our',
'https_required' => 'HTTPS is required, form will fail',
'if_you_need_help' => 'If you need help you can either post to our',
'reversed' => 'Reversed',
'update_password_on_confirm' => 'After updating password, your account will be confirmed.',
'bank_account_not_linked' => 'To pay with bank account, first you have to add it as payment method.',
];

View File

@ -90,7 +90,7 @@
{!! App\Models\Quote::badgeForStatus($quote->status_id) !!}
</td>
<td class="px-6 py-4 whitespace-no-wrap flex items-center justify-end text-sm leading-5 font-medium">
<a href="{{ route('client.quotes.show', $quote->hashed_id) }}" class="button-link">
<a href="{{ route('client.quote.show', $quote->hashed_id) }}" class="button-link">
@lang('texts.view')
</a>
</td>

View File

@ -30,6 +30,9 @@
<div class="grid grid-cols-6 gap-4">
<div class="col-span-6 md:col-start-2 md:col-span-3">
<div class="alert alert-failure mb-4" hidden id="errors"></div>
@if(!Request::isSecure())
<p class="alert alert-failure">{{ ctrans('texts.https_required') }}</p>
@endif
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
<div class="px-4 py-5 border-b border-gray-200 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">

View File

@ -2,18 +2,20 @@
@section('meta_title', ctrans('texts.ach'))
@section('body')
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
@csrf
@foreach($invoices as $invoice)
<input type="hidden" name="hashed_ids[]" value="{{ $invoice->hashed_id }}">
@endforeach
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">
<input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}">
<input type="hidden" name="source" value="{{ $token->meta->id }}">
<input type="hidden" name="amount" value="{{ $amount }}">
<input type="hidden" name="currency" value="{{ $currency }}">
<input type="hidden" name="customer" value="{{ $customer->id }}">
</form>
@if($token)
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
@csrf
@foreach($invoices as $invoice)
<input type="hidden" name="hashed_ids[]" value="{{ $invoice->hashed_id }}">
@endforeach
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">
<input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}">
<input type="hidden" name="source" value="{{ $token->meta->id }}">
<input type="hidden" name="amount" value="{{ $amount }}">
<input type="hidden" name="currency" value="{{ $currency }}">
<input type="hidden" name="customer" value="{{ $customer->id }}">
</form>
@endif
<div class="container mx-auto">
<div class="grid grid-cols-6 gap-4">
@ -29,27 +31,36 @@
</p>
</div>
<div>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
{{ ctrans('texts.payment_type') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ ctrans('texts.ach') }} ({{ ctrans('texts.bank_transfer') }}) (****{{ $token->meta->last4 }})
</dd>
</div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
{{ ctrans('texts.amount') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<span class="font-bold">{{ App\Utils\Number::formatMoney($amount, $client) }}</span>
</dd>
</div>
<div class="bg-gray-50 px-4 py-5 flex justify-end">
<button type="button" id="pay-now" class="button button-primary" onclick="document.getElementById('server-response').submit()">
{{ ctrans('texts.pay_now') }}
</button>
</div>
@if($token)
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
{{ ctrans('texts.payment_type') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ ctrans('texts.ach') }} ({{ ctrans('texts.bank_transfer') }}) (****{{ $token->meta->last4 }})
</dd>
</div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
{{ ctrans('texts.amount') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<span class="font-bold">{{ App\Utils\Number::formatMoney($amount, $client) }}</span>
</dd>
</div>
<div class="bg-gray-50 px-4 py-5 flex justify-end">
<button type="button" id="pay-now" class="button button-primary" onclick="document.getElementById('server-response').submit()">
{{ ctrans('texts.pay_now') }}
</button>
</div>
@else
<div class="bg-gray-50 px-4 py-5 sm:px-6 flex items-center">
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<span>{{ ctrans('texts.bank_account_not_linked') }}</span>
<a class="button button-link" href="{{ route('client.payment_methods.index') }}">{{ ctrans('texts.add_payment_method') }}</a>
</dd>
</div>
@endif
</div>
</div>
</div>

View File

@ -13,7 +13,6 @@
@section('body')
<div class="flex justify-between items-center">
<span>{{ ctrans('texts.with_selected') }}</span>
<form action="{{ route('client.quotes.bulk') }}" method="post" id="bulkActions">
@csrf
<button type="submit" class="button button-primary" name="action"

View File

@ -0,0 +1,43 @@
@extends('portal.ninja2020.layout.clean')
@section('meta_title', ctrans('texts.set_password'))
@section('body')
<div class="flex h-screen">
<div class="m-auto md:w-1/3 lg:w-1/5">
<div class="flex flex-col">
<img src="{{ asset('images/invoiceninja-black-logo-2.png') }}" class="border-b border-gray-100 h-18 pb-4" alt="Invoice Ninja logo">
<h1 class="text-center text-3xl mt-10">{{ ctrans('texts.set_password') }}</h1>
<span class="text-gray-900 text-sm text-center">{{ ctrans('texts.update_password_on_confirm') }}</span>
<form action="{{ url()->current() }}" method="post" class="mt-6">
@csrf
<div class="flex flex-col mt-4">
<label for="password" class="input-label">{{ ctrans('texts.password') }}</label>
<input type="password" name="password" id="password"
class="input"
autofocus>
@error('password')
<div class="validation validation-fail">
{{ $message }}
</div>
@enderror
</div>
<div class="flex flex-col mt-4">
<label for="password" class="input-label">{{ ctrans('texts.password_confirmation') }}</label>
<input type="password" name="password_confirmation" id="password_confirmation"
class="input"
autofocus>
@error('password_confirmation')
<div class="validation validation-fail">
{{ $message }}
</div>
@enderror
</div>
<div class="mt-5">
<button class="button button-primary button-block">{{ ctrans('texts.update') }}</button>
</div>
</form>
</div>
</div>
</div>
@endsection

View File

@ -38,7 +38,7 @@
@enderror
</div>
<div class="flex flex-col mt-4">
<label for="password" class="input-label">{{ ctrans('texts.password') }}</label>
<label for="password" class="input-label">{{ ctrans('texts.password_confirmation') }}</label>
<input type="password" name="password_confirmation" id="password_confirmation"
class="input"
autofocus>

View File

@ -25,4 +25,5 @@ Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('passw
*/
Route::group(['middleware' => ['url_db']], function () {
Route::get('/user/confirm/{confirmation_code}', 'UserController@confirm');
Route::post('/user/confirm/{confirmation_code}', 'UserController@confirmWithPassword');
});

View File

@ -47,9 +47,6 @@ class UserTest extends TestCase
$this->makeTestData();
$this->withoutMiddleware(
ThrottleRequests::class
);
}
public function testUserList()
@ -68,7 +65,7 @@ class UserTest extends TestCase
$data = [
'first_name' => 'hey',
'last_name' => 'you',
'email' => 'bob@good.ole.boys.com',
'email' => 'bob1@good.ole.boys.com',
'company_user' => [
'is_admin' => false,
'is_owner' => false,
@ -79,7 +76,7 @@ class UserTest extends TestCase
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
])->post('/api/v1/users?include=company_user', $data);
$response->assertStatus(200);