Ejemplo n.º 1
12
 public function charge($Token, $Amount, $Description, $Meta = array(), $Currency = 'gbp')
 {
     // Set your secret key: remember to change this to your live secret key in production
     // See your keys here https://dashboard.stripe.com/account/apikeys
     \Stripe\Stripe::setApiKey($this->config['secret_key']);
     // Create the charge on Stripe's servers - this will charge the user's card
     try {
         $charge = \Stripe\Charge::create(array("amount" => floatval($Amount) * 100, "currency" => $Currency, "source" => $Token, "description" => $Description, "metadata" => $Meta));
         return true;
     } catch (\Stripe\Error\ApiConnection $e) {
         // Network problem, perhaps try again.
         return $e;
     } catch (\Stripe\Error\InvalidRequest $e) {
         // You screwed up in your programming. Shouldn't happen!
         return $e;
     } catch (\Stripe\Error\Api $e) {
         // Stripe's servers are down!
         return $e;
     } catch (\Stripe\Error\Card $e) {
         // Card was declined.
         return $e;
     } catch (\Stripe\Error\Base $e) {
         // ?????
         return $e;
     } catch (\Stripe\Error\RateLimit $e) {
         // ?????
         return $e;
     }
     return false;
 }
Ejemplo n.º 2
2
 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");
 }
Ejemplo n.º 3
1
 public function checkout(Request $request)
 {
     \Stripe\Stripe::setApiKey('sk_test_gzviHPn6POLwymNxUXTpFhhG');
     $token = $request->input('stripeToken');
     //Retriieve cart information
     $cart = Cart::where('user_id', Auth::user()->id)->first();
     $items = $cart->cartItems;
     $total = 0;
     foreach ($items as $item) {
         $total += $item->product->price;
     }
     if (Auth::user()->charge($total * 100, ['source' => $token, 'receipt_email' => Auth::user()->email])) {
         $order = new Order();
         $order->total_paid = $total;
         $order->user_id = Auth::user()->id;
         $order->save();
         foreach ($items as $item) {
             $orderItem = new OrderItem();
             $orderItem->order_id = $order->id;
             $orderItem->product_id = $item->product->id;
             $orderItem->file_id = $item->product->file->id;
             $orderItem->save();
             CartItem::destroy($item->id);
         }
         return redirect('/order/' . $order->id);
     } else {
         return redirect('/cart');
     }
 }
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     /*
      * Load Stripe configuration
      *
      * API keys should be utilizing Laravel's "dot files" to keep them out of source
      * control and making them easily overridable on dev environments
      *
      * Read more: http://laravel.com/docs/configuration#environment-configuration
      */
     $api_key = isset($_ENV['stripe.api_key']) ? $_ENV['stripe.api_key'] : $this->app['config']->get('services.stripe')['api_key'];
     \Stripe\Stripe::setApiKey($api_key);
     // Set API Version (optional)
     $api_version = isset($_ENV['stripe.api_version']) ? $_ENV['stripe.api_version'] : $this->app['config']->get('services.stripe')['api_version'];
     if ($api_version !== null) {
         \Stripe\Stripe::setApiVersion($api_version);
     }
     $publishableKey = isset($_ENV['stripe.publishable_key']) ? $_ENV['stripe.publishable_key'] : $this->app['config']->get('services.stripe')['publishable_key'];
     /*
      * Register blade compiler for the Stripe publishable key.
      */
     $blade = $this->app['view']->getEngineResolver()->resolve('blade')->getCompiler();
     $blade->extend(function ($value, $compiler) use($publishableKey) {
         $matcher = "/(?<!\\w)(\\s*)@stripeKey/";
         return preg_replace($matcher, $publishableKey, $value);
     });
 }
Ejemplo n.º 5
1
 public function init()
 {
     $stripe_setting = Stripe::findOne(1);
     if ($stripe_setting) {
         $api_key = $stripe_setting->private_key;
         \Stripe\Stripe::setApiKey($api_key);
     }
 }
Ejemplo n.º 6
0
 public function testGetApi()
 {
     $stripe = new Stripe("key");
     $cards = $stripe->cards();
     $this->assertInstanceOf('Stripe\\Api\\Cards', $cards);
     $customers = $stripe->customers;
     $this->assertInstanceOf('Stripe\\Api\\Customers', $customers);
     $invoiceItems = $stripe->invoiceItems;
     $this->assertInstanceOf('Stripe\\Api\\InvoiceItems', $invoiceItems);
 }
 /**
  * Check stripe data.
  *
  * @access public
  * @return void
  */
 public function run()
 {
     try {
         $paymentGateway = Payment_gateways::findOneActiveBySlug('stripe');
         if ($paymentGateway->exists()) {
             \Stripe\Stripe::setApiKey($paymentGateway->getFieldValue('apiKey'));
             $subscriptions = new Subscription();
             $allSubscriptions = $subscriptions->get();
             /* @var Subscription $_subscription */
             foreach ($allSubscriptions as $_subscription) {
                 if ($_subscription->end_date <= strtotime('now')) {
                     $paymentTransaction = $_subscription->payment_transaction->get();
                     if ($paymentTransaction->system == 'stripe') {
                         $user = new User($_subscription->user_id);
                         $customer = \Stripe\Customer::retrieve($user->stripe_id);
                         $subscription = $customer->subscriptions->retrieve($paymentTransaction->payment_id);
                         if ($subscription->status == 'active') {
                             $date = new DateTime();
                             $date->setTimestamp($subscription->current_period_end);
                             $_subscription->end_date = $date->format('Y-m-d');
                             $_subscription->activate();
                             $_subscription->save();
                         }
                     }
                 }
             }
             log_message('CRON_SUCCESS', __FUNCTION__);
         } else {
             log_message('CRON_ERROR', __FUNCTION__ . ' > ' . 'No Stripe Api key.');
         }
     } catch (Exception $e) {
         log_message('CRON_ERROR', __FUNCTION__ . ' > ' . $e->getMessage());
     }
 }
Ejemplo n.º 8
0
 public function checkout($bill)
 {
     $this->load->helper('url');
     if (isset($_SESSION['id'])) {
         try {
             require_once './vendor/autoload.php';
             \Stripe\Stripe::setApiKey("sk_test_ZR7R8cxse2Nz0TFsmxTDlwey");
             //Replace with your Secret Key
             $charge = \Stripe\Charge::create(array("amount" => $bill * 100, "currency" => "EUR", "card" => $_POST['stripeToken'], "description" => "Transaction BookSmart"));
             $this->load->helper('url');
             $this->load->database();
             $ids = implode(",", $_SESSION['cart']);
             $query10 = "UPDATE Book SET buyerid='" . $_SESSION['id'] . "' WHERE id IN (" . $ids . ");";
             echo $query10;
             $this->db->query($query10);
             $data['payment'] = $bill;
             unset($_SESSION['cart']);
             $this->load->view('static_page', $data);
         } catch (Stripe_CardError $e) {
         } catch (Stripe_InvalidRequestError $e) {
         } catch (Stripe_AuthenticationError $e) {
         } catch (Stripe_ApiConnectionError $e) {
         } catch (Stripe_Error $e) {
         } catch (Exception $e) {
         }
     } else {
         $data['log'] = "<h1> You must be log to sell a book</h1>";
         $this->load->view('static_page', $data);
     }
 }
Ejemplo n.º 9
0
 function __construct($key)
 {
     $di = \Phalcon\DI::getDefault();
     $this->di = $di;
     // init stripe access
     \Stripe\Stripe::setApiKey($key);
 }
Ejemplo n.º 10
0
 /**
  * [__construct Youy need to put the configuration values in your config/config.php
  *              $config['stripe']['mode']='test';
  *              $config['stripe']['sk_test'] = 'sk_test_YOUR_KEY';
  *              $config['stripe']['pk_test'] = 'pk_test_YOUR_KEY';
  *              $config['stripe']['sk_live'] = 'sk_live_YOUR_KEY';
  *              $config['stripe']['pk_live'] = 'pk_live_YOUR_KEY';
  *              $config['stripe']['currency'] = 'usd';]
  */
 public function __construct()
 {
     $this->ci =& get_instance();
     $this->config = $this->ci->config->config['stripe'];
     $mode = $this->config['mode'];
     $this->config['secret_key'] = $this->config['sk_' . $mode];
     $this->config['publishable_key'] = $this->config['pk_' . $mode];
     try {
         // Use Stripe's bindings...
         \Stripe\Stripe::setApiKey($this->config['secret_key']);
     } catch (\Stripe\Error\Authentication $e) {
         // Authentication with Stripe's API failed
         // (maybe you changed API keys recently)
         if ($mode == 'test') {
             $body = $e->getJsonBody();
             $err = $body['error'];
             print 'Status is:' . $e->getHttpStatus() . "\n";
             print 'Type is:' . $err['type'] . "\n";
             print 'Code is:' . $err['code'] . "\n";
             // param is '' in this case
             print 'Param is:' . $err['param'] . "\n";
             print 'Message is:' . $err['message'] . "\n";
         }
     }
 }
 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();
     }
 }
Ejemplo n.º 12
0
 function charge($token, $billing_info, $cart, $user)
 {
     $data = $this->_form_data($billing_info);
     $data['amount'] = $cart['total'] * 100;
     //amount is in cents
     $data['source'] = $token;
     $data['description'] = $user['email'];
     try {
         //Set API Key
         \Stripe\Stripe::setApiKey($this->ci->config->item('test_secret_key'));
         $charge = \Stripe\Charge::create($data);
         return $charge;
     } catch (\Stripe\Error\Card $e) {
         return $e->getJsonBody();
     } catch (\Stripe\Error\InvalidRequest $e) {
         return $e->getJsonBody();
     } catch (\Stripe\Error\ApiConnection $e) {
         return $e->getJsonBody();
     } catch (\Stripe\Error\Api $e) {
         return $e->getJsonBody();
     } catch (\Stripe\Error\Authentication $e) {
         return $e->getJsonBody();
     } catch (\Stripe\Error\Base $e) {
         return $e->getJsonBody();
     }
 }
Ejemplo n.º 13
0
 protected function chargeCustomer()
 {
     if ($this->isPostBack() && !$this->input('mark_payed')) {
         $this->post->amount->addValidation([new ValidateInputNotNullOrEmpty(), new ValidateInputFloat()]);
         if (!$this->hasErrors()) {
             $amount = (double) $this->input('amount') * 100;
             try {
                 Stripe::setApiKey(env('STRIPE_KEY'));
                 $stripe = Charge::create(['customer' => $this->organisation->stripe_identifier_id, 'amount' => $amount, 'currency' => $this->settings->getCurrency(), 'description' => 'NinjaImg ' . date('m-Y', strtotime($this->startDate)) . '-' . date('m-Y', strtotime($this->endDate))]);
                 if (!isset($stripe->paid) || !$stripe->paid) {
                     $this->setError('Failed to charge credit-card');
                 }
                 if (!$this->hasErrors()) {
                     $payment = new ModelPayment();
                     $payment->amount = $amount;
                     $payment->currency = $this->settings->getCurrency();
                     $payment->period_start = $this->startDate;
                     $payment->period_end = $this->endDate;
                     $payment->transaction_id = $stripe->id;
                     $payment->organisation_id = $this->organisation->id;
                     $payment->save();
                 }
             } catch (\Exception $e) {
                 $this->setError($e->getMessage());
             }
             if (!$this->hasErrors()) {
                 $this->organisation->getPayment($this->startDate, $this->endDate)->updateFreeCredits();
                 $this->setMessage('Successfully charged ' . $this->input('amount') . ' ' . $this->settings->getCurrency(), 'success');
             }
             response()->refresh();
         }
     }
 }
Ejemplo n.º 14
0
 public function check($bid)
 {
     $bid = Bids::findOrFail(Input::get("bid"));
     $offset = Input::get("offset");
     if ($offset < 0) {
         $now = \Carbon\Carbon::now()->subHours($offset);
     } else {
         $now = \Carbon\Carbon::now()->addHours($offset);
     }
     if (strtotime($bid->expiration) - strtotime($now) < 0) {
         //bid is expired
         if ($bid->amount < $bid->reservedPrice) {
             //void since bidding price is less then reserved price
             $bid->delete();
             return "Bidding price less then reserved price";
         } else {
             //proceed and Charge
             //since we get information about expiration from client we have to check it on the server as well
             //check wether winning user has its card working
             if ($bid->customerId) {
                 \Stripe\Stripe::setApiKey("sk_test_Z98H9hmuZWjFWfbkPFvrJMgk");
                 \Stripe\Charge::create(array("amount" => $bid->priceToCents(), "currency" => "usd", "customer" => $bid->customerId));
                 \Log::info('Charged: ' . $bid->amount);
             }
             $bid->complete = 1;
             $bid->save();
             $bid->delete();
         }
     } else {
         //someone is messing with javascript
         return "error";
     }
     return "Bidding is valid";
 }
Ejemplo n.º 15
0
 /**
  * @param \Enlight_Controller_ActionEventArgs $args
  */
 public function onPostDispatchCheckout($args)
 {
     $action = $args->getSubject();
     $request = $action->Request();
     $view = $action->View();
     $apiKey = $this->bootstrap->Config()->get('stripeSecretKey');
     \Stripe\Stripe::setApiKey($apiKey);
     $token = $request->getPost('stripeToken');
     if (!empty($token)) {
         try {
             $this->onStripeToken($request);
         } catch (\Stripe\Error\Card $e) {
             $eJson = $e->getJsonBody();
             $error = $eJson['error'];
             $view->assign('sErrorMessages', [$error['message']]);
             if ($request->getControllerName() == 'checkout') {
                 $action->forward('shippingPayment');
             } else {
                 $action->forward('payment');
             }
             $request->setPost('stripeToken', null);
             $action->Response()->clearHeader('Location')->setHttpResponseCode(200);
             return;
         }
     }
     if (!empty($view->sPayments) && !empty($view->sUserData['additional']['user']['viisonStripeCustomerId'])) {
         $customerId = $view->sUserData['additional']['user']['viisonStripeCustomerId'];
         $customer = \Stripe\Customer::retrieve($customerId);
         $view->stripeSources = $this->convertCards($customer['sources']['data']);
     }
 }
 /**
  * Check stripe data.
  *
  * @access public
  * @return void
  */
 public function run()
 {
     $paymentGateway = Payment_gateways::findOneActiveBySlug('stripe');
     if ($paymentGateway->exists()) {
         \Stripe\Stripe::setApiKey($paymentGateway->getFieldValue('apiKey'));
         $subscriptions = new Subscription();
         $allSubscriptions = $subscriptions->where('status', Subscription::STATUS_ACTIVE)->get();
         /* @var Subscription $_subscription */
         foreach ($allSubscriptions as $_subscription) {
             $end = DateTime::createFromFormat('Y-m-d', $_subscription->end_date);
             if ($end->getTimestamp() > strtotime('now')) {
                 $paymentTransaction = $_subscription->payment_transaction->get();
                 if ($paymentTransaction->system == 'stripe') {
                     $user = new User($_subscription->user_id);
                     try {
                         $customer = \Stripe\Customer::retrieve($user->stripe_id);
                         $subscription = $customer->subscriptions->retrieve($paymentTransaction->payment_id);
                     } catch (Exception $e) {
                         log_message('CRON_ERROR', __FUNCTION__ . ' > ' . $e->getMessage());
                     }
                     if (!isset($subscription) || $subscription->status != 'active') {
                         $_subscription->deactivate();
                         $_subscription->save();
                     }
                 }
             }
         }
         log_message('CRON_SUCCESS', __FUNCTION__);
     }
 }
 public function init($file)
 {
     if (!loggedIn()) {
         return false;
     }
     if (!is_a($file, "SocialApparatus\\File")) {
         return false;
     }
     $product = getEntity($file->container_guid);
     if (!is_a($product, "SocialApparatus\\Product")) {
         return false;
     }
     $user = getLoggedInUser();
     if ($user->stripe_cust) {
         \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey());
         $orders = \Stripe\Order::all(array("limit" => 300, "customer" => $user->stripe_cust));
         foreach ($orders['data'] as $order) {
             foreach ($order->items as $item) {
                 if ($item->description != "Taxes (included)" && $item->description != "Free shipping") {
                     $sku = $item->parent;
                     if ($sku == $product->stripe_sku) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
Ejemplo n.º 18
0
 public function completeDonation()
 {
     // Validate amount
     $amount = $this->request->data('amount');
     if (!is_numeric($amount)) {
         throw new ForbiddenException('Donation amount must be numeric');
     } elseif ($amount < 1) {
         throw new ForbiddenException('Donation must be at least one dollar');
     }
     $metadata = [];
     if ($this->Auth->user('id')) {
         $metadata['Donor name'] = $this->Auth->user('name');
     } else {
         $metadata['Donor name'] = '';
     }
     $metadata['Donor email'] = $this->request->data('email');
     // Create the charge on Stripe's servers - this will charge the user's card
     $apiKey = Configure::read('Stripe.Secret');
     \Stripe\Stripe::setApiKey($apiKey);
     try {
         $description = 'Donation to MACC of $' . number_format($amount, 2);
         $charge = \Stripe\Charge::create(['amount' => $amount * 100, 'currency' => 'usd', 'source' => $this->request->data('stripeToken'), 'description' => $description, 'metadata' => $metadata, 'receipt_email' => $this->request->data('email')]);
     } catch (\Stripe\Error\Card $e) {
         throw new ForbiddenException('The provided credit card has been declined');
     }
     $this->viewBuilder()->layout('json');
     $this->set(['_serialize' => ['retval'], 'retval' => ['success' => true]]);
 }
 public function processPreLaunchPayment(Request $request)
 {
     $secret_key = config('seathero.stripe.secret_key');
     Stripe::setApiKey($secret_key);
     $this->oneTimePayment($request->stripeToken, config('seathero.stripe.pre_launch_sign_up_price'));
     return view('thanks');
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $product = getEntity($guid);
     \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey());
     if ($product->interval != "one_time") {
         try {
             $plan = \Stripe\Plan::retrieve($guid);
             $plan->delete();
         } catch (Exception $e) {
             forward();
         }
     } else {
         if ($product->stripe_sku) {
             $sku = \Stripe\SKU::retrieve($product->stripe_sku);
             $sku->delete();
         }
         if ($product->stripe_product_id) {
             $stripe_product = \Stripe\Product::retrieve($product->stripe_product_id);
             $stripe_product->delete();
         }
     }
     $product->delete();
     new SystemMessage("Your product has been deleted.");
     forward("store");
 }
 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");
 }
Ejemplo n.º 22
0
 /**
  * Create a new Stripe gateway instance.
  *
  * @param null $connection
  */
 public function __construct($connection = null)
 {
     if (null === $connection) {
         $connection = Config::get('billing.gateways.stripe');
     }
     $this->connection = $connection;
     Stripe::setApiKey($connection['secret']);
 }
Ejemplo n.º 23
0
 /**
  * Set the Stripe library
  *
  * @param $key
  *
  * @since 1.0.0
  */
 public function __construct($key)
 {
     if (!class_exists('Stripe')) {
         include_once dirname(dirname(__FILE__)) . '/vendor/autoload.php';
     }
     $this->private_key = $key;
     Stripe::setApiKey($this->private_key);
 }
Ejemplo n.º 24
0
 /**
  * Authenticate Stripe API client.
  */
 public function authenticate()
 {
     if ($this->isAuthenticated) {
         return;
     }
     Stripe::setApiKey($this->secretKey);
     $this->isAuthenticated = true;
 }
Ejemplo n.º 25
0
 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');
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     if (config('stripe.live') === true) {
         Stripe::setApiKey(config('stripe.secret_key'));
     } else {
         Stripe::setApiKey(config('stripe.test_secret_key'));
     }
 }
Ejemplo n.º 27
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     \Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
     $account = \Stripe\Account::create(array("managed" => true, "country" => "US", "email" => $data['email'], "legal_entity" => ["dob" => ["day" => $data['dob_day'], "month" => $data['dob_month'], "year" => $data['dob_year']], "first_name" => $data['first_name'], "last_name" => $data['last_name'], "type" => "individual", "ssn_last_4" => $data['last_4'], "address" => ["city" => $data['address_city'], "country" => "US", "line1" => $data['address_line1'], "line2" => $data['address_line2'], "postal_code" => $data['address_zip'], "state" => $data['address_state']]], "tos_acceptance" => ["date" => time(), "ip" => $_SERVER['REMOTE_ADDR']], "external_account" => $data['stripe_token']));
     $user = User::create(['name' => $data['first_name'] . ' ' . $data['last_name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'api_token' => str_random(60), 'slug' => str_random(10)]);
     $stripeAccount = \App\StripeAccount::Create(['user_id' => $user->id, 'stripe_id' => $account->id]);
     return $user;
 }
Ejemplo n.º 28
0
 public function __construct(DatabaseManager $db, TransactionRepositoryInterface $ledger)
 {
     // DI Member Assignment
     $this->db = $db;
     $this->ledger = $ledger;
     // Set Stripe API Key
     Stripe::setApiKey(env('STRIPE_SECRET_KEY'));
 }
Ejemplo n.º 29
0
 /**
  * @param $apiKey
  */
 function setApiKey($apiKey)
 {
     if (self::$testMode) {
         StripeMock::setApiKey($apiKey);
     } else {
         StripeAPI::setApiKey($apiKey);
     }
 }
Ejemplo n.º 30
-1
 public function createCharge()
 {
     Stripe::setApiKey($this->stripeConfig['testSecretKey']);
     $stripeCharge = StripeCharge::create(['amount' => 2000, 'currency' => 'usd', 'card' => 'tok_16ZzIaH7PksWTbQLK6AvzuVR', 'description' => 'Describe your product']);
     echo '<pre>';
     print_r($stripeCharge);
     echo '</pre>';
 }