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


PHP Charge::all方法代码示例

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


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

示例1: stripe_tls_check

 /**
  * Stripe TLS requirement.
  * https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2
  */
 private static function stripe_tls_check($for_export)
 {
     global $sc_options;
     // Set Stripe API key. Force test key.
     Stripe_Checkout_Functions::set_key('true');
     $test_key = $sc_options->get_setting_value('test_secret_key');
     // If test key isn't set...
     if (empty($test_key)) {
         if ($for_export) {
             return __('Cannot test TLS 1.2 support until your Stripe Test Secret Key is entered.', 'stripe');
         } else {
             return '<mark class="error">' . __('Cannot test TLS 1.2 support until your Stripe Test Secret Key is entered.', 'stripe') . '</mark>';
         }
     }
     \Stripe\Stripe::$apiBase = 'https://api-tls12.stripe.com';
     try {
         \Stripe\Charge::all();
         if ($for_export) {
             return __('TLS 1.2 supported, no action required.', 'stripe');
         } else {
             return '<mark class="ok">' . __('TLS 1.2 supported, no action required.', 'stripe') . '</mark>';
         }
     } catch (\Stripe\Error\ApiConnection $e) {
         if ($for_export) {
             return sprintf(__('TLS 1.2 is not supported. You will need to upgrade your integration. See %1$s.', 'stripe'), 'https://stripe.com/blog/upgrading-tls');
         } else {
             return '<mark class="error">' . sprintf(__('TLS 1.2 is not supported. You will need to upgrade your integration. <a href="%1$s">Please read this</a> for more information.', 'stripe'), 'https://stripe.com/blog/upgrading-tls') . '</mark>';
         }
     }
 }
开发者ID:pcuervo,项目名称:wp-yolcan,代码行数:34,代码来源:class-stripe-checkout-shared-system-status.php

示例2: listCharges

 /**
  * [listCharges Returns a list of charges you've previously created. The charges are
  *             returned in sorted order, with the most recent charges appearing first.]
  *
  * @param  array  $options [  'created' A filter on the list based on the object created field. The value can be a
  *                                       string with an integer Unix timestamp, or
  *                              it can be a dictionary with the following options:
  *                                  child arguments
  *                                      'gt' where 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.
  *
  *                             'customer'
  *
  *                             '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' default is 10, Limit can range between 1 and 100 items.
  *
  *                             'starting_after' 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           [A associative array with a data property that contains an array
  *                          of up to limit charges, starting after charge starting_after.]
  */
 public function listCharges($options = [])
 {
     return \Stripe\Charge::all($options);
 }
开发者ID:205media,项目名称:codeIgniter-stripe-library,代码行数:33,代码来源:stripe.php

示例3: foreach

<?php

\Stripe\Stripe::setApiKey("sk_your_api_key");
$charges = \Stripe\Charge::all(array("limit" => 100));
foreach ($charges as $charge) {
    echo $charge->id;
}
while ($charges->has_more) {
    $charges = \Stripe\Charge::all(array("limit" => 100, "starting_after" => end($charges->data->id)));
    foreach ($charges as $charge) {
        echo $charge->id;
    }
}
开发者ID:adamjstevenson,项目名称:stripe-examples,代码行数:13,代码来源:charges_paginate.php

示例4: charges

 /**
  * Gets all charges for a customer.
  *
  * @return array
  */
 public function charges()
 {
     $this->info();
     if (!$this->stripe_customer) {
         return array();
     }
     $charges = Stripe_Charge::all(array('customer' => $this->id, 'limit' => 100));
     $charges_array = array();
     foreach ($charges->data as $charge) {
         $charges_array[] = $this->charge($charge);
     }
     return $charges_array;
 }
开发者ID:linkthrow,项目名称:laravel-billing,代码行数:18,代码来源:Customer.php

示例5: submitOrder

 public function submitOrder($short_name)
 {
     $university = $this->university->where('short_name', $short_name)->first();
     $firstName = $this->request->input('first_name', '');
     $lastName = $this->request->input('last_name', '');
     $emainAddress = $this->request->input('email_address', '');
     $customer = $this->customer->where('first_name', $firstName)->where('last_name', $lastName)->where('email_address', $emainAddress)->first();
     $customerId;
     if ($customer === null) {
         //This customer is new
         $this->customer->fill($this->request->all())->save();
         $customerId = $this->customer->id;
     } else {
         $this->customer->find($customer->id)->fill($this->request->all())->save();
         $customerId = $customer->id;
     }
     $totalPrice = $this->request->input('totalPrice', '');
     $orderId = $this->order->insertGetId(['customer_id' => $customerId, 'payment' => $this->request->input('payment', ''), 'order_status' => "initialized", 'street_address1' => $this->request->input('street_address1', ''), 'street_address2' => $this->request->input('street_address2', ''), 'city' => $this->request->input('city', ''), 'post_code' => $this->request->input('post_code', ''), 'country' => $this->request->input('country', ''), 'created_at' => \Carbon\Carbon::now()->toDateTimeString(), 'total_price' => $totalPrice]);
     $itemsInCart = $this->cart->where('customer_id', $this->request->cookie('customer_id'))->get();
     foreach ($itemsInCart as $item) {
         $this->orderitem->insert(['order_id' => $orderId, 'product_id' => $item->product_id, 'created_at' => \Carbon\Carbon::now()->toDateTimeString(), 'price' => $item->price]);
         $cart = $this->cart->find($item->id);
         $cart->order_id = $orderId;
         $cart->save();
     }
     $temporaryCustomerId = $this->request->cookie('customer_id');
     $allProductsInCart = $this->getAllProductsInCart($temporaryCustomerId);
     $allProductsInCart = $this->convertProductsForCheckout($allProductsInCart);
     \Stripe\Stripe::setApiKey("sk_test_I561ILtdEXsIVDoAc9169tcC");
     $transactionInformation = \Stripe\Charge::all();
     $transactionId = $transactionInformation->data[0]->id;
     $token = $this->request->input('stripeToken', '');
     $tokenInformation = \Stripe\Token::retrieve($token);
     $chargeInformation = \Stripe\Charge::retrieve($transactionId);
     //dd($transactionInformation);
     try {
         $charge = \Stripe\Charge::create(array("amount" => bcmul($totalPrice, 100), "currency" => "aud", "source" => $token, "description" => "Example charge"));
         $type = $tokenInformation->type;
         $clientIp = $tokenInformation->client_ip;
         $createdTime = $chargeInformation->created;
         $country = $chargeInformation->source->country;
         $expMonth = $chargeInformation->source->exp_month;
         $expYear = $chargeInformation->source->exp_year;
         $brand = $chargeInformation->source->brand;
         $last4CardNumber = $chargeInformation->source->last4;
         $paymentResponse = json_encode(array('type' => $type, 'client_ip' => $clientIp, 'created' => $createdTime, 'country' => $country, 'expMonth' => $expMonth, 'expYear' => $expYear, 'brand' => $brand, 'last4CardNumber' => $last4CardNumber));
         $transactionId = \Stripe\Charge::all()->data[0]->id;
         $order = $this->order->find($orderId);
         $order->transaction_id = $transactionId;
         $order->order_status = "paid";
         $order->payment_response = $paymentResponse;
         $order->save();
         $shippingFee = $this->request->input('shipping_fee', '');
         $this->sendConfirmationMail($customerId, $allProductsInCart, $totalPrice, $shippingFee);
         foreach ($allProductsInCart as $productInCart) {
             $product = $this->product->find($productInCart['id']);
             $product->stock -= $productInCart['quantity'];
             $product->save();
             if ($product->stock < 0) {
                 $this->sendStockShortageNotification($product, $orderId);
                 $order->order_status = "out_of_stock";
                 $order->save();
             }
         }
         foreach ($itemsInCart as $item) {
             $this->cart->destroy($item->id);
         }
         return view('www.orderSubmitted', ['template' => $university->template, 'basket' => $this->getTheNumberOfItems(), 'products' => $allProductsInCart, 'totalPrice' => $totalPrice, 'shippingFee' => $shippingFee, 'headerLinks' => $this->headerPages, 'footerLinks' => $this->footerPages]);
     } catch (\Stripe\Error\Card $e) {
         $type = $tokenInformation->type;
         $clientIp = $tokenInformation->client_ip;
         $createdTime = $chargeInformation->created;
         $country = $chargeInformation->source->country;
         $expMonth = $chargeInformation->source->exp_month;
         $expYear = $chargeInformation->source->exp_year;
         $brand = $chargeInformation->source->brand;
         $last4CardNumber = $chargeInformation->source->last4;
         $failureCode = $chargeInformation->failure_code;
         $failureMessage = $chargeInformation->failure_message;
         $paymentResponse = json_encode(array('type' => $type, 'client_ip' => $clientIp, 'created' => $createdTime, 'country' => $country, 'expMonth' => $expMonth, 'expYear' => $expYear, 'brand' => $brand, 'last4CardNumber' => $last4CardNumber, 'failureCode' => $failureCode, 'failureMessage' => $failureMessage));
         $order = $this->order->find($orderId);
         $order->order_status = "failed";
         $order->payment_response = $paymentResponse;
         $order->save();
         include 'countries.php';
         $isShipping = false;
         foreach ($allProductsInCart as $productInCart) {
             if ($productInCart['is_shipping'] === "Yes" && $isShipping === false) {
                 $isShipping = true;
             }
         }
         $domesticShippingFee = $this->setting->where('key', 'domesticShippingFee')->first();
         $domesticShippingFee = json_decode($domesticShippingFee->json)->data;
         $overseasShippingFee = $this->setting->where('key', 'overseasShippingFee')->first();
         $overseasShippingFee = json_decode($overseasShippingFee->json)->data;
         $message = "Unfortunately, the submission has been failed :" . $failureCode;
         return view('www.checkout', ['template' => $university->template, 'universityShortName' => $short_name, 'basket' => $this->getTheNumberOfItems(), 'products' => $allProductsInCart, 'totalPrice' => $totalPrice, 'countries' => $countries, 'is_shipping' => $isShipping, 'domesticShippingFee' => $domesticShippingFee, 'overseasShippingFee' => $overseasShippingFee, 'message' => $message, 'headerLinks' => $this->headerPages, 'footerLinks' => $this->footerPages]);
     }
 }
开发者ID:Hiroki1116,项目名称:helloworld_laravel,代码行数:99,代码来源:PageController.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: retrieveCharges

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

示例8: getLatestCharges

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


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