Using Stripe Connect with a node strip to pay for a joint customer

I am trying to land on the correct syntax to charge the client in favor of a connected user using Stripe Connect. I am using stripe-node api. I tried what seems like a hundred combinations of parameters to create a charge and no one will work for me.

The client I want to charge has already been added as a client to my Stripe account (Connect app application), and the user I want to receive the fee is already connected to my application. Everything went well. After completing these steps, I get a token for a new charge, which also seems beautiful. I'm calling:

Stripe.tokens.create(
  { customer: myCustomer },
  connectedUserAccessToken,
  function(error, token){
    if (error){
      return error;
    } else {
      return token;
    }
  }
);

What returns:

{ id: 'tok_15L16gLFEmuXszazTaVUA0ty',
livemode: false,
created: 1421280206,
used: false,
object: 'token',
type: 'card',
card:
  { id: 'card_15L16gLFEmuXszaz7VAu2ciH',
  object: 'card',
  last4: '8210',
  brand: 'MasterCard',
  funding: 'debit',
  exp_month: 1,
  exp_year: 2020,
  fingerprint: 'ny39g9uj2lfhYA2H',
  country: 'US',
  name: null,
  address_line1: null,
  address_line2: null,
  address_city: 'New York',
  address_state: 'NY',
  address_zip: '10003',
  address_country: 'US',
  cvc_check: null,
  address_line1_check: null,
  address_zip_check: null,
  dynamic_last4: null,
  customer: null },
  client_ip: '99.99.9.99'
}

(These cards are fake on the Stripe test page).

, . var :

Stripe.charges.create(
  { card: token.id },
  function(error, result){
    if (error){
      return error;
    } else {
      return result;
    }
  }
);

:

[ Error: There is no token with ID tok_15L16gLFEmuXszazTaVUA0ty. ]

, , , , . ( , , Stripe, ).

{ card: token.id } Stripe.charges.create() :

Stripe.charges.create(
  token,
  function(error, result){}
);

:

[Error: [Error: Missing required param: currency]

, . , :

Stripe.charges.create(
  { currency: user.currency, amount: transaction.amount },
  token,
  function(error, result){}
);

:

[Error: Stripe: Unknown arguments ([object Object]). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.]

, :

Stripe.charges.create(
  token,
  { currency: user.currency, amount: transaction.amount },
  function(error, result){}
);

, , , .

:

Stripe.charges.create(
  { customer: token.id, currency: user.currency, amount: transaction.amount },
  function(error. result){}
);

:

[Error: No such customer: tok_15L16gLFEmuXszazTaVUA0ty]

token.currency = user.currency Stripe.charges.create(token). , , :

[Error: Missing required param: amount]

token.currency = user.currency; token.amount = transaction.amount;, , :

[Error: Received unknown parameters: id, livemode, created, used, object, type, client_ip]

, .

, , https://github.com/stripe/stripe-node/wiki/Using-Stripe-Connect-with-node.js, . . .

+4
2

, publishable_key, , access_token. , , :

// Get the credit card details submitted by the form
var token = request.body.stripeToken;

// Create the charge on Stripe servers - this will charge the user card
stripe.charges.create(
  {
    amount: 1000, // amount in cents
    currency: "eur",
    card: token,
    description: "payinguser@example.com",
    application_fee: 123 // amount in cents
  },
  ACCESS_TOKEN, // user access token from the Stripe Connect flow
  function(err, charge) {
    // check for `err`
    // do something with `charge`
  }
);
+2

, ....

 var stripe = require("stripe")("<STRIPE SECRET KEY>");
 // var stripe = require("stripe")("sk_test_**********");
 stripe.charges.create({
    amount: <AMOUNT>,
    currency: "<CURRENCY>", // EUR
    source: "<CARD ID>", // card_1233442FFHDJSDFJM
    customer:"<CUSTOMER ID>",// cus_E06YG6h0DFDFSDF
    description: "<DESCRIPTION>" // CHARGE FOR ORDER #8487
 },function(err, charge) {
    if(err)
      console.log('ERROR : '+err);
    else
      console.log('charge : '+JSON.stringify(charge,null,2));
 });
0

All Articles