wechat_payment 2.0.2 → 2.0.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c408e5bd232b6b23b55c5bff7f77dfe85d914cd5944df0939b43eb2491a1864
|
4
|
+
data.tar.gz: 55c60366e4261ea7f89cd6d23c1008226e1042c6531ea1dcdabc6c00b66e95b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79cac1d0f255db96a6b794410801753025f32911808bcc03df2297f943f626282ff40eb1a7bd164c4feb3166ebd0519dc9c18660517b0fe91f6e6cb4545ee6e5
|
7
|
+
data.tar.gz: a22ceb04e1a5207698c7acbe02252a667c9b2b7c6a85af9cbdc25c3ff1a61cf100e33a364c2a6fe36c5f1c700aa5f54ac40c7750bff304f32efa6978c4468293
|
@@ -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
|
@@ -72,10 +72,17 @@ module WechatPayment
|
|
72
72
|
# "paySign": "1F5CBC345B86E5DD055F235A22961422",
|
73
73
|
# "orderId": 17
|
74
74
|
# }
|
75
|
-
def pay
|
75
|
+
def pay(repay: false)
|
76
|
+
if payment_params.present? && !repay
|
77
|
+
return ServiceResult.new(success: true, data: payment_params, message: "获取支付参数成功")
|
78
|
+
end
|
79
|
+
|
76
80
|
order_result = WechatPayment::Service.new(self).order
|
77
81
|
if order_result.success?
|
78
82
|
payload = WechatPayment::Client.gen_js_pay_payload(order_result.data).merge(orderId: id).with_indifferent_access
|
83
|
+
|
84
|
+
update(payment_params: payload)
|
85
|
+
|
79
86
|
WechatPayment::ServiceResult.new(success: true, data: payload)
|
80
87
|
else
|
81
88
|
order_result
|
@@ -86,7 +93,7 @@ module WechatPayment
|
|
86
93
|
def repay
|
87
94
|
gen_out_trade_no
|
88
95
|
save
|
89
|
-
pay
|
96
|
+
pay(repay: true)
|
90
97
|
end
|
91
98
|
|
92
99
|
# 发起退款
|
@@ -102,7 +109,7 @@ module WechatPayment
|
|
102
109
|
|
103
110
|
# 已退款的金额(包括正在退款的金额)
|
104
111
|
def refunded_fee
|
105
|
-
refund_orders.where(state: [:
|
112
|
+
refund_orders.where(state: [:pending_refund, :refunded]).sum(:refund_fee)
|
106
113
|
end
|
107
114
|
|
108
115
|
# 实际已退的金额
|
@@ -203,7 +210,8 @@ module WechatPayment
|
|
203
210
|
update(
|
204
211
|
state: :paid,
|
205
212
|
transaction_id: result["transaction_id"],
|
206
|
-
paid_at: Time.current
|
213
|
+
paid_at: Time.current,
|
214
|
+
payment_params: nil
|
207
215
|
)
|
208
216
|
|
209
217
|
if goods.respond_to? :payment_exec_success
|
@@ -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
|