Search code examples
ruby-on-railspaypalpaypal-sandboxactivemerchant

ActiveMerchant PayPal Express possible bug?


I am a little bit confused, somehow I am able to change the amount of the purchase:

First I setup my purchase,

@setup_response = gateway.setup_purchase(
  10*100,
  :ip                => request.remote_ip,
  :return_url        => url_for(:controller => "payments", :action => 'confirm', :only_path => false),
  :cancel_return_url => url_for(:controller => "payments", :action => 'error', :only_path => false),
  :currency => 'EUR',
  :email => current_user.email,
  :no_shipping => true,
  :items => items
)

Later I do the purchase:

  purchase = gateway.purchase(
      500*100,
      :ip       => request.remote_ip,
      :payer_id => params[:payer_id],
      :token    => params[:token],
      :currency => 'EUR'
      )

As you can see I have changed the amount from 10 -> setup/user agreed to 1000 when purchasing and it did work in the Paypal Sandbox.

I think this is really strange. Can anybody confirm this? This should not happen? Is this perhaps only possible in the Sandbox?


Solution

  • Pretty sure Paypal Express Checkout does not require the amount at DoExpressCheckoutPayment (which is what setup_purchase maps to) to be the same as that at SetExpressCheckout. To quote Paypal's documentation:

    In the simplest case, you set the total amount of the order when you call the SetExpressCheckout API. However, you can change the amount before calling the DoExpressCheckoutPayment API if you did not know the total amount when you called the SetExpressCheckout API.