Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Parse创建条带客户_Javascript_Ios_Parse Platform - Fatal编程技术网

Javascript 使用Parse创建条带客户

Javascript 使用Parse创建条带客户,javascript,ios,parse-platform,Javascript,Ios,Parse Platform,我试图使用parse创建一个条带客户,但似乎无法从响应中获取customer.id值 var newCustomer; Stripe.Customers.create( card: request.params.cardToken, email: request.params.email //These values are a success but below is where I have an issue. ).then(function(customer)

我试图使用parse创建一个条带客户,但似乎无法从响应中获取customer.id值

var newCustomer;

Stripe.Customers.create(


   card: request.params.cardToken,
   email: request.params.email
   //These values are a success but below is where I have an issue.

  ).then(function(customer){

    newCustomer = customer.id;
    //newCustomer never gets set to the id, it's always undefined. 

 }, function(error){


 });

下面是一种使用parse stripe模块api在解析云代码中创建新客户的方法

解析引用:

确保已存储发布api密钥

var Stripe = require('stripe');

Stripe.initialize('sk_test_***************');

Parse.Cloud.define("createCustomer", function(request, response) {    
    Stripe.Customers.create({
        account_balance: 0,
        email: request.params.email,
        description: 'new stripe user',
        metadata: {
            name: request.params.name,
            userId: request.params.objectId, // e.g PFUser object ID
            createWithCard: false
        }
    }, {
        success: function(httpResponse) {
            response.success(customerId); // return customerId
        },
        error: function(httpResponse) {
            console.log(httpResponse);
            response.error("Cannot create a new customer.");
        }
    });
});

你在使用解析云代码吗?但是给这个用户添加一张卡怎么样?我会添加一个卡键值对吗?