Plaid integration Rails

萝らか妹 提交于 2020-02-06 07:29:44

问题


I would like to make a payment using Stripe ACH.

I use gem plaid.

Here is my Link code:

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);
    }
});

Plaid controller:

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

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

Browser console: Selected account ID: null

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


回答1:


Enable Select Account view from Plaid dashboard.



来源:https://stackoverflow.com/questions/58373656/plaid-integration-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!