public function doPaypalMassPayment()
 {
     $paypal = new prestaPaypal(gcr::rootDir . 'plugins/prestaPaypalPlugin/sdk/lib');
     $credentials = $this->getCredentials();
     GcrPaypalTable::initializePaypalCaller($paypal, gcr::paypalSandbox);
     $paypal->setTransactionTotal($this->amount);
     //check balance on account first
     $balance = $paypal->getBalance();
     if ($balance - $this->amount < gcr::paypalMinimumBalance) {
         global $CFG;
         $CFG->current_app->gcError('Balance on Paypal Account too low to process payoff ID ' . $this->id, 'paypalbalancetoolow');
     }
     $paypal->setBillingEmail($credentials->getUserPaypalEmail());
     if (!$paypal->doMassPayment()) {
         global $CFG;
         $CFG->current_app->gcError('Payoff ID ' . $this->id . ' MassPay Failed: ' . $paypal->getErrorString(), 'paypalmasspayfailed');
     }
     $purchase = $this->createPurchaseRecord('Account Withdrawal Via PayPal', time(), 'MassPayment');
     $this->payoff_status = 'completed';
     $this->purchase_id = $purchase->getId();
     $this->save();
 }
 public static function initializePaypalCaller($paypal, $testing)
 {
     GcrPaypalTable::initializePaypalCaller($paypal, $testing);
 }