I'm trying to implement Stripe payments. I've been...
# prisma-whats-new
s
I'm trying to implement Stripe payments. I've been following the tutorial here: https://www.graph.cool/docs/tutorials/stripe-payments-with-mutation-callbacks-using-micro-and-now-soiyaquah7/, but adapting it for the new Server-side subscriptions. I've got it half working, and customers are being correctly created in Stripe, but no update is being performed on the user (updating the stripeId field). Wondering what I'm wrong there. I'm using pretty much the same code as in the tutorial:
Copy code
stripe.customers.create({
    email: user.email,
    description: user.name,
    source: cardDetails.cardToken
  }, (err, customer) => {
    if (err) {
      console.log(err)
      send(res, 400, { error: `Stripe customer with card details ${cardDetailsId} could not be created for user ${userId}` })
    } else {
      // then update user with obtained Stripe customer id
      const updateUser = `mutation {
        updateUser(id: "${userId}", stripeId: "${customer.id}") {
          id
        }
      }`
      <http://request.post|request.post>({
        url: endpoint,
        headers: {
          'Authorization' : graphcoolToken,
          'content-type': 'application/json',
        },
        body: JSON.stringify({query: updateUser}),
      }).on('error', (e) => {
        send(res, 400, { error: `User ${userId} could not be updated` })
      }).on('response', (response) => {
        send(res, 200, { message: `User ${userId} was successfully registered at Stripe` })
      })
    }
  }
)
I set the
endpoint
to my Graphcool simple API endpoint and
graphcoolToken
to a permanent auth token that I generated. I also have the update permission on users fully open for now.