wechat_payment 2.0.4 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87f4044d658d3093db1078f065765d207441d6556419de26fd6e7f88169a8467
|
4
|
+
data.tar.gz: 3bc5fbf36af300ca50c15e1ae37523df59da4aa6169f7cac57b696a59a8bfdb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d87869b6dab7c779d1ec4a5f5de801989b5058f9e7f34e7eff4455fc641e2196e2ebc0d2894df5486ec8d1d829fca8e39cf65c91deac5f9c8d16096e774c86cb
|
7
|
+
data.tar.gz: 9cb4c3a15a3422ecfeb1a26d7eaafd20b7274de371b1241c42723b52bec8c7398a8ef56633986b977ebdc5172cdb0f63a73f8f961b11c95fcae7c6c860c7c304
|
@@ -14,10 +14,10 @@ module WechatPayment
|
|
14
14
|
|
15
15
|
enum state: {
|
16
16
|
paid: "paid",
|
17
|
-
|
17
|
+
pending_pay: "pending_pay",
|
18
18
|
refunded: "refunded",
|
19
19
|
failed: "failed"
|
20
|
-
}, _default: "
|
20
|
+
}, _default: "pending_pay"
|
21
21
|
|
22
22
|
# 将部分用户信息保存至订单
|
23
23
|
def set_customer_info
|
@@ -109,7 +109,7 @@ module WechatPayment
|
|
109
109
|
|
110
110
|
# 已退款的金额(包括正在退款的金额)
|
111
111
|
def refunded_fee
|
112
|
-
refund_orders.where(state: [:
|
112
|
+
refund_orders.where(state: [:pending_refund, :refunded]).sum(:refund_fee)
|
113
113
|
end
|
114
114
|
|
115
115
|
# 实际已退的金额
|
@@ -8,10 +8,10 @@ module WechatPayment
|
|
8
8
|
belongs_to :customer, polymorphic: true
|
9
9
|
|
10
10
|
enum state: {
|
11
|
-
|
11
|
+
pending_refund: "pending_refund",
|
12
12
|
refunded: "refunded",
|
13
13
|
failed: "failed"
|
14
|
-
}, _default:
|
14
|
+
}, _default: "pending_refund"
|
15
15
|
|
16
16
|
# 生成退款编号
|
17
17
|
def gen_out_refund_no
|
@@ -62,7 +62,7 @@ module WechatPayment
|
|
62
62
|
|
63
63
|
update(
|
64
64
|
refund_id: result["refund_id"],
|
65
|
-
state: :
|
65
|
+
state: :pending_refund
|
66
66
|
)
|
67
67
|
|
68
68
|
result
|
@@ -44,7 +44,7 @@ module WechatPayment
|
|
44
44
|
result = WechatPayment::Client.handle_payment_notify(notify_data)
|
45
45
|
payment_order = WechatPayment::PaymentOrder.find_by(out_trade_no: notify_data["out_trade_no"])
|
46
46
|
|
47
|
-
if result.success? && payment_order.
|
47
|
+
if result.success? && payment_order.pending_pay?
|
48
48
|
payment_order.with_lock do
|
49
49
|
payment_order.payment_exec_success(result.data)
|
50
50
|
end
|
@@ -60,7 +60,7 @@ module WechatPayment
|
|
60
60
|
result = WechatPayment::Client.handle_refund_notify(notify_data)
|
61
61
|
refund_order = WechatPayment::RefundOrder.find_by(out_refund_no: result.data["out_refund_no"])
|
62
62
|
|
63
|
-
if result.success? && refund_order.
|
63
|
+
if result.success? && refund_order.pending_refund?
|
64
64
|
refund_order.with_lock do
|
65
65
|
refund_order.refund_exec_success(result.data)
|
66
66
|
end
|
@@ -49,20 +49,20 @@ module WechatPayment
|
|
49
49
|
|
50
50
|
# 重新支付,应用场景是: 用户取消了支付后,使用最后一张订单进行支付
|
51
51
|
# @return [WechatPayment::ServiceResult]
|
52
|
-
def repay
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
result = payment_orders.last.repay
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
52
|
+
# def repay
|
53
|
+
# # 如果不是待支付状态
|
54
|
+
# unless pending?
|
55
|
+
# WechatPayment::ServiceResult.new(message: "当前状态不可支付")
|
56
|
+
# end
|
57
|
+
|
58
|
+
# result = payment_orders.last.repay
|
59
|
+
|
60
|
+
# if result.success?
|
61
|
+
# WechatPayment::ServiceResult.new(success: true, data: result.data[:js_payload])
|
62
|
+
# else
|
63
|
+
# WechatPayment::ServiceResult.new(message: result.errors.first[:err_code_des])
|
64
|
+
# end
|
65
|
+
# end
|
66
66
|
|
67
67
|
|
68
68
|
# 退款
|
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.0.
|
4
|
+
version: 2.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|