【问题标题】:Plaid integration Rails格子集成 Rails
【发布时间】:2020-02-10 21:27:33
【问题描述】:

我想使用 Stripe ACH 付款。

我使用 gem plaid

这是我的链接代码:

var linkHandler = Plaid.create({
    clientName: 'Some Name',
    env: 'sandbox',
    key: ENV['key'],
    product: ['auth'],
    onSuccess: function(public_token, metadata) {
        $.post('/plaid/set_auth', {
            public_token: public_token,
            account: metadata.account_id
        });

        console.log('Public Token: ' + public_token);
        console.log('Selected account ID: ' + metadata.account_id);
    }
});

格子控制器:

def set_auth
  public_token = params['public_token']
  account_id   = params['account']

  client = Plaid::Client.new(env: :sandbox, 
                       client_id: ENV['client_id'],
                          secret: ENV['secret'],
                      public_key: ENV['public_key'])

  exchange_token_response = client.item.public_token.exchange(public_token)
  access_token = exchange_token_response.access_token


  #Create a Stripe bank_account_token

  stripe_response = client.processor.stripe.bank_account_token.create(access_token, account_id)
  bank_account_token = stripe_response.stripe_bank_account_token

  customer = Stripe::Customer.retrieve("<customer-id>")

  customer.sources.create({
    :source => bank_account_token
  })

  #...Stripe::Charge.create()...
end

问题metadata.account_id参数没有传递给控制器​​。

浏览器控制台:Selected account ID: null

如果我这样做puts client.accounts.get(access_token),我会得到几个余额不同的帐户。

【问题讨论】:

  • 您是否尝试在控制台中打印 public_token 和元数据?检查值。
  • public_token 工作正常。
  • public_token 中有什么?元数据可以在 public_token 中吗?
  • public_token = public-sandbox-ce9c11...metadata = {"institution"=&gt;{"name"=&gt;"Chase", "institution_id"=&gt;"ins_3"}, "account"=&gt;{"id"=&gt;"", "name"=&gt;"", "type"=&gt;"", "subtype"=&gt;"", "mask"=&gt;""}, "account_id"=&gt;"", "accounts"=&gt;{"0"=&gt;{"id"=&gt;"PG7xK5xVJ5tqe...", "name"=&gt;"Plaid Checking", "mask"=&gt;"0000", "type"=&gt;"depository", "subtype"=&gt;"checking"},..
  • @demir 非常感谢!我重新阅读了文档,但没有找到。包括帐户选择,现在我有了 ID。

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


【解决方案1】:

从格子仪表板启用Select Account 视图。

【讨论】:

    猜你喜欢
    • 2020-01-07
    • 2017-11-13
    • 1970-01-01
    • 2020-12-18
    • 1970-01-01
    • 2022-12-22
    • 2011-12-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多