当我尝试将新客户保存到Parse时,我突然开始在设备上收到此警告。 “TypeError:无法在main.js 16:21调用undefined方法'create'(第16行以stripe.customer.create开头)
Main.js代码是:
//STRIPE
var Stripe = require("stripe")
Stripe.initialize = ("sk_test_uXXXXXXXXXT");
Parse.Cloud.define("saveSCID", function(request, response) {
Parse.Cloud.useMasterKey();
Stripe.customer.create // main.js line 16
({
source : request.params.token,
email: request.params.email,
description: request.params.description,
},
{
success : function(err, customer) {
var Usr = request.user;
var newcust = Parse.Object.extend("Customer");
var newUsr = new newcust();
newUsr.set("sCID", customer.id);
newUsr.set("parent", Usr);
var pACL = new Parse.ACL();
pACL.setPublicReadAccess(false);
pACL.setPublicWriteAccess(false);
pACL.setReadAccess(Usr, true);
pACL.setWriteAccess(Usr, true);
newUsr.set("ACL", pACL);
newUsr.save(null,
{
success : function(customer)
{
response.success("customer saved to parse = " + Usr.get("username"));
},
error : function(error)
{
response.error("Ops failed to saved customer id ");
}
});
},
error : function(customer,error)
{
response.error("Error");
}
});
});
解析日志:
E2015-09-19T01:46:04.416Z]v25 Ran cloud function saveSCID for user jKyXXXP with:
Input: {"description":"Andrew Jackson","email":"andrewXXXX@icloud.com","token":"tok_XXXXp"}
Result: TypeError: Cannot call method 'create' of undefined
at main.js:16:21
在生产版本中,我没有得到同样的错误。我仔细检查了API密钥,它们是正确的。我不知道这里可能出现什么问题:/我将不胜感激任何帮助。
答案 0 :(得分:0)
Parse删除了1.6.0版本中的云模块。您可以使用终端中项目目录中的RewriteRule ^test/([a-zA-Z0-9_-]+)(|/)$ index.php?url=test&cat=$1
恢复为1.5.0。那应该解决它。