测试PayPal快速网关重定向到生活,而不是沙盒(Test Paypal Express Gatew

2019-10-19 17:52发布

我想通过在请求中添加行项目详细信息来定制我快速退房。 我下面所提到的说明这里

但要做出这种改变重定向我paypal.com/cgi-bin/webscr而不是sandbox.paypal.com/cgi-bin/webscr

我development.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"}
文章来源: Test Paypal Express Gateway redirecting to live and not sandbox