我一直在关注本教程
http://railscasts.com/episodes/146-paypal-express-checkout?autoplay=true
我已将paypal按钮放入购物车页面
<%= link_to(image_tag("https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif"), express_checkout_path) %>
我的快速结账方法如下
def express_checkout
response = EXPRESS_GATEWAY.setup_purchase(1000,
ip: request.remote_ip,
return_url: cart_item_index_path,
cancel_return_url: cart_item_index_path,
currency: "USD",
allow_guest_checkout: true,
items: [{name: "Order", description: "Order description", quantity: 1, amount: 1000}]
)
puts "printing token #{response.token}"
redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token)
end
当我打印response.token然后它打印空字符串。此外,当我运行应用程序并单击paypal按钮然后它重定向到
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=
出现以下错误
没有令牌传递
我在rails中使用activemerchant gem。
答案 0 :(得分:0)
确定。 byebug救了那一天。
我检查了响应对象中的错误,发现返回url和取消url是无效路径。
所以我改变了
response = EXPRESS_GATEWAY.setup_purchase(1000,
ip: request.remote_ip,
return_url: cart_item_index_path,
cancel_return_url: cart_item_index_path,
currency: "USD",
allow_guest_checkout: true,
items: [{name: "Order", description: "Order description", quantity: 1, amount: 1000}]
)
到
response = EXPRESS_GATEWAY.setup_purchase(1000,
ip: request.remote_ip,
return_url: cart_item_index_url,
cancel_return_url: cart_item_index_url,
currency: "USD",
allow_guest_checkout: true,
items: [{name: "Order", description: "Order description", quantity: 1, amount: 1000}]
)
它有效!谢谢byebug!