Parse.com +云代码+ Android + Stripe

时间:2016-01-27 09:02:01

标签: javascript android parse-platform stripe-payments

在将条带作为自定义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上调用undefined方法'create':218:37

请帮帮我。

1 个答案:

答案 0 :(得分:1)

由于您现在使用的是基于Stripe-Node而不是Parse版本的Stripe库,因此函数调用的代码看起来有点不同,类似于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);
  }
});