mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Check gateway supports refunding payment
This commit is contained in:
parent
48d22a48bf
commit
8f43eb02b3
@ -38,6 +38,8 @@ class BasePaymentDriver
|
||||
protected $customerReferenceParam;
|
||||
protected $transactionReferenceParam;
|
||||
|
||||
public $canRefundPayments = false;
|
||||
|
||||
public function __construct($accountGateway = false, $invitation = false, $gatewayType = false)
|
||||
{
|
||||
$this->accountGateway = $accountGateway;
|
||||
|
@ -11,6 +11,7 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
protected $customerReferenceParam = 'customerId';
|
||||
protected $sourceReferenceParam = 'paymentMethodToken';
|
||||
public $canRefundPayments = true;
|
||||
|
||||
public function gatewayTypes()
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ use Exception;
|
||||
class StripePaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
protected $customerReferenceParam = 'customerReference';
|
||||
public $canRefundPayments = true;
|
||||
|
||||
public function gatewayTypes()
|
||||
{
|
||||
|
@ -10,6 +10,8 @@ use Utils;
|
||||
|
||||
class WePayPaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
public $canRefundPayments = true;
|
||||
|
||||
public function gatewayTypes()
|
||||
{
|
||||
$types = [
|
||||
|
@ -178,8 +178,11 @@ class PaymentService extends BaseService
|
||||
foreach ($payments as $payment) {
|
||||
if (Auth::user()->can('edit', $payment)) {
|
||||
$amount = ! empty($params['refund_amount']) ? floatval($params['refund_amount']) : null;
|
||||
$paymentDriver = false;
|
||||
if ($accountGateway = $payment->account_gateway) {
|
||||
$paymentDriver = $accountGateway->paymentDriver();
|
||||
}
|
||||
if ($paymentDriver && $paymentDriver->canRefundPayments) {
|
||||
if ($paymentDriver->refundPayment($payment, $amount)) {
|
||||
$successful++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user