2016-09-11 16 views
5

Cố gắng sử dụng tài khoản được quản lý cho các khoản thanh toán. Về cơ bản người dùng bị tính phí và tiền được gửi đến tài khoản được quản lý thay vì tài khoản nền tảng. Tôi đang sử dụng "chia sẻ khách hàng" Tôi đang sử dụng mã ở cuối liên kết này https://stripe.com/docs/connect/shared-customers. Sau khi lấy token tôi cố gắng làm một lần sạc duy nhất tôi nhận được một lỗi nói rằng "không tìm thấy thông tin thẻ", nhưng tôi đi qua các cardId khi tạo tokenGặp lỗi khi tôi cố gắng thanh toán cho tài khoản được quản lý

Lỗi: message: "Could not find payment information"

Stripe.tokens.create(
{ customer: request.params.customerId, card: request.params.cardId }, 
{ stripe_account: 'acct_xyz' }, // id of the connected account 
    function(err, token) { 

    Stripe.charges.create(
{ 
amount: 1000, // amount in cents 
currency: "usd", 
source: token, 
description: "Example charge", 
application_fee: 123 // amount in cents 
}, 
function(err, charge) { 
console.log(err); 
}); 
}); 

Trả lời

5

Liệu công việc này cho bạn? Sự khác biệt quan trọng ở đây là

  1. tôi bao gồm { stripe_account: 'acct_xyz' } theo yêu cầu stripe.charges.create cũng như này cần phải xảy ra trên tài khoản kết nối riêng của mình nếu sử dụng khách hàng đã chia sẻ. https://stripe.com/docs/connect/payments-fees#charging-directly

  2. Thay vì token như source Tôi đang sử dụng chỉ có id thuộc tính của đối tượng token (ví dụ tok_xxxyyyzzz).

mẫu:

// id of connected account you want to create customer on, charge 
var connectedAccountId = "acct_16MNx0I5dd9AuSl3"; 

// id of customer and card you want to create a token from 

var platformCustomerId = "cus_8vEdBa4rQTGond"; 
var platformCustomerCardId = "card_18dOAcFwTuOiiF4uwtDe2Nip"; 

var stripe = require("stripe")(
    "sk_test_xxxyyyyzzz" 
); 

    // create a token using a customer and card on the Platform account 
    stripe.tokens.create(
     {customer: platformCustomerId, card: platformCustomerCardId }, 
     {stripe_account: connectedAccountId}, 
     function(err, token) { 
     if (err) 
      throw (err); 

      stripe.charges.create({ 
       amount: 4444, 
       currency: "usd", 
       source: token.id, 
       description: "Charge on a connected account", 
       application_fee: 1111 
      }, 
      {stripe_account: connectedAccountId}, 
      function(err, charge) { 
       if (err) 
       throw (err); 
       console.log(charge); 
      }); 
     }); 

Ngoài ra, như bạn nói bạn đang sử dụng tài khoản được quản lý, bạn có thể muốn xem xét việc sạc thông qua Cương lĩnh, cho phép bạn để tránh những khách hàng chung chảy hoàn toàn, xem ở đây để lấy mẫu, https://stripe.com/docs/connect/payments-fees#charging-through-the-platform

+1

Id là điều đã làm cho tôi. Cảm ơn bạn đời :) –

Các vấn đề liên quan