当前位置: 首页>>代码示例>>PHP>>正文


PHP ElggUser::setPrivateSetting方法代码示例

本文整理汇总了PHP中ElggUser::setPrivateSetting方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggUser::setPrivateSetting方法的具体用法?PHP ElggUser::setPrivateSetting怎么用?PHP ElggUser::setPrivateSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElggUser的用法示例。


在下文中一共展示了ElggUser::setPrivateSetting方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMerchantAccount

 /**
  * Retrieve a Stripe account for this mercant
  *
  * @return Stripe_Customer|boolean
  * @throws Stripe_Error
  */
 public function getMerchantAccount()
 {
     if ($this->account->id) {
         return $this->account;
     }
     if (!$this->entity) {
         return false;
     }
     if (!($access_token = $this->getAccessToken())) {
         return false;
     }
     try {
         $stripe = new StripeClient();
         $stripe->setAccessToken($access_token);
         $account = $stripe->getAccount();
         if (!$account->id || isset($account->deleted)) {
             throw new Stripe_Error('Account does not exist or has been deleted');
         }
         $this->account = $account;
         return $this->account;
     } catch (Stripe_Error $e) {
         $this->entity->setPrivateSetting('stripe_secret_key', null);
         $this->entity->setPrivateSetting('stripe_publishable_key', null);
         return false;
     }
 }
开发者ID:Daltonmedia,项目名称:stripe,代码行数:32,代码来源:StripeMerchant.php

示例2: getCustomerId

 /**
  * Get Stripe customer ID for the user
  * @return string|boolean
  */
 public function getCustomerId()
 {
     $customer_id = $this->user->getPrivateSetting('stripe_customer_id');
     if (!$customer_id) {
         $stripe = new StripeClient();
         // Try other customer IDs stored on this user
         $customer_ids = $this->user->stripe_customer_id;
         if ($customer_ids) {
             if (!is_array($customer_ids)) {
                 $customer_ids = array($customer_ids);
             }
             foreach ($customer_ids as $customer_id) {
                 $account = $stripe->getCustomer($customer_id);
                 if ($account) {
                     break;
                 }
             }
         }
         if (!$account) {
             $account = $stripe->createCustomer($this->user);
         }
         $customer_id = $account->id;
         $this->user->setPrivateSetting('stripe_customer_id', $customer_id);
     }
     return $customer_id;
 }
开发者ID:Daltonmedia,项目名称:stripe,代码行数:30,代码来源:StripeCustomer.php

示例3: stripe_register_user

/**
 * Check if the email of the user has already been associated with a Stripe customer
 * If so, map them
 *
 * @param string $event
 * @param string $type
 * @param ElggUser $user
 * @param true
 */
function stripe_register_user($event, $type, $user)
{
    $customer_ref = elgg_get_plugin_setting($user->email, 'stripe');
    if (!$customer_ref) {
        return;
    }
    $customer_ref = unserialize($customer_ref);
    if (is_array($customer_ref) && sizeof($customer_ref)) {
        $user->setPrivateSetting('stripe_customer_id', $customer_ref[0]);
        $customer_ref = array_reverse($customer_ref);
        foreach ($customer_ref as $c_ref) {
            create_metadata($user->guid, 'stripe_customer_id', $c_ref, '', $user->guid, ACCESS_PUBLIC, true);
        }
    }
    elgg_unset_plugin_setting($user->email, 'stripe');
    return true;
}
开发者ID:Daltonmedia,项目名称:stripe,代码行数:26,代码来源:events.php

示例4: createCustomer

 /**
  * Create a new customer
  * @param ElggUser $user
  * @param array $data
  * @return Stripe_Customer|false
  */
 public function createCustomer($user = null, $data = array())
 {
     $fields = array('account_balance', 'card', 'coupon', 'plan', 'quantity', 'trial_end', 'metadata', 'description', 'email');
     try {
         foreach ($data as $key => $value) {
             if (!in_array($key, $fields)) {
                 $data[$key] = '';
             }
         }
         $data = array_filter($data);
         if ($user) {
             if (!$data['email']) {
                 $data['email'] = $user->email;
             }
             if (!$data['description']) {
                 $data['description'] = $user->name;
             }
             if (!is_array($data['metadata'])) {
                 $data['metadata'] = array();
             }
             $data['metadata']['guid'] = $user->guid;
             $data['metadata']['username'] = $user->username;
         }
         $customer = Stripe_Customer::create($data);
         if ($user && $user->guid) {
             // Store any customer IDs this user might have for reference
             $stripe_ids = $user->stripe_customer_id;
             if (!$stripe_ids) {
                 $stripe_ids = array();
             } else {
                 if (!is_array($stripe_ids)) {
                     $stripe_ids = array($stripe_ids);
                 }
             }
             if (!in_array($customer->id, $stripe_ids)) {
                 create_metadata($user->guid, 'stripe_customer_id', $customer->id, '', $user->guid, ACCESS_PUBLIC, true);
             }
             // Store current Customer ID
             $user->setPrivateSetting('stripe_customer_id', $customer->id);
         } else {
             // Store customer IDs with their email reference locally
             // so that users can be assigned their existing customer ID upon registration
             $customer_ref = elgg_get_plugin_setting($customer->email, 'stripe');
             if ($customer_ref) {
                 $customer_ref = unserialize($customer_ref);
             } else {
                 $customer_ref = array();
             }
             array_unshift($customer_ref, $customer->id);
             elgg_set_plugin_setting($customer->email, serialize($customer_ref), 'stripe');
         }
         return $customer;
     } catch (Exception $ex) {
         $this->log($ex);
         return false;
     }
 }
开发者ID:Daltonmedia,项目名称:stripe,代码行数:63,代码来源:StripeClient.php


注:本文中的ElggUser::setPrivateSetting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。