Reputation: 1310
I can not make a purchase
via activemerchant
if 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?
Upvotes: 2
Views: 671
Reputation: 2353
I'm using this gem in one of my projects with 'EUR' currency.
My configuration is as follows:
# config/application.rb
config.after_initialize do
ActiveMerchant::Billing::PaypalExpressGateway.default_currency = 'EUR'
end
And that's it. No need to configure anything else.
Upvotes: 3
Reputation: 26036
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.
Upvotes: 1