public function canRefund($member = null, $partial = false)
    {
        if (!(
            $this->Status == 'Captured' &&
            ($partial ? GatewayInfo::allowPartialRefund($this->Gateway) : GatewayInfo::allowRefund($this->Gateway))
        )) {
            return false;
        }

        if ($this->isInDB()) {
            // Check if there are partial refunds and deny further refunds if multiple refunds aren't enabled
            $hasPartials = $this->getPartialPayments()
                    ->filter('Status', array('Refunded', 'PendingRefund'))
                    ->count() > 0;
            if ($hasPartials && GatewayInfo::refundMode($this->Gateway) !== GatewayInfo::MULTIPLE) {
                return false;
            }
        }

        $extended = $this->extendedCan('canRefund', $member);
        if ($extended !== null) {
            return $extended;
        }

        return Permission::check('REFUND_PAYMENTS', 'any', $member);
    }