Stripe integration returns no data

Feature(s) impacted

Stripe integration

Observed behavior

My stripe fields are not returning any data
I’m currently using a sandbox stripe api key

Expected behavior

Having Stripe data being returned (my Stripe sandbox has a lot of cards / payments linked to my clients local database)

Failure Logs

Here is my forestadmin.js middleware

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_ENV_KEY,
        mapping: 'clients.stripe_client_id',
        stripe: require('stripe')
      }
    }
  }));

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

In the Stripe API logs, the API seems to never be called at all.
I don’t have any error in the forest node console.

Context

  • Project name: Blockpulse Admin Panel
  • Team name: Operations
  • Environment name: Development

Hello @baptiste ! :wave: Welcome to our community :tada: :confetti_ball:

Looking at your mapping the Stripe Customer ID should be find in the stripe_client_id field of the clients collection, am I right ?

Can you share the clients collection to check your collection name ? (I’m thinking you should use client instead of clients)

Thanks in advance.

Kind regards,
Morgan.

Hello,

Yes my clients collection has a stripe_client_id field.

this is my clients collection (default one) :

const { collection } = require('forest-express-sequelize');

collection('clients', {
  actions: [],
  fields: [],
  segments: [],
});

I tried writing a wrong value for the mapping and got an error message saying Stripe integration couldn’t be started so I’m guessing that my value is valid.

Hey again,

You are right, everything looks ok. A colleague will try to reproduce and take over the thread.

In the meanwhile, can you share the sequelize definition of clients ?

Kind regards,
Morgan

Hello,

thank you for the quick answers.

This is my clients 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 Clients = sequelize.define('clients', {
    accountId: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    email: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    companyName: {
      type: DataTypes.STRING,
    },
    addressLine: {
      type: DataTypes.STRING,
    },
    postcode: {
      type: DataTypes.STRING,
    },
    city: {
      type: DataTypes.STRING,
    },
    tvaIntraCommunity: {
      type: DataTypes.STRING,
    },
    billingStartDate: {
      type: DataTypes.DATE,
    },
    billingEndDate: {
      type: DataTypes.DATE,
    },
    paymentMethodId: {
      type: DataTypes.STRING,
    },
    createdAt: {
      type: DataTypes.DATE,
      defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
    },
    updatedAt: {
      type: DataTypes.DATE,
    },
    stripeClientId: {
      type: DataTypes.STRING,
    },
    pennylaneClientId: {
      type: DataTypes.STRING,
    },
    subscribed: {
      type: DataTypes.BOOLEAN,
    },
  }, {
    tableName: 'clients',
    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.
  Clients.associate = (models) => {
    Clients.belongsToMany(models.coupons, {
      through: 'clientCoupon',
      foreignKey: 'client_id',
      otherKey: 'coupon_id',
      as: 'couponsThroughClientCoupons',
    });
    Clients.hasMany(models.invoices, {
      foreignKey: {
        name: 'clientIdKey',
        field: 'client_id',
      },
      as: 'invoices',
    });
    Clients.hasMany(models.operations, {
      foreignKey: {
        name: 'clientIdKey',
        field: 'client_id',
      },
      as: 'operations',
    });
  };

  return Clients;
};

Regards,
Baptiste

I see that the stripeClientId is defined as following:

Can you try to change the mapping to:

mapping: 'clients.stripeClientId',

Does it help ?

Kind regards,
Morgan

Yes I did try that before posting and didn’t work.

Regards,
Baptiste

1 Like

Hey @baptiste,

Coudl you give me the version of the stripe package you are using ? :pray:

I’ll check on my setup if I’m able to reproduce and I’ll let you know.

Hello,
my stripe version is 8.195.0.

This is my package.json :

{
  "name": "blockpulse-admin-dev",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node ./server.js"
  },
  "dependencies": {
    "body-parser": "1.19.0",
    "chalk": "~1.1.3",
    "cookie-parser": "1.4.4",
    "cors": "2.8.5",
    "debug": "~4.0.1",
    "dotenv": "~6.1.0",
    "express": "~4.17.1",
    "express-jwt": "6.0.0",
    "forest-express-sequelize": "^8.0.0",
    "morgan": "1.9.1",
    "pg": "~8.2.2",
    "require-all": "^3.0.0",
    "sequelize": "~5.15.1",
    "stripe": "^8.195.0"
  }
}

Regards,
Baptiste

1 Like

Just did a quick setup on my end, and I’m able to fetch data correctly using "stripe": "^8.195.0", on a setup similar to yours

      integrations: {
        stripe: {
          apiKey: process.env.STRIPE_API_KEY,
          mapping: "clients.stripeClientId",
          stripe: require("stripe"),
        },
      },

Do you have any error logs in your browser developer console or on your agent ?

After checking again with clients.stripeClientId, I noticed I am now successfully getting the payments data but it is incomplete : I only have 7 payments displayed while there are 34 payments with this customer, and the cards / bank accounts are empty when they should not (this is what baited me thinking it didn’t work)

Only displaying 7 payments

Customer payment methods in stripe

There are no errors in the browser console and in the node app.

Regards,
Baptiste

Weird indeed.

I’m currently not able to reproduce.

Would it eventually be possible for you to share (as DM & obfuscated) the response of the HTTP GET /stripe_payments call?
If not, could you eventually just check if the number of records returned in the response of this service matches with the number of records you have in stripe?

Thanks in advance

Thanks for the DM. I can see that the response sent by your agent only contains 7 payments, so the issue is not a frontend one.

On my end, I don’t see anything for now that can lead to this result, either in the code, or in my test project - thus I’m still unable to reproduce.

Just to check if this is indeed an agent issue, would you mind running this specific stripe curl command on the same client, just to check if the stripe API returns you the 34 results you are mentioning?

2 Likes

Hello,

The API returned me the full 34 payments list with the limit: 40 parameter.
Sent you the response in DM.

Regards

After checking the output, I can see that the payment that does not appear in the UI are payment issued with a method other than card.

We currently don’t supported issued payment with method != card, so the best I can do is to push this as a feature suggestion in our product board. I can’t provide any ETA for feature suggestions.

In the meantime, the best solution I can provide is based on Smart Collection.

1 Like