Commit 46d39014f109a44cc979d4d28c7776616066d102
1 parent
79784bf1
Exists in
master
添加刷卡支付的接口。 WxPay::Service.invoke_micropay
Showing
1 changed file
with
16 additions
and
0 deletions
Show diff stats
lib/wx_pay/service.rb
@@ -93,6 +93,22 @@ module WxPay | @@ -93,6 +93,22 @@ module WxPay | ||
93 | r | 93 | r |
94 | end | 94 | end |
95 | 95 | ||
96 | + INVOKE_MICROPAY_REQUIRED_FIELDS = %i(body out_trade_no total_fee spbill_create_ip auth_code) | ||
97 | + def self.invoke_micropay(params) | ||
98 | + params = { | ||
99 | + appid: WxPay.appid, | ||
100 | + mch_id: WxPay.mch_id, | ||
101 | + nonce_str: SecureRandom.uuid.tr('-', '') | ||
102 | + }.merge(params) | ||
103 | + puts params | ||
104 | + check_required_options(params, INVOKE_MICROPAY_REQUIRED_FIELDS) | ||
105 | + | ||
106 | + r = invoke_remote "#{GATEWAY_URL}/pay/micropay", make_payload(params) | ||
107 | + | ||
108 | + yield(r) if block_given? | ||
109 | + | ||
110 | + r | ||
111 | + end | ||
96 | 112 | ||
97 | private | 113 | private |
98 | 114 |