mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 13:34:29 -04:00
Merge pull request #8397 from turbo124/v5-develop
Change Pre Payments to be always available as recurring
This commit is contained in:
commit
b42267d881
@ -471,12 +471,12 @@ class CompanySettings extends BaseSettings
|
|||||||
|
|
||||||
public $client_initiated_payments_minimum = 0;
|
public $client_initiated_payments_minimum = 0;
|
||||||
|
|
||||||
public $client_initiated_payments_recurring = false;
|
// public $client_initiated_payments_recurring = false;
|
||||||
|
|
||||||
public $sync_invoice_quote_columns = true;
|
public $sync_invoice_quote_columns = true;
|
||||||
|
|
||||||
public static $casts = [
|
public static $casts = [
|
||||||
'client_initiated_payments_recurring'=> 'bool',
|
// 'client_initiated_payments_recurring'=> 'bool',
|
||||||
'client_initiated_payments' => 'bool',
|
'client_initiated_payments' => 'bool',
|
||||||
'client_initiated_payments_minimum' => 'float',
|
'client_initiated_payments_minimum' => 'float',
|
||||||
'sync_invoice_quote_columns' => 'bool',
|
'sync_invoice_quote_columns' => 'bool',
|
||||||
@ -505,7 +505,6 @@ class CompanySettings extends BaseSettings
|
|||||||
'purchase_order_design_id' => 'string',
|
'purchase_order_design_id' => 'string',
|
||||||
'purchase_order_footer' => 'string',
|
'purchase_order_footer' => 'string',
|
||||||
'purchase_order_number_pattern' => 'string',
|
'purchase_order_number_pattern' => 'string',
|
||||||
'purchase_order_number_counter' => 'int',
|
|
||||||
'page_numbering_alignment' => 'string',
|
'page_numbering_alignment' => 'string',
|
||||||
'page_numbering' => 'bool',
|
'page_numbering' => 'bool',
|
||||||
'auto_archive_invoice_cancelled' => 'bool',
|
'auto_archive_invoice_cancelled' => 'bool',
|
||||||
@ -537,7 +536,6 @@ class CompanySettings extends BaseSettings
|
|||||||
'reminder_send_time' => 'int',
|
'reminder_send_time' => 'int',
|
||||||
'email_sending_method' => 'string',
|
'email_sending_method' => 'string',
|
||||||
'gmail_sending_user_id' => 'string',
|
'gmail_sending_user_id' => 'string',
|
||||||
'currency_id' => 'string',
|
|
||||||
'counter_number_applied' => 'string',
|
'counter_number_applied' => 'string',
|
||||||
'quote_number_applied' => 'string',
|
'quote_number_applied' => 'string',
|
||||||
'email_subject_custom1' => 'string',
|
'email_subject_custom1' => 'string',
|
||||||
|
@ -34,6 +34,8 @@ class InvoiceItemExport extends BaseExport
|
|||||||
'amount' => 'amount',
|
'amount' => 'amount',
|
||||||
'balance' => 'balance',
|
'balance' => 'balance',
|
||||||
'client' => 'client_id',
|
'client' => 'client_id',
|
||||||
|
'client_number' => 'client.number',
|
||||||
|
'client_id_number' => 'client.id_number',
|
||||||
'custom_surcharge1' => 'custom_surcharge1',
|
'custom_surcharge1' => 'custom_surcharge1',
|
||||||
'custom_surcharge2' => 'custom_surcharge2',
|
'custom_surcharge2' => 'custom_surcharge2',
|
||||||
'custom_surcharge3' => 'custom_surcharge3',
|
'custom_surcharge3' => 'custom_surcharge3',
|
||||||
@ -198,6 +200,8 @@ class InvoiceItemExport extends BaseExport
|
|||||||
|
|
||||||
// if(in_array('client_id', $this->input['report_keys']))
|
// if(in_array('client_id', $this->input['report_keys']))
|
||||||
$entity['client'] = $invoice->client->present()->name();
|
$entity['client'] = $invoice->client->present()->name();
|
||||||
|
$entity['client_id_number'] = $invoice->client->id_number;
|
||||||
|
$entity['client_number'] = $invoice->client->number;
|
||||||
|
|
||||||
// if(in_array('status_id', $this->input['report_keys']))
|
// if(in_array('status_id', $this->input['report_keys']))
|
||||||
$entity['status'] = $invoice->stringStatus($invoice->status_id);
|
$entity['status'] = $invoice->stringStatus($invoice->status_id);
|
||||||
|
@ -38,11 +38,16 @@ class PrePaymentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
$client = auth()->guard('contact')->user()->client;
|
||||||
|
$minimum = $client->getSetting('client_initiated_payments_minimum');
|
||||||
|
$minimum_amount = $minimum == 0 ? "" : Number::formatMoney($minimum, $client);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'title' => ctrans('texts.amount'). " " .auth()->guard('contact')->user()->client->currency()->code." (".auth()->guard('contact')->user()->client->currency()->symbol . ")",
|
'title' => ctrans('texts.amount'). " " .$client->currency()->code." (".auth()->guard('contact')->user()->client->currency()->symbol . ")",
|
||||||
'allows_recurring' => auth()->guard('contact')->user()->client->getSetting('client_initiated_payments_recurring'),
|
// 'allows_recurring' => auth()->guard('contact')->user()->client->getSetting('client_initiated_payments_recurring'),
|
||||||
'allows_recurring' => true,
|
'allows_recurring' => true,
|
||||||
'minimum_amount' => auth()->guard('contact')->user()->client->getSetting('client_initiated_payments_minimum'),
|
'minimum' => $minimum,
|
||||||
|
'minimum_amount' => $minimum_amount,
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->render('pre_payments.index', $data);
|
return $this->render('pre_payments.index', $data);
|
||||||
|
@ -19,22 +19,28 @@ use App\Utils\Ninja;
|
|||||||
|
|
||||||
class SubscriptionController extends Controller
|
class SubscriptionController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* This function is used to display the subscription page.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
|
||||||
|
*/
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
if (Ninja::isHosted()) {
|
// if (Ninja::isHosted()) {
|
||||||
$count = RecurringInvoice::query()
|
// $count = RecurringInvoice::query()
|
||||||
->where('client_id', auth()->guard('contact')->user()->client->id)
|
// ->where('client_id', auth()->guard('contact')->user()->client->id)
|
||||||
->where('company_id', auth()->guard('contact')->user()->client->company_id)
|
// ->where('company_id', auth()->guard('contact')->user()->client->company_id)
|
||||||
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
// ->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||||
->where('is_deleted', 0)
|
// ->where('is_deleted', 0)
|
||||||
->whereNotNull('subscription_id')
|
// ->whereNotNull('subscription_id')
|
||||||
->withTrashed()
|
// ->withTrashed()
|
||||||
->count();
|
// ->count();
|
||||||
|
|
||||||
if ($count == 0) {
|
// if ($count == 0) {
|
||||||
return redirect()->route('client.ninja_contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'company_key' => auth()->guard('contact')->user()->company->company_key]);
|
// return redirect()->route('client.ninja_contact_login', ['contact_key' => auth()->guard('contact')->user()->contact_key, 'company_key' => auth()->guard('contact')->user()->company->company_key]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return render('subscriptions.index');
|
return render('subscriptions.index');
|
||||||
}
|
}
|
||||||
@ -44,7 +50,6 @@ class SubscriptionController extends Controller
|
|||||||
*
|
*
|
||||||
* @param ShowRecurringInvoiceRequest $request
|
* @param ShowRecurringInvoiceRequest $request
|
||||||
* @param RecurringInvoice $recurring_invoice
|
* @param RecurringInvoice $recurring_invoice
|
||||||
* @return Factory|View
|
|
||||||
*/
|
*/
|
||||||
public function show(ShowRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
public function show(ShowRecurringInvoiceRequest $request, RecurringInvoice $recurring_invoice)
|
||||||
{
|
{
|
||||||
|
@ -136,7 +136,7 @@ class EmailController extends BaseController
|
|||||||
$mo->email_template_body = $request->input('template');
|
$mo->email_template_body = $request->input('template');
|
||||||
$mo->email_template_subject = str_replace("template", "subject", $request->input('template'));
|
$mo->email_template_subject = str_replace("template", "subject", $request->input('template'));
|
||||||
|
|
||||||
if ($request->has('cc_email')) {
|
if ($request->has('cc_email') && $request->cc_email) {
|
||||||
$mo->cc[] = new Address($request->cc_email);
|
$mo->cc[] = new Address($request->cc_email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,17 @@ class StorePrePaymentRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'notes' => 'required|bail|',
|
'notes' => 'required|bail|',
|
||||||
'amount' => 'required|bail|',
|
'amount' => 'required|bail|gte:minimum_amount',
|
||||||
|
'minimum_amount' => '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function prepareForValidation()
|
||||||
|
{
|
||||||
|
$input = $this->all();
|
||||||
|
|
||||||
|
|
||||||
|
$this->replace($input);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class SendEmailRequest extends Request
|
|||||||
'template' => 'bail|required',
|
'template' => 'bail|required',
|
||||||
'entity' => 'bail|required',
|
'entity' => 'bail|required',
|
||||||
'entity_id' => 'bail|required',
|
'entity_id' => 'bail|required',
|
||||||
'cc_email' => 'bail|sometimes|email',
|
'cc_email' => 'bail|sometimes|email|nullable',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,9 +138,9 @@ class PortalComposer
|
|||||||
$data[] = ['title' => ctrans('texts.subscriptions'), 'url' => 'client.subscriptions.index', 'icon' => 'calendar'];
|
$data[] = ['title' => ctrans('texts.subscriptions'), 'url' => 'client.subscriptions.index', 'icon' => 'calendar'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (property_exists($this->settings, 'client_initiated_payments') && $this->settings->client_initiated_payments) {
|
if (auth()->guard('contact')->user()->client->getSetting('client_initiated_payments')) {
|
||||||
$data[] = ['title' => ctrans('texts.pre_payment'), 'url' => 'client.pre_payments.index', 'icon' => 'dollar-sign'];
|
$data[] = ['title' => ctrans('texts.pre_payment'), 'url' => 'client.pre_payments.index', 'icon' => 'dollar-sign'];
|
||||||
// }
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,8 @@ class PaymentFailedMailer implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
if (!is_string($this->error)) {
|
if (!is_string($this->error) || strlen($this->error) <=1) {
|
||||||
$this->error = "Payment failed, no reason given.";
|
$this->error = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set DB
|
//Set DB
|
||||||
|
@ -37,6 +37,8 @@ class CleanStaleInvoiceOrder implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle(InvoiceRepository $repo) : void
|
public function handle(InvoiceRepository $repo) : void
|
||||||
{
|
{
|
||||||
|
nlog("Cleaning Stale Invoices:");
|
||||||
|
|
||||||
if (! config('ninja.db.multi_db_enabled')) {
|
if (! config('ninja.db.multi_db_enabled')) {
|
||||||
Invoice::query()
|
Invoice::query()
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
|
@ -124,6 +124,10 @@ class ClientPaymentFailureObject
|
|||||||
'company' => $this->company,
|
'company' => $this->company,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (strlen($this->error > 1)) {
|
||||||
|
$data['content'] .= "\n\n".$this->error;
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,10 @@ class PaymentFailureObject
|
|||||||
'additional_info' => $this->error,
|
'additional_info' => $this->error,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (strlen($this->error > 1)) {
|
||||||
|
$data['content'] .= "\n\n".$this->error;
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Routing\Redirector;
|
use Illuminate\Routing\Redirector;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
//@deprecated
|
||||||
class ACH implements MethodInterface
|
class ACH implements MethodInterface
|
||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
@ -172,10 +173,13 @@ class ACH implements MethodInterface
|
|||||||
$description = "Amount {$request->amount} from client {$this->go_cardless->client->present()->name()}";
|
$description = "Amount {$request->amount} from client {$this->go_cardless->client->present()->name()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$amount = $this->go_cardless->convertToGoCardlessAmount($this->go_cardless->payment_hash?->amount_with_fee(), $this->go_cardless->client->currency()->precision);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$payment = $this->go_cardless->gateway->payments()->create([
|
$payment = $this->go_cardless->gateway->payments()->create([
|
||||||
'params' => [
|
'params' => [
|
||||||
'amount' => $request->amount,
|
// 'amount' => $request->amount,
|
||||||
|
'amount' => $amount,
|
||||||
'currency' => $request->currency,
|
'currency' => $request->currency,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'metadata' => [
|
'metadata' => [
|
||||||
|
@ -49,37 +49,97 @@ class DirectDebit implements MethodInterface
|
|||||||
* @return Redirector|RedirectResponse|void
|
* @return Redirector|RedirectResponse|void
|
||||||
*/
|
*/
|
||||||
public function authorizeView(array $data)
|
public function authorizeView(array $data)
|
||||||
|
{
|
||||||
|
return $this->billingRequestFlows($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()->guard('contact')->user()->first_name ?: '',
|
||||||
|
// 'family_name' => auth()->guard('contact')->user()->last_name ?: '',
|
||||||
|
// 'email' => auth()->guard('contact')->user()->email ?: '',
|
||||||
|
// 'address_line1' => auth()->guard('contact')->user()->client->address1 ?: '',
|
||||||
|
// 'city' => auth()->guard('contact')->user()->client->city ?: '',
|
||||||
|
// 'postal_code' => auth()->guard('contact')->user()->client->postal_code ?: '',
|
||||||
|
// 'country_code' => auth()->guard('contact')->user()->client->country->iso_3166_2,
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
// return redirect(
|
||||||
|
// $redirect->redirect_url
|
||||||
|
// );
|
||||||
|
// } catch (\Exception $exception) {
|
||||||
|
// return $this->processUnsuccessfulAuthorization($exception);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response
|
||||||
|
* {
|
||||||
|
* "billing_request_flows": {
|
||||||
|
* "authorisation_url": "https://pay.gocardless.com/flow/static/billing_request?id=<br_id>",
|
||||||
|
* "lock_customer_details": false,
|
||||||
|
* "lock_bank_account": false,
|
||||||
|
* "auto_fulfil": true,
|
||||||
|
* "created_at": "2021-03-30T16:23:10.679Z",
|
||||||
|
* "expires_at": "2021-04-06T16:23:10.679Z",
|
||||||
|
* "redirect_uri": "https://my-company.com/completed",
|
||||||
|
* "links": {
|
||||||
|
* "billing_request": "BRQ123"
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function billingRequestFlows(array $data)
|
||||||
{
|
{
|
||||||
$session_token = \Illuminate\Support\Str::uuid()->toString();
|
$session_token = \Illuminate\Support\Str::uuid()->toString();
|
||||||
|
$exit_uri = route('client.payment_methods.index');
|
||||||
|
|
||||||
|
$response = $this->go_cardless->gateway->billingRequests()->create([
|
||||||
|
"params" => [
|
||||||
|
"mandate_request" => [
|
||||||
|
"currency" => auth()->guard('contact')->user()->client->currency()->code
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$redirect = $this->go_cardless->gateway->redirectFlows()->create([
|
$brf = $this->go_cardless->gateway->billingRequestFlows()->create([
|
||||||
'params' => [
|
"params" => [
|
||||||
'session_token' => $session_token,
|
"redirect_uri" => route('client.payment_methods.confirm', [
|
||||||
'success_redirect_url' => route('client.payment_methods.confirm', [
|
'method' => GatewayType::DIRECT_DEBIT,
|
||||||
'method' => GatewayType::DIRECT_DEBIT,
|
'session_token' => $session_token,
|
||||||
'session_token' => $session_token,
|
'billing_request' => $response->id,
|
||||||
]),
|
]),
|
||||||
'prefilled_customer' => [
|
"exit_uri" => $exit_uri,
|
||||||
'given_name' => auth()->guard('contact')->user()->first_name ?: '',
|
"links" => [
|
||||||
'family_name' => auth()->guard('contact')->user()->last_name ?: '',
|
"billing_request" => $response->id
|
||||||
'email' => auth()->guard('contact')->user()->email ?: '',
|
|
||||||
'address_line1' => auth()->guard('contact')->user()->client->address1 ?: '',
|
|
||||||
'city' => auth()->guard('contact')->user()->client->city ?: '',
|
|
||||||
'postal_code' => auth()->guard('contact')->user()->client->postal_code ?: '',
|
|
||||||
'country_code' => auth()->guard('contact')->user()->client->country->iso_3166_2,
|
|
||||||
],
|
],
|
||||||
],
|
"show_redirect_buttons" => true,
|
||||||
|
"show_success_redirect_button" => true,
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect(
|
return redirect($brf->authorisation_url);
|
||||||
$redirect->redirect_url
|
|
||||||
);
|
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
|
nlog($exception->getMessage());
|
||||||
return $this->processUnsuccessfulAuthorization($exception);
|
return $this->processUnsuccessfulAuthorization($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle unsuccessful authorization.
|
* Handle unsuccessful authorization.
|
||||||
*
|
*
|
||||||
@ -109,37 +169,68 @@ class DirectDebit implements MethodInterface
|
|||||||
*/
|
*/
|
||||||
public function authorizeResponse(Request $request)
|
public function authorizeResponse(Request $request)
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
$redirect_flow = $this->go_cardless->gateway->redirectFlows()->complete(
|
try{
|
||||||
$request->redirect_flow_id,
|
|
||||||
['params' => [
|
$billing_request = $this->go_cardless->gateway->billingRequests()->get($request->billing_request);
|
||||||
'session_token' => $request->session_token,
|
|
||||||
]],
|
|
||||||
);
|
|
||||||
|
|
||||||
$payment_meta = new \stdClass;
|
$payment_meta = new \stdClass;
|
||||||
$payment_meta->brand = ctrans('texts.payment_type_direct_debit');
|
$payment_meta->brand = $billing_request->resources->customer_bank_account->bank_name;
|
||||||
$payment_meta->type = GatewayType::DIRECT_DEBIT;
|
$payment_meta->type = $this->resolveScheme($billing_request->mandate_request->scheme);
|
||||||
$payment_meta->state = 'authorized';
|
$payment_meta->state = 'pending';
|
||||||
|
$payment_meta->last4 = $billing_request->resources->customer_bank_account->account_number_ending;
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'payment_meta' => $payment_meta,
|
'payment_meta' => $payment_meta,
|
||||||
'token' => $redirect_flow->links->mandate,
|
'token' => $billing_request->mandate_request->links->mandate,
|
||||||
'payment_method_id' => $this->resolveScheme($redirect_flow->scheme),
|
'payment_method_id' => $this->resolveScheme($billing_request->mandate_request->scheme),
|
||||||
];
|
];
|
||||||
|
|
||||||
$payment_method = $this->go_cardless->storeGatewayToken($data, ['gateway_customer_reference' => $redirect_flow->links->customer]);
|
$payment_method = $this->go_cardless->storeGatewayToken($data, ['gateway_customer_reference' => $billing_request->resources->customer->id]);
|
||||||
|
|
||||||
|
$mandate = $this->go_cardless->gateway->mandates()->get($billing_request->mandate_request->links->mandate);
|
||||||
|
|
||||||
|
nlog($mandate);
|
||||||
|
|
||||||
return redirect()->route('client.payment_methods.show', $payment_method->hashed_id);
|
return redirect()->route('client.payment_methods.show', $payment_method->hashed_id);
|
||||||
} catch (\Exception $exception) {
|
|
||||||
|
}
|
||||||
|
catch (\Exception $exception) {
|
||||||
return $this->processUnsuccessfulAuthorization($exception);
|
return $this->processUnsuccessfulAuthorization($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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' => $this->resolveScheme($redirect_flow->scheme),
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// $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);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private function resolveScheme(string $scheme): int
|
private function resolveScheme(string $scheme): int
|
||||||
{
|
{
|
||||||
match ($scheme) {
|
match ($scheme) {
|
||||||
'sepa_core' => $type = GatewayType::SEPA,
|
'sepa_core' => $type = GatewayType::SEPA,
|
||||||
|
'ach' => $type = GatewayType::BANK_TRANSFER,
|
||||||
default => $type = GatewayType::DIRECT_DEBIT,
|
default => $type = GatewayType::DIRECT_DEBIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -176,10 +267,13 @@ class DirectDebit implements MethodInterface
|
|||||||
$description = "Amount {$request->amount} from client {$this->go_cardless->client->present()->name()}";
|
$description = "Amount {$request->amount} from client {$this->go_cardless->client->present()->name()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$amount = $this->go_cardless->convertToGoCardlessAmount($this->go_cardless->payment_hash?->amount_with_fee(), $this->go_cardless->client->currency()->precision);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$payment = $this->go_cardless->gateway->payments()->create([
|
$payment = $this->go_cardless->gateway->payments()->create([
|
||||||
'params' => [
|
'params' => [
|
||||||
'amount' => $request->amount,
|
// 'amount' => $request->amount,
|
||||||
|
'amount' => $amount,
|
||||||
'currency' => $request->currency,
|
'currency' => $request->currency,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'metadata' => [
|
'metadata' => [
|
||||||
|
@ -172,10 +172,12 @@ class SEPA implements MethodInterface
|
|||||||
$description = "Amount {$request->amount} from client {$this->go_cardless->client->present()->name()}";
|
$description = "Amount {$request->amount} from client {$this->go_cardless->client->present()->name()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$amount = $this->go_cardless->convertToGoCardlessAmount($this->go_cardless->payment_hash?->amount_with_fee(), $this->go_cardless->client->currency()->precision);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$payment = $this->go_cardless->gateway->payments()->create([
|
$payment = $this->go_cardless->gateway->payments()->create([
|
||||||
'params' => [
|
'params' => [
|
||||||
'amount' => $request->amount,
|
'amount' => $amount,
|
||||||
'currency' => $request->currency,
|
'currency' => $request->currency,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'metadata' => [
|
'metadata' => [
|
||||||
|
@ -14,6 +14,7 @@ namespace App\PaymentDrivers;
|
|||||||
use App\Factory\ClientContactFactory;
|
use App\Factory\ClientContactFactory;
|
||||||
use App\Factory\ClientFactory;
|
use App\Factory\ClientFactory;
|
||||||
use App\Http\Requests\Payments\PaymentWebhookRequest;
|
use App\Http\Requests\Payments\PaymentWebhookRequest;
|
||||||
|
use App\Jobs\Mail\PaymentFailedMailer;
|
||||||
use App\Jobs\Util\SystemLogger;
|
use App\Jobs\Util\SystemLogger;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\ClientGatewayToken;
|
use App\Models\ClientGatewayToken;
|
||||||
@ -46,7 +47,7 @@ class GoCardlessPaymentDriver extends BaseDriver
|
|||||||
private bool $completed = true;
|
private bool $completed = true;
|
||||||
|
|
||||||
public static $methods = [
|
public static $methods = [
|
||||||
GatewayType::BANK_TRANSFER => \App\PaymentDrivers\GoCardless\ACH::class,
|
GatewayType::BANK_TRANSFER => \App\PaymentDrivers\GoCardless\DirectDebit::class,
|
||||||
GatewayType::DIRECT_DEBIT => \App\PaymentDrivers\GoCardless\DirectDebit::class,
|
GatewayType::DIRECT_DEBIT => \App\PaymentDrivers\GoCardless\DirectDebit::class,
|
||||||
GatewayType::SEPA => \App\PaymentDrivers\GoCardless\SEPA::class,
|
GatewayType::SEPA => \App\PaymentDrivers\GoCardless\SEPA::class,
|
||||||
GatewayType::INSTANT_BANK_PAY => \App\PaymentDrivers\GoCardless\InstantBankPay::class,
|
GatewayType::INSTANT_BANK_PAY => \App\PaymentDrivers\GoCardless\InstantBankPay::class,
|
||||||
@ -79,7 +80,7 @@ class GoCardlessPaymentDriver extends BaseDriver
|
|||||||
$this->client
|
$this->client
|
||||||
&& isset($this->client->country)
|
&& isset($this->client->country)
|
||||||
// && in_array($this->client->country->iso_3166_3, ['GBR'])
|
// && in_array($this->client->country->iso_3166_3, ['GBR'])
|
||||||
&& in_array($this->client->currency()->code, ['EUR', 'GBP','DKK','SEK','AUD','NZD','USD'])
|
&& in_array($this->client->currency()->code, ['EUR', 'GBP','DKK','SEK','AUD','NZD'])
|
||||||
) {
|
) {
|
||||||
$types[] = GatewayType::DIRECT_DEBIT;
|
$types[] = GatewayType::DIRECT_DEBIT;
|
||||||
}
|
}
|
||||||
@ -242,7 +243,6 @@ class GoCardlessPaymentDriver extends BaseDriver
|
|||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
nlog('GoCardless Event');
|
nlog('GoCardless Event');
|
||||||
nlog($request->all());
|
|
||||||
|
|
||||||
if (! $request->has('events')) {
|
if (! $request->has('events')) {
|
||||||
nlog('No GoCardless events to process in response?');
|
nlog('No GoCardless events to process in response?');
|
||||||
@ -278,9 +278,26 @@ class GoCardlessPaymentDriver extends BaseDriver
|
|||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($payment) {
|
if ($payment) {
|
||||||
|
if ($payment->status_id == Payment::STATUS_PENDING) {
|
||||||
|
$payment->service()->deletePayment();
|
||||||
|
}
|
||||||
|
|
||||||
$payment->status_id = Payment::STATUS_FAILED;
|
$payment->status_id = Payment::STATUS_FAILED;
|
||||||
$payment->save();
|
$payment->save();
|
||||||
nlog('GoCardless completed');
|
|
||||||
|
$payment_hash = PaymentHash::where('payment_id', $payment->id)->first();
|
||||||
|
$error = '';
|
||||||
|
|
||||||
|
if (isset($event['details']['description'])) {
|
||||||
|
$error = $event['details']['description'];
|
||||||
|
}
|
||||||
|
|
||||||
|
PaymentFailedMailer::dispatch(
|
||||||
|
$payment_hash,
|
||||||
|
$payment->client->company,
|
||||||
|
$payment->client,
|
||||||
|
$error
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,17 +21,29 @@
|
|||||||
@endisset
|
@endisset
|
||||||
|
|
||||||
@isset($url)
|
@isset($url)
|
||||||
<!-- <a href="{{ $url }}" class="button" target="_blank">{{ ctrans($button) }}</a> -->
|
|
||||||
|
|
||||||
<table border="0" cellspacing="0" cellpadding="0" align="center">
|
<div>
|
||||||
<tr style="border: 0 !important; ">
|
<!--[if (gte mso 9)|(IE)]>
|
||||||
<td class="new_button" style="padding: 12px 18px 12px 18px; border-radius:5px;" align="center">
|
<table align="center" cellspacing="0" cellpadding="0" style="width: 600px;">
|
||||||
<a href="{{ $url }}") }}" target="_blank" style="border: 0 !important;font-size: 18px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; display: inline-block;">
|
<tr>
|
||||||
{{ ctrans($button) }}
|
<td align="center" valign="top">
|
||||||
|
<![endif]-->
|
||||||
|
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" >
|
||||||
|
<tbody><tr>
|
||||||
|
<td align="center" class="new_button" style="border-radius: 2px; background-color: '.$this->settings->primary_color.'">
|
||||||
|
<a href="{{ $url }}" target="_blank" class="new_button" style="text-decoration: none; border: 1px solid '.$this->settings->primary_color.'; display: inline-block; border-radius: 2px; padding-top: 15px; padding-bottom: 15px; padding-left: 25px; padding-right: 25px; font-size: 20px; color: #fff">
|
||||||
|
<singleline label="cta button">{{ ctrans($button) }}</singleline>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<!--[if (gte mso 9)|(IE)]>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<![endif]-->
|
||||||
|
</div>
|
||||||
|
|
||||||
@endisset
|
@endisset
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<label class="mr-4">
|
<label class="mr-4">
|
||||||
<input type="radio" data-token="{{ $token->token }}" name="payment-type"
|
<input type="radio" data-token="{{ $token->token }}" name="payment-type"
|
||||||
class="form-radio cursor-pointer toggle-payment-with-token" />
|
class="form-radio cursor-pointer toggle-payment-with-token" />
|
||||||
<span class="ml-1 cursor-pointer">{{ ctrans('texts.payment_type_direct_debit') }}
|
<span class="ml-1 cursor-pointer">{{ App\Models\GatewayType::getAlias($token->gateway_type_id) }}
|
||||||
(#{{ $token->token }})</span>
|
(#{{ $token->token }})</span>
|
||||||
</label>
|
</label>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@ -34,16 +34,16 @@
|
|||||||
@endif
|
@endif
|
||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
||||||
|
<input type="hidden" name="minimum_amount" value="{{ $minimum }}">
|
||||||
|
|
||||||
@component('portal.ninja2020.components.general.card-element', ['title' => $title])
|
@component('portal.ninja2020.components.general.card-element', ['title' => $title])
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="input mt-0 mr-4 relative"
|
class="input mt-0 mr-4 relative"
|
||||||
name="amount"
|
name="amount"
|
||||||
placeholder=""
|
placeholder=""/>
|
||||||
min="{{ $minimum_amount }}"/>
|
|
||||||
|
|
||||||
@if($minimum_amount > 0)
|
@if($minimum > 0)
|
||||||
<p>{{ ctrans('texts.minimum_required_payment', ['amount' => $minimum_amount])}}</p>
|
<p>{{ ctrans('texts.minimum_required_payment', ['amount' => $minimum_amount])}}</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@ -62,9 +62,9 @@
|
|||||||
<div x-cloak x-show="show">
|
<div x-cloak x-show="show">
|
||||||
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.number_of_payments')])
|
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.number_of_payments')])
|
||||||
<select name="remaining_cycles" class="form-select input w-full bg-white">
|
<select name="remaining_cycles" class="form-select input w-full bg-white">
|
||||||
<option value="-1" selected>{{ ctrans('texts.pre_payment_indefinitely')}}</option>
|
<option value="-1">{{ ctrans('texts.pre_payment_indefinitely')}}</option>
|
||||||
@for($i = 1; $i < 60; $i++)
|
@for($i = 1; $i < 60; $i++)
|
||||||
<option value={{$i}}>{{$i}}</option>
|
<option value={{$i}} @if($i == 1) selected @endif>{{$i}}</option>
|
||||||
@endfor
|
@endfor
|
||||||
</select>
|
</select>
|
||||||
<span class="py-2">
|
<span class="py-2">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user