【问题标题】:stripe params using javascript使用 javascript 条带化参数
【发布时间】:2014-09-21 19:05:23
【问题描述】:

我将 Stripe 与 Parse Cloud Code 结合使用。

我可以传递令牌 ID 和客户电子邮件,但我也需要他们的姓名。 Stripe 没有任何直接的 JS 文档,因此很难理解。如何传递名称?

这是我的客户端代码:

  Parse.Cloud.run('createCustomer',{
        token: token.id,
        email: token.email,
    }, {
        // Success handler
            success: function(message) {
                alert('Success: ' + message);
            },
            // Error handler
            error: function(message) {
                alert('Error: ' + message);
            }
    })

和后端云代码:

Parse.Cloud.define("createCustomer", function(request, response) {   
console.log(request.params) 
    Stripe.Customers.create({
        account_balance: 0,
        email: request.params.email,
        description: "stripe customer",
        metadata: {

            userId: request.params.objectId, // e.g PFUser object ID
            createWithCard: true
        }

    }, {
        success: function(httpResponse) {
            response.success(name + userId); // return customerId

        },
        error: function(httpResponse) {
            console.log(httpResponse");
            response.error("Cannot create a new customer.");
        }
    });
});

【问题讨论】:

    标签: javascript parse-platform stripe-payments


    【解决方案1】:

    这对我有用。是的,这方面的文档很少。 :)

    Parse.Cloud.define("createCustomer", function(request, response) {    
    
    Stripe.Customers.create({
        card: request.params.cardToken, // the token id should be sent from the client
        // account_balance: 0,
        email: request.params.email,
        description: 'new stripe user',
        metadata: {
            name: request.params.name
        }
    }, 
    {
        success: function(httpResponse) {
            response.success(httpResponse); // return customerId
        },
        error: function(httpResponse) {
            console.log(httpResponse);
            response.error(httpResponse);
        }
     });
    });
    

    【讨论】:

    • 我们可以创建一个解析用户对象的客户吗?如果我设置 userId,则元信息对查询不是很有用。条带客户检索需要 customerid
    猜你喜欢
    • 1970-01-01
    • 2011-10-11
    • 1970-01-01
    • 2021-02-05
    • 2019-12-01
    • 1970-01-01
    • 2016-11-26
    • 2018-04-23
    • 1970-01-01
    相关资源
    最近更新 更多