Пример #1
0
 /**
  * Force Check payment now
  *
  * @return  void
  */
 public function checkPayment()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $ids = $input->get('cid', array(), 'array');
     foreach ($ids as $id) {
         $status = RApiPaymentHelper::checkPayment($id);
         if (!empty($status)) {
             $app->enqueueMessage($status['message'], !empty($status['type']) ? $status['type'] : 'message');
         }
     }
     // Redirect to the list screen
     $this->setRedirect($this->getRedirectToListRoute($this->getRedirectToListAppend()));
 }
Пример #2
0
 /**
  * Entry point for the script
  *
  * @return  void
  *
  * @since   2.5
  */
 public function doExecute()
 {
     JFactory::getApplication('site');
     JPluginHelper::importPlugin('redcore');
     JPluginHelper::importPlugin('redpayment');
     // Set up statuses that are in their final stage
     $this->finalStatuses = array(RApiPaymentStatus::getStatusCompleted(), RApiPaymentStatus::getStatusCanceled_Reversal(), RApiPaymentStatus::getStatusDenied(), RApiPaymentStatus::getStatusExpired(), RApiPaymentStatus::getStatusRefunded(), RApiPaymentStatus::getStatusReversed());
     $this->out('============================');
     $this->out('Check Payments status change');
     $this->out('============================');
     $payments = $this->getPaymentsForChecking();
     $this->out('Number of payments for checking:' . count($payments));
     $this->out('============================');
     if (!empty($payments)) {
         foreach ($payments as $payment) {
             // Print out payment info
             $this->out('============================');
             $this->out(sprintf('Check for order name "%s" for extension "%s" using "%s" payment plugin:', $payment->order_name, $payment->extension_name, $payment->payment_name));
             $this->out('============================');
             // Preform check
             $status = RApiPaymentHelper::checkPayment($payment->id);
             // Print out status result
             foreach ($status as $statusKey => $message) {
                 if (is_array($message)) {
                     foreach ($status as $key => $value) {
                         $this->out($key . ': ' . $value);
                     }
                 } else {
                     $this->out($statusKey . ': ' . $message);
                 }
             }
             // Subtract retry count or reset it
             $paymentNew = RApiPaymentHelper::getPaymentById($payment->id);
             if (!in_array($paymentNew->status, $this->finalStatuses)) {
                 // We are still not done, we will subtract retry counter for this payment
                 $paymentNew->retry_counter -= 1;
                 RApiPaymentHelper::updatePaymentCounter($paymentNew->id, $paymentNew->retry_counter);
                 $this->out('Retry checks left: ' . $paymentNew->retry_counter);
             }
             $this->out('============================');
         }
     }
     $this->out('============================');
     $this->out('Done !');
 }