/**
  * Get payment information
  * 
  * @author coeus solutions
  * @param integer $id the user's id
  * @return \Zend\View\Model\JsonModel
  */
 public function get($id)
 {
     $request = $this->getRequest();
     $acceptRequest = $this->getUserService()->requestCheckEventType($request);
     if ($acceptRequest) {
         $customer = $this->getService()->viewPaymentByCustomerId($id);
         if (!empty($customer)) {
             $account_code = $customer[0]['accountCode'];
             \Recurly_Client::$subdomain = 'incoverage123';
             \Recurly_Client::$apiKey = '1087e99b0df34eb4835412e55217dc6f';
             $result['error'] = 0;
             try {
                 $subscriptions = \Recurly_SubscriptionList::getForAccount($account_code);
                 foreach ($subscriptions as $subscription) {
                     $result['plan']['plan_code'] = $subscription->plan->plan_code;
                     $result['plan']['plan_name'] = $subscription->plan->name;
                     $result['plan']['cents'] = $subscription->unit_amount_in_cents / 100;
                     $result['plan']['currency'] = $subscription->currency;
                     $result['plan']['activated_at'] = $subscription->activated_at->format('F d, Y H:i:s');
                     $result['plan']['ends_at'] = $subscription->current_period_ends_at->format('F d, Y H:i:s');
                 }
                 $invoices = \Recurly_InvoiceList::getForAccount($account_code);
                 foreach ($invoices as $invoice) {
                     $transactions = $invoice->transactions;
                     if (!empty($transactions)) {
                         foreach ($transactions as $key => $transaction) {
                             $result['transaction'][$key]['status'] = $transaction->status;
                             $result['transaction'][$key]['amount'] = $transaction->amount_in_cents / 100;
                             $result['transaction'][$key]['payment_method'] = $transaction->payment_method == 'credit_card' ? 'credit card' : '';
                             $result['transaction'][$key]['created_at'] = $transaction->created_at->format('F d, Y');
                             $result['transaction'][$key]['currency'] = $transaction->currency;
                         }
                     }
                 }
             } catch (\Recurly_NotFoundError $e) {
                 $result['error'] = 1;
                 $result['error_desc'] = $e;
                 //print "Account Not Found: $e";
             }
         }
     } else {
         $result = array('un-authorized Access');
     }
     return new JsonModel($result);
 }
 public static function getSubscription($accountId)
 {
     try {
         $subscriptions = Recurly_SubscriptionList::getForAccount($accountId);
         foreach ($subscriptions as $subscription) {
             if ($subscription->state == 'active') {
                 return $subscription;
             }
         }
     } catch (Recurly_NotFoundError $e) {
         return false;
     }
     return false;
 }
예제 #3
0
 /**
  * ingest
  * 
  * This method provides the ability to grab and insert all of the current recurly data
  * and insert it into the grind database
  * it loops through all of the active users and gets their subscription information
  * it adds it to the table subscription_sync
  *
  * ** WARNING ** 
  * This function is only meant to be used on an empty database. Clear the table first
  * then run this method.
  *
  * @joshcampbell
  * 
  */
 public function ingest()
 {
     $this->load->helper('date');
     $this->db->select('id');
     $query = $this->db->get_where('user', array('membership_status_luid' => 4));
     $this->db->trans_start();
     foreach ($query->result() as $row) {
         try {
             $account = Recurly_Account::get($row->id);
         } catch (Exception $e) {
             continue;
         }
         $subscriptions = Recurly_SubscriptionList::getForAccount($account->account_code, array('state' => 'active'));
         $subscription = $subscriptions->current();
         $data = array();
         $data["user_id"] = $row->id;
         $plan = $subscription != null && isset($subscription->plan) ? $subscription->plan : null;
         if (isset($plan)) {
             $data["plan_code"] = $plan->plan_code;
             $data["state"] = $subscription->state;
             $data["quantity"] = $subscription->quantity;
             $data["total_amount_in_cents"] = $subscription->unit_amount_in_cents;
             $data["activated_at"] = $subscription->activated_at != "" ? $subscription->activated_at->format('Y-m-d H:i:s') : null;
             $data["canceled_at"] = $subscription->canceled_at != "" ? $subscription->canceled_at->format('Y-m-d H:i:s') : null;
             $data["expires_at"] = $subscription->expires_at != "" ? $subscription->expires_at->format('Y-m-d H:i:s') : null;
             $data["current_period_started_at"] = $subscription->current_period_started_at != "" ? $subscription->current_period_started_at->format('Y-m-d H:i:s') : null;
             $data["current_period_ends_at"] = $subscription->current_period_ends_at != "" ? $subscription->current_period_ends_at->format('Y-m-d H:i:s') : null;
             $data["trial_started_at"] = $subscription->trial_started_at != "" ? $subscription->trial_started_at->format('Y-m-d H:i:s') : null;
             $data["trial_ends_at"] = $subscription->trial_ends_at != "" ? $subscription->trial_ends_at->format('Y-m-d H:i:s') : null;
         } else {
             $data["plan_code"] = "daily";
             $data["state"] = "active";
         }
         $this->db->insert("subscription_sync", $data);
     }
     $this->db->trans_complete();
     echo "import complete";
 }
예제 #4
0
파일: aaa.php 프로젝트: ram-1501/rs
             echo $alertMsg . $paymentLicense . '.';
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         break;
     }
 } else {
     if (!array_key_exists('credit_num', $_POST)) {
         $json = new stdClass();
         $json->userName = $email;
         $json->password = $pass;
         echo "SHOW_POP_UP-" . json_encode($json);
         break;
     }
     try {
         $subscriptions = Recurly_SubscriptionList::getForAccount($email);
         foreach ($subscriptions as $sub) {
             if ($sub->state == 'canceled') {
                 $subscription = Recurly_Subscription::get($sub->uuid);
                 $subscription->terminateWithoutRefund();
             }
         }
     } catch (Exception $e) {
     }
     try {
         $subscription = new Recurly_Subscription();
         $subscription->plan_code = $paymentLicense;
         $subscription->currency = "USD";
         $recAccount = new Recurly_Account();
         $recAccount->account_code = $email;
         $recAccount->email = $email;