Module: Chinapay
- Defined in:
- lib/chinapay.rb,
lib/chinapay/config.rb,
lib/chinapay/version.rb,
lib/chinapay/request/alipay.rb,
lib/chinapay/request/tencent.rb,
lib/chinapay/response/alipay.rb,
lib/chinapay/response/tencent.rb
Defined Under Namespace
Constant Summary collapse
- ADAPTER_TYPES =
["alipay", "tenpay", "1002", "1038", "1003", "1052", "1005", "1020", "1024", "1022", "1006", "1008", "1004", "1021", "1009", "1025", "1027", "1032"]
- VERSION =
"1.2.0"
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
- .build_request(adapter, title, total_fee, notify_url, attach) ⇒ Object
- .build_response(params) ⇒ Object
-
.load_config ⇒ Object
配置采用统一的 parter_id key seller.
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/chinapay/config.rb', line 3 def config @config end |
Class Method Details
.build_request(adapter, title, total_fee, notify_url, attach) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/chinapay.rb', line 17 def self.build_request(adapter, title, total_fee, notify_url, attach) adapter = adapter.to_s raise "Not vaid chinapay adapter, it should be in #{ADAPTER_TYPES}" unless ADAPTER_TYPES.include?(adapter) return Chinapay::Request::Alipay.new(title, total_fee, notify_url, attach, nil) if adapter == "alipay" return Chinapay::Request::Tencent.new(title, total_fee, notify_url, attach, '0') if adapter == "tenpay" Chinapay::Request::Tencent.new(title, total_fee, notify_url, attach, adapter) end |
.build_response(params) ⇒ Object
27 28 29 30 31 |
# File 'lib/chinapay.rb', line 27 def self.build_response(params) return Chinapay::Response::Tencent.new(params) if params["sp_billno"].present? return Chinapay::Response::Alipay.new(params) if params["out_trade_no"].present? nil end |
.load_config ⇒ Object
配置采用统一的 parter_id key seller
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/chinapay/config.rb', line 6 def self.load_config begin # filename = "#{Rails.root}/config/chinapay.yml" filename = File.(Rails.root.to_s + "/config/chinapay.yml") @config = YAML.load(File.open(filename))[Rails.env] rescue Exception => e puts " ---\n development:\n tencent:\n parter: 121111XXXX\n key: XXXXXXXXXXXXXXXXXX\n seller: 121111XXXX\n alipay:\n parter: 12111XXXX\n key: XXXXXXX\n seller: [email protected]\n EXAMPLE\n raise \"Please configure your Chinapay settings in \#{filename}.\"\n end\nend\n" |