Exemplo n.º 1
0
 /**
  * Refresh local model data for this subscription.
  *
  * @return Subscription
  */
 public function refresh()
 {
     $info = array();
     if ($this->subscription) {
         try {
             $info = $this->subscription->info();
         } catch (Exception $e) {
         }
     }
     if ($info) {
         $this->model->billing_active = 1;
         $this->model->billing_subscription = $this->subscription->id();
         $this->model->billing_free = 0;
         $this->model->billing_plan = Arr::get($info, 'plan');
         $this->model->billing_amount = Arr::get($info, 'amount', 0);
         $this->model->billing_interval = Arr::get($info, 'interval');
         $this->model->billing_quantity = Arr::get($info, 'quantity');
         $this->model->billing_card = Arr::get($info, 'card');
         $this->model->billing_trial_ends_at = Arr::get($info, 'trial_ends_at');
         $this->model->billing_subscription_discounts = Arr::get($info, 'discounts');
         $this->model->billing_subscription_ends_at = null;
         if (!Arr::get($info, 'active') || Arr::get($info, 'active') && !Arr::get($info, 'neverExpires')) {
             if (!Arr::get($info, 'active')) {
                 $this->model->billing_active = 0;
             }
             $this->model->billing_trial_ends_at = null;
             $this->model->billing_subscription_ends_at = Arr::get($info, 'period_ends_at', date('Y-m-d H:i:s'));
         }
     } else {
         $this->model->billing_active = 0;
         $this->model->billing_subscription = null;
         $this->model->billing_free = 0;
         $this->model->billing_plan = null;
         $this->model->billing_amount = 0;
         $this->model->billing_interval = null;
         $this->model->billing_quantity = 0;
         $this->model->billing_card = null;
         $this->model->billing_trial_ends_at = null;
         $this->model->billing_subscription_ends_at = null;
         $this->model->billing_subscription_discounts = null;
     }
     $this->model->save();
     $this->info = $info;
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Refresh local model data for this subscription.
  *
  * @return Subscription
  */
 public function refresh()
 {
     $info = array();
     if ($this->subscription) {
         try {
             $info = $this->subscription->info();
         } catch (Exception $e) {
         }
     }
     if ($info) {
         $this->model->billing_active = 1;
         $this->model->billing_subscription = $this->subscription->id();
         $this->model->billing_free = 0;
         $this->model->billing_plan = $info['plan'];
         $this->model->billing_amount = $info['amount'];
         $this->model->billing_interval = $info['interval'];
         $this->model->billing_quantity = $info['quantity'];
         $this->model->billing_card = $info['card'];
         $this->model->billing_trial_ends_at = $info['trial_ends_at'];
         $this->model->billing_subscription_ends_at = $info['period_ends_at'];
         $this->model->billing_subscription_discounts = $info['discounts'];
         if (!$info['active']) {
             $this->model->billing_active = 0;
             $this->model->billing_trial_ends_at = null;
         }
     } else {
         $this->model->billing_active = 0;
         $this->model->billing_subscription = null;
         $this->model->billing_free = 0;
         $this->model->billing_plan = null;
         $this->model->billing_amount = 0;
         $this->model->billing_interval = null;
         $this->model->billing_quantity = 0;
         $this->model->billing_card = null;
         $this->model->billing_trial_ends_at = null;
         $this->model->billing_subscription_ends_at = null;
         $this->model->billing_subscription_discounts = null;
     }
     $this->model->save();
     $this->info = $info;
     return $this;
 }