I am going to implement transfer and payout functional with stripe between accounts using node js. But I met one issue to implement this one.
Code:
const stripe = require('stripe')('****');
try {
cardInfo = await PayInfo.findOne({user_id: uid});
if (!cardInfo ) {
return ctx.badRequest(
null,
formatError({
id: 'PayInfo.create.findByUserId.error',
message: 'User is not available',
})
);
}
let targetId = cardInfo.account_id;
let payoutState = null;
try {
const payoutState = await stripe.transfers.create({
amount: 400,
currency: 'usd',
destination: targetId,
source_type: 'bank_account',
});
await record.create({
order_id: id,
user_id: user.id,
payment_id: payoutState.id,
transaction: 'transfer',
amount: 400,
state: payoutState.reversed ? 'failed' : 'succeeded',
});
} catch (error) {
return ctx.send(null, {
error,
payoutState,
});
}
} catch (e) {
return ctx.badRequest(
null,
{
error: e,
}
);
}
But I met this issue message from it. If I delete stripe integration part then it works well. - so wired.
{
actual: false
code: "ERR_ASSERTION"
expected: true
generatedMessage: false
operator: "=="
}
I am not sure what I was wrong, would you let me know on it please? Thanks.