如何使用 PayPal/Ruby on Rails/活跃商家创建安全的信用卡网关

发布于 2024-07-11 07:36:58 字数 1236 浏览 5 评论 0原文

我现在正在使用 Active Merchant 和 PayPal 沙箱创建商店。 它似乎工作正常,但我认为它根本不安全。 我对 HTTPS 以及如何实现安全连接实在不太了解。

我目前正在会话中传递信用卡和账单信息(可能不是最聪明的想法)。 我当前的代码发布在下面。 我真的需要帮助来确定要采取什么方向和步骤,才能使其成为一个安全、可用的商店。

 def payment
session[:billing_address] = params[:billing_address] 
 end

 def summary
    @credit_card = params[:credit_card]
    session[:credit_card] = params[:credit_card]
    @billing_address = session[:billing_address]
    @cart = get_cart
    @purchases  = @cart.purchases
    @total = @cart.total
 end

 def finish
     @cart = get_cart
     @total = @cart.total

     credit_card = ActiveMerchant::Billing::CreditCard.new( session[:credit_card] )

     billing_address = session[:billing_address]

     flash[:notice] = credit_card.errors and return unless credit_card.valid?

     gateway = ActiveMerchant::Billing::PaypalGateway.new(:login=>$PAYPAL_LOGIN, :password=>$PAYPAL_PASSWORD)

     res = gateway.authorize(@total, credit_card, :ip=>request.remote_ip, :billing_address=>billing_address)

     if res.success?
        gateway.capture(@total, res.authorization)
        flash[:notice] = "Authorized" 
     else
        flash[:notice] = "Failure: " + res.message.to_s
     end    
  end

I am creating a store using Active Merchant and PayPal sandbox right now. It seems to be working fine, but I don't think it is even remotely secure. I don't really know too much about HTTPS and how to implement secure connections.

I am currently passing the credit card and billing information in the session (probably not the smartest idea). My current code is posted below. I really need help with what direction and steps to take in order to make this a secure, usable store.

 def payment
session[:billing_address] = params[:billing_address] 
 end

 def summary
    @credit_card = params[:credit_card]
    session[:credit_card] = params[:credit_card]
    @billing_address = session[:billing_address]
    @cart = get_cart
    @purchases  = @cart.purchases
    @total = @cart.total
 end

 def finish
     @cart = get_cart
     @total = @cart.total

     credit_card = ActiveMerchant::Billing::CreditCard.new( session[:credit_card] )

     billing_address = session[:billing_address]

     flash[:notice] = credit_card.errors and return unless credit_card.valid?

     gateway = ActiveMerchant::Billing::PaypalGateway.new(:login=>$PAYPAL_LOGIN, :password=>$PAYPAL_PASSWORD)

     res = gateway.authorize(@total, credit_card, :ip=>request.remote_ip, :billing_address=>billing_address)

     if res.success?
        gateway.capture(@total, res.authorization)
        flash[:notice] = "Authorized" 
     else
        flash[:notice] = "Failure: " + res.message.to_s
     end    
  end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心房敞 2024-07-18 07:36:58

有一个关于如何实施 ssl 的很好的railscast。

http://railscasts.com/episodes/143-paypal-security

There was a good railscast about how to implement ssl.

http://railscasts.com/episodes/143-paypal-security

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文