Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error when I try to payout to managed account

Trying to used managed accounts for payouts. Basically a user is charged and the money is sent to the managed account instead of the platform account. I am using "sharing customers" I am using the code at the bottom of this link https://stripe.com/docs/connect/shared-customers. After retrieving the token I try to do a single charge I get an error saying "Card information not found", but I am passing the cardId when creating the token

Error: 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);
 });
});
like image 538
anonymous Avatar asked Sep 11 '16 00:09

anonymous


1 Answers

Does this work for you? The key differences here are

  1. I'm including { stripe_account: 'acct_xyz' } on the stripe.charges.create request as well as this needs to happen on the connected account itself if using Shared Customers. https://stripe.com/docs/connect/payments-fees#charging-directly

  2. Instead of token as source I'm using only the id attribute of the token object (e.g. tok_xxxyyyzzz).

Sample:

// 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);
            });
        });

Alternatively, as you said you're using Managed Accounts, you might want to consider charging through the Platform, which allows you to avoid the Shared Customers flow altogether, see here for a sample, https://stripe.com/docs/connect/payments-fees#charging-through-the-platform

like image 116
duck Avatar answered Sep 16 '22 18:09

duck