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


PHP Customer::create方法代码示例

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


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

示例1: bill_user

 public function bill_user()
 {
     \Stripe\Stripe::setApiKey("sk_test_BzcfGDAVwQw9efuWp2eVvyVg");
     $stripe_info = $this->input->post();
     $billing = $this->user->get_billing_id($this->session->userdata("id"));
     $total = $this->cart->get_total_cents($this->cart->get_all());
     if ($billing["billing_id"]) {
         // var_dump($total);
         // die();
         \Stripe\Charge::create(array("amount" => $total, "currency" => "usd", "customer" => $billing["billing_id"]));
     } else {
         $customer = \Stripe\Customer::create(array("source" => $stripe_info["stripeToken"], "description" => "Example customer"));
         $this->user->set_billing_id($customer["id"]);
         try {
             $charge = \Stripe\Charge::create(array("amount" => $total, "currency" => "usd", "customer" => $customer["id"], "description" => "Example charge"));
         } catch (\Stripe\Error\Card $e) {
             // The card has been declined
         }
     }
     $cart_items = $this->cart->get_all();
     foreach ($cart_items as $item) {
         $this->cart->delete($item['product_id'], $item['recipient_id']);
         $this->wishlist->delete_from_wishlist($item['product_id'], $item['recipient_id']);
     }
     redirect("/carts/viewcart");
 }
开发者ID:Jeff-Ch,项目名称:Wishlist,代码行数:26,代码来源:billing.php

示例2: createCard

 public static function createCard($details)
 {
     self::init();
     $expiry = explode('/', $details['expiry']);
     // Check if they arent already a stripe customer.
     if (!Auth::user()->stripe_key) {
         try {
             // Create a stripe customer.
             $customer = \Stripe\Customer::create(['source' => ['object' => 'card', 'number' => $details['number'], 'exp_month' => trim($expiry[0]), 'exp_year' => trim($expiry[1]), 'cvc' => $details['cvc']]]);
             // Update the user with their stripe token.
             Auth::user()->stripe_key = $customer['id'];
             Auth::user()->save();
             return true;
         } catch (Exception $e) {
             return false;
         }
     }
     try {
         // Add a card to an existing customer.
         $customer = \Stripe\Customer::retrieve(Auth::user()->stripe_key);
         $customer->sources->create(['source' => ['object' => 'card', 'number' => $details['number'], 'exp_month' => trim($expiry[0]), 'exp_year' => trim($expiry[1]), 'cvc' => $details['cvc']]]);
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
开发者ID:Fash1,项目名称:Fash1,代码行数:26,代码来源:Stripe.php

示例3: createStripeCustomer

 protected function createStripeCustomer($token)
 {
     require_once '/api/stripe-php-2.1.1/init.php';
     \Stripe\Stripe::setApiKey($this->test_secret_key);
     $customer = \Stripe\Customer::create(array("source" => $token, "description" => "Razor Commerce Customer"));
     return $customer;
 }
开发者ID:ExchangeCore,项目名称:razor-commerce,代码行数:7,代码来源:Stripe.php

示例4: charge

 public function charge()
 {
     $id = $this->inputfilter->clean($this->app->get('PARAMS.id'), 'alnum');
     $subscription = $this->getModel()->setState('filter.id', $id)->getItem();
     // Get the credit card token submitted by the form
     $token = $this->inputfilter->clean($this->app->get('POST.stripeToken'), 'string');
     $email = $this->inputfilter->clean($this->app->get('POST.stripeEmail'), 'string');
     // Create the charge on Stripe's servers - this will charge the user's card
     try {
         //create a stripe user
         $user = \Stripe\Customer::create(array("description" => "Customer for " . $email, "email" => $email, "card" => $token));
         $user->subscriptions->create(array("plan" => $subscription->plan));
         // this needs to be created empty in model
         $subscription->set('subscriber.id', $user->id);
         $subscription->set('subscriber.email', $user->email);
         $subscription->set('client.email', $email);
         $subscription->save();
         // SEND email to the client
         $this->app->set('subscription', $subscription);
         $this->app->set('plan', \Stripe\Plan::retrieve($subscription->{'plan'}));
         // $subscription->sendChargeEmailClient($subscription);
         //$subscription->sendChargeEmailAdmin($subscription);
         $view = \Dsc\System::instance()->get('theme');
         echo $view->render('Striper/Site/Views::subscription/success.php');
     } catch (\Stripe\CardError $e) {
         //set error message
         // The card has been declined
         $view = \Dsc\System::instance()->get('theme');
         echo $view->render('Striper/Site/Views::subscription/index.php');
     }
 }
开发者ID:dioscouri,项目名称:f3-striper,代码行数:31,代码来源:Subscription.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $token = $request->input('stripeToken');
     $email = $request->input('email');
     Stripe::setApiKey($this->stripeConfig['testSecretKey']);
     $customer = StripeCustomer::create(["email" => $email, "description" => "Description of {$email}", "source" => $token]);
 }
开发者ID:kongtoonarmy,项目名称:laravel-stripe,代码行数:13,代码来源:CustomerController.php

示例6: postPayment

 public function postPayment(PaymentFormRequest $request, $eventId, $attendeeId)
 {
     $registeredAttendee = $this->attendees->findById($attendeeId);
     $event = $this->events->findById($eventId);
     $input = $request->all();
     $token = $input['stripeToken'];
     if (empty($token)) {
         Flash::error('Your order could not be processed.  Please ensure javascript in enabled and try again.');
         return redirect()->back();
     }
     try {
         \Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
         $stripeCustomer = \Stripe\Customer::create(['source' => $token, 'description' => 'Stripe charge for AARMS customer: ' . $registeredAttendee->id, 'email' => $registeredAttendee->email]);
         $charge = \Stripe\Charge::create(['amount' => $event->price_cents, 'currency' => 'usd', 'customer' => $stripeCustomer->id, 'description' => 'Stripe charge for event: ' . $event->title]);
         if (!$charge) {
             Flash::error("Could not process Credit Card Payment");
             return redirect()->back();
         } else {
             $registeredAttendee->amount_paid = $event->price;
             $registeredAttendee->save();
             $sendMail = new SendInvoiceEmail($registeredAttendee);
             $this->dispatch($sendMail);
         }
         Flash::success("Payment successful!");
         return redirect()->back();
     } catch (\Stripe\Error\Card $e) {
         Flash::error($e->getMessage());
         return redirect()->back();
     }
 }
开发者ID:dirtyblankets,项目名称:allaccessrms,代码行数:30,代码来源:RegistrationPaymentController.php

示例7: processStripePayment

function processStripePayment($cents_amount, $email)
{
    if (isset($_POST['stripeToken'])) {
        $token = $_POST['stripeToken'];
        $customer = \Stripe\Customer::create(array('card' => $token, 'email' => strip_tags(trim($_POST['email']))));
        $customer_id = $customer->id;
        try {
            $charge = \Stripe\Charge::create(array("amount" => $cents_amount, "currency" => "usd", "description" => "Weblytics Sign-Up", "customer" => $customer_id));
            $mail = new PHPMailer();
            $mail->IsSMTP();
            // send via SMTP
            $mail->SMTPAuth = true;
            // turn on SMTP authentication
            $mail->SMTPSecure = 'tls';
            $mail->Host = 'smtp.gmail.com';
            $mail->Port = 587;
            $mail->Username = 'cs4753.eCommerce@gmail.com';
            // Enter your SMTP username
            $mail->Password = '12qwas3.';
            // SMTP password
            $mail->FromName = 'Weblytics';
            $mail->addAddress($email);
            $mail->Subject = 'Weblytics - Payment Received';
            $mail->Body = 'Your payment of $5.00 associated with our sign-up fee has been received.';
            if (!$mail->send()) {
                //error
            } else {
                //good
            }
        } catch (\Stripe\Error\Card $e) {
            //Card has been declined
        }
    }
}
开发者ID:johnmirby,项目名称:CS4753-eCommerce-Project,代码行数:34,代码来源:signup.php

示例8: __construct

 function __construct()
 {
     \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey());
     $order_items = array();
     $user = getLoggedInUser();
     $stripe_cust = $user->stripe_cust;
     $cart = Cache::get("cart", "session");
     if (!$stripe_cust) {
         try {
             $cu = \Stripe\Customer::create(array("description" => $user->email, "source" => getInput("stripeToken")));
         } catch (Exception $e) {
             new SystemMessage("There has been an error.  Please contact us.");
             forward("home");
         }
         $user->stripe_cust = $cu->id;
         $user->save();
     } else {
         $cu = \Stripe\Customer::retrieve($stripe_cust);
         try {
             $cu->source = getInput("stripeToken");
         } catch (Exception $e) {
             new SystemMessage("There has been an error.  Please contact us.");
             forward("home");
         }
         $cu->save();
     }
     foreach ($cart as $guid => $details) {
         $product = getEntity($guid);
         if ($product->interval == "one_time") {
             $order_item = array("type" => "sku", "parent" => $product->stripe_sku, "description" => $product->description . $details);
             $order_items[] = $order_item;
         } else {
             try {
                 $cu->subscriptions->create(array("plan" => $guid));
             } catch (Exception $e) {
                 new SystemMessage("There has been an error.  Please contact us.");
                 forward("home");
             }
         }
     }
     if (!empty($order_items)) {
         try {
             $order = \Stripe\Order::create(array("items" => $order_items, "currency" => "usd", "customer" => $cu->id));
             $order->pay(array("customer" => $cu->id, "email" => $user->email));
         } catch (Exception $e) {
             new SystemMessage("There has been an error.  Please contact us.");
             forward("home");
         }
     }
     $invoice = new Invoice();
     $invoice->items = $cart;
     $invoice->status = "paid";
     $invoice->owner_guid = getLoggedInUserGuid();
     $invoice->stripe_order = $order->id;
     $invoice->save();
     Cache::delete("cart", "session");
     new SystemMessage("Your purchase is complete.");
     forward("billing");
 }
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:59,代码来源:ChargeCardActionHandler.php

示例9: charge

 public static function charge($token, $email, $amount)
 {
     $key = Config::get('stripeKey');
     Stripe\Stripe::setApiKey($key);
     $customer = Stripe\Customer::create(array('email' => $email, 'card' => $token));
     $charge = Stripe\Charge::create(array('customer' => $customer->id, 'amount' => $amount, 'currency' => 'USD'));
     return $charge;
 }
开发者ID:SharkIng,项目名称:ss-panel,代码行数:8,代码来源:StripePayment.php

示例10: indexAction

 public function indexAction()
 {
     \Stripe\Stripe::setApiKey("sk_test_xN2J6grU84FCtP69dJEncERE");
     $token = $_POST['stripeToken'];
     $customer = \Stripe\Customer::create(array("source" => $token, "description" => "Example customer"));
     \Stripe\Charge::create(array("amount" => 1000, "currency" => "gbp", "customer" => $customer->id));
     return $this->render('TestStripeBundle:Stripe:index.html.twig');
 }
开发者ID:jordanmanning,项目名称:Symfony,代码行数:8,代码来源:chargeController.php

示例11: createCustomer

 public function createCustomer($email)
 {
     $customer = \Stripe\Customer::create(array("description" => "Customer for '{$email}'", "email" => $email));
     $user = new userControllerClass();
     $user->setAssocCustomerId($customer->id, $email);
     return $customer;
     // store customer's id into database
 }
开发者ID:nicklyz,项目名称:Tixzoo,代码行数:8,代码来源:customerController.php

示例12: customerCreate

 /**
  * @param $params
  * @return StripeCustomerMock|Customer
  */
 function customerCreate($params)
 {
     if (self::$testMode) {
         return StripeCustomerMock::create($params);
     } else {
         return Customer::create($params);
     }
 }
开发者ID:patternseek,项目名称:ecommerce,代码行数:12,代码来源:StripeFacade.php

示例13: stripe

 public function stripe($stripeToken)
 {
     $customer = \Stripe\Customer::create(array('email' => AuthModel::getUser('email'), 'source' => $stripeToken));
     $charge = \Stripe\Charge::create(array('customer' => $customer->id, 'amount' => $_SESSION['grandPrice'][0] * 100, 'currency' => 'cad'));
     unset($_SESSION['grandPrice']);
     // TODO: need handle payment errors
     return true;
 }
开发者ID:zhaoyiyi,项目名称:php-project,代码行数:8,代码来源:Payment.php

示例14: postProcess

 public function postProcess()
 {
     $cart = $this->context->cart;
     $customer = new Customer((int) $cart->id_customer);
     \Stripe\Stripe::setApiKey((string) Configuration::get('STRIPE_SECRET_KEY'));
     $token = Tools::getValue('stripeToken');
     $customer = \Stripe\Customer::create(array('email' => $customer->email, 'card' => $token));
     $charge = \Stripe\Charge::create(array('customer' => $customer->id, 'amount' => (int) ($cart->getOrderTotal(true, CART::BOTH) * 100), 'currency' => 'sek'));
 }
开发者ID:prestarocket,项目名称:stripe,代码行数:9,代码来源:charge.php

示例15: createFromRequest

 /**
  * @param Request $request
  * @param string  $email
  *
  * @return Customer
  */
 public function createFromRequest(Request $request, $email = null)
 {
     if (!($token = $request->get(StripeFactory::TOKEN_REQUEST_PARAMETER))) {
         throw new \RuntimeException(sprintf('"%s" not found in given request.', StripeFactory::TOKEN_REQUEST_PARAMETER));
     }
     $stripeCustomer = StripeCustomer::create(array('source' => $token, 'email' => $email));
     $customer = $this->stripeToCustomerTransformer->transform($stripeCustomer);
     return $customer;
 }
开发者ID:sylvaindeloux,项目名称:StripeBundle,代码行数:15,代码来源:CustomerManager.php


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