本文介绍了格子集成Rails的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 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参数没有传递给控制器​​.

The problem is that metadata.account_id parameter is not passed to controller.

浏览器控制台:所选账户 ID:空

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

If i do puts client.accounts.get(access_token) I get several accounts with different balances.

推荐答案

从 Plaid 仪表板启用 Select Account 视图.

Enable Select Account view from Plaid dashboard.

这篇关于格子集成Rails的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 14:42