测试Paypal Express Gateway重定向到live而不是sandbox

我想通过在请求中添加订单项详细信息来自定义我的快速结帐。 我按照这里提到的说明进行操作

但是,进行此更改会将我重定向到paypal.com/cgi-bin/webscr而不是sandbox.paypal.com/cgi-bin/webscr

我的开发.rb:

 MyApp::Application.config.after_initialize do ActiveMerchant::Billing::Base.mode = :test ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(:login => "***", :password => "***", :signature => "***") 

test.rb:

  config.after_initialize do ActiveMerchant::Billing::Base.mode = :test ::EXPRESS_GATEWAY = ActiveMerchant::Billing::BogusGateway.new 

我的订单管理员:

 def express @order1 = current_order @options = express_options(@order1) @total1 = @order1.item_total.to_i @response = EXPRESS_GATEWAY.setup_purchase(@total1, @options) redirect_to EXPRESS_GATEWAY.redirect_url_for(@response.token) end private def express_options order options = {} options[:ip] = request.remote_ip #options[:order_id] = @order2.id options[:subtotal] = order.item_total.to_i options[:shipping] = 0 options[:handling] = 0 options[:tax] = 0 options[:items] = order.line_items.map do |line_item| { :name => line_item.variant.name, :number => line_item.variant.sku, :quantity => line_item.quantity, :description => line_item.variant.description, :amount => line_item.price.to_i } end options[:return_url] = "http://127.0.0.1:3000"+order_path(order) options[:cancel_return_url] = "http://127.0.0.1:3000/t/jewellery" return options end 

如果我只是使用:

  @response = EXPRESS_GATEWAY.setup_purchase(@total1, :return_url => @return1, :cancel_return_url => @cancel) 

它工作得很好。

如何在沙箱中测试自定义项。 请帮忙!!

编辑 :我想显示每个订单项的名称,描述,sku,数量和金额。 因此,选项哈希看起来像:

 {:ip=>"127.0.0.1", :subtotal=>3216, :shipping=>0, :handling=>0, :tax=>0, :items=>[{:name=>"Exuberant Yellow Beads, Silver Plated Anklets", :number=>"JMJAI20184", :quantity=>1, :description=>"The quintessential ankle adornments, this pristine pair of silver plated anklets catch everyone's attention effortlessly! Grab them now!", :amount=>349}, {:name=>"Gold Plated Single String Mangalsutra Set With Drop Shaped Pendant", :number=>"PSJAI24199", :quantity=>2, :description=>"Add to your collection this sparkling gold plated mangalsutra set, featuring an elegant leaf-drop pendant design. Graceful piece encrusted with cz stones and set with a single chain.", :amount=>819}, {:name=>"Beaded Anklet With Charming Lavender Bead Ball", :number=>"KJBDQ20112", :quantity=>1, :description=>"Step out in style with this funky anklet, set with tiny multicolor beads and a conspicuous lavender beaded ball to pep up your look. Get it today!", :amount=>220}, {:name=>"Silver Plated Anklets Studded With Green Cz", :number=>"ARJAI20128", :quantity=>1, :description=>"Adorn yourself with these shimmering silver plated pair of anklets, embellished with green cz stones. Simple yet elegant design to add grace to your feet!", :amount=>619}, {:name=>"Cuff Bracelet Featuring Sunflower Inspired Design, Antique Finish", :number=>"ARJAI20154", :quantity=>1, :description=>"This cuff bracelet showcases a gorgeous design featuring sunflower inspired design and antique finish. Polished and oxidized silver colour add depth and interest to the pattern. This is an eye-catching accessory that's easy to wear and will complement any outfit.", :amount=>390}], :return_url=>"http://127.0.0.1:3000/orders/R854433362", :cancel_return_url=>"http://127.0.0.1:3000/t/jewellery"}