使用Parse创build条带客户

我试图创build一个条纹客户使用parsing,但似乎无法得到响应的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){ }); 

以下是使用parsing条带模块API来parsing云代码的新客户的一种方法。

parsing参考: http : //parse.com/docs/js/symbols/Stripe.Customers.html

确保你已经存储了你的发布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, // eg 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."); } }); });