PayPal / Ruby on Rails / Active Merchant를 사용하여 보안 신용 카드 게이트웨이를 만드는 방법
-
19-08-2019 - |
문제
나는 지금 Active Merchant와 Paypal Sandbox를 사용하여 매장을 만들고 있습니다. 잘 작동하는 것 같지만 원격으로 안전하다고 생각하지 않습니다. 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
해결책
SSL을 구현하는 방법에 대한 좋은 철도가있었습니다.
제휴하지 않습니다 StackOverflow