Last active
August 29, 2015 13:56
Alipay checkout url within three line Ruby code - 三行 Ruby 代码实现支付宝付款地址
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def alipay_url(options) | |
options.merge!(seller_email: EMAIL, partner: ACCOUNT, _input_charset: 'utf-8') | |
options.merge!(sign_type: 'MD5', sign: Digest::MD5.hexdigest(options.sort_by(&:first).to_h.to_param + KEY)) | |
HTTParty.get("https://www.alipay.com/cooperate/gateway.do?#{options.sort.map{ |k, v| "#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}"}.join('&') }") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment