Skip to content

Instantly share code, notes, and snippets.

@swordray
Last active August 29, 2015 13:56
Show Gist options
  • Save swordray/8882330 to your computer and use it in GitHub Desktop.
Save swordray/8882330 to your computer and use it in GitHub Desktop.
Alipay checkout url within three line Ruby code - 三行 Ruby 代码实现支付宝付款地址
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