我在Cloud Code上设置了这个函数,有时会被调用两次,尽管我打算让它运行一次。它通过Swift函数调用。
Cloud Code
Parse.Cloud.define("customer", function(request, response) {
var user = request.user;
stripe.customers.create({ email: request.params.useremail }).then(function(customer) {
user.set("cusToken", customer.id);
return user.save(null, { useMasterKey: true });
}).then(function(result) {
console.log("Customer created");
}, function(err) {
console.log(err);
response.error(err);
});
});
夫特
PFCloud.callFunctionInBackground("customer", withParameters: ["useremail": self.userEmailAdressTextField.text ?? ""], block: { (success: AnyObject?, error: NSError?) -> Void in
})