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.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +514 -514
- data/lib/nowpayments/client.rb +295 -271
- data/lib/nowpayments/constants.rb +27 -27
- data/lib/nowpayments/error.rb +21 -21
- data/lib/nowpayments/helpers.rb +44 -44
- data/lib/nowpayments/http.rb +94 -94
- data/lib/nowpayments/ipn.rb +72 -63
- data/lib/nowpayments/version.rb +5 -5
- data/lib/nowpayments.rb +20 -22
- metadata +13 -10
data/lib/nowpayments/client.rb
CHANGED
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def
|
|
31
|
-
@http.
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@http.get('/v1/
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
@http.get('/v1/
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
def
|
|
153
|
-
@http.get(
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def
|
|
157
|
-
@http.get('/v1/
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
# ---
|
|
161
|
-
|
|
162
|
-
def
|
|
163
|
-
@http.get('/v1/
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
def
|
|
177
|
-
@http.
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
@http.
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
@http.
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
def
|
|
207
|
-
raise ArgumentError, 'JWT token is required for
|
|
208
|
-
|
|
209
|
-
@http.post('/v1/
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
@http.
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
@http.post('/v1/sub-partner/
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
def
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
def
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
@http.
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|