【问题标题】:Plaid link not opening w/ rails ENV格子链没有打开 w/rails ENV
【发布时间】:2018-03-25 04:02:30
【问题描述】:

在 Stripe 网站上关注 Plaid integration tutorial 后,我无法让格子链接正常工作。

我尝试用环境键替换“env”和“key”变量,如下所示:

<button id='linkButton'>Open Plaid Link</button>
<script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js">
</script>
<script>
var linkHandler = Plaid.create({
  env: ENV['PLAID_ENV'],
  clientName: 'Divco',
  key: ENV['PLAID_PUBLIC_KEY'],
  product: ['auth'],
  selectAccount: true,
  onSuccess: function(public_token, metadata) {
    // Send the public_token and account ID to your app server.
    console.log('public_token: ' + public_token);
    console.log('account ID: ' + metadata.account_id);
  },
  onExit: function(err, metadata) {
    // The user exited the Link flow.
    if (err != null) {
      // The user encountered a Plaid API error prior to exiting.
    }
  },
});

// Trigger the Link UI
document.getElementById('linkButton').onclick = function() {
  linkHandler.open();
};

当我放弃“花哨”的环境变量,直接插入我的密钥时,我没有问题。我觉得我打错了一些东西……但为了我的生活,我找不到它。

【问题讨论】:

    标签: ruby-on-rails ruby stripe-payments plaid


    【解决方案1】:

    实际上,ENV 是一个 Ruby 调用。您需要在您的 javascript 中使用 &lt;%= ENV[*] %&gt; 并将 .erb 扩展名添加到您的 javascript 文件中。

    您可以使用Figaro 之类的gem 轻松处理ENV 变量。

    【讨论】:

    • 我在.erb 中有文件。正如您提到的,我更改了添加&lt;%=%&gt;,安装了Figaro 并将我的环境变量从secrets.yml 移动到application.yml。重新启动服务器并没有成功。 :(还有什么想法吗?
    猜你喜欢
    • 2021-04-02
    • 2014-01-26
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 2019-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多