Commit 2127fbb0bd287d5c155ac8113f4ffeb12feb8458

Authored by Jun Jiang
2 parents 147a5075 2bf3b347
Exists in master

Merge pull request #29 from wikimo/master

#28 fixed close order
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 22  
23 23 r
24 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 44 GENERATE_APP_PAY_REQ_REQUIRED_FIELDS = %i(prepayid noncestr)
27 45 def self.generate_app_pay_req(params, options = {})
... ...