paymos 1.6.0 → 1.7.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: 5e0c80046042c2f9d6412a4634125c0a4394e9aab174d20d6b6a26fe60517e76
4
- data.tar.gz: 52280f1bd972bf101b857e697addf3d1c115c09e87ae2287fdfc506c83606e09
3
+ metadata.gz: b4b2825ca7de83a212ccb05ee60ca1a00456d4e8db3a87517a3ec9f48601a578
4
+ data.tar.gz: e997c75cd1c6f4ba28856d7d0028c233238f62dbc67d3fe1218cd7094ea9a764
5
5
  SHA512:
6
- metadata.gz: 2a205a28f143426bbbedcafe4240751448d4161d60d7f30650570567a4e5eebf7232a4c0e313ad88853bcaa7e49a4170ddfafe3f0f4ad7e41d6946882e052531
7
- data.tar.gz: ce658911f58df1d6b5f30bdb4f9c4c5894118019e57604b94d29ea759f3b9e2e568ddf0265b818eb33c91e1da05d0cd848fca5afe1e545c27ce3172767c3271d
6
+ metadata.gz: a5400d64070f388f4aa881655cc0e3bd7bec28873e74e9464071415e4303a9363853f9462c14772b547f6467a34add12cda5858c963018998cd81161c1948459
7
+ data.tar.gz: '0364786fcc8214ae4d109feab9f8d9b363efff7810cbfa2514f1b07b707865ded95e6971b043eeb2be33c99255a562010b0969a4b360b5f1368fbe632a771051'
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.7.0] - 2026-11-16
6
+
7
+ - docs(sdk,drupal): document invoice products[] and update OpenAPI snapshot
8
+ - feat(sdk): support invoice products in Ruby SDK and RBS types (8.3)
9
+ - feat(sdk): add products wire conformance fixtures (7.1)
10
+
11
+ ## [1.6.1] - 2026-11-13
12
+
13
+ - fix(plugins,publicweb): SDK webhook credit recipes, CMS recovery, redirects and CSP logs (audit 2026-11-13)
14
+ - docs(sdk): backfill published mirror changelogs across SDKs and MCP
15
+
5
16
  ## [1.6.0] - 2026-11-03
6
17
 
7
18
  - fix(sdk): resolve preflight lint and conformance vector count for autorelease
data/README.md CHANGED
@@ -16,6 +16,7 @@ paymos = Paymos::Client.new(
16
16
  api_secret: ENV.fetch("PAYMOS_API_SECRET")
17
17
  )
18
18
 
19
+ # Compatible amount-only call (products omitted or nil)
19
20
  invoice = paymos.invoices.create(
20
21
  project_id: "prj_...",
21
22
  amount: "10.00",
@@ -28,7 +29,49 @@ end
28
29
  balances = paymos.balances.get
29
30
  ```
30
31
 
31
- Responses are immutable Ruby objects with documented RBS signatures; request
32
+ ### Product line items (`products[]`)
33
+
34
+ Pass optional `products:` (`1..50` `Paymos::InvoiceProduct` instances or Hashes) to display purchase context on hosted checkout, or omit `products:` / pass `products: nil` for a compatible `amount-only` invoice. Each `Paymos::InvoiceProduct` requires `title:` (<= 200 Unicode scalar values), positive integer `quantity:`, and decimal string `unit_amount:` (in the invoice currency); `description:` (plain text, <= 2000 scalars) and `image_url:` (HTTPS URL, <= 2048 scalars) are optional keywords and are omitted on the wire when `nil`.
35
+
36
+ ```ruby
37
+ # 1-item invoice with optional description and image_url
38
+ studio_pro = Paymos::InvoiceProduct.new(
39
+ title: "Studio Pro",
40
+ description: "One-month access",
41
+ image_url: "https://shop.example/images/studio-pro.webp",
42
+ quantity: 2,
43
+ unit_amount: "24.50"
44
+ )
45
+ single_invoice = paymos.invoices.create(
46
+ project_id: "prj_...",
47
+ amount: "47.00",
48
+ currency: "USD",
49
+ external_order_id: "order_product_single",
50
+ products: [studio_pro]
51
+ )
52
+
53
+ # Multi-item cart including a minimal 3-field item (no description / image_url)
54
+ cart_invoice = paymos.invoices.create(
55
+ project_id: "prj_...",
56
+ amount: "59.00",
57
+ currency: "USD",
58
+ external_order_id: "order_product_multi",
59
+ products: [
60
+ studio_pro,
61
+ Paymos::InvoiceProduct.new(title: "Priority Support", quantity: 1, unit_amount: "12.00")
62
+ ]
63
+ )
64
+
65
+ (cart_invoice.order.products || []).each do |item|
66
+ puts "#{item.title} x#{item.quantity} @ #{item.unit_amount}"
67
+ end
68
+ ```
69
+
70
+ - **Authoritative `amount`:** `amount` is the exact order total and is never recomputed from `sum(quantity * unit_amount)`.
71
+ - **First-success replay:** the first successful create freezes `order.products` on the invoice. Replaying the same `external_order_id` with unchanged `(amount, currency, network)` returns HTTP 200 with the original `Paymos::Invoice` and `order.products`, even if `products` changed; changing `(amount, currency, network)` raises `Paymos::ConflictError` (`409 invoice_idempotency_conflict`). Legacy and `amount-only` invoices return `order.products == nil`.
72
+ - **Image/product fallback & webhooks:** invoice creation stores `image_url` without fetching it server-side; if the buyer's browser fails to load an image or an item omits `description`/`image_url`, checkout hides only the missing media/description and keeps payment active. Signed invoice webhooks omit `products`.
73
+
74
+ Responses are immutable Ruby objects with documented RBS signatures (`sig/paymos.rbs`); request
32
75
  keywords remain idiomatic `snake_case` and are converted directly to the Paymos
33
76
  wire contract.
34
77
 
@@ -66,7 +109,6 @@ outcome. Creation returns 201 and an identical replay returns 200; both yield a
66
109
  `Paymos::ConflictError` (409). Missing or foreign refund IDs raise
67
110
  `Paymos::NotFoundError` (404). List periods use RFC 3339 timestamps, and
68
111
  `paymos.refunds.each` provides the same bounded cursor iteration as invoices.
69
- In sandbox, use `paymos.withdrawals.simulate_completion(refund.withdrawal_id)`,
70
112
  In sandbox, use `paymos.refunds.simulate(refund.withdrawal_id, status: 'completed')`,
71
113
  then read the refund again. Refunds have their own list and do not appear in the
72
114
  ordinary withdrawals list.
@@ -83,7 +125,7 @@ channel.networks.each do |rail|
83
125
  end
84
126
 
85
127
  feed = paymos.payment_channel_deposits.read(cursor: saved_cursor, limit: 100)
86
- feed.items.each { |deposit| credit(deposit) }
128
+ feed.items.each { |deposit| credit_deposit(deposit) } # one credit per deposit.id, see below
87
129
  save_cursor(feed.next_cursor)
88
130
  ```
89
131
 
@@ -121,10 +163,40 @@ to get the same typed model the deposit feed returns:
121
163
  case event.event_type
122
164
  when "payment_channel.deposit.confirmed"
123
165
  deposit = Paymos::PaymentChannelDeposit.from(event.data)
124
- credit(deposit.payment_channel_external_id, deposit.net) if deposit.is_final
166
+ credit_deposit(deposit) if deposit.is_final # once per deposit.id, shared with the feed
125
167
  end
126
168
  ```
127
169
 
170
+ The feed and the deposit webhook report the same deposits, so both go through one
171
+ `credit_deposit` keyed by the deposit's own `id` (`pcd_...`). A sketch with the `pg` gem
172
+ (`credited_deposits.deposit_id` is the primary key):
173
+
174
+ ```ruby
175
+ def credit_deposit(deposit)
176
+ return unless deposit.is_final && deposit.project_id == MY_PROJECT_ID && deposit.is_test == MY_IS_TEST
177
+
178
+ db.transaction do |tx|
179
+ # The insert and the balance update commit together or not at all. A second
180
+ # delivery, a second endpoint's copy, or a re-read feed page inserts nothing.
181
+ inserted = tx.exec_params(
182
+ 'INSERT INTO credited_deposits (deposit_id, payer, amount) VALUES ($1, $2, $3::numeric) ' 'ON CONFLICT (deposit_id) DO NOTHING',
183
+ [deposit.id, deposit.payment_channel_external_id, deposit.net]
184
+ )
185
+ if inserted.cmd_tuples == 1
186
+ tx.exec_params('UPDATE balances SET amount = amount + $1::numeric WHERE payer = $2',
187
+ [deposit.net, deposit.payment_channel_external_id])
188
+ end
189
+ end
190
+ end
191
+ ```
192
+
193
+ `event.event_id` identifies one delivery, not one payment. Paymos creates a separate
194
+ event, with its own `event_id`, for every webhook endpoint subscribed to the event, and
195
+ every later event about the same invoice or deposit has its own `event_id` too. Store
196
+ `event_id` to skip a redelivered request, but key money and fulfilment on the business
197
+ identity: the invoice/order for invoice events, the deposit `id` for deposit events.
198
+ Write that key in the same database transaction as the order or balance change.
199
+
128
200
  `confirming` and `reorged` are advisory and may arrive out of order — a `confirming`
129
201
  can land after the `confirmed` for the same deposit, and a `reorged` can be superseded
130
202
  by a later `confirmed`. Credit only on `payment_channel.deposit.confirmed` with