问题
I am trying to customize my express checkout by adding line item details in the request. I am following the instructions mentioned here
But making this change redirects me to paypal.com/cgi-bin/webscr
and not sandbox.paypal.com/cgi-bin/webscr
My 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
my order controller:
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
if I simply use :
@response = EXPRESS_GATEWAY.setup_purchase(@total1, :return_url => @return1, :cancel_return_url => @cancel)
it works perfectly fine.
How can I test the customizations in sandbox. Please help!!
EDIT: I want to show name,description,sku,quantity and amount for each line item. So, the options hash looks something like:
{: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"}
来源:https://stackoverflow.com/questions/22809440/test-paypal-express-gateway-redirecting-to-live-and-not-sandbox