【问题标题】:Parse.com + Cloud code + Android + StripeParse.com + 云代码 + Android + Stripe
【发布时间】:2016-05-04 03:17:11
【问题描述】:

添加条带作为自定义js模块解析后的我的Parse云功能是-

main.js

Parse.Cloud.define("createCustomer", function(request, response) {
             //      var Stripe = require("stripe");
                var Stripe = require("cloud/stripe.js")(kStripePrivateKey);
               //    Stripe.initialize(kStripePrivateKey);
                   Stripe.Customers.create(
                                           {
                                           description : request.params.description
                                           },
                                           {
                                           success: function(httpResponse)
                                           {
                                           console.log(httpResponse);
                                           response.success(httpResponse);
                                           },
                                           error: function(httpResponse)
                                           {
                                           console.log(httpResponse.message);
                                           response.error(httpResponse.message);
                                           }
                                           }
                                           );
                   });

我试图将此函数称为:

**

mCustomerUserName = ParseUser.getCurrentUser().getUsername();

        HashMap<String, Object> params = new HashMap<String, Object>();

        params.put("description",mCustomerUserName);
        ParseCloud.callFunctionInBackground("createCustomer", params, new FunctionCallback<Object>() {
            @Override
            public void done(Object object, ParseException e) {
                if (e == null) {
                    Log.e("SUCCESS CREATE CUSTOMER", "" + object.toString());
                } else {
                    e.printStackTrace();
                    Log.e("", "" + e.getCode() + "/" + e.getMessage());
                }
            }
        });

**

现在我的错误是:

结果:TypeError:无法在 main.js:218:37 调用未定义的方法“创建”

请帮帮我。

【问题讨论】:

  • 需要注意的一点是 Parse 不再支持他们的 Stripe 库。我建议使用基于最新版本的 Stripe Node.js 模块的github.com/matthewarkin/stripe-parse
  • 有什么办法可以在解析云上使用stripe的旧版本?
  • 旧版本不是 Stripe 的,它是 4 年前通过 parse 构建的。他们从中删除了支持和文档,这使得调试有点困难。有人说降级他们的云代码版本已经解决了问题。
  • @MatthewArkin 我使用了您的 gitHub 链接并将“stripe.js”文件导入我的云文件夹。我改变了行 var Stripe = require("stripe");到 var Stripe = require("cloud/stripe.js")(kStripePrivateKey);并评论了这两行 var Stripe = require("stripe");和 Stripe.initialize(kStripePrivateKey);现在我得到错误结果:TypeError: Cannot call method 'create' of undefined at main.js:218:37
  • @MatthewArkin 在这里我不确定我是否应该评论行“Stripe.initialize(kStripePrivateKey);”

标签: javascript android parse-platform stripe-payments


【解决方案1】:

由于您现在使用的是基于 Stripe-Node 的 Stripe 库而不是 Parse 版本,因此函数调用的代码看起来有点不同,类似于 Node 回调样式

stripe.customers.create({
  description: request.params.description,
}, function(err, customer) {
  if(err){
    console.log(err);
    response.error(err);
  }
  else{
    console.log(customer);
    response.success(customer);
  }
});

【讨论】:

  • 好的。我将尝试实现条带节点版本代码,然后回复您。谢谢你的帮助。真的很感激。
猜你喜欢
  • 2015-08-08
  • 1970-01-01
  • 2014-08-31
  • 2014-11-23
  • 2016-02-08
  • 2016-02-24
  • 2013-06-23
  • 2015-04-14
  • 1970-01-01
相关资源
最近更新 更多