コード例 #1
0
 /**
  * Gets info for a customer.
  *
  * @return array|null
  */
 public function info()
 {
     if (!$this->id) {
         return null;
     }
     if (!$this->local_customer) {
         $this->local_customer = Models\Customer::find($this->id);
         $this->gateway->apiDelay();
     }
     if (!$this->local_customer) {
         return null;
     }
     $discounts = array();
     if ($this->local_customer->coupon) {
         $ends_at = null;
         if ($this->local_customer->coupon->duration_in_months) {
             $ends_at = $this->local_customer->created_at->copy()->addMonths($this->local_customer->coupon->duration_in_months);
         }
         $discounts[] = array('coupon' => $this->local_customer->coupon->code, 'amount_off' => $this->local_customer->coupon->amount_off, 'percent_off' => $this->local_customer->coupon->percent_off, 'started_at' => (string) $this->local_customer->created_at, 'ends_at' => (string) $ends_at);
     }
     return array('id' => $this->id, 'description' => $this->local_customer->description, 'email' => $this->local_customer->email, 'created_at' => (string) $this->local_customer->created_at, 'discounts' => $discounts);
 }