6/2/2015 - 12:40 AM

Parse.com + Stripe.com API Workaround

Parse.com + Stripe.com API Workaround

Seems that parse.com has either neutered a portion of the their stripe.com integration, just decided it is not needed. The docs seem to point to the Stripe.Customers.update(id, token) as the way to add a card (using a token) to a customers account. This works, but only allows a single card. This overwrites the initial card with the new card. Not great. 

// This should work, but only allows a single card.
Stripe.Customers.update(customer, { card: found.get('token') },
  function(err, token) {
    console.log('got here for token');

// This works, and seems to point to the need for parse.com to add some work to their backlog. Looks
// like it has been left open or undocumented for a least a year.

    url: "https://" + STRIPE_SECRET_KEY + ':@' + STRIPE_API_BASE_URL + "/customers/" + customer + "/cards",
    body: "card="+ found.get('token'),
    success: function(httpResponse) {
      console.log('All Done with update')
    error: function(httpResponse) {
      console.log('Failure in the HTTP request to Stripe.');

Remember to create your token on the client. This allows for the Stripe.Tokens.Create(). Store the token on in the parse class, and then use the hook after save to push the token to stripe.