hi,
Amazon is Doing a great job in rails Payments.
here is the ruby code for generation of button.
require 'base64'
require 'openssl'
module PayNowWidgetUtils
def generate_signed_form(access_key, aws_secret_key, form_params)
form_params['accessKey'] = access_key
str_to_sign = ""
form_params.keys.sort.each { |k| str_to_sign += "#{k}#{form_params[k]}" }
digest = OpenSSL::Digest::Digest.new('sha1')
hmac = OpenSSL::HMAC.digest(digest, aws_secret_key, str_to_sign)
form_params['signature'] = Base64.encode64(hmac).chomp
signed_form =<<-STARTFORM
ENDFORM
return signed_form
end
end
include PayNowWidgetUtils
ACCESS_KEY = 'your amazon aws access key'
SECRET_KEY = 'your amazon aws secret key'
print generate_signed_form(ACCESS_KEY, SECRET_KEY,
'amount' => 'USD 100',
'description' => 'Test Button',
'referenceId' => 'txn1102',
'returnUrl' => 'http://localhost:3000/success',
'abandonUrl' => 'http://localhost:3000/fail')
amazon aws signup..
http://aws.amazon.com/
use a sandbox account for doing test case.
No comments:
Post a Comment