How to use the stripe.Customers function in stripe

To help you get started, we’ve selected a few stripe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github green-bot / greenbot-core / kisst / cloud / app.js View on Github external
app.post('/billing', function (req, res) {
  var req_data = req.body
  console.log('Entered billing function -> ' + req_data.type)
  console.log(req_data)
  Stripe.initialize('sk_live_CDYuW7Nsp4dtyKXT7ifjZ47q')

  if (req_data.type === 'customer.subscription.created') {
    // First things first, get the customer record.
    Stripe.Customers.retrieve(req_data.data.object.customer, {
      success: function (customer) {
        // OK, got the customer and the subscription.
        console.log('customer.subscription.created')
        var Room = Parse.Object.extend('Room')
        var room = new Room()
        var notification_emails = [customer.email]
        room.set('notification_emails', notification_emails)
        var owners = [customer.metadata.owner_cell]
        room.set('owners', owners)
        room.set('owner_cmd', 'ruby owner_settings.rb')
        room.set('desc', customer.email)
        room.set('default_cmd', 'ruby default.rb')
        room.set('default_path', 'scripts')
        room.set('stripe_sub_id', req_data.data.object.id)
        room.set('stripe_cust_id', customer.id)
        room.set('settings', {})
github green-bot / greenbot-core / kisst / cloud / app.js View on Github external
app.post('/new_order', function (req, res) {
  console.log('Entered new_order function ')
  console.log(req.body)
  var token_info = req.body

  Stripe.initialize('sk_live_CDYuW7Nsp4dtyKXT7ifjZ47q')
  Stripe.Customers.create({
    source: token_info.id,
    plan: token_info.plan_id,
    email: token_info.email,
    metadata: {
      owner_cell: token_info.owner_cell
    }
  }, {
    success: function (httpResponse) {
      console.log('Subscription successfully performed')
      res.send('Success')
    },
    error: function (httpResponse) {
      console.log(JSON.stringify(httpResponse.body, null, 4))
      res.send('Uh oh, something went wrong')
    }
  })