Module: WeixinPay::Pay
- Defined in:
- lib/weixin_pay/pay.rb
Constant Summary collapse
- API_BASE_URL =
"https://api.mch.weixin.qq.com/pay"
- API_MICRPAY_URL =
"#{API_BASE_URL}/micropay"
- API_ORDERQUERY_URL =
"#{API_BASE_URL}/orderquery"
- INVOKE_MICRPAY_REQUIRED_FIELDS =
%w(appid mch_id nonce_str sign body out_trade_no total_fee spbill_create_ip auth_code)
Class Method Summary collapse
Class Method Details
.micrpay(params = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/weixin_pay/pay.rb', line 11 def self.micrpay(params={}) params = { appid: WeixinPay.appid, mch_id: WeixinPay.mch_id, nonce_str: SecureRandom.uuid.tr('-', ''), time_expire: Time.now.since(1.minutes).strftime("%Y%m%d%H%M%S") }.merge(params) # TODO check_required_params(params, INVOKE_MICRPAY_REQUIRED_FIELDS) remote_params = params.merge(sign: WeixinPay::Sign.generate(params)) xml = make_xml(remote_params) post_pay(API_MICRPAY_URL, xml) end |
.orderquery(params = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/weixin_pay/pay.rb', line 26 def self.orderquery(params={}) params = { appid: WeixinPay.appid, mch_id: WeixinPay.mch_id, nonce_str: SecureRandom.uuid.tr('-', '') }.merge(params) # TODO check_required_params(params, INVOKE_MICRPAY_REQUIRED_FIELDS) remote_params = params.merge(sign: WeixinPay::Sign.generate(params)) xml = make_xml(remote_params) post_pay(API_ORDERQUERY_URL, xml) end |