【问题标题】:Creating a Stripe Customer Using Parse使用 Parse 创建 Stripe 客户
【发布时间】:2014-02-12 15:22:31
【问题描述】:

我正在尝试使用 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){


 });

【问题讨论】:

  • 你在使用解析云代码吗?

标签: javascript ios parse-platform


【解决方案1】:

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

解析参考: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, // 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.");
        }
    });
});

【讨论】:

  • 但是给这个用户添加一张卡片呢?我可以添加一个卡键值对吗?
猜你喜欢
  • 2016-04-17
  • 2023-01-18
  • 2015-12-26
  • 2014-11-12
  • 2014-03-30
  • 2019-03-28
  • 1970-01-01
  • 2016-11-20
  • 2022-10-19
相关资源
最近更新 更多