コード例 #1
0
 /**
  * Empty string prefix if current locale is the primary
  * @param $locale
  * @return string
  */
 public static function localePrefix($locale = '')
 {
     if (!$locale) {
         $locale = App::getLocale();
     }
     return $locale == ClientHelper::getClientInfo()->primary_language->language_code ? '' : $locale . '.';
 }
コード例 #2
0
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     $this->loadViewsFrom(__DIR__ . '/../../resources/views', 'vendirun');
     // use artisan vendor:publish to copy views to standard view folder
     // commented out since generally we don't want to publish all the views
     /*$this->publishes([
     			__DIR__.'/../../resources/views' => base_path('resources/views/vendor/vendirun'),
     		]);*/
     // use artisan vendor:publish to copy config
     $this->publishes([__DIR__ . '/../../config/vendirun.php' => config_path('vendirun.php')]);
     // use artisan vendor:publish to copy public assets
     // use artisan vendor:publish --tag=public --force   to force overwrite of assets tagged as "public"
     $this->publishes([__DIR__ . '/../../public' => public_path('vendor/vendirun')], 'public');
     // this publishes the error views
     $this->publishes([__DIR__ . '/../../resources/views/errors' => base_path('resources/views/errors')], 'public');
     // include my package custom routes
     include __DIR__ . '/../../routes.php';
     // load translation files
     $this->loadTranslationsFrom(__DIR__ . '/../../resources/lang', 'vendirun');
     $clientInfo = ClientHelper::getClientInfo();
     if ($clientInfo->business_settings->tax->price_includes_tax) {
         $this->app->bind(CartValuesTransformer::class, CartValuesVATIncludedTransformer::class);
         $this->app->bind(CartItemValuesTransformer::class, CartItemValuesVATIncludedTransformer::class);
     } else {
         $this->app->bind(CartValuesTransformer::class, CartValuesVATExcludedTransformer::class);
         $this->app->bind(CartItemValuesTransformer::class, CartItemValuesVATExcludedTransformer::class);
     }
     $this->app->bind(CartRepository::class, function () {
         $clientInfo = ClientHelper::getClientInfo();
         $transformer = $clientInfo->business_settings->tax->price_includes_tax ? new CartValuesVATExcludedTransformer() : new CartValuesVATIncludedTransformer();
         return new ApiCartRepository($transformer);
     });
 }
コード例 #3
0
 public function __construct()
 {
     if ($this->primaryPages) {
         $this->setPrimaryPath();
     }
     // set public client information to the config so we have access to it everywhere
     $clientInfo = ClientHelper::getClientInfo();
     Config::set('clientInfo', $clientInfo);
 }
コード例 #4
0
 /**
  * @throws CardDeclinedException
  * @throws UnknownErrorException
  */
 public function takePayment()
 {
     $settings = ClientHelper::getPaymentGatewayInfo('stripe');
     $clientInfo = ClientHelper::getClientInfo();
     Stripe::setApiKey($settings->sandbox_mode ? $settings->test_secret : $settings->secret);
     // Create the charge on Stripe's servers - this will charge the user's card
     try {
         $charge = Charge::create(array("amount" => $this->order->getTotalPrice(), "currency" => $clientInfo->currency->currency_iso, "source" => $this->stripeToken, "description" => $clientInfo->name, "metadata" => ["order_id" => $this->order->getId()]));
         $payment = new Payment($this->order->getTotalPrice(), date("Y-m-d"), 'stripe', $charge->getLastResponse()->body);
         $this->order->addPayment($payment);
         $this->orderRepository->save($this->order);
     } catch (Card $e) {
         throw new CardDeclinedException();
     } catch (\Exception $e) {
         dd($e);
         throw new UnknownErrorException($e->getMessage());
     }
 }
コード例 #5
0
 public function checkout(View $view)
 {
     $paymentGateways = ClientHelper::getPaymentGatewayInfo();
     $view->with('paymentGateways', $paymentGateways);
 }
コード例 #6
0
 private function setApiContext()
 {
     $settings = ClientHelper::getPaymentGatewayInfo('paypal');
     $client_id = $settings->sandbox_mode ? $settings->test_client_id : $settings->client_id;
     $secret = $settings->sandbox_mode ? $settings->test_secret : $settings->secret;
     $this->apiContext = new ApiContext(new OAuthTokenCredential($client_id, $secret));
     $this->apiContext->setConfig(['mode' => $settings->sandbox_mode ? 'sandbox' : 'live', 'log.FileName' => './storage/logs/paypal.log', 'log.LogLevel' => $settings->sandbox_mode ? 'DEBUG' : 'INFO', 'cache.enabled' => false]);
 }