簡體   English   中英

使用Parse創建Stripe客戶

[英]Creating a Stripe Customer Using 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){


 });

這是一種使用解析條帶模塊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.");
        }
    });
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM