Integrating stripe, nothing new to the dashboard

Hello,

i come back here because i want to use the integration with Stripe that could be great and have been reading this Stripe - Developer guide

I have added the stripe secret key, and added integration in the forest-admin.js.
I actually had to run npm install stripe ( you should add this to the documentation)
Nothing more has to be done according to the docs and i deployed my new backend.

But nothing has been added in the dashboard of the user, nothing as i can see on the tutorial.

What more should i do ?

Hello @Jules_Truong :wave:

Can you share the content of your file middleware/forestadmin.js (erase your secrets if they are visible) and the content of your model that includes the Stripe id ?

const chalk = require('chalk');
const path = require('path');
const Liana = require('forest-express-sequelize');
const { objectMapping, connections } = require('../models');

module.exports = async function forestadmin(app) {
  app.use(await Liana.init({
    configDir: path.join(__dirname, '../forest'),
    envSecret: process.env.FOREST_ENV_SECRET,
    authSecret: process.env.FOREST_AUTH_SECRET,
    schemaDir: process.env.FOREST_SCHEMA_DIR,
    objectMapping,
    connections,
    integrations: {
      stripe: {
        apiKey: process.env.STRIPE_SECRET_KEY,
        mapping: 'user.stripeRef',
        stripe: require('stripe')
      }
    }
  }));

  console.log(chalk.cyan('Your admin panel is available here: https://app.forestadmin.com/projects'));
};

And my model

// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
  const { Sequelize } = sequelize;
  // This section contains the fields of your model, mapped to your table's columns.
  // Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
  const User = sequelize.define('user', {
    createdAt: {
      type: DataTypes.DATE,
    },
    updatedAt: {
      type: DataTypes.DATE,
    },
    firstname: {
      type: DataTypes.STRING,
    },
    lastname: {
      type: DataTypes.STRING,
    },
    phonenumber: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    authId: {
      type: DataTypes.STRING,
    },
    email: {
      type: DataTypes.STRING,
    },
    stripeRef: {
      type: DataTypes.STRING,
    },
    roles: {
      type: DataTypes.ARRAY(DataTypes.STRING),
      defaultValue: Sequelize.literal('\'{user}\'::text[]'),
      allowNull: false,
    },
    status: {
      type: DataTypes.STRING,
      defaultValue: "active",
      allowNull: false,
    },
    nbLateDepartureTotal: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
      allowNull: false,
    },
    nbLateDepartureConsecutive: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
      allowNull: false,
    },
  }, {
    tableName: 'user',
    underscored: true,
    schema: process.env.DATABASE_SCHEMA,
  });

  // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
  User.associate = (models) => {
    User.belongsTo(models.address, {
      foreignKey: {
        name: 'addressIdKey',
        field: 'address_id',
      },
      as: 'address',
    });
    User.hasMany(models.booking, {
      foreignKey: {
        name: 'userIdKey',
        field: 'user_id',
      },
      as: 'bookings',
    });
    User.hasMany(models.membership, {
      foreignKey: {
        name: 'userIdKey',
        field: 'user_id',
      },
      as: 'memberships',
    });
    User.hasMany(models.ticket, {
      foreignKey: {
        name: 'userIdKey',
        field: 'user_id',
      },
      as: 'tickets',
    });
  };

  return User;
};

@anon15528774 is that ok ?
Is there a log i should find that display that configuration for stripe is ok ?

@anon15528774 Just that you know, i have no warning in the logs,

It also seems like your types does not include integrations entry in the LianaOptions definition.

Hi Jules

Nicolas handed this thread to me
I’ll setup a test project and check out what happens

Hello @anon39940173 ,

I’m confused, i’m trying to understand how your repo GitHub - ForestAdmin/forest-express-sequelize: 🌱 Express/Sequelize agent for Forest Admin to integrate directly to your existing Express/Sequelize backend application. works, but can’t find anything about integrations options in the source code.

Yes I got it.

It is possible that our documentation is not up to date as I don’t see anything wrong in the code samples that you sent.

That is why, I’m creating a test project to check that everything works the way it should in my end before using more of your time for debugging

I understand your question only now

The code in inside of the forest-express repository, which is a dependency of forest-express-sequelize

Hello again

I’ve been testing with my sample project.
I noticed that when the apiKey is undefined, the behavior is the exact same than you are describing.

Can you add the following code above your call to app.use() ?
console.log('apiKey', process.env.STRIPE_SECRET_KEY) and check that the key is defined on your end?

(do not post a screenshot containing your API key here if it is defined)

Yes, there is a apiKey defined. Its my testKey for the staging env and prodKey for the production env.
Also, yes the mapping should be correct, ( @see my first post )

I dont know if that could help but i got this in the logs :

[forest] 🌳🌳🌳  Checking need for apimap update...
2022-05-11 10:11:19 default[20220511t120635]  POST /forest/authentication 404 161 - 26.303 ms
2022-05-11 10:11:19 default[20220511t120635]  [forest] 🌳🌳🌳  No change in apimap, nothing sent to Forest

Hello Jules

I’m working on improving parameter validation on forest-express, hoping that you get logs to indicate the issue.

I’ll release a new forest-express-sequelize version shortly

2 Likes

Hello again

The PR is done, and waiting for review.
It should help detecting misconfiguration errors in the future.

In the meantime, could you do a last check for me?
We checked your project configuration, and we do see the stripe collections there!

Is the issue that

  • the stripe collections are not showing at all?
  • or the stripe collections are always empty?

You should navigate to User > Details, like in the following screenshot

Thanks for your PR.

This is a screenshot of my user > detail view.


f

If i understand correctly, i should see a section under “Related Data” , right ?

Yes

I’m waiting for the new forest-express version with my patch to be reviewed so that we can investigate further…

As of now, I don’t see how else I can help you debugging your issue.

Allright, i’ll keep on eye on this thread then. See u

@Jules_Truong Hello
The PR has been merged

Can you try again with forest-express-sequelize@8.5.7 ?
Hopefully you get an error message of some kind in the console

Hello, i will only be able to check this next week.

1 Like

Hello, some news here !

I don’t know how because i’ve been running every commands possible but something added stripe_* in the schema.json file.
And this seems to work now.

Thanks anyway for the help and the PR , i believe this will help you debugging it next time.