Sin Token Pasado Pago exprés de PayPal en Rails 5

Estoy armando un carrito de compras básico con la función de Pago exprés de PayPal. Todo parece estar funcionando hasta que hago clic en el botón de pago, luego aparece una página en blanco que dice “no se ha pasado token”. En los registros del servidor, parece que no se está creando ningún token, pero no estoy seguro de por qué. Creo que este es probablemente un problema con la creación del token de pago rápido, pero realmente no estoy seguro de lo que estoy haciendo mal. Aquí es cómo se ve el registro del servidor:

Started GET "/express_checkout" for 10.240.0.204 at 2017-05-27 16:54:43 +0000 Cannot render console from 10.240.0.204! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255 Processing by OrdersController#express_checkout as HTML Order Load (0.1ms) SELECT "orders".* FROM "orders" WHERE "orders"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]] OrderItem Load (0.1ms) SELECT "order_items".* FROM "order_items" WHERE "order_items"."order_id" = ? [["order_id", 1]] Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."active" = ? AND "products"."id" = ? LIMIT ? [["active", true], ["id", 1], ["LIMIT", 1]] Redirected to https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token= Completed 302 Found in 615ms (ActiveRecord: 0.5ms) 

Aquí está mi Order.rb:

 class Order  ip, :token => express_token, :payer_id => express_payer_id } end end 

Mis orders_controller.rb:

 class OrdersController  params[:token]) end def create @order = current_order.create!(order_params) @order.ip = request.remote_ip if @order.save if @order.purchase redirect_to order_url(@order) else render :action => "failure" end else render :action => 'new' end end private def order_params params.require(:order).permit(:subtotal, :total, :ip, :express_token, :express_payer_id) end end 

Mi application_controller.rb:

 class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception helper_method :current_order def current_order if !session[:order_id].nil? Order.find(session[:order_id]) else Order.new(order_params) end end end 

El código de comerciante activo en mi desarrollo.rb:

 config.after_initialize do ActiveMerchant::Billing::Base.mode = :test paypal_options = { login: "merchant_api1.christianorourke.com", password: ************, signature: *************************** } ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options) end 

Mi archivo de rutas:

 Rails.application.routes.draw do root "products#index" resources :products, only: [:index] resource :cart, only: [:show] resources :order_items, only: [:create, :update, :destroy] get 'express_checkout', to: 'orders#express_checkout' resources :orders do collection do post 'express_checkout' end end end 

Acabo de encontrar este enlace que explica cómo configurar.

paypal-express

https://github.com/nov/paypal-express/wiki

 paypal_options = { no_shipping: true, # if you want to disable shipping information allow_note: false, # if you want to disable notes pay_on_paypal: true # if you don't plan on showing your own confirmation step } request = Paypal::Express::Request.new( :username => SET_YOUR_OWN, :password => SET_YOUR_OWN, :signature => SET_YOUR_OWN ) payment_request = Paypal::Payment::Request.new( :currency_code => :JPY, # if nil, PayPal use USD as default :description => FOO, # item description :quantity => 1, # item quantity :amount => 1.00, # item value :custom_fields => { CARTBORDERCOLOR: "C00000", LOGOIMG: "https://example.com/logo.png" } ) response = request.setup( payment_request, YOUR_SUCCESS_CALLBACK_URL, YOUR_CANCEL_CALLBACK_URL, paypal_options # Optional ) response.redirect_uri 

Luego tiene la configuración de ActiveMerchant y puede encontrar guías para escuchar:

https://duckduckgo.com/?q=rails+paypal+active+merchant+gem&atb=v52-6_b&ia=qa

Cómo integrar Paypal con Ruby on Rails

https://spin.atomicobject.com/2011/10/24/integrating-paypal-express-with-rails-3-1-part-1/