Commit 2bf3b3478e20b60e374e0f036ddd140d3180187e
1 parent
147a5075
Exists in
master
[wikimo] add closeorder
Showing
1 changed file
with
18 additions
and
0 deletions
Show diff stats
lib/wx_pay/service.rb
@@ -22,6 +22,24 @@ module WxPay | @@ -22,6 +22,24 @@ module WxPay | ||
22 | 22 | ||
23 | r | 23 | r |
24 | end | 24 | end |
25 | + | ||
26 | + INVOKE_CLOSEORDER_REQUIRED_FIELDS = %i(out_trade_no) | ||
27 | + def self.invoke_closeorder(params, options = {}) | ||
28 | + params = { | ||
29 | + appid: options.delete(:appid) || WxPay.appid, | ||
30 | + mch_id: options.delete(:mch_id) || WxPay.mch_id, | ||
31 | + key: options.delete(:key) || WxPay.key, | ||
32 | + nonce_str: SecureRandom.uuid.tr('-', '') | ||
33 | + }.merge(params) | ||
34 | + | ||
35 | + check_required_options(params, INVOKE_CLOSEORDER_REQUIRED_FIELDS) | ||
36 | + | ||
37 | + r = invoke_remote("#{GATEWAY_URL}/pay/closeorder", make_payload(params), options) | ||
38 | + | ||
39 | + yield r if block_given? | ||
40 | + | ||
41 | + r | ||
42 | + end | ||
25 | 43 | ||
26 | GENERATE_APP_PAY_REQ_REQUIRED_FIELDS = %i(prepayid noncestr) | 44 | GENERATE_APP_PAY_REQ_REQUIRED_FIELDS = %i(prepayid noncestr) |
27 | def self.generate_app_pay_req(params, options = {}) | 45 | def self.generate_app_pay_req(params, options = {}) |