Class: Onepay::SwiftpassRequest
- Inherits:
-
Object
- Object
- Onepay::SwiftpassRequest
- Defined in:
- lib/onepay/request/swiftpass.rb
Constant Summary collapse
- GATEWAY_URL =
'https://pay.swiftpass.cn/pay/gateway'.freeze
Instance Attribute Summary collapse
-
#order_id ⇒ Object
Returns the value of attribute order_id.
-
#title ⇒ Object
Returns the value of attribute title.
-
#total_fee ⇒ Object
Returns the value of attribute total_fee.
Instance Method Summary collapse
Instance Attribute Details
#order_id ⇒ Object
Returns the value of attribute order_id.
9 10 11 |
# File 'lib/onepay/request/swiftpass.rb', line 9 def order_id @order_id end |
#title ⇒ Object
Returns the value of attribute title.
9 10 11 |
# File 'lib/onepay/request/swiftpass.rb', line 9 def title @title end |
#total_fee ⇒ Object
Returns the value of attribute total_fee.
9 10 11 |
# File 'lib/onepay/request/swiftpass.rb', line 9 def total_fee @total_fee end |
Instance Method Details
#url ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/onepay/request/swiftpass.rb', line 11 def url params = { service: 'pay.weixin.wappay', mch_id: Onepay.config['swiftpass']['mch_id'], out_trade_no: @order_id, body: @title, total_fee: @total_fee, mch_create_ip: Onepay.config['swiftpass']['mch_create_ip'], notify_url: Onepay.config['swiftpass']['notify_url'], device_info: 'iOS_WAP', mch_app_name: '给玩', mch_app_id: 'com.geiwan666', nonce_str: SecureRandom.uuid.tr('-', '') } params = params.merge(sign: md5_sort(params)) resp = RestClient.post( GATEWAY_URL, xmlify_payload(params), { accept: :xml } ) Rails.logger.fatal GATEWAY_URL Rails.logger.fatal xmlify_payload(params) Rails.logger.fatal resp.body result = Hash.from_xml(resp.body) if result['xml']['status'] == '0' && result['xml']['result_code'] == '0' return result['xml']['pay_info'] end nil end |