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


PHP Stripe::setAppInfo方法代码示例

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


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

示例1: init

 public static function init()
 {
     // include class vendor
     require Kohana::find_file('vendor/stripe', 'init');
     // Set your secret key: remember to change this to your live secret key in production
     // See your keys here https://manage.stripe.com/account
     \Stripe\Stripe::setAppInfo('Open Classifieds', Core::VERSION, 'http://open-classifieds.com');
     \Stripe\Stripe::setApiKey(Core::config('payment.stripe_private'));
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:9,代码来源:stripeko.php

示例2: action_3d

 /**
  * [action_form] generates the form to pay at paypal
  */
 public function action_3d()
 {
     $this->auto_render = FALSE;
     $id_order = $this->request->param('id');
     //retrieve info for the item in DB
     $order = new Model_Order();
     $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
     if ($order->loaded()) {
         //dr($_GET);
         if (Core::get('status') == 'succeeded' and Core::get('id') != NULL) {
             try {
                 // include class vendor
                 require Kohana::find_file('vendor/stripe', 'init');
                 // Set your secret key: remember to change this to your live secret key in production
                 // See your keys here https://manage.stripe.com/account
                 \Stripe\Stripe::setAppInfo('Open eShop', Core::VERSION, 'https://open-eshop.com');
                 \Stripe\Stripe::setApiKey(Core::config('payment.stripe_private'));
                 // Create the charge on Stripe's servers - this will charge the user's card
                 $charge = \Stripe\Charge::create(array("amount" => StripeKO::money_format($order->amount), "currency" => $order->currency, "card" => Core::get('id'), "description" => $order->product->title, "metadata" => array("id_order" => $order->id_order)));
                 //mark as paid
                 $order->confirm_payment('stripe', $charge->id, NULL, NULL, NULL, StripeKO::calculate_fee($order->amount));
             } catch (Exception $e) {
                 // The card has been declined
                 Kohana::$log->add(Log::ERROR, 'Stripe The card has been declined');
                 Alert::set(Alert::ERROR, 'The card has been declined');
                 $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'checkout', 'id' => $order->id_order)));
             }
             //redirect him to the goal
             Alert::set(Alert::SUCCESS, __('Thanks for your payment!'));
             $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'goal', 'id' => $order->id_order)));
         } else {
             Alert::set(Alert::INFO, __('Please fill your card details.'));
             $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'checkout', 'id' => $order->id_order)));
         }
     } else {
         Alert::set(Alert::INFO, __('Order could not be loaded'));
         $this->redirect(Route::url('default', array('controller' => 'product', 'action' => 'checkout', 'id' => $order->id_order)));
     }
 }
开发者ID:johnulist,项目名称:open-eshop,代码行数:42,代码来源:stripe.php

示例3: process_signup

 /**
  * Process registration
  *
  * @since 2.1
  */
 public function process_signup()
 {
     \Stripe\Stripe::setApiKey($this->secret_key);
     if (method_exists('\\Stripe\\Stripe', 'setAppInfo')) {
         \Stripe\Stripe::setAppInfo('Restrict Content Pro', RCP_PLUGIN_VERSION, esc_url(site_url()));
     }
     $paid = false;
     $member = new RCP_Member($this->user_id);
     $customer_exists = false;
     if (empty($_POST['stripeToken'])) {
         wp_die(__('Missing Stripe token, please try again or contact support if the issue persists.', 'rcp'), __('Error', 'rcp'), array('response' => 400));
     }
     $customer_id = $member->get_payment_profile_id();
     if ($customer_id) {
         $customer_exists = true;
         try {
             // Update the customer to ensure their card data is up to date
             $customer = \Stripe\Customer::retrieve($customer_id);
             if (isset($customer->deleted) && $customer->deleted) {
                 // This customer was deleted
                 $customer_exists = false;
             }
             // No customer found
         } catch (Exception $e) {
             $customer_exists = false;
         }
     }
     if (empty($customer_exists)) {
         try {
             $customer_args = array('card' => $_POST['stripeToken'], 'email' => $this->email);
             $customer = \Stripe\Customer::create(apply_filters('rcp_stripe_customer_create_args', $customer_args, $this));
             // A temporary invoice is created to force the customer's currency to be set to the store currency. See https://github.com/restrictcontentpro/restrict-content-pro/issues/549
             if (!empty($this->signup_fee)) {
                 \Stripe\InvoiceItem::create(array('customer' => $customer->id, 'amount' => 0, 'currency' => rcp_get_currency(), 'description' => 'Setting Customer Currency'));
                 $temp_invoice = \Stripe\Invoice::create(array('customer' => $customer->id));
             }
             $member->set_payment_profile_id($customer->id);
         } catch (Exception $e) {
             $this->handle_processing_error($e);
         }
     } else {
         $customer->source = $_POST['stripeToken'];
     }
     $customer->description = 'User ID: ' . $this->user_id . ' - User Email: ' . $this->email . ' Subscription: ' . $this->subscription_name;
     $customer->metadata = array('user_id' => $this->user_id, 'email' => $this->email, 'subscription' => $this->subscription_name);
     try {
         $customer->save();
     } catch (Exception $e) {
         $this->handle_processing_error($e);
     }
     if ($this->auto_renew) {
         // process a subscription sign up
         if (!($plan_id = $this->plan_exists($this->subscription_name))) {
             // create the plan if it doesn't exist
             $plan_id = $this->create_plan($this->subscription_name);
         }
         try {
             // Add fees before the plan is updated and charged
             if (!empty($this->signup_fee)) {
                 $customer->account_balance = $customer->account_balance + $this->signup_fee * rcp_stripe_get_currency_multiplier();
                 // Add additional amount to initial payment (in cents)
                 $customer->save();
                 if (isset($temp_invoice)) {
                     $invoice = \Stripe\Invoice::retrieve($temp_invoice->id);
                     $invoice->closed = true;
                     $invoice->save();
                     unset($temp_invoice, $invoice);
                 }
             }
             // clean up any past due or unpaid subscriptions before upgrading/downgrading
             foreach ($customer->subscriptions->all()->data as $subscription) {
                 // check if we are renewing an existing subscription. This should not ever be 'active', if it is Stripe
                 // will do nothing. If it is 'past_due' the most recent invoice will be paid and the subscription will become active
                 if ($subscription->plan->id == $plan_id && in_array($subscription->status, array('active', 'past_due'))) {
                     continue;
                 }
                 // remove any subscriptions that are past_due or inactive
                 if (in_array($subscription->status, array('past_due', 'unpaid'))) {
                     $subscription->cancel();
                 }
             }
             // If the customer has an existing subscription, we need to cancel it
             if ($member->just_upgraded() && rcp_can_member_cancel($member->ID)) {
                 $cancelled = rcp_cancel_member_payment_profile($member->ID, false);
             }
             $sub_args = array('plan' => $plan_id, 'prorate' => false);
             if (!empty($this->discount_code)) {
                 $sub_args['coupon'] = $this->discount_code;
             }
             // Set the customer's subscription in Stripe
             $subscription = $customer->subscriptions->create(array($sub_args));
             $member->set_merchant_subscription_id($subscription->id);
             // subscription payments are recorded via webhook
             $paid = true;
         } catch (\Stripe\Error\Card $e) {
//.........这里部分代码省略.........
开发者ID:restrictcontentpro,项目名称:restrict-content-pro,代码行数:101,代码来源:class-rcp-payment-gateway-stripe.php


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