Sha256: 5169d3d81bc190abfcff88cafa23663b8206c5ff7b6c1cd93b80309e1065b767

Contents?: true

Size: 910 Bytes

Versions: 3

Compression:

Stored size: 910 Bytes

Contents

require 'securerandom'

module Wechat
  module Pay
    #
    module Redpack
      def redpack(transaction_id, openid, params = {})
        post\
          '/mmpaymkttransfers/sendredpack',
          params.merge(
            mch_billno: tran_id(transaction_id),
            wxappid: @wxappid, re_openid: openid
          )
      end

      def group_redpack(transaction_id, openid, params = {})
        post\
          '/mmpaymkttransfers/sendgroupredpack',
          params.merge(
            mch_billno: tran_id(transaction_id),
            wxappid: @wxappid, re_openid: openid
          )
      end

      def redpack_info(transaction_id)
        post\
          '/mmpaymkttransfers/gethbinfo',
          mch_billno: tran_id(transaction_id),
          bill_type: 'MCHT', appid: @wxappid
      end

      private

      def tran_id(origin)
        format('%s%s', @mch_id, origin)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wechat-api-0.2.1 lib/wechat/pay/redpack.rb
wechat-api-0.2.0 lib/wechat/pay/redpack.rb
wechat-api-0.1.3 lib/wechat/pay/redpack.rb