wechat-pay

所属分类:支付接口
开发工具:Ruby
文件大小:0KB
下载次数:0
上传日期:2021-07-07 05:32:48
上 传 者sh-1993
说明:  微信支付,,
(wechat-pay,,)

文件列表:
Gemfile (94, 2021-07-06)
LICENSE (1082, 2021-07-06)
LICENSE.txt (1068, 2021-07-06)
Rakefile (244, 2021-07-06)
lib/ (0, 2021-07-06)
lib/wechatpay.rb (544, 2021-07-06)
lib/wechatpay/ (0, 2021-07-06)
lib/wechatpay/service.rb (1968, 2021-07-06)
lib/wechatpay/sign.rb (359, 2021-07-06)
lib/wechatpay/utils.rb (1070, 2021-07-06)
lib/wechatpay/version.rb (41, 2021-07-06)
spec/ (0, 2021-07-06)
spec/spec_helper.rb (96, 2021-07-06)
spec/wechatpay/ (0, 2021-07-06)
spec/wechatpay/sign_spec.rb (589, 2021-07-06)
spec/wechatpay/utils_spec.rb (657, 2021-07-06)
wechatpay.gemspec (1158, 2021-07-06)

# Wechatpay A gem to deal with Wechatpay. The Wechatpay official document can be found [here](http://mch.weixin.qq.com/wiki/doc/api/index.html). You will receive the backend document when you get the Wechatpay access. ## Installation Add this line to your application's Gemfile: gem 'wechatpay', '~> 0.0.1' And then execute: $ bundle Or install it yourself as: $ gem install wechatpay ## Usage ### Configuration ```ruby Wechatpay.configure do |w| w.app_id = 'wx123456' w.mch_id = 'abcdefg' w.payment_key = 'abc123' end ``` The params contains: - app_id: 公众账号ID - mch_id: 微信商户账号 - payment_key: 商户支付秘钥 ### Unified Order/统一下单 ```ruby options = { body: 'awesome product name' out_trade_no: '20150101030320204', total_fee: 100, # in cents spbill_create_ip: '127.0.0.1', notify_url: 'http://example.com/notify', trade_type: "JSAPI", openid: '123123123' } response = Wechatpay::Service.unified_order(options) prepay_id = response["prepay_id"] ``` ### Refund/退款 ```ruby options = { out_trade_no: '20150101030320204', out_refund_no: '334443222222222', total_fee: 10000, refund_fee: 10000, refund_fee_type: 'CNY' } Wechatpay::Service.refund(options, cert, cert_pwd) ``` ### Generate payment params ```ruby params = Wechatpay::Service.pay_params(prepay_id) # { # timestamp: 0, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符 # nonceStr: '', // 支付签名随机串,不长于 32 位 # package: '', // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***) # signType: '', // 签名方式,默认为'SHA1',使用新版支付需传入'MD5' # paySign: '', // 支付签名 # } ``` ## Contributing 1. Fork it ( https://github.com/[my-github-username]/wechatpay/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request

近期下载者

相关文件


收藏者