Commit 86dc2f9147fcd860145703c429e9270b808e59c1
Committed by
GitHub
Exists in
master
Merge pull request #101 from moohao/patch-2
add gethbinfo method
Showing
1 changed file
with
25 additions
and
0 deletions
Show diff stats
lib/wx_pay/service.rb
... | ... | @@ -450,6 +450,31 @@ module WxPay |
450 | 450 | |
451 | 451 | r |
452 | 452 | end |
453 | + | |
454 | + # 用于商户对已发放的红包进行查询红包的具体信息,可支持普通红包和裂变包。 | |
455 | + GETHBINFO_FIELDS = [:mch_billno, :bill_type] | |
456 | + def self.gethbinfo(params, options = {}) | |
457 | + params = { | |
458 | + appid: options.delete(:appid) || WxPay.appid, | |
459 | + mch_id: options.delete(:mch_id) || WxPay.mch_id, | |
460 | + nonce_str: SecureRandom.uuid.tr('-', ''), | |
461 | + key: options.delete(:key) || WxPay.key | |
462 | + }.merge(params) | |
463 | + | |
464 | + check_required_options(params, GETHBINFO_FIELDS) | |
465 | + | |
466 | + options = { | |
467 | + ssl_client_cert: options.delete(:apiclient_cert) || WxPay.apiclient_cert, | |
468 | + ssl_client_key: options.delete(:apiclient_key) || WxPay.apiclient_key, | |
469 | + verify_ssl: OpenSSL::SSL::VERIFY_NONE | |
470 | + }.merge(options) | |
471 | + | |
472 | + r = WxPay::Result.new(Hash.from_xml(invoke_remote("/mmpaymkttransfers/gethbinfo", make_payload(params), options))) | |
473 | + | |
474 | + yield r if block_given? | |
475 | + | |
476 | + r | |
477 | + end | |
453 | 478 | |
454 | 479 | class << self |
455 | 480 | private | ... | ... |