Commit 8f8192ce354e5fcb4988e0b6951ee8ad830bd236

Authored by Jun Jiang
Committed by GitHub
2 parents 96e86ac8 742cbe8e
Exists in master

Merge pull request #56 from houdl/gettransferinfo

add gettransferinfo for service
Showing 1 changed file with 23 additions and 0 deletions   Show diff stats
lib/wx_pay/service.rb
@@ -159,6 +159,29 @@ module WxPay @@ -159,6 +159,29 @@ module WxPay
159 r 159 r
160 end 160 end
161 161
  162 + GETTRANSFERINFO_FIELDS = [:partner_trade_no]
  163 + def self.gettransferinfo(params, options = {})
  164 + params = {
  165 + mch_appid: options.delete(:appid) || WxPay.appid,
  166 + mchid: options.delete(:mch_id) || WxPay.mch_id,
  167 + nonce_str: SecureRandom.uuid.tr('-', '')
  168 + }.merge(params)
  169 +
  170 + check_required_options(params, GETTRANSFERINFO_FIELDS)
  171 +
  172 + options = {
  173 + ssl_client_cert: options.delete(:apiclient_cert) || WxPay.apiclient_cert,
  174 + ssl_client_key: options.delete(:apiclient_key) || WxPay.apiclient_key,
  175 + verify_ssl: OpenSSL::SSL::VERIFY_NONE
  176 + }.merge(options)
  177 +
  178 + r = WxPay::Result.new(Hash.from_xml(invoke_remote("#{GATEWAY_URL}/mmpaymkttransfers/gettransferinfo", make_payload(params), options)))
  179 +
  180 + yield r if block_given?
  181 +
  182 + r
  183 + end
  184 +
162 INVOKE_REVERSE_REQUIRED_FIELDS = [:out_trade_no] 185 INVOKE_REVERSE_REQUIRED_FIELDS = [:out_trade_no]
163 def self.invoke_reverse(params, options = {}) 186 def self.invoke_reverse(params, options = {})
164 params = { 187 params = {