如果我的货币不是“美元”,我无法通过 activemerchant
进行购买
以下是来自 response.message
的错误文本消息:
指定的交易货币必须与之前指定的货币相同。
以下是购买设置:
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
)
这是购买本身:
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
也许我还应该在 express_purchase_options
中指定货币?
最佳答案
我在我的一个使用“欧元”货币的项目中使用了这个 gem 。
我的配置如下:
# config/application.rb
config.after_initialize do
ActiveMerchant::Billing::PaypalExpressGateway.default_currency = 'EUR'
end
就是这样。无需配置任何其他内容。
关于paypal - 如何在activemerchant gem中允许不同于美元的货币?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22542927/