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


PHP Stripe_Charge::all方法代码示例

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


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

示例1: charges

 public function charges($params = null)
 {
     if (!$params) {
         $params = array();
     }
     $params['customer'] = $this->id;
     $charges = Stripe_Charge::all($params, $this->_apiKey);
     return $charges;
 }
开发者ID:slavic18,项目名称:cats,代码行数:9,代码来源:Customer.php

示例2: get_all_transactions

 public function get_all_transactions($num_charges = 100, $offset = 0)
 {
     try {
         $ch = Stripe_Charge::all(array('count' => $num_charges, 'offset' => $offset));
         $data['error'] = FALSE;
         $raw_data = array();
         foreach ($ch->data as $record) {
             $raw_data[] = $this->charge_to_array($record);
         }
         $data['data'] = $raw_data;
         return $data;
     } catch (Exception $e) {
         $this->error = TRUE;
         $this->message = $e->getMessage();
         $this->code = $e->getCode();
         return FALSE;
     }
 }
开发者ID:NimzyMaina,项目名称:sma,代码行数:18,代码来源:Stripe_payments.php

示例3: process_modify

 /**
  * Process the changes from the Modify Pro Site Status metabox.
  *
  * @param $blog_id
  */
 public static function process_modify($blog_id)
 {
     global $psts, $current_user;
     $success_msg = $error_msg = '';
     if (isset($_POST['stripe_mod_action'])) {
         $customer_id = self::get_customer_data($blog_id)->customer_id;
         $exitsing_invoice_object = Stripe_Invoice::all(array("customer" => $customer_id, "count" => 1));
         $last_payment = $exitsing_invoice_object->data[0]->total / 100;
         $refund_value = $_POST['refund_amount'];
         $refund_amount = $refund_value * 100;
         $refund_amount = (int) $refund_amount;
         $refund = $last_payment;
         switch ($_POST['stripe_mod_action']) {
             case 'cancel':
                 $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
                 try {
                     $customer_data = self::get_customer_data($blog_id);
                     $customer_id = $customer_data->customer_id;
                     $sub_id = $customer_data->subscription_id;
                     $cu = Stripe_Customer::retrieve($customer_id);
                     // Don't use ::cancelSubscription because it doesn't know which subscription if we have multiple
                     $cu->subscriptions->retrieve($sub_id)->cancel();
                     //record stat
                     $psts->record_stat($blog_id, 'cancel');
                     $psts->log_action($blog_id, sprintf(__('Subscription successfully cancelled by %1$s. They should continue to have access until %2$s', 'psts'), $current_user->display_name, $end_date));
                     $success_msg = sprintf(__('Subscription successfully cancelled. They should continue to have access until %s.', 'psts'), $end_date);
                     update_blog_option($blog_id, 'psts_stripe_canceled', 1);
                 } catch (Exception $e) {
                     $error_msg = $e->getMessage();
                     $psts->log_action($blog_id, sprintf(__('Attempt to Cancel Subscription by %1$s failed with an error: %2$s', 'psts'), $current_user->display_name, $error_msg));
                 }
                 break;
             case 'cancel_refund':
                 $end_date = date_i18n(get_option('date_format'), $psts->get_expire($blog_id));
                 $cancellation_success = false;
                 try {
                     $customer_data = self::get_customer_data($blog_id);
                     $customer_id = $customer_data->customer_id;
                     $sub_id = $customer_data->subscription_id;
                     $cu = Stripe_Customer::retrieve($customer_id);
                     // Don't use ::cancelSubscription because it doesn't know which subscription if we have multiple
                     $cu->subscriptions->retrieve($sub_id)->cancel();
                     $cancellation_success = true;
                     //record stat
                 } catch (Exception $e) {
                     $error_msg = $e->getMessage();
                 }
                 if ($cancellation_success == false) {
                     $psts->log_action($blog_id, sprintf(__('Attempt to Cancel Subscription and Refund Prorated (%1$s) Last Payment by %2$s failed with an error: %3$s', 'psts'), $psts->format_currency(false, $refund), $current_user->display_name, $error_msg));
                     $error_msg = sprintf(__('Whoops, Stripe returned an error when attempting to cancel the subscription. Nothing was completed: %s', 'psts'), $error_msg);
                     break;
                 }
                 $refund_success = false;
                 if ($cancellation_success == true) {
                     try {
                         $charge_object = Stripe_Charge::all(array("count" => 1, "customer" => $customer_id));
                         $charge_id = $charge_object->data[0]->id;
                         $ch = Stripe_Charge::retrieve($charge_id);
                         $ch->refund();
                         $refund_success = true;
                     } catch (Exception $e) {
                         $error_msg = $e->getMessage();
                     }
                 }
                 if ($refund_success == true) {
                     $psts->log_action($blog_id, sprintf(__('Subscription cancelled and a prorated (%1$s) refund of last payment completed by %2$s', 'psts'), $psts->format_currency(false, $refund), $current_user->display_name));
                     $success_msg = sprintf(__('Subscription cancelled and a prorated (%s) refund of last payment were successfully completed.', 'psts'), $psts->format_currency(false, $refund));
                     update_blog_option($blog_id, 'psts_stripe_canceled', 1);
                 } else {
                     $psts->log_action($blog_id, sprintf(__('Subscription cancelled, but prorated (%1$s) refund of last payment by %2$s returned an error: %3$s', 'psts'), $psts->format_currency(false, $refund), $current_user->display_name, $error_msg));
                     $error_msg = sprintf(__('Subscription cancelled, but prorated (%1$s) refund of last payment returned an error: %2$s', 'psts'), $psts->format_currency(false, $refund), $error_msg);
                     update_blog_option($blog_id, 'psts_stripe_canceled', 1);
                 }
                 break;
             case 'refund':
                 try {
                     $charge_object = Stripe_Charge::all(array("count" => 1, "customer" => $customer_id));
                     $charge_id = $charge_object->data[0]->id;
                     $ch = Stripe_Charge::retrieve($charge_id);
                     $ch->refund();
                     $psts->log_action($blog_id, sprintf(__('A full (%1$s) refund of last payment completed by %2$s The subscription was not cancelled.', 'psts'), $psts->format_currency(false, $refund), $current_user->display_name));
                     $success_msg = sprintf(__('A full (%s) refund of last payment was successfully completed. The subscription was not cancelled.', 'psts'), $psts->format_currency(false, $refund));
                     $psts->record_refund_transaction($blog_id, $charge_id, $refund);
                 } catch (Exception $e) {
                     $error_msg = $e->getMessage();
                     $psts->log_action($blog_id, sprintf(__('Attempt to issue a full (%1$s) refund of last payment by %2$s returned an error: %3$s', 'psts'), $psts->format_currency(false, $refund), $current_user->display_name, $error_msg));
                     $error_msg = sprintf(__('Attempt to issue a full (%1$s) refund of last payment returned an error: %2$s', 'psts'), $psts->format_currency(false, $refund), $error_msg);
                 }
                 break;
             case 'partial_refund':
                 try {
                     $charge_object = Stripe_Charge::all(array("count" => 1, "customer" => $customer_id));
                     $charge_id = $charge_object->data[0]->id;
                     $ch = Stripe_Charge::retrieve($charge_id);
                     $ch->refund(array("amount" => $refund_amount));
//.........这里部分代码省略.........
开发者ID:vilmark,项目名称:vilmark_main,代码行数:101,代码来源:gateway-stripe.php

示例4: getCharges

 /**
  * Getting all the charges for the user
  * @param stripe key
  *
  * @return an array with the charges
  */
 public static function getCharges($key)
 {
     $out_charges = array();
     // telling stripe who we are
     Stripe::setApiKey($_ENV['STRIPE_SECRET_KEY']);
     // getting the charges
     // https://stripe.com/docs/api/php#charges
     $returned_object = Stripe_Charge::all();
     // extractin json (this is not the best approach)
     $charges = json_decode(strstr($returned_object, '{'), true);
     // getting relevant fields
     foreach ($charges['data'] as $charge) {
         // updating array
         /*
         id                      - string
         created                 - timestamp
         amount                  - non negative integer
         currency                - string, 3 letter ISO currency code
         paid                    - boolean
         captured                - boolean
         description             - string
         statement_description   - string
         failure_code            - string (see https://stripe.com/docs/api#errors for a list of codes)
         */
         $out_charges[$charge['id']] = array('created' => $charge['created'], 'amount' => $charge['amount'], 'currency' => $charge['currency'], 'paid' => $charge['paid'], 'captured' => $charge['captured'], 'description' => $charge['description'], 'statement_description' => $charge['statement_description'], 'failure_code' => $charge['failure_code']);
     }
     //foreach
     // returning object
     return $out_charges;
 }
开发者ID:raschan,项目名称:fruit-dashboard,代码行数:36,代码来源:StripeHelper.php

示例5: getCharges

 /**
  * Get all customer charges
  * @param mixed $cus_attr
  * @param string $limit				Number of items to retrieve
  * @param string $ending_before		ID of the first element in the previous list
  * @param string $starting_after	ID of the last element in the previous list
  * @param mixed $created
  * @return boolean
  */
 public function getCharges($cus_attr = null, $limit = 10, $ending_before = null, $starting_after = null, $created = null)
 {
     try {
         if ($cus_attr) {
             $customer = new StripeCustomer($cus_attr);
             $customer_id = $customer->getCustomerAccount()->id;
         }
         $params = array_filter(array('created' => $created, 'customer' => $customer_id, 'limit' => $limit, 'ending_before' => $ending_before, 'starting_after' => $starting_after));
         return Stripe_Charge::all($params, $this->access_token);
     } catch (Exception $ex) {
         $this->log($ex);
         return false;
     }
 }
开发者ID:Daltonmedia,项目名称:stripe,代码行数:23,代码来源:StripeClient.php

示例6: leaky_paywall_has_user_paid

 /**
  * Verified if user has paid through Stripe
  *
  * @since 1.0.0
  *
  * @param string $email address of user "logged" in
  * @return mixed Expiration date or subscriptions status or false if not paid
  */
 function leaky_paywall_has_user_paid($email = false, $blog_id = null)
 {
     $settings = get_leaky_paywall_settings();
     $paid = false;
     $canceled = false;
     $expired = false;
     $sites = array('');
     //Empty String for non-Multisite, so we cycle through "sites" one time with no $site set
     if (is_multisite_premium()) {
         if (is_null($blog_id)) {
             global $blog_id;
             if (!is_main_site($blog_id)) {
                 $sites = array('_all', '_' . $blog_id);
             } else {
                 $sites = array('_all', '_' . $blog_id, '');
             }
         } else {
             if (is_int($blog_id)) {
                 $sites = array('_' . $blog_id);
             } else {
                 if (empty($blog_id)) {
                     $sites = array('');
                 } else {
                     $sites = array($blog_id);
                 }
             }
         }
     }
     $mode = 'off' === $settings['test_mode'] ? 'live' : 'test';
     if (empty($email)) {
         $user = wp_get_current_user();
     } else {
         if (is_email($email)) {
             $user = get_user_by('email', $email);
         } else {
             return false;
         }
     }
     foreach ($sites as $site) {
         $subscriber_id = get_user_meta($user->ID, '_issuem_leaky_paywall_' . $mode . '_subscriber_id' . $site, true);
         $expires = get_user_meta($user->ID, '_issuem_leaky_paywall_' . $mode . '_expires' . $site, true);
         $payment_gateway = get_user_meta($user->ID, '_issuem_leaky_paywall_' . $mode . '_payment_gateway' . $site, true);
         $payment_status = get_user_meta($user->ID, '_issuem_leaky_paywall_' . $mode . '_payment_status' . $site, true);
         $plan = get_user_meta($user->ID, '_issuem_leaky_paywall_' . $mode . '_plan' . $site, true);
         if (!$paid) {
             if ('stripe' === $payment_gateway) {
                 if (!class_exists('Stripe')) {
                     require_once LEAKY_PAYWALL_PATH . 'include/stripe/lib/Stripe.php';
                 }
                 if ($mode == 'test') {
                     $secret_key = isset($settings['test_secret_key']) ? trim($settings['test_secret_key']) : '';
                 } else {
                     $secret_key = isset($settings['live_secret_key']) ? trim($settings['live_secret_key']) : '';
                 }
                 Stripe::setApiKey($secret_key);
                 try {
                     if (empty($subscriber_id)) {
                         switch ($payment_status) {
                             case 'Active':
                             case 'active':
                             case 'refunded':
                             case 'refund':
                                 if (empty($expires) || '0000-00-00 00:00:00' === $expires) {
                                     return 'unlimited';
                                 }
                                 if (strtotime($expires) < time()) {
                                     $expired = $expires;
                                 } else {
                                     $paid = true;
                                 }
                                 break;
                             case 'cancelled':
                             case 'canceled':
                                 if (empty($expires) || '0000-00-00 00:00:00' === $expires) {
                                     $expired = true;
                                 } else {
                                     $canceled = true;
                                 }
                             case 'reversed':
                             case 'buyer_complaint':
                             case 'denied':
                             case 'expired':
                             case 'failed':
                             case 'voided':
                             case 'deactivated':
                                 continue;
                                 break;
                         }
                     }
                     $cu = Stripe_Customer::retrieve($subscriber_id);
                     if (!empty($cu)) {
                         if (!empty($cu->deleted) && true === $cu->deleted) {
//.........这里部分代码省略.........
开发者ID:zeen101,项目名称:leaky-paywall,代码行数:101,代码来源:functions.php

示例7: get_all_customer

 public function get_all_customer($customer, $num_charges = 10, $offset = 0)
 {
     try {
         $ch = Stripe_Charge::all(array('count' => $num_charges, 'offset' => $offset, 'customer' => $customer));
         $raw_data = array();
         foreach ($ch->data as $record) {
             $raw_data[] = $record;
         }
         if (count($raw_data) > 0) {
             return $raw_data;
         } else {
             return FALSE;
         }
     } catch (Exception $e) {
         $this->error = TRUE;
         $this->message = $e->getMessage();
         $this->code = $e->getCode();
         return FALSE;
     }
 }
开发者ID:ruchirkakkad,项目名称:stripe-integration-as-models,代码行数:20,代码来源:stripe_trans.php

示例8: stripslashes

				</div>
			<?php 
    }
    ?>
			<div class="customer-interal-notes">
				<?php 
    echo stripslashes($customer['metadata']['Internal Notes']);
    ?>
			</div>
		</div>
	</header>

<?php 
} else {
    //no customer set
    $charges = Stripe_Charge::all(array("count" => 100));
}
?>



	<table class="table" id="charges">

		<thead>
			<tr>
				<th>Charge ID</th>
				<th>Date</th>
				<th class="paid-th">Status</th>
				<th class="amount-th">Total</th>
				<th>Description</th>
				<th class="fname-th">First Name</th>
开发者ID:shadosoft,项目名称:point-of-sale,代码行数:31,代码来源:charges.php


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