ActiveMerchant是否支持基于订阅的事务

我想在我的rails应用程序中集成ActiveMerchant。 我有一些计划,如果订阅限制用户访问。 正如你们所有人都知道基于订阅的应用程序是什么,我不打算解释我的应用程序。 请告诉我一些实现这一目标的例子。 我已经查看过电视剧141到146,但Ryan只展示了Paypal Web Payments Standard和Paypal Web Payments Pro。 我也读了很多博客,但没有帮助。

请帮忙。

提前致谢。

迟到总比没有好,是吧?

ActiveMerchant的实际主分支包含集成到PaypalGatewayPaypalExpressGateway中的定期类。

这是一个有效的演示片段。 我只是不确定几点(一旦我弄清楚,我会更新答案),这是:

  • 无论设置如何,设置结算协议都不会显示任何价格: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 

您想了解PaypalRecurringAPI和PaypalExpressGateway / PayPalGateway,以了解处理哪些选项以及xml请求的位置。

编辑关于paypal和定期计费的更新,修订的截屏video是使用单独的PayPal-recurring gem完成的。 如果您无法使用ActiveMerchant,这可能会有所帮助。

活跃商家支持其部分网关的定期付款( 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要求。