Fix error; don't let users try to refund failed or already refunded payments

This commit is contained in:
Joshua Dwire 2016-05-02 18:04:57 -04:00
parent 059a23b612
commit 913c6eeff0

View File

@ -451,8 +451,8 @@ class PaymentService extends BaseService
$payment->payment_type_id = PAYMENT_TYPE_ACH; $payment->payment_type_id = PAYMENT_TYPE_ACH;
} }
else{ else{
$payment->expiration = $card['exp_year'] . '-' . $card['exp_month'] . '-00'; $payment->expiration = $source['exp_year'] . '-' . $source['exp_month'] . '-00';
$payment->payment_type_id = $this->parseCardType($card['brand']); $payment->payment_type_id = $this->parseCardType($source['brand']);
} }
} }
} elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) { } elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) {
@ -723,7 +723,9 @@ class PaymentService extends BaseService
return "javascript:showRefundModal({$model->public_id}, '{$max_refund}', '{$formatted}', '{$symbol}')"; return "javascript:showRefundModal({$model->public_id}, '{$max_refund}', '{$formatted}', '{$symbol}')";
}, },
function ($model) { function ($model) {
return Payment::canEditItem($model) && ( return Payment::canEditItem($model) && $model->payment_status_id != PAYMENT_STATUS_FAILED &&
$model->refunded < $model->amount &&
(
($model->transaction_reference && in_array($model->gateway_id , static::$refundableGateways)) ($model->transaction_reference && in_array($model->gateway_id , static::$refundableGateways))
|| $model->payment_type_id == PAYMENT_TYPE_CREDIT || $model->payment_type_id == PAYMENT_TYPE_CREDIT
); );