/**
  * Return the gateway customer object for this user.
  *
  * @return DorellJames\Billing\Gateways\CustomerInterface
  */
 public function gatewayCustomer()
 {
     if (!$this->readyForBilling()) {
         return null;
     }
     return Billing::customer($this->billing_id);
 }
 /**
  * Handle a Braintree webhook call.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function handleWebhook()
 {
     // Initialize Braintree gateway (config vars).
     Billing::customer();
     $payload = Braintree_WebhookNotification::parse(Input::get('bt_signature'), Input::get('bt_payload'));
     $method = 'handle' . studly_case(str_replace('.', '_', $payload->kind));
     if (method_exists($this, $method)) {
         return $this->{$method}($payload);
     } else {
         return $this->missingMethod();
     }
 }
 /**
  * Create this customer in the billing gateway.
  *
  * @param array $properties
  *
  * @return Billing
  */
 public function create(array $properties = array())
 {
     if ($this->model->readyForBilling()) {
         return $this;
     }
     $this->customer = \DorellJames\Billing\Facades\Billing::customer()->create(array_merge($properties, array('coupon' => $this->coupon, 'card_token' => $this->card_token)));
     $this->refresh();
     if ($this->with_subscriptions) {
         $this->createPendingSubscriptions();
     }
     return $this;
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if ('local' != Config::get('laravel-billing::default')) {
         return $this->error('Not configured to use the "local" driver.');
     }
     // Init gateway.
     Facades\Billing::customer();
     $key = $this->ask('What is the plan ID (eg. basic or pro)?');
     $amount = $this->ask('What is the plan Amount (in cents)?');
     $interval = $this->ask('What is the plan Interval (eg. monthly or yearly)?');
     $trial_period_days = $this->ask('How many days of trial do you want to give (press enter for none)?');
     $plan = Gateways\Local\Models\Plan::create(array('key' => $key, 'name' => ucwords($key), 'amount' => $amount, 'interval' => $interval, 'trial_period_days' => $trial_period_days));
     $this->info('Plan created successfully: ' . $plan->id);
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if ('local' != Config::get('laravel-billing::default')) {
         return $this->error('Not configured to use the "local" driver.');
     }
     // Init gateway.
     Facades\Billing::customer();
     $code = $this->ask('What is the coupon Code (eg. 20percentoff)?');
     $percent_off = $this->ask('What is the coupon Percent Off (enter for none)?');
     $amount_off = $this->ask('What is the coupon Amount Off (in cents) (enter for none)?');
     $duration_in_months = $this->ask('How many months should this coupon last (press enter for unlimited)?');
     $coupon = Gateways\Local\Models\Coupon::create(array('code' => $code, 'percent_off' => $percent_off ? $percent_off : null, 'amount_off' => $amount_off ? $amount_off : null, 'duration_in_months' => $duration_in_months ? $duration_in_months : null));
     $this->info('Coupon created successfully: ' . $coupon->id);
 }