當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。