1

Stripe を使用して、アプリケーションへのアクセスに対してユーザーに課金することに成功したアプリケーションがあります。これに基づいて、チェックアウト プロセスに Plaid を実装したいと考えています。Stripe を実装するのはこれが初めてで、Plaid を使用するのはこれが初めてだったので、方向性とこの機能を前進させる方法について少し迷っています。

plaid-ruby gemをインストールし、フィガロ経由で Plaid secret_key と client_id を追加しましたが、今は迷っています。

Plaid.rb:

   Plaid.configuration.stripe = {
    p.client_id = ENV['PLAID_CLIENT_ID'],
    p.secret = ENV['PLAID_SECRET_KEY'],
    p.env = :tartan  # or :production
  end  

チェック柄のリンク:

       <button id='linkButton'>Open Plaid Link</button>
        <script src="https://cdn.plaid.com/link/stable/link-initialize.js"></script>
        <script>
        var linkHandler = Plaid.create({
          env: 'tartan',
          clientName: 'ACCR',
          key: '<<< MY_PUBLIC_KEY >>>',
          product: 'auth',
          selectAccount: true,
          env: 'tartan',
          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);
          },
        });

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

これが、Stripe のコントローラーにあるものです。

    def new 
    @stripe_btn_data = {
     key: "#{ Rails.configuration.stripe[:publishable_key] }",
    }   
    end

  #1 Create a charge
      customer = if current_user.stripe_id?
                    Stripe::Customer.retrieve(current_user.stripe_id)
                  else
                    Stripe::Customer.create(email: :stripeEmail)
                  end

      current_user.update(
        stripe_id: customer.id,
      )

       stripe_charge = Stripe::Charge.create(
         customer:    customer.id,
         amount:      (current_order.subtotal * 100).to_i,
         currency:    'usd',
       )
... more information to create an order then send email after charge. 

Plaid and Stripe 経由で料金を作成するには、コントローラーまたは他の場所に何を含める必要がありますか?

4

1 に答える 1