require 'active_merchant'
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
login: "activemerchant-test_api1.example.com",
password: "HBC6A84QLRWC923A",
signature: "AFcWxV21C7fd0v3bYYYRCpSSRl31AC-11AKBL8FFO9tjImL311y8a0hx"
}
@gateway = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
response = @gateway.setup_purchase(50,
ip: request.remote_ip,
return_url: "http://local.mywebdomain.com:3000/mylocalhostpaymentsucceed",
cancel_return_url: "http://local.mywebdomain.com:3000/seeyouagain",
currency: "USD",
allow_guest_checkout: true,
items: [{name: "Order", description: "Order description", quantity: "1", amount: 50}]
)
redirect_to @gateway.redirect_url_for(response.token)
もう1つのヒントは、ローカルホストをlocal.mywebdomain.comに設定する方法です。マシンのsystem32フォルダ内の.hostファイルを次のように編集するだけです。
127.0.0.1 local.mywebdomain.com