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


PHP Customer::all方法代码示例

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


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

示例1: get_customers

 function get_customers(WP_REST_Request $data)
 {
     $this->set_api_key();
     $data = $data->get_params();
     try {
         $args = array('limit' => 10);
         if (isset($data['starting_after'])) {
             $args['starting_after'] = $data['starting_after'];
             $customers = \Stripe\Customer::all($args);
         } elseif (!isset($data['starting_after']) && !isset($data['id'])) {
             $customers = \Stripe\Customer::all(array('limit' => 10));
         } elseif (isset($data['id'])) {
             $customers = \Stripe\Customer::retrieve($data['id']);
         }
         return new WP_REST_Response($customers, 200);
     } catch (Stripe_AuthenticationError $e) {
         $body = $e->getJsonBody();
         $err = $body['error'];
         return new WP_Error($err['type'], __($err['message']), array('status' => 403));
     } catch (Stripe_Error $e) {
         $body = $e->getJsonBody();
         $err = $body['error'];
         return new WP_Error($err['type'], __($err['message']), array('status' => 403));
     } catch (\Stripe\Error\Base $e) {
         $body = $e->getJsonBody();
         $err = $body['error'];
         return new WP_Error($err['type'], __($err['message']), array('status' => 403));
     }
 }
开发者ID:jacobarriola,项目名称:Stripe-for-WordPress,代码行数:29,代码来源:stripe-api-customers.php

示例2: listCustomers

 /**
  * [listCustomers Returns a list of your customers. The customers are returned sorted by creation date,
  *                with the most recently created customers appearing first.]
  *
  * @param  array  $opctions ['created' The value can be a string with an integer Unix timestamp, or it can be a dictionary with
  *                                      the following options:
  *                                      'gt' here the created field is after this timestamp.
  *                                      'gte' where the created field is after or equal to this timestamp.
  *                                      'lt' where the created field is before this timestamp.
  *                                      'lte' where the created field is before or equal to this timestamp.
  *
  *                          'ending_before' A cursor for use in pagination. ending_before is an object ID that defines your place
  *                                          in the list. For instance, if you make a list request and receive 100 objects, starting
  *                                          with obj_bar, your subsequent call can include ending_before=obj_bar in order to fetch
  *                                          the previous page of the list.
  *
  *                           'limit' A limit on the number of objects to be returned. Limit can range between 1 and 100 items.
  *
  *                           'starting_after' A cursor for use in pagination. starting_after is an object ID that defines your place
  *                                           in the list. For instance, if you make a list request and receive 100 objects, ending
  *                                           with obj_foo, your subsequent call can include starting_after=obj_foo in order to fetch
  *                                           the next page of the list.]
  *
  * @return [type]           [A associative array with a data property that contains an array of up to limit customers,
  *                             starting after customer starting_after. Each entry in the array is a separate customer
  *                             object. If no more customers are available, the resulting array will be empty.
  *                             This request should never throw an error.]
  */
 public function listCustomers($opctions = [])
 {
     return \Stripe\Customer::all($opctions);
 }
开发者ID:205media,项目名称:codeIgniter-stripe-library,代码行数:32,代码来源:stripe.php

示例3: listUsersDetails

 /**
  * @param null $limit
  * @param null $startAfter
  * @return StripeCollection
  */
 public function listUsersDetails($limit = null, $startAfter = null)
 {
     $req = [];
     if ($limit) {
         $req['limit'] = $limit;
     }
     if ($startAfter) {
         $req['starting_after'] = $startAfter;
     }
     return Customer::all($req);
 }
开发者ID:Asisyas,项目名称:EqPay,代码行数:16,代码来源:CustomerService.php

示例4: getCustomers

 /**
  * Getting all the customers for the user
  * @param user object
  *
  * @return an array with the customers
  */
 public static function getCustomers($user)
 {
     // init out array
     $out_customers = array();
     // setting stripe key
     $returned_object = null;
     if (strlen($user->stripe_key) > 2) {
         // we have secret key
         Stripe::setApiKey($user->stripe_key);
         $returned_object = Customer::all();
     } else {
         // we have permission to connect
         Stripe::setApiKey($_ENV['STRIPE_SECRET_KEY']);
         $returned_object = Customer::all(array(), array('stripe_account' => $user->stripeUserId));
     }
     // getting the customers
     // extracting data
     $customers = json_decode(strstr($returned_object, '{'), true);
     // setting the data to our own format
     foreach ($customers['data'] as $customer) {
         // updating array
         /*
         livemode        - valid customer
         subscriptions   - all the subscription a user has
         */
         $out_customers[$customer['id']] = array('zombie' => $customer['livemode'], 'email' => $customer['email'], 'subscriptions' => $customer['subscriptions']['data']);
     }
     //foreach
     // return with the customers
     return $out_customers;
 }
开发者ID:raschan,项目名称:fruit-dashboard,代码行数:37,代码来源:StripeHelper.php

示例5: foreach

<?php

// Load Stripe's PHP bindings and set your API key
require_once 'vendor/autoload.php';
\Stripe\Stripe::setApiKey('sk_your_api_key');
// Retrieve the first 100 customers created in the last month
$customers = \Stripe\Customer::all(array("limit" => 100));
// Iterate through the first 100 and output the customer ID and created date
foreach ($customers->data as $customer) {
    echo $customer->id . " created " . date("m-d-y", $customer->created) . "<br>";
}
// While we have more results, iterate through them
while ($customers->has_more) {
    // Add the `starting_after` parameter to reflect the last customer ID
    $customers = \Stripe\Customer::all(array("limit" => 100, "starting_after" => $customer->id));
    foreach ($customers->data as $customer) {
        echo $customer->id . " created " . date("m-d-y", $customer->created) . "<br>";
    }
}
开发者ID:adamjstevenson,项目名称:stripe-examples,代码行数:19,代码来源:customers_paginate.php

示例6: request

 /**
  * request method
  *
  * @param string $method
  * @param array $data
  *
  * @return array - containing 'status', 'message' and 'data' keys
  * 					if response was successful, keys will be 'success', 'Success' and the stripe response as associated array respectively,
  *   				if request failed, keys will be 'error', the card error message if it was card_error, boolen false otherwise, and
  *   								error data as an array respectively
  */
 private function request($method = null, $data = null)
 {
     if (!$method) {
         throw new Exception(__('Request method is missing'));
     }
     if (is_null($data)) {
         throw new Exception(__('Request Data is not provided'));
     }
     Stripe::setApiKey($this->key);
     $success = null;
     $error = null;
     $message = false;
     $log = null;
     try {
         switch ($method) {
             /**
              *
              * 		CHARGES
              *
              */
             case 'charge':
                 $success = $this->fetch(Charge::create($data));
                 break;
             case 'retrieveCharge':
                 $success = $this->fetch(Charge::retrieve($data['charge_id']));
                 if (!empty($success['refunds'])) {
                     foreach ($success['refunds'] as &$refund) {
                         $refund = $this->fetch($refund);
                     }
                 }
                 break;
             case 'updateCharge':
                 $charge = Charge::retrieve($data['charge_id']);
                 foreach ($data['fields'] as $field => $value) {
                     $charge->{$field} = $value;
                 }
                 $success = $this->fetch($charge->save());
                 break;
             case 'refundCharge':
                 $charge = Charge::retrieve($data['charge_id']);
                 // to prevent unknown param error
                 unset($data['charge_id']);
                 $success = $this->fetch($charge->refund($data));
                 foreach ($success['refunds']['data'] as &$refund) {
                     $refund = $this->fetch($refund);
                 }
                 break;
             case 'captureCharge':
                 $charge = Charge::retrieve($data['charge_id']);
                 unset($data['charge_id']);
                 $success = $this->fetch($charge->capture($data));
                 if (!empty($success['refunds']['data'])) {
                     foreach ($success['refunds']['data'] as &$refund) {
                         $refund = $this->fetch($refund);
                     }
                 }
                 break;
             case 'listCharges':
                 $charges = Charge::all();
                 $success = $this->fetch($charges);
                 foreach ($success['data'] as &$charge) {
                     $charge = $this->fetch($charge);
                     if (isset($charge['refunds']['data']) && !empty($charge['refunds']['data'])) {
                         foreach ($charge['refunds']['data'] as &$refund) {
                             $refund = $this->fetch($refund);
                         }
                         unset($refund);
                     }
                 }
                 break;
                 /**
                  * 		CUSTOMERS
                  */
             /**
              * 		CUSTOMERS
              */
             case 'createCustomer':
                 $customer = Customer::create($data);
                 $success = $this->fetch($customer);
                 if (!empty($success['cards']['data'])) {
                     foreach ($success['cards']['data'] as &$card) {
                         $card = $this->fetch($card);
                     }
                     unset($card);
                 }
                 if (!empty($success['subscriptions']['data'])) {
                     foreach ($success['subscriptions']['data'] as &$subscription) {
                         $subscription = $this->fetch($subscription);
                     }
//.........这里部分代码省略.........
开发者ID:hashmode,项目名称:cakephp-stripe,代码行数:101,代码来源:StripeComponent.php

示例7: getCustomers

 /**
  * getCustomers
  * Getting a list of customers.
  * --------------------------------------------------
  * @returns The stripe customers.
  * @throws StripeNotConnected
  * --------------------------------------------------
  */
 public function getCustomers()
 {
     $rawData = array();
     $decodedData = array();
     $hasMore = TRUE;
     $startingAfter = null;
     while ($hasMore) {
         try {
             /* Collecting events with pagination. */
             if ($startingAfter) {
                 $rawData = \Stripe\Customer::all(array("limit" => 100, "starting_after" => $startingAfter));
             } else {
                 $rawData = \Stripe\Customer::all(array("limit" => 100));
             }
             /* Adding objects to collection. */
             $currentData = json_decode($this->loadJSON($rawData), TRUE);
             $decodedData = array_merge($decodedData, $currentData['data']);
         } catch (\Stripe\Error\Authentication $e) {
             // Access token expired. Calling handler.
             $this->getNewAccessToken();
         }
         $hasMore = $currentData['has_more'];
         $startingAfter = end($currentData['data'])['id'];
     }
     // Getting the plans.
     $customers = [];
     foreach ($decodedData as $customer) {
         array_push($customers, $customer);
     }
     // Return.
     return $customers;
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:40,代码来源:StripeDataCollector.php

示例8: dirname

<?php

require_once dirname(__FILE__) . '/init.php';
require_once dirname(__FILE__) . '/config.php';
$increment = 100;
$count = 0;
$continue = true;
$starting_after = NULL;
while ($continue) {
    $customersJSON = \Stripe\Customer::all(array("limit" => $increment, "starting_after" => $starting_after));
    $customers = $customersJSON->__toArray(true);
    $continue = $customers['has_more'];
    $starting_after = end($customers['data'])['id'];
    foreach ($customers['data'] as $customer) {
        if (count($customer['subscriptions']['data']) == 0) {
            $count++;
            $cu = \Stripe\Customer::retrieve($customer['id']);
            $cu->delete();
        }
    }
}
echo $count;
开发者ID:johndaskovsky,项目名称:stripe-playground,代码行数:22,代码来源:remove-customers-without-subscriptions.php

示例9: getCustomers

 public function getCustomers()
 {
     return Customer::all();
 }
开发者ID:scotthummel,项目名称:lambdaphx,代码行数:4,代码来源:StripeBilling.php

示例10: listAllReccuringCustomers

 function listAllReccuringCustomers()
 {
     $this->setApiKey();
     $customers = \Stripe\Customer::all(array("limit" => 3));
     return $customers;
 }
开发者ID:rahulrockers,项目名称:ci-stripe,代码行数:6,代码来源:Stripepayment.php


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