wechat_payment 2.0.3 → 2.0.7

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: 3ccc823e0ae167b60ffa78ba54e98c559c95c0019167a3c2e5033db6718f741b
4
- data.tar.gz: 68e1de8aa02ac29ebc7d6012173dfdaa0162c493dbcb08f36e55db7909ef38b3
3
+ metadata.gz: 47ac17c0ea1a99ad55e63958da4dfbefc0282f9962ce038a738b4322d09a501c
4
+ data.tar.gz: e61cc08c219cb5c90cb74be1836ada62f120ccb64481e5d2e2be6aa7ed4f7fcb
5
5
  SHA512:
6
- metadata.gz: 6dc4007ff8cbdd1cc8d347ed4d9193e43cddcf683192dae186ecf2b1f4511ce288acf40cffa6f10c66268382fb140f65d984ed9539a27388d6c258022f9c8b3b
7
- data.tar.gz: 7655b449f9e31b5e481b174648ee6019753607addceb45ee0e4e848ce0d3aec11da6ddf1007694c80a51a005c817a3c927f910b3c95310830209ed1e05201d52
6
+ metadata.gz: 6310f34d9941e697640cb0902415cc7dd9ecfdd743c2b02fa0b05d1202f57d81afd262a81d45999046f0b4f2e90dfc42f66c745ed1278339dc08207adb621297
7
+ data.tar.gz: dabde1251f1337d373be190c1dfd23b022d6b5e32ca4b50ceaa6b1a1aeccb54fd1c55cb354b47fdb43846948d3a6847b06f28dc4b926ca4be50b405d20bfc03e
@@ -14,10 +14,10 @@ module WechatPayment
14
14
 
15
15
  enum state: {
16
16
  paid: "paid",
17
- pending: "pending",
17
+ pending_pay: "pending_pay",
18
18
  refunded: "refunded",
19
19
  failed: "failed"
20
- }, _default: "pending"
20
+ }, _default: "pending_pay"
21
21
 
22
22
  # 将部分用户信息保存至订单
23
23
  def set_customer_info
@@ -72,8 +72,8 @@ module WechatPayment
72
72
  # "paySign": "1F5CBC345B86E5DD055F235A22961422",
73
73
  # "orderId": 17
74
74
  # }
75
- def pay
76
- if payment_params.present?
75
+ def pay(repay: false)
76
+ if payment_params.present? && !repay
77
77
  return ServiceResult.new(success: true, data: payment_params, message: "获取支付参数成功")
78
78
  end
79
79
 
@@ -93,7 +93,7 @@ module WechatPayment
93
93
  def repay
94
94
  gen_out_trade_no
95
95
  save
96
- pay
96
+ pay(repay: true)
97
97
  end
98
98
 
99
99
  # 发起退款
@@ -109,7 +109,7 @@ module WechatPayment
109
109
 
110
110
  # 已退款的金额(包括正在退款的金额)
111
111
  def refunded_fee
112
- refund_orders.where(state: [:pending, :refunded]).sum(:refund_fee)
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
- pending: "pending",
11
+ pending_refund: "pending_refund",
12
12
  refunded: "refunded",
13
13
  failed: "failed"
14
- }, _default: :pending
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: :pending
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.pending?
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.pending?
63
+ if result.success? && refund_order.pending_pay?
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
- 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
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
  # 退款
@@ -1,3 +1,3 @@
1
1
  module WechatPayment
2
- VERSION = '2.0.3'
2
+ VERSION = '2.0.7'
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.0.3
4
+ version: 2.0.7
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-19 00:00:00.000000000 Z
11
+ date: 2022-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails