Ejemplo n.º 1
0
 /**
  * Whether or not this payment can be captured
  * @param Member|int $member the member/memberID to check permissions on
  * @param boolean $partial check if payment can be partially captured. Defaults to false
  * @return bool
  */
 public function canCapture($member = null, $partial = false)
 {
     // premise
     if (!($this->Status === 'Authorized' && ($partial ? GatewayInfo::allowPartialCapture($this->Gateway) : GatewayInfo::allowCapture($this->Gateway)))) {
         return false;
     }
     if ($this->isInDB()) {
         // Check if there are partial captures and deny further captures if multiple captures aren't enabled
         $hasPartials = $this->getPartialPayments()->filter('Status', array('Captured', 'PendingCapture'))->count() > 0;
         if ($hasPartials && GatewayInfo::captureMode($this->Gateway) !== GatewayInfo::MULTIPLE) {
             return false;
         }
     }
     $extended = $this->extendedCan('canCapture', $member);
     if ($extended !== null) {
         return $extended;
     }
     return Permission::check('CAPTURE_PAYMENTS', 'any', $member);
 }