【问题标题】:Loopback and Stripe WebhooksLoopback 和 Stripe Webhook
【发布时间】:2018-09-18 05:36:35
【问题描述】:

我目前有一个环回项目设置,我正在尝试从条带接收 webhook。

我当前的远程方法如下所示:-

Stripeconnect.stripeWebhook = function(msg, cb) {
  cb(null, msg);
};

Stripeconnect.remoteMethod(
  'stripeWebhook', {
    description: 'This will insert the description',
    http: {
      path: '/stripeWebhook',
      verb: 'get'
    },
    accepts:
      {arg: 'msg', type: 'any'},
    returns: {
      arg: 'status',
      type: 'any'
    }
  }
)

但我从 Stripe 收到的回复是:-

undefined [Function: callback]

我无法在网上找到任何有关 Loopback 和 Stripe webhook 的文档。

有没有人可以帮忙,或者给我指出正确的方向?

我已将 Stripe 设置为指向 API 的此端点。

提前致谢。如果您需要更多信息,请告诉我。

【问题讨论】:

    标签: javascript api stripe-payments loopbackjs strongloop


    【解决方案1】:

    好的,所以我能够通过获取正文的响应来完成这项工作:-

    /**
     * Receiving Webhook
     * @desc Webhook EP
     * @param {data} Object from Stripe.
     * @return {response} response code
     */
    
    Stripeconnect.stripeWebhook  = function(request, cb) {
      console.log(request.type, request.data);
    };
    
    Stripeconnect.remoteMethod(
      'stripeWebhook', {
        accepts: { arg: 'data', type: 'object', http: { source: 'body' } },
        returns: [
          {arg: 'response', type: 'any', root: true }
        ]
      });
    

    你可以从中看到:-

    accepts: { arg: 'data', type: 'object', http: { source: 'body' } },
    

    希望这对遇到此问题或类似问题的其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 2017-10-03
      • 2015-04-18
      • 1970-01-01
      • 2016-10-18
      • 2021-01-14
      • 2021-11-28
      • 2015-02-27
      • 2013-08-13
      • 2020-01-08
      相关资源
      最近更新 更多