我可以在Rails 4应用程序中通过带有条纹的活动商人传递其他货币吗? [英] Can i pass different currency in active-merchant with stripe in Rails 4 application?

查看:101
本文介绍了我可以在Rails 4应用程序中通过带有条纹的活动商人传递其他货币吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Rails 4应用程序,用户可以使用该应用程序订阅一次付款。

I am developing Rails 4 application where user can subscribe one time pay with application.

要进行订阅,请使用带有条带的Active Merchant,现在用户现在需要支付$ 50,付款成功完成。下面的代码:

For subscription, use Active Merchant with stripe where now user pay $50 right now and payment done successfully. Below code :

 ActiveMerchant::Billing::Base.mode = :test

    transaction = ActiveMerchant::Billing::StripeGateway.new(:login => Rails.application.secrets.stripe_secret_key)

    paymentInfo = ActiveMerchant::Billing::CreditCard.new(
                :number             => purchage_params[:card_holder_number],
                :month              => purchage_params[:expiry_month],
                :year               => purchage_params[:expiry_year],
                :verification_value => purchage_params[:cvv])


    purchaseOptions = {:billing_address => {
        :name     => purchage_params[:card_holder_name],
        :currency => @country.currency,
        :address1 => session[:address],
        :city     => session[:city],
        :state    => @region.name,
        :zip      => session[:zip_postal]
    }}

    response = transaction.purchase((amount * 100).to_i, paymentInfo, purchaseOptions)

现在我的问题是,我想根据用户所在国家/地区明智地扣除付款。

Now my issue, I want to deduct payment as per user country wise. As per below country and payment.

 USA = $50 USD
 South Africa = 355 ZAR
 India = 520 INR
 Australia = $50 AUD

所以我如何明智地设置货币和付款国家。有人有想法吗?

So how can i set currency and payment country wise. Any one have a idea in it?

谢谢

推荐答案

I得到了我的解决方案。请检查下面的代码如何传递货币。

I got my solutions. Please check below code how to pass currency.

purchaseOptions = {:billing_address => {
        :name     => purchage_params[:card_holder_name],
        :currency => @country.currency,
        :address1 => session[:address],
        :city     => session[:city],
        :state    => @region.name,
        :zip      => session[:zip_postal]
    },
    :currency => "CAD"}

我们可以放置动态代码而不是 CAD。

We can place dynamic code instead of "CAD".

这篇关于我可以在Rails 4应用程序中通过带有条纹的活动商人传递其他货币吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆