nowpayments-ruby 1.0.0 → 1.0.5

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.
@@ -1,271 +1,295 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'http'
4
- require_relative 'ipn'
5
- require_relative 'constants'
6
-
7
- module NowPayments
8
- # Main client for NOWPayments API
9
- # @see https://documenter.getpostman.com/view/7907941/2s93JusNJt
10
- class Client
11
- def initialize(api_key:, sandbox: false, base_url: nil, timeout: 30_000, ipn_secret: nil)
12
- raise ArgumentError, 'NOWPayments API key is required. Get yours at https://account.nowpayments.io' if api_key.to_s.strip.empty?
13
-
14
- @config = {
15
- api_key: api_key.to_s.strip,
16
- sandbox: sandbox,
17
- base_url: base_url,
18
- timeout: (timeout || 30_000) / 1000.0, # Faraday uses seconds
19
- ipn_secret: ipn_secret
20
- }
21
- @http = Http.new(@config)
22
- end
23
-
24
- # --- Status & Auth ---
25
-
26
- def get_status
27
- @http.get('/v1/status')
28
- end
29
-
30
- def get_auth_token(email, password)
31
- @http.post('/v1/auth', { email: email, password: password })
32
- end
33
-
34
- # --- Currencies ---
35
-
36
- def get_currencies(fixed_rate = nil)
37
- params = fixed_rate.nil? ? {} : { fixed_rate: fixed_rate }
38
- @http.get('/v1/currencies', params)
39
- end
40
-
41
- def get_full_currencies
42
- @http.get('/v1/full-currencies')
43
- end
44
-
45
- def get_merchant_coins(fixed_rate = nil)
46
- params = fixed_rate.nil? ? {} : { fixed_rate: fixed_rate }
47
- @http.get('/v1/merchant/coins', params)
48
- end
49
-
50
- def get_currency(currency)
51
- code = currency.to_s.strip
52
- raise ArgumentError, 'Currency code is required (e.g. "btc", "eth")' if code.empty?
53
-
54
- @http.get("/v1/currencies/#{code}")
55
- end
56
-
57
- # --- Estimate & Min Amount ---
58
-
59
- def get_estimate_price(amount:, currency_from:, currency_to:)
60
- @http.get('/v1/estimate', {
61
- amount: amount,
62
- currency_from: currency_from,
63
- currency_to: currency_to
64
- })
65
- end
66
-
67
- def get_min_amount(currency_from:, currency_to:, fiat_equivalent: nil, is_fixed_rate: nil, is_fee_paid_by_user: nil)
68
- params = { currency_from: currency_from, currency_to: currency_to }
69
- params[:fiat_equivalent] = fiat_equivalent unless fiat_equivalent.nil?
70
- params[:is_fixed_rate] = is_fixed_rate unless is_fixed_rate.nil?
71
- params[:is_fee_paid_by_user] = is_fee_paid_by_user unless is_fee_paid_by_user.nil?
72
- @http.get('/v1/min-amount', params)
73
- end
74
-
75
- # --- Payments ---
76
-
77
- def create_payment(params)
78
- body = params.dup
79
- # Alias fixed_rate → is_fixed_rate (Node.js compatibility, supports both symbol and string keys)
80
- fixed_val = body[:fixed_rate] || body["fixed_rate"]
81
- has_is_fixed = body.key?(:is_fixed_rate) || body.key?("is_fixed_rate")
82
- if !fixed_val.nil? && !has_is_fixed
83
- body[:is_fixed_rate] = fixed_val
84
- body.delete(:fixed_rate)
85
- body.delete("fixed_rate")
86
- end
87
- @http.post('/v1/payment', body)
88
- end
89
-
90
- def get_payment_status(payment_id)
91
- raise ArgumentError, 'Payment ID is required' if payment_id.nil? || payment_id.to_s.strip.empty?
92
-
93
- @http.get("/v1/payment/#{payment_id}")
94
- end
95
-
96
- def get_payments(params = {})
97
- @http.get('/v1/payment/', params)
98
- end
99
-
100
- def update_payment_estimate(payment_id)
101
- @http.post("/v1/payment/#{payment_id}/update-merchant-estimate", {})
102
- end
103
-
104
- # --- Invoices ---
105
-
106
- def create_invoice(params)
107
- @http.post('/v1/invoice', params)
108
- end
109
-
110
- def create_invoice_payment(params)
111
- @http.post('/v1/invoice-payment', params)
112
- end
113
-
114
- # --- Payouts ---
115
-
116
- def validate_payout_address(params)
117
- @http.post('/v1/payout/validate-address', params)
118
- end
119
-
120
- def create_payout(params, jwt_token)
121
- raise ArgumentError, 'JWT token is required for create_payout. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
122
-
123
- @http.post('/v1/payout', params, jwt_token)
124
- end
125
-
126
- def verify_payout(payout_id, verification_code, jwt_token)
127
- raise ArgumentError, 'JWT token is required for verify_payout. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
128
-
129
- @http.post("/v1/payout/#{payout_id}/verify", { verification_code: verification_code }, jwt_token)
130
- end
131
-
132
- def cancel_payout(payout_id, jwt_token)
133
- raise ArgumentError, 'JWT token is required for cancel_payout. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
134
-
135
- @http.post("/v1/payout/#{payout_id}/cancel", { payout_id: payout_id }, jwt_token)
136
- end
137
-
138
- def get_payout_status(payout_id, jwt_token = nil)
139
- @http.get("/v1/payout/#{payout_id}", {}, jwt_token)
140
- end
141
-
142
- def get_payouts(params = {})
143
- @http.get('/v1/payout', params)
144
- end
145
-
146
- # --- Fiat Payouts ---
147
-
148
- def get_fiat_payouts_crypto_currencies(params = {}, jwt_token = nil)
149
- @http.get('/v1/fiat-payouts/crypto-currencies', params, jwt_token)
150
- end
151
-
152
- def get_fiat_payouts_payment_methods(params = {}, jwt_token = nil)
153
- @http.get('/v1/fiat-payouts/payment-methods', params, jwt_token)
154
- end
155
-
156
- def get_fiat_payouts(params = {}, jwt_token = nil)
157
- @http.get('/v1/fiat-payouts', params, jwt_token)
158
- end
159
-
160
- # --- Balance ---
161
-
162
- def get_balance(jwt_token = nil)
163
- @http.get('/v1/balance', {}, jwt_token)
164
- end
165
-
166
- # --- Subscriptions ---
167
-
168
- def get_subscriptions(params = {})
169
- @http.get('/v1/subscriptions', params)
170
- end
171
-
172
- def get_subscription(id)
173
- @http.get("/v1/subscriptions/#{id}")
174
- end
175
-
176
- def delete_subscription(id, jwt_token = nil)
177
- @http.delete("/v1/subscriptions/#{id}", jwt_token)
178
- end
179
-
180
- def get_subscription_plans(params = {})
181
- @http.get('/v1/subscriptions/plans', params)
182
- end
183
-
184
- def get_subscription_plan(id)
185
- @http.get("/v1/subscriptions/plans/#{id}")
186
- end
187
-
188
- def update_subscription_plan(id, updates)
189
- @http.patch("/v1/subscriptions/plans/#{id}", updates)
190
- end
191
-
192
- def create_subscription(params, jwt_token)
193
- raise ArgumentError, 'JWT token is required for create_subscription. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
194
-
195
- @http.post('/v1/subscriptions', params, jwt_token)
196
- end
197
-
198
- # --- Sub-Partners / Custody ---
199
-
200
- def create_sub_partner(name, jwt_token)
201
- raise ArgumentError, 'JWT token is required for create_sub_partner. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
202
-
203
- @http.post('/v1/sub-partner/balance', { name: name }, jwt_token)
204
- end
205
-
206
- def create_sub_partner_payment(params, jwt_token)
207
- raise ArgumentError, 'JWT token is required for create_sub_partner_payment. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
208
-
209
- @http.post('/v1/sub-partner/payment', params, jwt_token)
210
- end
211
-
212
- def get_sub_partners(params = {}, jwt_token = nil)
213
- @http.get('/v1/sub-partner', params, jwt_token)
214
- end
215
-
216
- def get_sub_partner_balance(sub_partner_id)
217
- @http.get("/v1/sub-partner/balance/#{sub_partner_id}")
218
- end
219
-
220
- def get_transfers(params = {}, jwt_token = nil)
221
- @http.get('/v1/sub-partner/transfers', params, jwt_token)
222
- end
223
-
224
- def get_transfer(id, jwt_token = nil)
225
- @http.get("/v1/sub-partner/transfer/#{id}", {}, jwt_token)
226
- end
227
-
228
- def create_transfer(params, jwt_token)
229
- raise ArgumentError, 'JWT token is required for create_transfer. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
230
-
231
- @http.post('/v1/sub-partner/transfer', params, jwt_token)
232
- end
233
-
234
- def deposit(params, jwt_token)
235
- raise ArgumentError, 'JWT token is required for deposit. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
236
-
237
- @http.post('/v1/sub-partner/deposit', params, jwt_token)
238
- end
239
-
240
- def write_off(params, jwt_token = nil)
241
- @http.post('/v1/sub-partner/write-off', params, jwt_token)
242
- end
243
-
244
- # --- Conversions ---
245
-
246
- def create_conversion(params, jwt_token)
247
- raise ArgumentError, 'JWT token is required for create_conversion. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
248
-
249
- @http.post('/v1/conversion', params, jwt_token)
250
- end
251
-
252
- def get_conversion_status(conversion_id, jwt_token)
253
- raise ArgumentError, 'JWT token is required for get_conversion_status. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
254
-
255
- @http.get("/v1/conversion/#{conversion_id}", {}, jwt_token)
256
- end
257
-
258
- def get_conversions(params = {}, jwt_token = nil)
259
- @http.get('/v1/conversion', params, jwt_token)
260
- end
261
-
262
- # --- IPN ---
263
-
264
- def verify_ipn(payload, signature)
265
- secret = @config[:ipn_secret]
266
- raise ArgumentError, 'IPN secret not configured. Pass ipn_secret in constructor or use verify_ipn_signature with explicit secret.' if secret.to_s.strip.empty?
267
-
268
- IPN.verify_signature(payload, signature, secret)
269
- end
270
- end
271
- end
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'http'
4
+ require_relative 'ipn'
5
+ require_relative 'constants'
6
+
7
+ module NowPayments
8
+ # Main client for NOWPayments API
9
+ # @see https://documenter.getpostman.com/view/7907941/2s93JusNJt
10
+ class Client
11
+ def initialize(api_key:, sandbox: false, base_url: nil, timeout: 30_000, ipn_secret: nil)
12
+ raise ArgumentError, 'NOWPayments API key is required. Get yours at https://account.nowpayments.io' if api_key.to_s.strip.empty?
13
+
14
+ # Accept seconds (<=100) or milliseconds (>100)
15
+ t = timeout || 30_000
16
+ timeout_sec = t.to_f > 100 ? t.to_f / 1000.0 : t.to_f
17
+
18
+ @config = {
19
+ api_key: api_key.to_s.strip,
20
+ sandbox: sandbox,
21
+ base_url: base_url,
22
+ timeout: timeout_sec,
23
+ ipn_secret: ipn_secret
24
+ }
25
+ @http = Http.new(@config)
26
+ end
27
+
28
+ # --- Status & Auth ---
29
+
30
+ def get_status
31
+ @http.get('/v1/status')
32
+ end
33
+
34
+ def get_auth_token(email, password)
35
+ @http.post('/v1/auth', { email: email, password: password })
36
+ end
37
+
38
+ # --- Currencies ---
39
+
40
+ def get_currencies(fixed_rate = nil)
41
+ params = fixed_rate.nil? ? {} : { fixed_rate: fixed_rate }
42
+ @http.get('/v1/currencies', params)
43
+ end
44
+
45
+ def get_full_currencies
46
+ @http.get('/v1/full-currencies')
47
+ end
48
+
49
+ def get_merchant_coins(fixed_rate = nil)
50
+ params = fixed_rate.nil? ? {} : { fixed_rate: fixed_rate }
51
+ @http.get('/v1/merchant/coins', params)
52
+ end
53
+
54
+ def get_currency(currency)
55
+ code = currency.to_s.strip
56
+ raise ArgumentError, 'Currency code is required (e.g. "btc", "eth")' if code.empty?
57
+
58
+ require 'uri'
59
+ @http.get("/v1/currencies/#{URI.encode_www_form_component(code.to_s)}")
60
+ end
61
+
62
+ # --- Estimate & Min Amount ---
63
+
64
+ def get_estimate_price(amount:, currency_from:, currency_to:)
65
+ @http.get('/v1/estimate', {
66
+ amount: amount,
67
+ currency_from: currency_from,
68
+ currency_to: currency_to
69
+ })
70
+ end
71
+
72
+ def get_min_amount(currency_from:, currency_to:, fiat_equivalent: nil, is_fixed_rate: nil, is_fee_paid_by_user: nil)
73
+ params = { currency_from: currency_from, currency_to: currency_to }
74
+ params[:fiat_equivalent] = fiat_equivalent unless fiat_equivalent.nil?
75
+ params[:is_fixed_rate] = is_fixed_rate unless is_fixed_rate.nil?
76
+ params[:is_fee_paid_by_user] = is_fee_paid_by_user unless is_fee_paid_by_user.nil?
77
+ @http.get('/v1/min-amount', params)
78
+ end
79
+
80
+ # --- Payments ---
81
+
82
+ def create_payment(params)
83
+ body = params.dup
84
+ # Alias fixed_rate → is_fixed_rate (Node.js compatibility, supports both symbol and string keys)
85
+ fixed_val = body[:fixed_rate] || body["fixed_rate"]
86
+ has_is_fixed = body.key?(:is_fixed_rate) || body.key?("is_fixed_rate")
87
+ if !fixed_val.nil? && !has_is_fixed
88
+ body[:is_fixed_rate] = fixed_val
89
+ body.delete(:fixed_rate)
90
+ body.delete("fixed_rate")
91
+ end
92
+ @http.post('/v1/payment', body)
93
+ end
94
+
95
+ def get_payment_status(payment_id)
96
+ raise ArgumentError, 'Payment ID is required' if payment_id.nil? || payment_id.to_s.strip.empty?
97
+
98
+ @http.get("/v1/payment/#{payment_id}")
99
+ end
100
+
101
+ def get_payments(params = {}, jwt_token = nil)
102
+ @http.get('/v1/payment/', params, jwt_token)
103
+ end
104
+
105
+ def update_payment_estimate(payment_id)
106
+ raise ArgumentError, 'Payment ID is required' if payment_id.to_s.strip.empty?
107
+
108
+ @http.post("/v1/payment/#{payment_id}/update-merchant-estimate", nil)
109
+ end
110
+
111
+ # --- Invoices ---
112
+
113
+ def create_invoice(params)
114
+ @http.post('/v1/invoice', params)
115
+ end
116
+
117
+ def create_invoice_payment(params)
118
+ @http.post('/v1/invoice-payment', params)
119
+ end
120
+
121
+ # --- Payouts ---
122
+
123
+ def validate_payout_address(params)
124
+ @http.post('/v1/payout/validate-address', params)
125
+ end
126
+
127
+ def create_payout(params, jwt_token)
128
+ raise ArgumentError, 'JWT token is required for create_payout. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
129
+
130
+ @http.post('/v1/payout', params, jwt_token)
131
+ end
132
+
133
+ def verify_payout(payout_id, verification_code, jwt_token)
134
+ raise ArgumentError, 'JWT token is required for verify_payout. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
135
+
136
+ @http.post("/v1/payout/#{payout_id}/verify", { verification_code: verification_code }, jwt_token)
137
+ end
138
+
139
+ def cancel_payout(payout_id, jwt_token)
140
+ raise ArgumentError, 'JWT token is required for cancel_payout. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
141
+
142
+ @http.post('/v1/payout/w_id/cancel', { payout_id: payout_id }, jwt_token)
143
+ end
144
+
145
+ def get_payout_fee(currency, amount)
146
+ raise ArgumentError, 'Currency is required (e.g. "btc", "eth")' if currency.to_s.strip.empty?
147
+ raise ArgumentError, 'Amount is required' if amount.nil?
148
+
149
+ @http.get('/v1/payout/fee', { currency: currency, amount: amount })
150
+ end
151
+
152
+ def get_payout_status(payout_id, jwt_token = nil)
153
+ @http.get("/v1/payout/#{payout_id}", {}, jwt_token)
154
+ end
155
+
156
+ def get_payouts(params = {})
157
+ @http.get('/v1/payout', params)
158
+ end
159
+
160
+ # --- Fiat Payouts ---
161
+
162
+ def get_fiat_payouts_crypto_currencies(params = {}, jwt_token = nil)
163
+ @http.get('/v1/fiat-payouts/crypto-currencies', params, jwt_token)
164
+ end
165
+
166
+ def get_fiat_payouts_payment_methods(params = {}, jwt_token = nil)
167
+ @http.get('/v1/fiat-payouts/payment-methods', params, jwt_token)
168
+ end
169
+
170
+ def get_fiat_payouts(params = {}, jwt_token = nil)
171
+ @http.get('/v1/fiat-payouts', params, jwt_token)
172
+ end
173
+
174
+ # --- Balance ---
175
+
176
+ def get_balance(jwt_token = nil)
177
+ @http.get('/v1/balance', {}, jwt_token)
178
+ end
179
+
180
+ # --- Subscriptions ---
181
+
182
+ def get_subscriptions(params = {})
183
+ @http.get('/v1/subscriptions', params)
184
+ end
185
+
186
+ def get_subscription(id)
187
+ @http.get("/v1/subscriptions/#{id}")
188
+ end
189
+
190
+ def delete_subscription(id, jwt_token = nil)
191
+ @http.delete("/v1/subscriptions/#{id}", jwt_token)
192
+ end
193
+
194
+ def get_subscription_plans(params = {})
195
+ @http.get('/v1/subscriptions/plans', params)
196
+ end
197
+
198
+ def get_subscription_plan(id)
199
+ @http.get("/v1/subscriptions/plans/#{id}")
200
+ end
201
+
202
+ def update_subscription_plan(id, updates)
203
+ @http.patch("/v1/subscriptions/plans/#{id}", updates)
204
+ end
205
+
206
+ def create_subscription(params, jwt_token)
207
+ raise ArgumentError, 'JWT token is required for create_subscription. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
208
+
209
+ @http.post('/v1/subscriptions', params, jwt_token)
210
+ end
211
+
212
+ # --- Sub-Partners / Custody ---
213
+
214
+ def create_sub_partner(name, jwt_token)
215
+ raise ArgumentError, 'JWT token is required for create_sub_partner. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
216
+
217
+ @http.post('/v1/sub-partner/balance', { name: name }, jwt_token)
218
+ end
219
+
220
+ def create_sub_partner_payment(params, jwt_token)
221
+ raise ArgumentError, 'JWT token is required for create_sub_partner_payment. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
222
+
223
+ body = params.dup
224
+ is_fixed_val = body[:is_fixed_rate] || body['is_fixed_rate']
225
+ has_fixed = body.key?(:fixed_rate) || body.key?('fixed_rate')
226
+ if !is_fixed_val.nil? && !has_fixed
227
+ body[:fixed_rate] = is_fixed_val
228
+ body.delete(:is_fixed_rate)
229
+ body.delete('is_fixed_rate')
230
+ end
231
+ @http.post('/v1/sub-partner/payment', body, jwt_token)
232
+ end
233
+
234
+ def get_sub_partners(params = {}, jwt_token = nil)
235
+ @http.get('/v1/sub-partner', params, jwt_token)
236
+ end
237
+
238
+ def get_sub_partner_balance(sub_partner_id)
239
+ @http.get("/v1/sub-partner/balance/#{sub_partner_id}")
240
+ end
241
+
242
+ def get_transfers(params = {}, jwt_token = nil)
243
+ @http.get('/v1/sub-partner/transfers', params, jwt_token)
244
+ end
245
+
246
+ def get_transfer(id, jwt_token = nil)
247
+ @http.get("/v1/sub-partner/transfer/#{id}", {}, jwt_token)
248
+ end
249
+
250
+ def create_transfer(params, jwt_token)
251
+ raise ArgumentError, 'JWT token is required for create_transfer. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
252
+
253
+ @http.post('/v1/sub-partner/transfer', params, jwt_token)
254
+ end
255
+
256
+ def deposit(params, jwt_token)
257
+ raise ArgumentError, 'JWT token is required for deposit. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
258
+
259
+ @http.post('/v1/sub-partner/deposit', params, jwt_token)
260
+ end
261
+
262
+ def write_off(params, jwt_token)
263
+ raise ArgumentError, 'JWT token is required for write_off. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
264
+
265
+ @http.post('/v1/sub-partner/write-off', params, jwt_token)
266
+ end
267
+
268
+ # --- Conversions ---
269
+
270
+ def create_conversion(params, jwt_token)
271
+ raise ArgumentError, 'JWT token is required for create_conversion. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
272
+
273
+ @http.post('/v1/conversion', params, jwt_token)
274
+ end
275
+
276
+ def get_conversion_status(conversion_id, jwt_token)
277
+ raise ArgumentError, 'JWT token is required for get_conversion_status. Call get_auth_token first.' if jwt_token.to_s.strip.empty?
278
+
279
+ @http.get("/v1/conversion/#{conversion_id}", {}, jwt_token)
280
+ end
281
+
282
+ def get_conversions(params = {}, jwt_token = nil)
283
+ @http.get('/v1/conversion', params, jwt_token)
284
+ end
285
+
286
+ # --- IPN ---
287
+
288
+ def verify_ipn(payload, signature)
289
+ secret = @config[:ipn_secret]
290
+ raise ArgumentError, 'IPN secret not configured. Pass ipn_secret in constructor or use verify_ipn_signature with explicit secret.' if secret.to_s.strip.empty?
291
+
292
+ IPN.verify_signature(payload, signature, secret)
293
+ end
294
+ end
295
+ end
@@ -1,27 +1,27 @@
1
- # frozen_string_literal: true
2
-
3
- module NowPayments
4
- PRODUCTION_URL = "https://api.nowpayments.io"
5
- SANDBOX_URL = "https://api-sandbox.nowpayments.io"
6
-
7
- PAYMENT_STATUSES = %w[
8
- waiting confirming confirmed spending sending
9
- partially_paid finished failed refunded expired
10
- ].freeze
11
-
12
- PAYMENT_DONE_STATUSES = %w[finished failed refunded expired].freeze
13
- PAYMENT_PENDING_STATUSES = %w[waiting confirming confirmed spending sending partially_paid].freeze
14
-
15
- PAYMENT_STATUS_LABELS = {
16
- "waiting" => "Awaiting payment",
17
- "confirming" => "Confirming",
18
- "confirmed" => "Confirmed",
19
- "spending" => "Processing",
20
- "sending" => "Sending to wallet",
21
- "partially_paid" => "Partially paid",
22
- "finished" => "Completed",
23
- "failed" => "Failed",
24
- "refunded" => "Refunded",
25
- "expired" => "Expired"
26
- }.freeze
27
- end
1
+ # frozen_string_literal: true
2
+
3
+ module NowPayments
4
+ PRODUCTION_URL = "https://api.nowpayments.io"
5
+ SANDBOX_URL = "https://api-sandbox.nowpayments.io"
6
+
7
+ PAYMENT_STATUSES = %w[
8
+ waiting confirming confirmed spending sending
9
+ partially_paid finished failed refunded expired
10
+ ].freeze
11
+
12
+ PAYMENT_DONE_STATUSES = %w[finished failed refunded expired].freeze
13
+ PAYMENT_PENDING_STATUSES = %w[waiting confirming confirmed spending sending partially_paid].freeze
14
+
15
+ PAYMENT_STATUS_LABELS = {
16
+ "waiting" => "Awaiting payment",
17
+ "confirming" => "Confirming",
18
+ "confirmed" => "Confirmed",
19
+ "spending" => "Processing",
20
+ "sending" => "Sending to wallet",
21
+ "partially_paid" => "Partially paid",
22
+ "finished" => "Completed",
23
+ "failed" => "Failed",
24
+ "refunded" => "Refunded",
25
+ "expired" => "Expired"
26
+ }.freeze
27
+ end