我試圖計算的支付形式的哈希值,但我得到的錯誤:如何計算付款表單的散列?
no implicit conversion of Fixnum into String
所以我理解這一點,我試圖做的是文本的數學計算。但是,我應該如何糾正我的代碼?
從支付商戶的指令是:
hash = SHA1(salt + "|" + description + "|" + amount + "|" + currency + "|" + transaction_type)
所以在我的控制,我有:
def checkout
@organization = Organization.new(organizationnew_params)
if @organization.save
@organization.members.each do |single_member|
single_member.send_activation_email
end
@amount = 100.00
@currency = "EUR"
@description = @organization.id
@transaction_description = "My description"
@transaction_type = "S"
### LINE BELOW HAS THE HASH, WHICH REFERS TO THE PRIVATE METHOD BELOW ###
@hash = hash(@description, @amount, @currency, @transaction_type)
render 'checkout'
else
render 'new_premium'
end
end
private
def hash(description, amount, currency, transaction_type)
@hash = SHA1(SALT + "|" + description + "|" + amount + "|" + currency + "|" + transaction_type)
end
在我已經定義SALT
的初始化(以及我MERCHANT_ID這是在使用在結賬視圖中發佈給商家的表單)。
您的金額和描述是浮動/整數 – kobaltz