gpt4 book ai didi

javascript - 使用 Parse 创建 Stripe 客户

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:16:48 24 4
gpt4 key购买 nike

我正在尝试使用解析创建 strip 客户,但似乎无法从响应中获取 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){


});

最佳答案

这是一种使用解析 strip 模块 API 在解析云代码中创建新客户的方法。

解析引用:http://parse.com/docs/js/symbols/Stripe.Customers.html

确保您已存储您的发布 api key

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

关于javascript - 使用 Parse 创建 Stripe 客户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21732026/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com