From 2ed2421b00af87f2fa3ad37a34321c1b35f143ab Mon Sep 17 00:00:00 2001 From: guochunzhong Date: Tue, 12 Jul 2016 14:57:49 +0800 Subject: [PATCH] Add downloadbill api --- lib/wx_pay/service.rb | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/wx_pay/service.rb b/lib/wx_pay/service.rb index 60613c4..b9bbb47 100644 --- a/lib/wx_pay/service.rb +++ b/lib/wx_pay/service.rb @@ -183,7 +183,24 @@ module WxPay r end - + + DOWNLOAD_BILL_REQUIRED_FIELDS = [:bill_date, :bill_type] + def self.download_bill(params, options = {}) + params = { + appid: options.delete(:appid) || WxPay.appid, + mch_id: options.delete(:mch_id) || WxPay.mch_id, + nonce_str: SecureRandom.uuid.tr('-', ''), + }.merge(params) + + check_required_options(params, DOWNLOAD_BILL_REQUIRED_FIELDS) + + r = invoke_remote("#{GATEWAY_URL}/pay/downloadbill", make_payload(params), options) + + yield r if block_given? + + r + end + def self.sendgroupredpack(params, options={}) params = { wxappid: options.delete(:appid) || WxPay.appid, @@ -255,10 +272,10 @@ module WxPay }.merge(options) ) - if r + begin WxPay::Result.new(Hash.from_xml(r)) - else - nil + rescue REXML::ParseException + r end end end -- libgit2 0.21.0