cloud-code

Store credit card using Stripe + Parse with cloud code

不羁岁月 提交于 2019-12-04 22:58:16
I am attempting to store a users credit card into stripe. Once the token is made, I attempt to save the token with the user to Stripe as a customer. But I didnt find any answer to my problem, I just need to store a card to a user that already exist. I tried to use the method Stripe.Customers.update but it store the new card removing the "default" card if the user had one. And using the method Stripe.Customers.create it create a new customer with the new card, but I need to store in specific user. Cloud Code: Parse.Cloud.define("stripeCreateCard", function(request,response) { Stripe.initialize

Parse Server Cloud Code Setting ACL

北城以北 提交于 2019-12-04 19:18:53
I try to set the ACLs with the code below, but in my mongolab database I do not see the ACL settings. Am I doing something wrong in the code? I could not find any good tutorial for the cloud code examples. Parse.Cloud.afterSave('_User', function(req) { var user = req.user; var acl = new Parse.ACL(); acl.setReadAccess(req.user, true); acl.setWriteAccess(req.user, true); user.setACL(acl); user.save(); }); Parse.Cloud.afterSave('userSetting', function(req) { var userSet = req.object; var acl = new Parse.ACL(); acl.setReadAccess(Parse.User.current().id, true); acl.setWriteAccess(Parse.User.current

Parse-server cloud code function 'Cannot POST'

試著忘記壹切 提交于 2019-12-04 04:33:20
Most parts of my migration to open source parse-server are successful, with my data correctly stored, accessible. I am however having problems with cloud code, specifically with running simple curl tests. The initial parse-server installation includes a sample main.js file that contains a hello world function My own parse installation is hosted at '/parse' so URLs use this as the root The following is a simple request test curl -X POST \ -H "X-Parse-Application-Id: myAppId" \ -H "X-Parse-REST-API-Key:myRESTKey" \ -H "Content-Type: application/json" \ -d '{}' \ http://localhost:1337/parse/1

automatically updating data using cloud code in Parse.com

会有一股神秘感。 提交于 2019-12-03 16:36:56
I'm looking a method to automatically updating data using cloud code. Let say I have a class Table . inside of it, I have three column : firstname , lastname , and fullname . Currently, I only have firstname and lastname data only. Column fullname is still empty. Is it possible to fill the fullname automatically, by just combining the value in firstname and lastname ? Thank you, @RoyH is 100% right to maintain your computed column as new objects are created. To do an initial migration, try a cloud function, like: var _ = require("underscore"); Parse.Cloud.define("addFullnames", function

How to pass extra data down a Parse Promise chain [duplicate]

为君一笑 提交于 2019-12-03 04:27:12
问题 This question already has answers here : How do I access previous promise results in a .then() chain? (17 answers) Closed 4 years ago . In my Parse Cloude code I need to run a few successive queries, each of them using a "find()". Example: var promise = firstQuery.get(objectId).then(function(result1){ return secondQuery.find(); }).then(function(result2){ return thirdQuery.find(); }).then(function(result3) { // here I want to use "result1", "result2" and "result3" }); The question is: how do I

How to pass extra data down a Parse Promise chain [duplicate]

喜你入骨 提交于 2019-12-02 17:41:55
This question already has an answer here: How do I access previous promise results in a .then() chain? 17 answers In my Parse Cloude code I need to run a few successive queries, each of them using a "find()". Example: var promise = firstQuery.get(objectId).then(function(result1){ return secondQuery.find(); }).then(function(result2){ return thirdQuery.find(); }).then(function(result3) { // here I want to use "result1", "result2" and "result3" }); The question is: how do I access "result1" and "result2" in the final "then" statement, without assigning them to variables declared in the parent

Parse.com create stripe card token in cloud code (main.js)

安稳与你 提交于 2019-12-02 11:08:23
I am looking to create stripe token in parse cloud code.. I dont want to create token in client side HTML page. My complete web application is in HTML + Javascript so dont want to expose my Stripe.setPublishableKey('pk_test_xxxxxxx'); Because of this reason interest to define function in cloud code. Parse.Cloud.define("addCreditCard", function(request, response) { var token; var group; var Stripe = require('https://js.stripe.com/v2/'); Stripe.setPublishableKey('pk_test_xxxxxxxxx'); Stripe.card.createToken({ number : request.params.number, cvc : request.params.cvc, exp_month : request.params

How to query objects in the CloudCode beforeSave?

痴心易碎 提交于 2019-12-02 05:15:16
I'm trying to compare a new object with the original using CloudCode beforeSave function. I need to compare a field sent in the update with the existing value. The problem is that I can't fetch the object correctly. When I run the query I always get the value from the sent object. UPDATE : I tried a different approach and could get the old register ( the one already saved in parse). But the new one, sent in the request, was overridden by the old one . WHAT?! Another issue is that, even thought the code sent a response.success() , the update wasn't saved. I believe that I'm missing something

How to send Push Notifications with Parse.com Cloudcode

一世执手 提交于 2019-12-01 01:01:00
I want to send a Push Notification with Cloudcode on Parse.com. The push notification should be sent to all android devices that are subscribed to a specific channel and trigger a service. BHendricks All you need is an installation query, along with an accompanying push. For example: var pushQuery = new Parse.Query(Parse.Installation); pushQuery.containedIn("user", userlist); Parse.Push.send({ where: pushQuery, data: { alert: "Your push message here!" } }, { success: function() { response.success("pushed"); }, error: function(error) { reponse.error("didn't push"); } }); That installation query

How to send Push Notifications with Parse.com Cloudcode

别说谁变了你拦得住时间么 提交于 2019-11-30 20:06:44
问题 I want to send a Push Notification with Cloudcode on Parse.com. The push notification should be sent to all android devices that are subscribed to a specific channel and trigger a service. 回答1: All you need is an installation query, along with an accompanying push. For example: var pushQuery = new Parse.Query(Parse.Installation); pushQuery.containedIn("user", userlist); Parse.Push.send({ where: pushQuery, data: { alert: "Your push message here!" } }, { success: function() { response.success(