wechat_payment 2.1.0 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c976e72ae7aec4d893bb8682f324f69759ee2c42a62efa19d7363931798c21bb
4
- data.tar.gz: 1069c1c332dc0253a3e57b9c3301ff293e6accbdb279791892623d09db23d361
3
+ metadata.gz: 553d692e4ca6343ab5659e22bf5cf76c734dc1d4109cae1ceeb5426b4f1bff9a
4
+ data.tar.gz: dc9290c8e36be4e101600126b8080676fc86a5145582e7272081819c826bc5dd
5
5
  SHA512:
6
- metadata.gz: '09eb12bc79a0dbd83e6dba6c3f2d67becd956b28665013e77ca30bfddd3ec51be79b6473b287096b7c1fe055014e532b8fb3133af146575c06190f56dbacfdcd'
7
- data.tar.gz: 12228e2ea147aca00e1ee29e25c6d30956e4519fd98645cbec05f1de6e3057ae0d8a77ccac6eac6cae9ebb50f14bd88334f50a1e2ae43e2be6f4da3865d09612
6
+ metadata.gz: 874bce827cb9a321d398ae57cfb3a073c5a6368bccdcc44e0092c8a972cbf14bb248aa183ae560cf2b4532a2178d67f460d51400a4e04ebcf02a04cf57316cbd
7
+ data.tar.gz: 6bfd37db07f20ca87bfb210249e36170e4cad6fef2904106d46034e6c539b1cfae3a6e891f4cabb1276aaa5f2976592969b79667dbc94584aeab6d543f5a9f62
@@ -21,11 +21,13 @@ module WechatPayment
21
21
 
22
22
  if order_result.success?
23
23
  message = "发起支付成功"
24
- WechatPayment::PaymentLogger.info { "{ msg: '#{message}', params: #{order_params}, result: #{order_result} }" }
24
+ log_content = { message:, params: order_params, result: order_result }.to_json
25
+ WechatPayment::PaymentLogger.info { log_content }
25
26
  WechatPayment::SuccessResult.new(data: order_result, message:, message_kind: :payment_apply_success)
26
27
  else
27
28
  message = "发起支付失败"
28
- WechatPayment::PaymentLogger.error { "{ msg: '#{message}', params: #{order_params}, result: #{order_result} }" }
29
+ log_content = { message: , params: order_params, result: order_result }.to_json
30
+ WechatPayment::PaymentLogger.error { log_content }
29
31
  WechatPayment::FailureResult.new(error: order_result, message:, message_kind: :payment_apply_failed)
30
32
  end
31
33
  end
@@ -46,11 +48,13 @@ module WechatPayment
46
48
 
47
49
  if refund_result.success?
48
50
  message = '发起退款成功'
49
- WechatPayment::RefundLogger.info { "{ msg: '#{message}', params: #{refund_params}, result: #{refund_result}" }
51
+ log_content = { message:, params: refund_params, result: refund_result}.to_json
52
+ WechatPayment::RefundLogger.info { log_content }
50
53
  WechatPayment::SuccessResult.new(data: refund_result, message:, message_kind: :refund_apply_success)
51
54
  else
52
55
  message = "发起退款失败"
53
- WechatPayment::RefundLogger.error { "{ msg: '#{message}', params: #{refund_params}, result: #{refund_result}" }
56
+ log_content = { message:, params: refund_params, result: refund_result }.to_json
57
+ WechatPayment::RefundLogger.error { log_content }
54
58
  WechatPayment::FailureResult.new(error: refund_result, message:, message_kind: :refund_apply_failed)
55
59
  end
56
60
  end
@@ -64,18 +68,20 @@ module WechatPayment
64
68
  def self.handle_payment_notify(notify_data)
65
69
  if !WechatPayment::Sign.verify?(notify_data)
66
70
  message = "回调签名验证失败"
67
- WechatPayment::PaymentLogger.error { "{ msg: '#{message}', error: #{notify_data} }" }
71
+ WechatPayment::PaymentLogger.error { { message: , error: notify_data }.to_json }
68
72
  WechatPayment::FailureResult.new(error: notify_data, message:, message_kind: :validate_sign_failed)
69
73
  end
70
74
 
71
75
  result = WechatPayment::InvokeResult.new(notify_data)
72
76
  if result.success?
73
77
  message = "支付执行成功"
74
- WechatPayment::PaymentLogger.info { "{ msg: '#{message}', callback: #{notify_data} }" }
78
+ log_content = { message:, callback: notify_data }.to_json
79
+ WechatPayment::PaymentLogger.info { log_content }
75
80
  WechatPayment::SuccessResult.new(data: notify_data, message:, message_kind: :payment_exec_success)
76
81
  else
77
82
  message = "支付执行失败"
78
- WechatPayment::PaymentLogger.error{ "{ msg: '#{message}', callback: #{notify_data} }" }
83
+ log_content = { message:, callback: notify_data }.to_json
84
+ WechatPayment::PaymentLogger.error { log_content }
79
85
  WechatPayment::FailureResult.new(error: notify_data, message:, message_kind: :payment_exec_failed)
80
86
  end
81
87
  end
@@ -87,11 +93,13 @@ module WechatPayment
87
93
  result = WechatPayment::InvokeResult.new(notify_data)
88
94
  if result.success?
89
95
  message = "退款执行成功"
90
- WechatPayment::RefundLogger.info { "{ msg: '#{message}', callback: #{notify_data} }" }
96
+ log_content = { message:, callback: notify_data }.to_json
97
+ WechatPayment::RefundLogger.info { log_content }
91
98
  WechatPayment::SuccessResult.new(data: notify_data, message:, message_kind: :refund_exec_success)
92
99
  else
93
100
  message = "退款执行失败"
94
- WechatPayment::RefundLogger.error { "{ msg: '#{message}', callback: #{notify_data} }" }
101
+ log_content = { message:, callback: notify_data}.to_json
102
+ WechatPayment::RefundLogger.error { log_content }
95
103
  WechatPayment::FailureResult.new(error: notify_data, message:, message_kind: :refund_exec_failed)
96
104
  end
97
105
  end
@@ -42,7 +42,13 @@ module WechatPayment
42
42
  )
43
43
 
44
44
  unless user_goods.save
45
- return WechatPayment::FailureResult.new(error: user_goods.error,
45
+ log_content = {
46
+ message: "商品中间表 #{user_goods_model.table_name} 插入数据失败",
47
+ error: user_goods.errors.full_messages
48
+ }.to_json
49
+
50
+ WechatPayment::Logger.info { log_content }
51
+ return WechatPayment::FailureResult.new(error: user_goods.errors.full_messages,
46
52
  message: "商品中间表 #{user_goods_model.table_name} 插入数据失败",
47
53
  message_kind: :create_user_goods_failed)
48
54
  end
@@ -59,7 +65,9 @@ module WechatPayment
59
65
  WechatPayment::SuccessResult.new(data: payment_order, message:, message_kind: :create_payment_order_success)
60
66
  else
61
67
  message = "支付订单创建失败"
62
- WechatPayment::FailureResult.new(error: user_goods.error, message:, message_kind: :create_payment_order_failed)
68
+ log_content = { message:, error: payment_order.errors.full_messages }.to_json
69
+ WechatPayment::Logger.error { log_content }
70
+ WechatPayment::FailureResult.new(error: user_goods.errors.full_messages, message:, message_kind: :create_payment_order_failed)
63
71
  end
64
72
  end
65
73
 
@@ -1,5 +1,9 @@
1
1
 
2
2
  class WechatPayment::Logger
3
+ def self.tags
4
+ ["WechatPayment"]
5
+ end
6
+
3
7
  %w{ info error warn fatal }.each do |level|
4
8
  define_singleton_method level do |content = "", &block|
5
9
  Rails.logger.tagged *self.tags do
@@ -15,7 +15,7 @@ module WechatPayment
15
15
  message_type: nil)
16
16
 
17
17
  self.success = success
18
- self.data = data
18
+ self.data = (data || {}).with_indifferent_access
19
19
  self.error = error
20
20
  self.message = message
21
21
  self.message_type = message_type
@@ -1,3 +1,3 @@
1
1
  module WechatPayment
2
- VERSION = '2.1.0'
2
+ VERSION = '2.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wechat_payment
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-16 00:00:00.000000000 Z
11
+ date: 2022-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -98,7 +98,6 @@ files:
98
98
  - lib/wechat_payment/logger.rb
99
99
  - lib/wechat_payment/missing_key_error.rb
100
100
  - lib/wechat_payment/payment_logger.rb
101
- - lib/wechat_payment/r_logger.rb
102
101
  - lib/wechat_payment/refund_logger.rb
103
102
  - lib/wechat_payment/service_result.rb
104
103
  - lib/wechat_payment/sign.rb
@@ -126,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
125
  - !ruby/object:Gem::Version
127
126
  version: '0'
128
127
  requirements: []
129
- rubygems_version: 3.3.7
128
+ rubygems_version: 3.3.13
130
129
  signing_key:
131
130
  specification_version: 4
132
131
  summary: Summary of WechatPayment.
@@ -1,36 +0,0 @@
1
- module WechatPayment
2
- class RLogger
3
- def initialize
4
- raise Exceptions::InitializeDenied.new("please use 'ILogger.make' instead of 'ILogger.new'")
5
- end
6
-
7
- class << self
8
- def make(log_file)
9
- @logger ||= {}
10
-
11
- log_file_name = if log_file.class.in? [String, Symbol]
12
- log_file_name = log_file.to_sym
13
-
14
- unless log_file_name.to_s.end_with? ".log"
15
- log_file_name = "#{log_file_name}.log"
16
- end
17
-
18
- "#{root_path}/#{log_file_name}"
19
- elsif log_file.respond_to? :to_path
20
- log_file.to_path
21
- else
22
- raise Exceptions::UnsupportdParamType.new("log file parameter only support 'File' or 'String' Type.")
23
- end
24
-
25
- # 如果已经存在日志对象,则返回已有的日志对象
26
- @logger[log_file_name] ||= ::Logger.new(log_file_name)
27
- end
28
-
29
- def root_path
30
- @root ||= "#{Rails.root}/log"
31
- end
32
- end
33
-
34
-
35
- end
36
- end