<?php access_show_hidden_entities(true); $stripe = new StripeClient(); $has_more = true; $starting_after = null; while ($has_more) { $customers = $stripe->getCustomers(100, null, $starting_after, null); if ($customers->data && sizeof($customers->data)) { foreach ($customers->data as $customer) { // Check if the user with this customer id already exists $user = stripe_get_user_from_customer_id($customer->id); if (!$user) { // Check if user guid is supplied with customer metadata if (isset($customer->metadata->guid)) { $guid = $customer->metadata->guid; $user = get_entity($guid); } } if (!$user) { // Try mapping by email $users = get_user_by_email($customer->email); $user = $users ? $users[0] : false; } if ($user) { // 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)) {
<?php $limit = get_input('limit', 10); $ending_before = get_input('ending_before'); $starting_after = get_input('starting_after'); $stripe = new StripeClient(); $customers = $stripe->getCustomers($limit, $ending_before, $starting_after); $mod = elgg_view('output/url', array('text' => elgg_echo('stripe:customers:sync'), 'href' => 'action/stripe/customers/sync', 'is_action' => true, 'class' => 'elgg-button elgg-button-action mam pam')); echo elgg_view_module('main', elgg_echo('stripe:customers:sync'), $mod); $mod2 = elgg_view('stripe/objects/list', array('objects' => $customers, 'starting_after' => $starting_after, 'ending_before' => $ending_before, 'limit' => $limit)); echo elgg_view_module('main', elgg_echo('stripe:customers:list'), $mod2);