0

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.

  • The code you provided looks correct. Are you sure this error isn't coming from another line of code? Can you provide more of the code involved, as well as details about where you're seeing that error? – Justin Michael Dec 19 '20 at 00:06
  • This error occurs on strapi CMS. and updated post. –  Dec 19 '20 at 08:23
  • Sorry, I'm still not seeing anything that might cause the error. It looks like Strapi is concealing the real error details. Can you add more `try`/`catch` blocks around more code in an attempt to reveal more details? – Justin Michael Dec 19 '20 at 18:44

0 Answers0