Search code examples
paypalruby-on-rails-4paypal-sandboxactivemerchant

How to allow different from USD currency in activemerchant gem?


I can not make a purchase via activemerchantif my currency is not 'USD' Here's error text message from response.message: The transaction currency specified must be the same as previously specified.

Here's purchase setup:

response = EXPRESS_GATEWAY.setup_purchase(product.price,       
      :currency          => product.currency.upcase, # it's 'EUR'
      :items             => [{name: product.name, quantity: 1, amount: product.price, description: product.description}],
      :ip                => request.remote_ip,
      :return_url        => paypal_checkout_url,
      :cancel_return_url => paypal_checkout_url
)

And here's purchase itself:

def purchase
  response = EXPRESS_GATEWAY.purchase(product.price, express_purchase_options)
end

def express_purchase_options
{
  :ip => ip_address,
  :token => express_token,
  :payer_id => express_payer_id
}
end

Maybe I should specify currency in express_purchase_options also?


Solution

  • Yes, the currency specified needs to be the same in all calls throughout the flow. It looks like this must be using Express Checkout..?? You just need to make sure the SetExpressCheckout request and the DoExpressCheckoutPayment request are using the same currency code.