mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
GoCardless: New payment flow (#72)
* pass livewirePaymentView & processPaymentView thru base driver * gocardless
This commit is contained in:
parent
8fbd8a9593
commit
83ced6d340
@ -20,6 +20,7 @@ use App\Models\Invoice;
|
|||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
|
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||||
use App\PaymentDrivers\Common\MethodInterface;
|
use App\PaymentDrivers\Common\MethodInterface;
|
||||||
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -31,7 +32,7 @@ use Illuminate\Routing\Redirector;
|
|||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
//@deprecated
|
//@deprecated
|
||||||
class ACH implements MethodInterface
|
class ACH implements MethodInterface, LivewireMethodInterface
|
||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
@ -146,9 +147,7 @@ class ACH implements MethodInterface
|
|||||||
*/
|
*/
|
||||||
public function paymentView(array $data): View
|
public function paymentView(array $data): View
|
||||||
{
|
{
|
||||||
$data['gateway'] = $this->go_cardless;
|
$data = $this->paymentData($data);
|
||||||
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
|
||||||
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
|
||||||
|
|
||||||
return render('gateways.gocardless.ach.pay', $data);
|
return render('gateways.gocardless.ach.pay', $data);
|
||||||
}
|
}
|
||||||
@ -257,4 +256,23 @@ class ACH implements MethodInterface
|
|||||||
|
|
||||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function livewirePaymentView(array $data): string
|
||||||
|
{
|
||||||
|
return 'gateways.gocardless.ach.pay_livewire';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function paymentData(array $data): array
|
||||||
|
{
|
||||||
|
$data['gateway'] = $this->go_cardless;
|
||||||
|
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
||||||
|
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ use App\Models\Invoice;
|
|||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
|
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||||
use App\PaymentDrivers\Common\MethodInterface;
|
use App\PaymentDrivers\Common\MethodInterface;
|
||||||
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -29,7 +30,7 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Routing\Redirector;
|
use Illuminate\Routing\Redirector;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class DirectDebit implements MethodInterface
|
class DirectDebit implements MethodInterface, LivewireMethodInterface
|
||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
@ -218,9 +219,7 @@ class DirectDebit implements MethodInterface
|
|||||||
*/
|
*/
|
||||||
public function paymentView(array $data): View
|
public function paymentView(array $data): View
|
||||||
{
|
{
|
||||||
$data['gateway'] = $this->go_cardless;
|
$data = $this->paymentData($data);
|
||||||
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
|
||||||
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
|
||||||
|
|
||||||
return render('gateways.gocardless.direct_debit.pay', $data);
|
return render('gateways.gocardless.direct_debit.pay', $data);
|
||||||
}
|
}
|
||||||
@ -330,4 +329,24 @@ class DirectDebit implements MethodInterface
|
|||||||
|
|
||||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function livewirePaymentView(array $data): string
|
||||||
|
{
|
||||||
|
return 'gateways.gocardless.direct_debit.pay_livewire';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function paymentData(array $data): array
|
||||||
|
{
|
||||||
|
$data['gateway'] = $this->go_cardless;
|
||||||
|
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
||||||
|
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,14 @@ use App\Models\GatewayType;
|
|||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
|
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||||
use App\PaymentDrivers\Common\MethodInterface;
|
use App\PaymentDrivers\Common\MethodInterface;
|
||||||
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
||||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class InstantBankPay implements MethodInterface
|
class InstantBankPay implements MethodInterface, LivewireMethodInterface
|
||||||
{
|
{
|
||||||
protected GoCardlessPaymentDriver $go_cardless;
|
protected GoCardlessPaymentDriver $go_cardless;
|
||||||
|
|
||||||
@ -197,9 +198,8 @@ class InstantBankPay implements MethodInterface
|
|||||||
* Process unsuccessful payments for Direct Debit.
|
* Process unsuccessful payments for Direct Debit.
|
||||||
*
|
*
|
||||||
* @param ResourcesPayment $payment
|
* @param ResourcesPayment $payment
|
||||||
* @return never
|
|
||||||
*/
|
*/
|
||||||
public function processUnsuccessfulPayment(\GoCardlessPro\Resources\Payment $payment)
|
public function processUnsuccessfulPayment(\GoCardlessPro\Resources\Payment $payment): void
|
||||||
{
|
{
|
||||||
PaymentFailureMailer::dispatch($this->go_cardless->client, $payment->status, $this->go_cardless->client->company, $this->go_cardless->payment_hash->data->amount_with_fee);
|
PaymentFailureMailer::dispatch($this->go_cardless->client, $payment->status, $this->go_cardless->client->company, $this->go_cardless->payment_hash->data->amount_with_fee);
|
||||||
|
|
||||||
@ -224,4 +224,24 @@ class InstantBankPay implements MethodInterface
|
|||||||
$this->go_cardless->client->company,
|
$this->go_cardless->client->company,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function livewirePaymentView(array $data): string
|
||||||
|
{
|
||||||
|
// not supported, this is offsite payment method.
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function paymentData(array $data): array
|
||||||
|
{
|
||||||
|
$this->paymentView($data);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ use App\Models\Invoice;
|
|||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
|
use App\PaymentDrivers\Common\LivewireMethodInterface;
|
||||||
use App\PaymentDrivers\Common\MethodInterface;
|
use App\PaymentDrivers\Common\MethodInterface;
|
||||||
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
use App\PaymentDrivers\GoCardlessPaymentDriver;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -29,7 +30,7 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Routing\Redirector;
|
use Illuminate\Routing\Redirector;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class SEPA implements MethodInterface
|
class SEPA implements MethodInterface, LivewireMethodInterface
|
||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
@ -145,9 +146,7 @@ class SEPA implements MethodInterface
|
|||||||
*/
|
*/
|
||||||
public function paymentView(array $data): View
|
public function paymentView(array $data): View
|
||||||
{
|
{
|
||||||
$data['gateway'] = $this->go_cardless;
|
$data = $this->paymentData($data);
|
||||||
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
|
||||||
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
|
||||||
|
|
||||||
return render('gateways.gocardless.sepa.pay', $data);
|
return render('gateways.gocardless.sepa.pay', $data);
|
||||||
}
|
}
|
||||||
@ -257,4 +256,24 @@ class SEPA implements MethodInterface
|
|||||||
|
|
||||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function livewirePaymentView(array $data): string
|
||||||
|
{
|
||||||
|
return 'gateways.gocardless.sepa.pay_livewire';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function paymentData(array $data): array
|
||||||
|
{
|
||||||
|
$data['gateway'] = $this->go_cardless;
|
||||||
|
$data['amount'] = $this->go_cardless->convertToGoCardlessAmount($data['total']['amount_with_fee'], $this->go_cardless->client->currency()->precision);
|
||||||
|
$data['currency'] = $this->go_cardless->client->getCurrencyCode();
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user