public function buildTransactionHistory($purchases, $start_ts = false) { if (!$start_ts) { $start_ts = $this->start_ts; } $this->has_eclassroom = false; $this->total_gc = 0; $this->total_eclassroom = 0; $this->gross_income = 0; $this->net_income = 0; $this->owner_expenses = 0; $this->transaction_history = new GcrTransactionHistory($this->institution); if (!empty($purchases)) { foreach ($purchases as $purchase) { $txns = ''; if ($purchase->isRecurring()) { $txns = $purchase->getPaypalTransactions('Completed', $start_ts, $this->end_ts); $refunds = $purchase->getPaypalTransactions('Refunded', $start_ts, $this->end_ts); } else { if ($purchase->isEclassroomCourse()) { $this->has_eclassroom = true; } $refunds = GcrPaypalTable::getRefunds($purchase->getProfileId(), $start_ts, $this->end_ts); } $this->transaction_history->add(new GcrTransaction($purchase, $txns, $refunds)); } } $this->transaction_history->buildItems(); }
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); }
public function getRefunds($start_ts = null, $end_ts = null) { return GcrPaypalTable::getRefunds($this->txn_id, $start_ts, $end_ts); }