Parse.com + 云代码 + Android + Stripe [英] Parse.com + Cloud code + Android + Stripe

查看:19
本文介绍了Parse.com + 云代码 + Android + Stripe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

添加stripe作为自定义js模块解析后的我的解析云函数是-

My Parse cloud function after adding stripe as custom js module to parse is-

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);
                                           }
                                           }
                                           );
                   });

我试图将这个函数称为:

and I am trying to call this function as:

**

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());
                }
            }
        });

**

现在我的错误是:

结果:类型错误:无法在 main.js:218:37 处调用未定义的方法 'create'

Result: TypeError: Cannot call method 'create' of undefined at main.js:218:37

请帮帮我.

推荐答案

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

Since you're now using the Stripe library based on Stripe-Node instead of the Parse version, the code for the function call looks a bit different to resemble Node callback style

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);
  }
});

这篇关于Parse.com + 云代码 + Android + Stripe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆