4

環境:
Ruby 1.9.2
Rails 3.2.8
gem 'ActiveMerchant' 1.34.1

自動更新オプションに Paypal 定期支払いオプションを使用したいと考えています。

このために、ユーザーがログインして支払いを確認してから処理できるようにするために、PayPal Web サイトにアクセスする Paypal 支払いオプションを使用しています。

通常の支払い(定期支払いではない)には問題なく機能しています。通常の支払いには、次を使用しました。

クラスで:

ActiveMerchant::Billing::Base.mode = :test

@@paypal_express_gateway = ActiveMerchant::Billing::PaypalExpressGateway.new(
    :login => 'my_login_id@domail.com',
    :password => 'password',
    :signature => 'Signature'
)

メソッドexpress_checkout内:

setup_response = @@paypal_express_gateway.setup_purchase(@@amount,
      :ip                => request.remote_ip,
      :return_url        => url_for(:action => 'confirm', :only_path => false),
      :cancel_return_url => url_for(:action => 'new', :only_path => false)
)
redirect_to @@paypal_express_gateway.redirect_url_for(setup_response.token)

メソッドconfirm内:

details_response = @@paypal_express_gateway.details_for(params[:token])

その後details_response、success メソッドtrueまたはで戻りますfalse。そして、完了またはエラーページに送信します。それは私が定期的な支払いで欲しいです


PaypalExpressCheckout での定期支払いには、以下を使用しました。

クラスで:

ActiveMerchant::Billing::Base.mode = :test

@@paypal_express_gateway = ActiveMerchant::Billing::PaypalExpressGateway.new(
    :login => 'my_login_id@domail.com',
    :password => 'password',
    :signature => 'Signature'
)

メソッドexpress_checkout内:

setup_response = @@paypal_express_gateway.setup_purchase(@@amount, <br>
    :ip                => request.remote_ip, <br>
    :return_url        => url_for(:action => 'confirm', :only_path => false),
    :cancel_return_url => url_for(:action => 'new', :only_path => false)
)
redirect_to @@paypal_express_gateway.redirect_url_for(setup_response.token)

メソッドconfirm内:

details_response = @@paypal_express_gateway.recurring(@@amount, "", options = {
    :token => params[:token],
    :period => "Month",
    :frequency => 3,
    :start_date => Time.now,
    :description => "Checking recurring auto-renewal"
})

今、私はエラーが発生していますundefined method "add_credit_card" for #<ActiveMerchant::Billing::PaypalExpressGateway:0x00000006c831a0>

profile_idを返すrecurring メソッドは、Here (Active Merchant)で定義されています。

したがって、支払いはPaypal Webサイトで行われるため、開発者がクレジットカードの詳細を定期的な方法に送信できない定期的な支払いにPaypalExpressGateway(PaypalGatewayではない)を使用したいと考えています。

次に、 PaypalExpressGateway の場合にcredit_cardパラメータが使用されているのはなぜですか。また、メソッドによって呼び出されるメソッド「 build_create_profile_request(options)recurring 」は、オプションでパラメーター「credit_card」を渡していないため、credit_card をチェックしないでください (指定されたリンクの 127 行目を参照) 。

コードを確認して、どこが間違っているか教えてください。誰かが私に準備されたコードを提供できれば、それはより便利になります。

多くのブログやソリューションを試しましたが、成功しませんでした。このASAPの解決策を教えてください。

4

1 に答える 1

3

ActiveMerchant を使用して定期的な PayPal 支払いを行っています。nil空の文字列ではなく、2 番目のパラメーター (クレジット カード オブジェクトを表すある種のオブジェクトですが、ActiveMerchant の PayPal Express Checkout 統合では実装されていないと思います) をメソッドに渡す必要がありますrecurring

details_response = @@paypal_express_gateway.recurring(@@amount, nil, { 
  :token => params[:token], 
  :period => "Month", 
  :frequency => 3, 
  :start_date => Time.now, 
  :description => "Checking recurring auto-renewal" 
}) 
于 2013-07-22T14:41:21.243 に答える