5

Rails アプリに ActiveMerchant を統合しようとしています。購読するとユーザーアクセスを制限する特定の計画があります。皆さんはサブスクリプション ベースのアプリが何であるかを知っているかもしれないので、私のアプリについて説明するつもりはありません。これを実現するためのいくつかの例を教えてください。Railscasts のエピソード 141 から 146 までは既に見ましたが、Ryan は Paypal Web Payments Standard と Paypal Web Payments Pro しか実演していません。私もたくさんのブログを読みましたが、役に立ちませんでした。

助けてください。

前もって感謝します。

4

2 に答える 2

9

遅刻したほうがいいですよね?

PaypalGatewayActiveMerchantの実際のマスターブランチには、との両方に統合された繰り返しクラスが含まれていPaypalExpressGatewayます。

これが機能するデモスニペットです。私はいくつかの点についてよくわかりません(私がそれらを理解したらすぐに答えを更新します)、それは次のとおりです:

  • 請求契約を設定するだけでは、設定に関係なく価格は表示されません:initial_amount。アイテムを含めると、アイテムの価格が。より上に表示されbilling_agreement[:description]ます。そのため、これがキャプチャにどのように影響するかはわかりません。これは、最近テストしているものです。
  • IPN通知。次のスニペットにはありません。以下を更新...

    class PaymentsController < ApplicationController
      include ActiveMerchant::Billing
    
    
      # GET /subscriptions/:id/checkout
      def checkout
        payment_request = PAYPAL_EXPRESS_GATEWAY.setup_purchase(@subscription.price_in_cents,
            :billing_agreement => {
                :type => 'RecurringPayments',
                :description => 'Subscription agreement',
            },
    
            :currency => 'CHF',
            :no_shipping => true,
            :allow_guest_checkout => true,
            :allow_note => false,
            :initial_amount => @subscription.price_in_cents,
            :locale => 'de',
            :ip => request.remote_ip,
            :return_url => url_for(:action => :confirm, :only_path => false),
            :cancel_return_url => url_for(:action => :cancel, :only_path => false),
            # Looks like :notify_url is not used here, but in the next section 
        )
    
        if payment_request.success?
          redirect_to PAYPAL_EXPRESS_GATEWAY.redirect_url_for(payment_request.token)
        else
          # Render something informal
          render :text => payment_request.inspect.to_s and return
        end
      end
    
      # POST /subscriptions/:id/confirm 
      # params having token and PayerID
      def confirm
        profile = PAYPAL_EXPRESS_GATEWAY.recurring(@subscription.price_in_cents, nil, 
            :description => 'Subscription agreement',
            :start_date => Date.tomorrow, # PayPal throws an error if the date is not in the future
            :period => 'Year',
            :frequency => 1,
            :amount => @subscription.price_in_cents,
            :currency => 'CHF',
            :initial_amount => @subscription.price_in_cents,
            :auto_bill_outstanding => true,
    
            :token => params[:token]
        )
    
        # profile has profile_id and profile_status. remember status because this gets updated via IPN.
        @debug = {:params => params.inspect.to_s, :profile => profile.inspect.to_s }
    
        # Render something informal
        render :text => @debug.to_s and return
      end
    
    
      # implement instead of just log
      def notification
        log = Logger.new 'log/ipn.log'
        log.debug params.inspect
        render :text => params.inspect.to_s and return
      end
    
    
      # Private methods omitted
    
    end
    

PaypalRecurringAPIPaypalExpressGateway / PayPalGatewayを調べて、処理されるオプションとxmlリクエストの場所を確認する必要があります。

編集ペイパルと定期的な請求に関する新しい改訂されたスクリーンキャストは、別のペイパル定期的な宝石で行われます。ActiveMerchantで動作させることができない場合は、これが役立つかもしれません。

于 2012-08-29T09:45:07.707 に答える
1

アクティブなマーチャントは、一部のゲートウェイの定期支払いをサポートしています ( https://github.com/Shopify/active_merchant/wiki/GatewayFeatureMatrix )。

それぞれの構文はわずかに異なります ( https://github.com/Shopify/active_merchant/blob/master/lib/active_merchant/billing/gateways/authorize_net_cim.rb ) が、目的を達成できます。

ただし、支払いゲートウェイを選択し、特定の APi を使用することをお勧めします。AM は (私の経験から) やや遅れており、定期的な支払いは主な目的ではありません。

また、すべてのゲートウェイ インタラクションを処理するサービスもあり、その API を処理するだけです。サードパーティがホストする支払いページの場合、支払いの受け入れと PCI DSS 要件の処理が容易になります。

于 2010-11-11T12:35:17.787 に答える