本期内容是:ActiveMerchant + PaypalExpressCheckout + Rails 3.2
我一直在尝试在我的 Rails 3.2 应用程序上构建 Paypal Express Checkout。那里的大多数教程都已经过时了,所以我遵循了一些然后阅读了 Paypal Express Checkout 集成指南。我已经设置了我的 Sandobx 和我的贝宝信息。
当我尝试通过单击我的视图中的“立即购买”链接来处理付款时:
<%= link_to image_tag('http://img36.imageshack.us/img36/249/buttonpaypal.png'),
action: 'checkout', controller: 'orders'%>
我收到以下错误:
This transaction is invalid. Please return to the recipient's website to complete
you transaction using their regular checkout flow.
Return to merchant
At this time, we are unable to process your request. Please return to and try
another option.
--- 我的控制器:
class OrdersController < ApplicationController
include ActiveMerchant::Billing
def checkout
setup_response = ::GATEWAY.setup_purchase(2000,
:ip => request.remote_ip,
:return_url => url_for('confirm'),
:cancel_return_url => url_for(root_path)
)
redirect_to ::GATEWAY.redirect_url_for(setup_response.token)
end
end
--- 我的初始化程序 ActiveMerchant.rb:
ActiveMerchant::Billing::Base.mode = :test
::GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(
:login => "I_PUT_MY_EMAIL_HERE",
:password => "I_PUT_MY_PASS_HERE",
:signature => "I_PUT_MY_SIGNATURE_HERE",
:allow_guest_checkout => true
)
--- 我的路线:routes.rb:
resources :orders do
# Im not sure why 'get :checkout' by itself doesn't work.
get :checkout, :on => :new
get :confirm
get :complete
end
获取“页面/索引”
这是要点:https ://gist.github.com/11be6cef6a97632343b9
谁能给我指出一个“最近的”教程或帮我弄清楚我在这里做错了什么?