Forum: Ruby on Rails suggestion in plugin for amazon payment

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Srikanth J. (Guest)
on 2009-06-01 11:02
Hi,
Please suggest me a good plugin for amazon payment in Rails.
Thanks in advance,
Srikanth J

http://www.srikanthjeeva.blogspot.com
http://www.srikanthj.co.nr
Srikanth J. (Guest)
on 2009-06-09 16:24
HI,
I finally didn't use any plugin for amazon payment, & did with Amazon
simple pay..
It offers a good ruby code, to create checkout button.

here is the code given by amazon for creating button. The Price,return
url can be dynamically changed.

            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
                 <form
action="https://authorize.payments-sandbox.amazon.com/pba/...
                       method="post">
                 STARTFORM

                 form_params.each do |key, value|
                   next unless key and value
                   signed_form +=<<-"FORMELEM"
                     <input type="hidden" name="#{key}" value="#{value}"
>
            FORMELEM
                 end

                 signed_form +=<<-ENDFORM
                     <input type="image"
                            src="https://authorize.payments-sandbox.amazon.com/pba/...
            border="0" >
                 </form>
            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')



For getting amazon aws account, sign up for its service here.
http://aws.amazon.com/

any help mail me,
Thanks,

http://srikanthjeeva.blogspot.com
http://srikanthj.co.nr
This topic is locked and can not be replied to.