mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fix PaymentWasCreated event second parameter (#3175)
This commit is contained in:
parent
e406020ee5
commit
1f7c661929
@ -92,14 +92,14 @@ class CreateTestData extends Command
|
||||
$user = User::whereEmail('small@example.com')->first();
|
||||
|
||||
if(!$user)
|
||||
{
|
||||
{
|
||||
$user = factory(\App\Models\User::class)->create([
|
||||
// 'account_id' => $account->id,
|
||||
'email' => 'small@example.com',
|
||||
'confirmation_code' => $this->createDbHash(config('database.default'))
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$token = \Illuminate\Support\Str::random(64);
|
||||
|
||||
$company_token = CompanyToken::create([
|
||||
@ -147,14 +147,14 @@ class CreateTestData extends Command
|
||||
$user = User::whereEmail('medium@example.com')->first();
|
||||
|
||||
if(!$user)
|
||||
{
|
||||
{
|
||||
$user = factory(\App\Models\User::class)->create([
|
||||
// 'account_id' => $account->id,
|
||||
'email' => 'medium@example.com',
|
||||
'confirmation_code' => $this->createDbHash(config('database.default'))
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$token = \Illuminate\Support\Str::random(64);
|
||||
|
||||
$company_token = CompanyToken::create([
|
||||
@ -203,14 +203,14 @@ class CreateTestData extends Command
|
||||
$user = User::whereEmail('large@example.com')->first();
|
||||
|
||||
if(!$user)
|
||||
{
|
||||
{
|
||||
$user = factory(\App\Models\User::class)->create([
|
||||
// 'account_id' => $account->id,
|
||||
'email' => 'large@example.com',
|
||||
'confirmation_code' => $this->createDbHash(config('database.default'))
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$token = \Illuminate\Support\Str::random(64);
|
||||
|
||||
$company_token = CompanyToken::create([
|
||||
@ -283,7 +283,7 @@ class CreateTestData extends Command
|
||||
$invoice = InvoiceFactory::create($client->company->id,$client->user->id);//stub the company and user_id
|
||||
$invoice->client_id = $client->id;
|
||||
$invoice->date = $faker->date();
|
||||
|
||||
|
||||
$invoice->line_items = $this->buildLineItems();
|
||||
$invoice->uses_inclusive_taxes = false;
|
||||
|
||||
@ -315,7 +315,7 @@ class CreateTestData extends Command
|
||||
$invoice->save();
|
||||
|
||||
event(new CreateInvoiceInvitation($invoice));
|
||||
|
||||
|
||||
UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance);
|
||||
|
||||
$this->invoice_repo->markSent($invoice);
|
||||
@ -349,7 +349,7 @@ class CreateTestData extends Command
|
||||
$quote = QuoteFactory::create($client->company->id,$client->user->id);//stub the company and user_id
|
||||
$quote->client_id = $client->id;
|
||||
$quote->date = $faker->date();
|
||||
|
||||
|
||||
$quote->line_items = $this->buildLineItems();
|
||||
$quote->uses_inclusive_taxes = false;
|
||||
|
||||
@ -379,7 +379,7 @@ class CreateTestData extends Command
|
||||
$quote = $quote_calc->getInvoice();
|
||||
|
||||
$quote->save();
|
||||
|
||||
|
||||
CreateQuoteInvitations::dispatch($quote, $quote->company);
|
||||
|
||||
|
||||
@ -393,19 +393,19 @@ class CreateTestData extends Command
|
||||
$item->quantity = 1;
|
||||
$item->cost =10;
|
||||
|
||||
if(rand(0, 1))
|
||||
if(rand(0, 1))
|
||||
{
|
||||
$item->tax_name1 = 'GST';
|
||||
$item->tax_rate1 = 10.00;
|
||||
}
|
||||
|
||||
if(rand(0, 1))
|
||||
if(rand(0, 1))
|
||||
{
|
||||
$item->tax_name1 = 'VAT';
|
||||
$item->tax_rate1 = 17.50;
|
||||
}
|
||||
|
||||
if(rand(0, 1))
|
||||
if(rand(0, 1))
|
||||
{
|
||||
$item->tax_name1 = 'Sales Tax';
|
||||
$item->tax_rate1 = 5;
|
||||
@ -421,7 +421,7 @@ class CreateTestData extends Command
|
||||
{
|
||||
/* Warm up the cache !*/
|
||||
$cached_tables = config('ninja.cached_tables');
|
||||
|
||||
|
||||
foreach ($cached_tables as $name => $class) {
|
||||
if (! Cache::has($name)) {
|
||||
// check that the table exists in case the migration is pending
|
||||
|
@ -54,12 +54,12 @@ use Omnipay\Common\Item;
|
||||
'PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE' => 'None',
|
||||
'PAYMENTINFO_0_ERRORCODE' => '0',
|
||||
'PAYMENTINFO_0_ACK' => 'Success',
|
||||
)
|
||||
)
|
||||
*/
|
||||
|
||||
class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
|
||||
|
||||
use MakesHash;
|
||||
|
||||
protected $refundable = false;
|
||||
@ -80,7 +80,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
|
||||
/**
|
||||
* Processes the payment with this gateway
|
||||
*
|
||||
*
|
||||
* @var $data['invoices']
|
||||
* @var $data['amount']
|
||||
* @var $data['fee']
|
||||
@ -88,13 +88,13 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
* @var $data['token']
|
||||
* @var $data['payment_method_id']
|
||||
* @var $data['hashed_ids']
|
||||
*
|
||||
*
|
||||
* @param array $data variables required to build payment page
|
||||
* @return view Gateway and payment method specific view
|
||||
*/
|
||||
public function processPaymentView(array $data)
|
||||
{
|
||||
|
||||
|
||||
$response = $this->purchase($this->paymentDetails($data), $this->paymentItems($data));
|
||||
|
||||
|
||||
@ -103,14 +103,14 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
$response->redirect();
|
||||
} elseif ($response->isSuccessful()) {
|
||||
// payment was successful: update database
|
||||
/* for this driver this method wont be hit*/
|
||||
/* for this driver this method wont be hit*/
|
||||
} else {
|
||||
// payment failed: display message to customer
|
||||
|
||||
SystemLogger::dispatch([
|
||||
'server_response' => $response->getData(),
|
||||
'data' => $data
|
||||
],
|
||||
],
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_FAILURE,
|
||||
SystemLog::TYPE_PAYPAL,
|
||||
@ -118,7 +118,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
);
|
||||
|
||||
throw new \Exception("Error Processing Payment", 1);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,13 +131,13 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
|
||||
if ($response->isCancelled()) {
|
||||
return redirect()->route('client.invoices.index')->with('warning',ctrans('texts.status_voided'));
|
||||
}
|
||||
}
|
||||
elseif($response->isSuccessful()){
|
||||
|
||||
|
||||
SystemLogger::dispatch([
|
||||
'server_response' => $response->getData(),
|
||||
'data' => $request->all()
|
||||
],
|
||||
],
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_SUCCESS,
|
||||
SystemLog::TYPE_PAYPAL,
|
||||
@ -145,12 +145,12 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
);
|
||||
}
|
||||
elseif (! $response->isSuccessful()) {
|
||||
|
||||
|
||||
|
||||
|
||||
SystemLogger::dispatch([
|
||||
'data' => $request->all(),
|
||||
'server_response' => $response->getData()
|
||||
],
|
||||
],
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_FAILURE,
|
||||
SystemLog::TYPE_PAYPAL,
|
||||
@ -164,8 +164,8 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
|
||||
$this->attachInvoices($payment, $request->input('hashed_ids'));
|
||||
|
||||
event(new PaymentWasCreated($payment));
|
||||
|
||||
event(new PaymentWasCreated($payment, $payment->company));
|
||||
|
||||
UpdateInvoicePayment::dispatchNow($payment, $payment->company);
|
||||
|
||||
return redirect()->route('client.payments.show', ['payment'=>$this->encodePrimaryKey($payment->id)]);
|
||||
@ -193,7 +193,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
$url = $this->client->company->domain() . "client/payments/process/response";
|
||||
$url .= "?company_gateway_id={$this->company_gateway->id}&gateway_type_id=".GatewayType::PAYPAL;
|
||||
$url .= "&hashed_ids=" . implode(",", $input['hashed_ids']);
|
||||
$url .= "&hashed_ids=" . implode(",", $input['hashed_ids']);
|
||||
$url .= "&amount=".$input['amount'];
|
||||
$url .= "&fee=".$input['fee'];
|
||||
|
||||
@ -210,7 +210,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
private function buildDescription($input) : string
|
||||
{
|
||||
$invoice_numbers = "";
|
||||
|
||||
|
||||
foreach($input['invoices'] as $invoice)
|
||||
{
|
||||
$invoice_numbers .= $invoice->number." ";
|
||||
@ -222,7 +222,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
|
||||
private function buildTransactionId($input) : string
|
||||
{
|
||||
return implode(",", $input['hashed_ids']);
|
||||
return implode(",", $input['hashed_ids']);
|
||||
}
|
||||
|
||||
private function paymentItems($input) : array
|
||||
@ -231,7 +231,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
$items = [];
|
||||
$total = 0;
|
||||
|
||||
foreach ($input['invoices'] as $invoice)
|
||||
foreach ($input['invoices'] as $invoice)
|
||||
{
|
||||
foreach($invoice->line_items as $invoiceItem)
|
||||
{
|
||||
@ -266,7 +266,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function createPayment($data) : Payment
|
||||
{
|
||||
|
||||
@ -284,4 +284,4 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
return $payment;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class RandomDataSeeder extends Seeder
|
||||
|
||||
/* Warm up the cache !*/
|
||||
$cached_tables = config('ninja.cached_tables');
|
||||
|
||||
|
||||
foreach ($cached_tables as $name => $class) {
|
||||
if (! Cache::has($name)) {
|
||||
// check that the table exists in case the migration is pending
|
||||
@ -63,7 +63,7 @@ class RandomDataSeeder extends Seeder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->command->info('Running RandomDataSeeder');
|
||||
|
||||
@ -141,7 +141,7 @@ class RandomDataSeeder extends Seeder
|
||||
|
||||
/** Invoice Factory */
|
||||
factory(\App\Models\Invoice::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
|
||||
|
||||
|
||||
$invoices = Invoice::cursor();
|
||||
$invoice_repo = new InvoiceRepository();
|
||||
|
||||
@ -151,15 +151,15 @@ class RandomDataSeeder extends Seeder
|
||||
|
||||
if($invoice->uses_inclusive_taxes)
|
||||
$invoice_calc = new InvoiceSumInclusive($invoice);
|
||||
else
|
||||
else
|
||||
$invoice_calc = new InvoiceSum($invoice);
|
||||
|
||||
$invoice = $invoice_calc->build()->getInvoice();
|
||||
|
||||
|
||||
$invoice->save();
|
||||
|
||||
event(new CreateInvoiceInvitation($invoice));
|
||||
|
||||
|
||||
UpdateCompanyLedgerWithInvoice::dispatchNow($invoice, $invoice->balance);
|
||||
|
||||
$invoice_repo->markSent($invoice);
|
||||
@ -169,8 +169,8 @@ class RandomDataSeeder extends Seeder
|
||||
if(rand(0, 1)) {
|
||||
$payment = App\Models\Payment::create([
|
||||
'date' => now(),
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $user->id,
|
||||
'company_id' => $company->id,
|
||||
'client_id' => $client->id,
|
||||
'amount' => $invoice->balance,
|
||||
'transaction_reference' => rand(0,500),
|
||||
@ -180,13 +180,13 @@ class RandomDataSeeder extends Seeder
|
||||
|
||||
$payment->invoices()->save($invoice);
|
||||
|
||||
event(new PaymentWasCreated($payment));
|
||||
event(new PaymentWasCreated($payment, $payment->company));
|
||||
|
||||
UpdateInvoicePayment::dispatchNow($payment, $payment->company);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
/** Recurring Invoice Factory */
|
||||
factory(\App\Models\RecurringInvoice::class,10)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
|
||||
|
||||
@ -210,7 +210,7 @@ class RandomDataSeeder extends Seeder
|
||||
'settings' => ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults()),
|
||||
'name' => 'Default Client Settings',
|
||||
]);
|
||||
|
||||
|
||||
|
||||
if(config('ninja.testvars.stripe'))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user