openreceive-rails 0.2.2 → 0.3.0
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: 146123aec012ee584a8b76fd2a0377abb9e972fafd56f5332e67deee15fc7ad3
|
|
4
|
+
data.tar.gz: d38a035c403bffa06b058ed1030a7bb55170cce1e9853c26d8ff71d4698ec6be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4703f944a363b826d607c7e63a3e918fb76465e5e260f54bc59a00e2e84b316ebdfd5909a91943a1bf3e7ce92051216b0c7f35b61a2e6b17a66cf20b81f3e92a
|
|
7
|
+
data.tar.gz: 9b13db6baea87e02685030ef09ec88f741c3bd18b13b30a54189d43e2c3ecb9ba2b7e656c93b1aff2c80bd321d99bd96aebfc99eae0046b8ab0873e914fa0126
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 - 2026-08-26
|
|
4
|
+
|
|
5
|
+
### `config.amount_for` may return a `:description` beside the price
|
|
6
|
+
|
|
7
|
+
One optional display string — what the payer is buying — returned from the same
|
|
8
|
+
hook that already answers the price:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
config.amount_for = lambda do |reference|
|
|
12
|
+
order = Order.find_by(reference: reference)
|
|
13
|
+
next nil unless order
|
|
14
|
+
{ currency: "USD", value: order.total.to_s, description: "#{order.line_items.size} items" }
|
|
15
|
+
end
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The engine peels it off before the amount reaches the minting service, and the
|
|
19
|
+
handler echoes it on the prepare and create responses, where both shipped
|
|
20
|
+
checkout renderers draw it above the amount. Deliberately one string and not a
|
|
21
|
+
line-item schema: OpenReceive owns no orders. The install generator's
|
|
22
|
+
initializer documents it inline.
|
|
23
|
+
|
|
24
|
+
The full release narrative lives in the repository-root
|
|
25
|
+
[CHANGELOG](https://github.com/openreceive/openreceive/blob/master/CHANGELOG.md).
|
|
26
|
+
|
|
27
|
+
## 0.2.4 - 2026-08-26
|
|
28
|
+
|
|
29
|
+
No Ruby changes in this release. 0.2.4 is browser-side only —
|
|
30
|
+
`@openreceive/browser`, `@openreceive/elements`, `@openreceive/react` and
|
|
31
|
+
`@openreceive/provider-data`. This gem is byte-identical to 0.2.3 and ships to
|
|
32
|
+
keep the one-version-for-everything rule, so the engine, the HTTP contract and
|
|
33
|
+
the settlement path are unchanged. The full release narrative lives in the
|
|
34
|
+
repository-root
|
|
35
|
+
[CHANGELOG](https://github.com/openreceive/openreceive/blob/master/CHANGELOG.md).
|
|
36
|
+
|
|
37
|
+
## 0.2.3 - 2026-08-25
|
|
38
|
+
|
|
39
|
+
The Ruby gems release in lockstep with the npm workspace version. The full
|
|
40
|
+
release narrative lives in the repository-root
|
|
41
|
+
[CHANGELOG](https://github.com/openreceive/openreceive/blob/master/CHANGELOG.md);
|
|
42
|
+
entries here are scoped to this gem.
|
|
43
|
+
|
|
44
|
+
- The mounted engine inherits `openreceive-server`'s `POST /checkouts` change:
|
|
45
|
+
the response now carries `payment_methods` alongside `checkout` (HTTP
|
|
46
|
+
contract 0.4.1). No configuration change; hosts using `@openreceive/browser`
|
|
47
|
+
see no difference.
|
|
48
|
+
|
|
3
49
|
## 0.2.2 - 2026-08-25
|
|
4
50
|
|
|
5
51
|
The Ruby gems release in lockstep with the npm workspace version. The full
|
|
@@ -40,10 +40,17 @@ OpenReceive.configure do |config|
|
|
|
40
40
|
# { sats: 1200 }, or nil when there is nothing to pay for (a 404). The
|
|
41
41
|
# engine refuses to serve checkouts until this is set.
|
|
42
42
|
#
|
|
43
|
+
# An optional :description beside the price is what the payer is BUYING, in
|
|
44
|
+
# your own words — one display string the checkout renders above the amount.
|
|
45
|
+
# Without it the payer sees a QR and a number and no sign of what the number
|
|
46
|
+
# is for; OpenReceive owns no line items, so this is the whole of what it can
|
|
47
|
+
# show on its own.
|
|
48
|
+
#
|
|
43
49
|
# TODO(price): look the reference up in your own application, e.g.
|
|
44
50
|
# config.amount_for = lambda do |reference|
|
|
45
51
|
# order = Order.find_by(id: reference)
|
|
46
|
-
# order && { currency: "USD", value: order.total.to_s
|
|
52
|
+
# order && { currency: "USD", value: order.total.to_s,
|
|
53
|
+
# description: "#{order.line_items.size} items" }
|
|
47
54
|
# end
|
|
48
55
|
|
|
49
56
|
# Runs inside the settlement transaction, only for the order's first settled
|
|
@@ -264,9 +264,16 @@ module OpenReceive
|
|
|
264
264
|
def engine_resolve_checkout
|
|
265
265
|
lambda do |action:, request:, reference:, input:, pay_in_asset: nil|
|
|
266
266
|
pricing = %w[checkout.prepare swap.quote checkout.create swap.create].include?(action)
|
|
267
|
-
|
|
268
|
-
raise OpenReceive::Server::NotFoundError, "Unknown reference." if pricing &&
|
|
269
|
-
|
|
267
|
+
price = pricing ? @amount_for.call(reference) : nil
|
|
268
|
+
raise OpenReceive::Server::NotFoundError, "Unknown reference." if pricing && price.nil?
|
|
269
|
+
# `description` — what the payer is buying, in the host's own words — is
|
|
270
|
+
# returned beside the price and peeled off here, so the amount handed to
|
|
271
|
+
# the minting service stays exactly the price.
|
|
272
|
+
amount = price_only(price)
|
|
273
|
+
description = price_description(price)
|
|
274
|
+
if %w[checkout.prepare swap.quote].include?(action)
|
|
275
|
+
next({ amount: amount, description: description }.compact)
|
|
276
|
+
end
|
|
270
277
|
|
|
271
278
|
requested_hash = input["payment_hash"] || input[:payment_hash]
|
|
272
279
|
begin
|
|
@@ -285,6 +292,7 @@ module OpenReceive
|
|
|
285
292
|
|
|
286
293
|
{
|
|
287
294
|
amount: amount,
|
|
295
|
+
description: description,
|
|
288
296
|
payment_hash: payment&.payment_hash,
|
|
289
297
|
checkout: payment&.checkout_data,
|
|
290
298
|
swap_data: payment&.swap_data
|
|
@@ -292,6 +300,25 @@ module OpenReceive
|
|
|
292
300
|
end
|
|
293
301
|
end
|
|
294
302
|
|
|
303
|
+
# The price alone. A host that returns a display string beside it must not
|
|
304
|
+
# have that string reach the amount resolver.
|
|
305
|
+
def price_only(price)
|
|
306
|
+
return price unless price.is_a?(Hash)
|
|
307
|
+
|
|
308
|
+
price.reject { |key, _| key.to_s == "description" }
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
# One optional display string, blank treated as absent.
|
|
312
|
+
def price_description(price)
|
|
313
|
+
return nil unless price.is_a?(Hash)
|
|
314
|
+
|
|
315
|
+
value = price[:description] || price["description"]
|
|
316
|
+
return nil unless value.is_a?(String)
|
|
317
|
+
|
|
318
|
+
trimmed = value.strip
|
|
319
|
+
trimmed.empty? ? nil : trimmed
|
|
320
|
+
end
|
|
321
|
+
|
|
295
322
|
def engine_on_checkout_created
|
|
296
323
|
lambda do |reference:, payment_hash:, checkout:, swap_data: nil, client_ip: nil, **|
|
|
297
324
|
begin
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openreceive-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OpenReceive
|
|
@@ -15,28 +15,28 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.3.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.3.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: openreceive-server
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - '='
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
32
|
+
version: 0.3.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - '='
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.
|
|
39
|
+
version: 0.3.0
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: rails
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|