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:
, :
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, . . .