public findInvoiceByInvitation ( $invitationKey ) : |
||
$invitationKey | ||
Résultat |
public function findInvoiceByInvitation($invitationKey)
{
/** @var \App\Models\Invitation $invitation */
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
if (!$invitation) {
return false;
}
$invoice = $invitation->invoice;
if (!$invoice || $invoice->is_deleted) {
return false;
}
$invoice->load('user', 'invoice_items', 'documents', 'invoice_design', 'account.country', 'client.contacts', 'client.country');
$client = $invoice->client;
if (!$client || $client->is_deleted) {
return false;
}
return $invitation;
}
/** * @param $invitationKey * @param bool $gatewayType * @param bool $sourceId * @return \Illuminate\Http\RedirectResponse */ public function showPayment($invitationKey, $gatewayTypeAlias = false, $sourceId = false) { if (!($invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey))) { return response()->view('error', ['error' => trans('texts.invoice_not_found'), 'hideHeader' => true]); } if (!$invitation->invoice->canBePaid()) { return redirect()->to('view/' . $invitation->invitation_key); } $invitation = $invitation->load('invoice.client.account.account_gateways.gateway'); $account = $invitation->account; $account->loadLocalizationSettings($invitation->invoice->client); if (!$gatewayTypeAlias) { $gatewayTypeId = Session::get($invitation->id . 'gateway_type'); } elseif ($gatewayTypeAlias != GATEWAY_TYPE_TOKEN) { $gatewayTypeId = GatewayType::getIdFromAlias($gatewayTypeAlias); } else { $gatewayTypeId = $gatewayTypeAlias; } $paymentDriver = $account->paymentDriver($invitation, $gatewayTypeId); try { return $paymentDriver->startPurchase(Input::all(), $sourceId); } catch (Exception $exception) { return $this->error($paymentDriver, $exception); } }