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