paymos 1.6.1 → 1.7.1

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: 7bfc8552db30245323684620dc4db5b8e206de6c2cae9eddeab9f80f68c583a7
4
- data.tar.gz: eb8c7eace8288653d5beb401e498c279124891fbe0f8a1f448c4b845644c6b7d
3
+ metadata.gz: 57b262c38d6cb857ca0d294ce81d4597f1bfbfa0424c547d1503d67c679f19e7
4
+ data.tar.gz: 78d77c7ea30e6bfa9a364b69518bd5ce815d4b4346c914adfef1ac684fcc063d
5
5
  SHA512:
6
- metadata.gz: 6200473cb3bb0d8f98403bfa9ed512e27e042ea33cfee95cbdfd09662e323bc3a388931caeda284501832c446b6f9aa937338a6fcaf4098aa945f3732bdbb9d0
7
- data.tar.gz: 53c7e6389ad62f2cc2bc59242c41e49fb096bb2ec565789ea2608e74f0b79decce504be7ec0719f97a1485428879ffa23a561fe5dabae10fc16d038c3a6b3cff
6
+ metadata.gz: 1b7d6b4c2eb4e485f491498b66b15ea078c9ae1b5cfae766f0307a3a565b26ee5f08456f7a3a5c72e8a2b4314a7e5d33167f5a015478791dab5bc554b9de33c3
7
+ data.tar.gz: 8f10f5358a1b2a8d1e0946b1b4bab01064d05ca78ad1edeae824420dad5af26cd6f9beea2b3eefbf3b5cf63ad6751c24eeebfe7c3cc4badcd6b451b24a75a5f8
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.7.1] - 2026-11-17
6
+
7
+ - refactor(checkout): remove product images from invoice products
8
+
9
+ ## [1.7.0] - 2026-11-16
10
+
11
+ - docs(sdk,drupal): document invoice products[] and update OpenAPI snapshot
12
+ - feat(sdk): support invoice products in Ruby SDK and RBS types (8.3)
13
+ - feat(sdk): add products wire conformance fixtures (7.1)
14
+
5
15
  ## [1.6.1] - 2026-11-13
6
16
 
7
17
  - fix(plugins,publicweb): SDK webhook credit recipes, CMS recovery, redirects and CSP logs (audit 2026-11-13)
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,48 @@ 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) is an optional keyword and is omitted on the wire when `nil`.
35
+
36
+ ```ruby
37
+ # 1-item invoice with optional description
38
+ studio_pro = Paymos::InvoiceProduct.new(
39
+ title: "Studio Pro",
40
+ description: "One-month access",
41
+ quantity: 2,
42
+ unit_amount: "24.50"
43
+ )
44
+ single_invoice = paymos.invoices.create(
45
+ project_id: "prj_...",
46
+ amount: "47.00",
47
+ currency: "USD",
48
+ external_order_id: "order_product_single",
49
+ products: [studio_pro]
50
+ )
51
+
52
+ # Multi-item cart including a minimal 3-field item (no description)
53
+ cart_invoice = paymos.invoices.create(
54
+ project_id: "prj_...",
55
+ amount: "59.00",
56
+ currency: "USD",
57
+ external_order_id: "order_product_multi",
58
+ products: [
59
+ studio_pro,
60
+ Paymos::InvoiceProduct.new(title: "Priority Support", quantity: 1, unit_amount: "12.00")
61
+ ]
62
+ )
63
+
64
+ (cart_invoice.order.products || []).each do |item|
65
+ puts "#{item.title} x#{item.quantity} @ #{item.unit_amount}"
66
+ end
67
+ ```
68
+
69
+ - **Authoritative `amount`:** `amount` is the exact order total and is never recomputed from `sum(quantity * unit_amount)`.
70
+ - **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`.
71
+ - **Webhooks:** signed invoice webhooks omit `products`.
72
+
73
+ Responses are immutable Ruby objects with documented RBS signatures (`sig/paymos.rbs`); request
32
74
  keywords remain idiomatic `snake_case` and are converted directly to the Paymos
33
75
  wire contract.
34
76
 
@@ -1133,6 +1133,169 @@
1133
1133
  }
1134
1134
  ]
1135
1135
  }
1136
+ },
1137
+ "invoices": {
1138
+ "authentication": "Payment key with verified HMAC",
1139
+ "create_single_product": {
1140
+ "method": "POST",
1141
+ "path": "/v1/invoices",
1142
+ "body": {
1143
+ "project_id": "prj_1",
1144
+ "amount": "47.00",
1145
+ "currency": "USD",
1146
+ "external_order_id": "order-product-single",
1147
+ "products": [
1148
+ {
1149
+ "title": "Studio Pro",
1150
+ "description": "One-month access",
1151
+ "quantity": 2,
1152
+ "unit_amount": "24.50"
1153
+ }
1154
+ ]
1155
+ },
1156
+ "response": {
1157
+ "invoice_id": "inv_prod_1",
1158
+ "project_id": "prj_1",
1159
+ "status": "awaiting_client",
1160
+ "is_final": false,
1161
+ "is_test": true,
1162
+ "payment_url": "https://pay.paymos.io/i/inv_prod_1",
1163
+ "order": {
1164
+ "external_id": "order-product-single",
1165
+ "amount": "47.00",
1166
+ "currency": "USD",
1167
+ "products": [
1168
+ {
1169
+ "title": "Studio Pro",
1170
+ "description": "One-month access",
1171
+ "quantity": 2,
1172
+ "unit_amount": "24.50"
1173
+ }
1174
+ ]
1175
+ },
1176
+ "created_at": 1700000000,
1177
+ "updated_at": 1700000000
1178
+ }
1179
+ },
1180
+ "create_multi_product": {
1181
+ "method": "POST",
1182
+ "path": "/v1/invoices",
1183
+ "body": {
1184
+ "project_id": "prj_1",
1185
+ "amount": "59.00",
1186
+ "currency": "USD",
1187
+ "external_order_id": "order-product-multi",
1188
+ "products": [
1189
+ {
1190
+ "title": "Studio Pro",
1191
+ "description": "One-month access",
1192
+ "quantity": 2,
1193
+ "unit_amount": "24.50"
1194
+ },
1195
+ {
1196
+ "title": "Priority Support",
1197
+ "quantity": 1,
1198
+ "unit_amount": "12.00"
1199
+ }
1200
+ ]
1201
+ },
1202
+ "response": {
1203
+ "invoice_id": "inv_prod_2",
1204
+ "project_id": "prj_1",
1205
+ "status": "awaiting_client",
1206
+ "is_final": false,
1207
+ "is_test": true,
1208
+ "payment_url": "https://pay.paymos.io/i/inv_prod_2",
1209
+ "order": {
1210
+ "external_id": "order-product-multi",
1211
+ "amount": "59.00",
1212
+ "currency": "USD",
1213
+ "products": [
1214
+ {
1215
+ "title": "Studio Pro",
1216
+ "description": "One-month access",
1217
+ "quantity": 2,
1218
+ "unit_amount": "24.50"
1219
+ },
1220
+ {
1221
+ "title": "Priority Support",
1222
+ "quantity": 1,
1223
+ "unit_amount": "12.00"
1224
+ }
1225
+ ]
1226
+ },
1227
+ "created_at": 1700000000,
1228
+ "updated_at": 1700000000
1229
+ }
1230
+ },
1231
+ "legacy_without_products": {
1232
+ "method": "POST",
1233
+ "path": "/v1/invoices",
1234
+ "body": {
1235
+ "project_id": "prj_1",
1236
+ "amount": "30.00",
1237
+ "currency": "USD",
1238
+ "external_order_id": "order-legacy-1"
1239
+ },
1240
+ "response": {
1241
+ "invoice_id": "inv_legacy_1",
1242
+ "project_id": "prj_1",
1243
+ "status": "awaiting_client",
1244
+ "is_final": false,
1245
+ "is_test": true,
1246
+ "payment_url": "https://pay.paymos.io/i/inv_legacy_1",
1247
+ "order": {
1248
+ "external_id": "order-legacy-1",
1249
+ "amount": "30.00",
1250
+ "currency": "USD"
1251
+ },
1252
+ "created_at": 1700000000,
1253
+ "updated_at": 1700000000
1254
+ }
1255
+ },
1256
+ "null_products": {
1257
+ "method": "POST",
1258
+ "path": "/v1/invoices",
1259
+ "body": {
1260
+ "project_id": "prj_1",
1261
+ "amount": "30.00",
1262
+ "currency": "USD",
1263
+ "external_order_id": "order-null-products-1",
1264
+ "products": null
1265
+ },
1266
+ "response": {
1267
+ "invoice_id": "inv_null_1",
1268
+ "project_id": "prj_1",
1269
+ "status": "awaiting_client",
1270
+ "is_final": false,
1271
+ "is_test": true,
1272
+ "payment_url": "https://pay.paymos.io/i/inv_null_1",
1273
+ "order": {
1274
+ "external_id": "order-null-products-1",
1275
+ "amount": "30.00",
1276
+ "currency": "USD"
1277
+ },
1278
+ "created_at": 1700000000,
1279
+ "updated_at": 1700000000
1280
+ }
1281
+ },
1282
+ "products_wire": {
1283
+ "min_items": 1,
1284
+ "max_items": 50,
1285
+ "required_item_fields": [
1286
+ "title",
1287
+ "quantity",
1288
+ "unit_amount"
1289
+ ],
1290
+ "optional_item_fields": [
1291
+ "description"
1292
+ ],
1293
+ "omit_null_optional_item_fields": true,
1294
+ "quantity_type": "integer",
1295
+ "unit_amount_type": "decimal string",
1296
+ "amount_independent_of_products_sum": true,
1297
+ "excluded_from_webhooks": true
1298
+ }
1136
1299
  }
1137
1300
  }
1138
1301
  }
data/lib/paymos/client.rb CHANGED
@@ -211,7 +211,7 @@ module Paymos
211
211
 
212
212
  class Invoices < Resource
213
213
  def create(project_id:, amount:, currency:, external_order_id:, network: nil,
214
- customer_fee_percent: nil, client_id: nil)
214
+ customer_fee_percent: nil, client_id: nil, products: nil)
215
215
  required_keywords(project_id:, amount:, currency:, external_order_id:)
216
216
  if !customer_fee_percent.nil? && !(customer_fee_percent.is_a?(Integer) && customer_fee_percent.between?(0, 100))
217
217
  raise ArgumentError, 'customer_fee_percent must be between 0 and 100'
@@ -219,6 +219,7 @@ module Paymos
219
219
 
220
220
  payload = { project_id:, amount:, currency:, external_order_id:, network:,
221
221
  customer_fee_percent:, client_id: }.compact
222
+ payload[:products] = serialize_products(products) unless products.nil?
222
223
  Invoice.from(@client.request('POST', '/v1/invoices', payload:))
223
224
  end
224
225
 
@@ -261,6 +262,18 @@ module Paymos
261
262
  missing = values.select { |_name, value| !value.is_a?(String) || value.strip.empty? }.keys
262
263
  raise ArgumentError, "Required values are missing: #{missing.join(', ')}" unless missing.empty?
263
264
  end
265
+
266
+ def serialize_products(products)
267
+ raise ArgumentError, 'products must be an array' unless products.is_a?(Array)
268
+
269
+ products.map do |item|
270
+ raise ArgumentError, 'products items must respond to to_h' unless item.respond_to?(:to_h)
271
+
272
+ item.to_h.transform_keys(&:to_sym).reject do |key, value|
273
+ key == :description && value.nil?
274
+ end
275
+ end
276
+ end
264
277
  end
265
278
 
266
279
  class Withdrawals < Resource
data/lib/paymos/models.rb CHANGED
@@ -79,9 +79,28 @@ module Paymos
79
79
  end
80
80
  end
81
81
 
82
+ class InvoiceProduct < Model
83
+ fields :title, :description, :quantity, :unit_amount,
84
+ required: %i[title quantity unit_amount]
85
+
86
+ def to_h
87
+ super.reject { |key, value| key == :description && value.nil? }
88
+ end
89
+ end
90
+
82
91
  class Order < Model
83
- fields :external_id, :client_id, :amount, :currency, :network,
92
+ fields :external_id, :client_id, :amount, :currency, :network, :products,
84
93
  required: %i[external_id amount currency]
94
+
95
+ def self.from(value)
96
+ model = super
97
+ return model if model.products.nil?
98
+
99
+ raise Error, 'Paymos API order products must be an array' unless model.products.is_a?(Array)
100
+
101
+ products = model.products.map { |item| InvoiceProduct.from(item) }
102
+ new(**model.to_h, products: products)
103
+ end
85
104
  end
86
105
 
87
106
  class Transfer < Model
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paymos
4
- VERSION = '1.6.1'
4
+ VERSION = '1.7.1'
5
5
  end
data/sig/paymos.rbs CHANGED
@@ -73,12 +73,22 @@ module Paymos
73
73
  def to_h: () -> Hash[Symbol, untyped]
74
74
  end
75
75
 
76
+ class InvoiceProduct < Model
77
+ attr_reader title: String
78
+ attr_reader description: String?
79
+ attr_reader quantity: Integer
80
+ attr_reader unit_amount: String
81
+
82
+ def initialize: (title: String, quantity: Integer, unit_amount: String, ?description: String?) -> void
83
+ end
84
+
76
85
  class Order < Model
77
86
  attr_reader external_id: String
78
87
  attr_reader client_id: String?
79
88
  attr_reader amount: String
80
89
  attr_reader currency: String
81
90
  attr_reader network: String?
91
+ attr_reader products: Array[InvoiceProduct]?
82
92
  end
83
93
 
84
94
  class Transfer < Model
@@ -280,7 +290,7 @@ module Paymos
280
290
  end
281
291
 
282
292
  class Invoices
283
- def create: (project_id: String, amount: String, currency: String, external_order_id: String, ?network: String?, ?customer_fee_percent: Integer?, ?client_id: String?) -> Invoice
293
+ def create: (project_id: String, amount: String, currency: String, external_order_id: String, ?network: String?, ?customer_fee_percent: Integer?, ?client_id: String?, ?products: Array[InvoiceProduct | Hash[Symbol | String, untyped]]?) -> Invoice
284
294
  def get: (String invoice_id) -> Invoice
285
295
  def list: (?limit: Integer?, ?cursor: String?, ?status: String | Array[String]?, ?external_order_id: String?, ?project_id: String?, ?created_from: Integer?, ?created_to: Integer?) -> Page[InvoiceListItem]
286
296
  def cancel: (String invoice_id, reason: String) -> Invoice
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paymos
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paymos Labs