@doswiftly/storefront-operations 16.0.0 → 17.0.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.
package/schema.graphql CHANGED
@@ -880,7 +880,9 @@ type Cart implements Node {
880
880
  """
881
881
  attributes: [CartAttribute!]!
882
882
 
883
- """Available payment methods dla tego cart (shop-configured providers)"""
883
+ """
884
+ Available payment methods dla tego carta — deduplikowane per type, sorted by merchant priority.
885
+ """
884
886
  availablePaymentMethods: [PaymentMethod!]!
885
887
 
886
888
  """
@@ -955,6 +957,11 @@ type Cart implements Node {
955
957
  """
956
958
  requiresShipping: Boolean!
957
959
 
960
+ """
961
+ Optional concrete instrument code selected within `selectedPaymentMethod` (e.g. `"blik"`, `"mb"`, `"154"`). Set gdy klient klika konkretny instrument tile na storefront (per `PaymentMethod.instruments`). Pre-payment intent: skopiowany do `Order.paymentInstrumentCode` przy `cartComplete`. Storefront może cross-reference z `availablePaymentMethods.methods[].instruments[]` żeby dostać `displayName` / `brandImageUrl`. Added by payment-instrument-preselection core sprint Req 3 AC7.
962
+ """
963
+ selectedPaymentInstrumentCode: String
964
+
958
965
  """
959
966
  The payment method currently selected on the cart. Null until the buyer picks a method via `cartSelectPaymentMethod`.
960
967
  """
@@ -982,6 +989,11 @@ type Cart implements Node {
982
989
 
983
990
  """When the cart was last modified (ISO 8601)."""
984
991
  updatedAt: DateTime!
992
+
993
+ """
994
+ Non-fatal advisories computed at query time. Currently emitted: `PAYMENT_SELECTION_STALE` when `selectedPaymentMethod` / `selectedPaymentInstrumentCode` are no longer in live gateway capabilities (storefront re-prompts the buyer). Read-only — backend state is not mutated. Added by payment-instrument-preselection-advanced sub-sprint Adv-2 Req 1.
995
+ """
996
+ warnings: [CartWarning!]!
985
997
  }
986
998
 
987
999
  """Result of `cartAddLines`."""
@@ -1171,6 +1183,30 @@ input CartBuyerIdentityInput {
1171
1183
  phone: String
1172
1184
  }
1173
1185
 
1186
+ """
1187
+ Input for `cartClearPaymentSelection` — explicit deselect mutation. Use when the buyer goes back to the payment method picker w accordion UI bez hack typu re-selectując method. Atomic NULL na wszystkich payment selection fields (method type + provider code + instrument code + legacy method ID). Idempotent — wielokrotne wywołanie = same final state. Added by payment-instrument-preselection-advanced Adv-1 Req 3.1.
1188
+ """
1189
+ input CartClearPaymentSelectionInput {
1190
+ """ID of the cart to clear payment selection on."""
1191
+ cartId: ID!
1192
+ }
1193
+
1194
+ """
1195
+ Result of `cartClearPaymentSelection`. `cart` populated on success z cleared selection fields (`selectedPaymentMethod === null`, `selectedPaymentInstrumentCode === null`). `userErrors` populated gdy cart locked (CONVERTED status → `ALREADY_COMPLETED` code).
1196
+ """
1197
+ type CartClearPaymentSelectionPayload {
1198
+ """The updated cart z cleared payment selection."""
1199
+ cart: Cart
1200
+
1201
+ """
1202
+ Business / validation errors carrying a stable `CartErrorCode` in `code` (e.g. `ALREADY_COMPLETED`).
1203
+ """
1204
+ userErrors: [UserError!]!
1205
+
1206
+ """Non-fatal advisories — the mutation itself succeeded."""
1207
+ warnings: [CartWarning!]!
1208
+ }
1209
+
1174
1210
  """Input for `cartComplete` — finalises the cart into an `Order`."""
1175
1211
  input CartCompleteInput {
1176
1212
  """ID of the cart to complete."""
@@ -1360,6 +1396,11 @@ type CartLine {
1360
1396
  """
1361
1397
  cost: CartLineCost!
1362
1398
 
1399
+ """
1400
+ Recipient details captured for a `GIFT_CARD` line via `cartUpdateGiftCardRecipient`. Null for non-gift-card lines or when no recipient has been set yet — in that case the gift card is delivered to the order `customerEmail` on completion. Use to initialise the "gift recipient" form from cart state on SSR / page reload / deep link instead of keeping it in client-only state.
1401
+ """
1402
+ giftCardRecipient: GiftCardLineRecipient
1403
+
1363
1404
  """
1364
1405
  Stable line identifier. Use it to address the line in `cartUpdateLines` / `cartRemoveLines`.
1365
1406
  """
@@ -1546,15 +1587,27 @@ type CartRemoveLinesPayload {
1546
1587
  warnings: [CartWarning!]!
1547
1588
  }
1548
1589
 
1549
- """Input for `cartSelectPaymentMethod`."""
1590
+ """
1591
+ Input for `cartSelectPaymentMethod` (Intelligent Payment Methods). Method-centric: the buyer picks a category (BLIK, CARD, BANK_TRANSFER, ...) and the backend resolves the preferred provider from `MerchantPaymentConfig` (priority-sorted, merchant-configurable per shop). Optional `preferredProviderCode` + `preferredInstrumentCode` enable instrument-level deep-link na gateway hosted page (skipa default landing).
1592
+ """
1550
1593
  input CartSelectPaymentMethodInput {
1551
1594
  """ID of the cart to update."""
1552
1595
  cartId: ID!
1553
1596
 
1554
1597
  """
1555
- ID of the chosen payment method (matches a `PaymentMethod.id` from `availablePaymentMethods`).
1598
+ Category of the payment method the buyer picked (matches `PaymentMethod.type` from `availablePaymentMethods`).
1599
+ """
1600
+ methodType: PaymentMethodType!
1601
+
1602
+ """
1603
+ Optional gateway-specific instrument code (`blik`, `mb`, `c`, `154`, ...) z `PaymentMethod.instruments[].instrumentCode`. Wymaga ustawienia `preferredProviderCode` — instrument code jest provider-specific. Bez restrictive regex (różne bramki używają `.` / `:` / `/` w przyszłości). SQL injection chroniona przez Prisma parametrized queries. Added by payment-instrument-preselection core sprint Req 3.1.
1604
+ """
1605
+ preferredInstrumentCode: String
1606
+
1556
1607
  """
1557
- paymentMethodId: ID!
1608
+ Optional override of `PaymentMethod.preferredProvider`. Pass a provider code (`payu`, `przelewy24`, ...) from `providersAvailable` when the buyer explicitly picks one (rare — usually the merchant priority is enough). Format: lowercase alphanumerics + underscore + hyphen, 2-50 characters. Renamed from `preferredProviderId` — `*Code` is reserved for lowercase string identifiers, `*Id` for UUIDs.
1609
+ """
1610
+ preferredProviderCode: String
1558
1611
  }
1559
1612
 
1560
1613
  """Result of `cartSelectPaymentMethod`."""
@@ -1802,6 +1855,7 @@ enum CartWarningCode {
1802
1855
  MERCHANDISE_NOT_AVAILABLE
1803
1856
  MERCHANDISE_NOT_ENOUGH_STOCK
1804
1857
  PAYMENTS_AMOUNT_REGION_MISMATCH
1858
+ PAYMENT_SELECTION_STALE
1805
1859
  SHIPPING_METHOD_AUTO_CLEARED
1806
1860
  }
1807
1861
 
@@ -3025,6 +3079,22 @@ enum GiftCardErrorCode {
3025
3079
  NOT_FOUND
3026
3080
  }
3027
3081
 
3082
+ """
3083
+ Recipient details attached to a `GIFT_CARD` line — set with `cartUpdateGiftCardRecipient`. All fields are nullable individually so a partial set (e.g. email only) is representable.
3084
+ """
3085
+ type GiftCardLineRecipient {
3086
+ """Personalised message included with the gift card."""
3087
+ message: String
3088
+
3089
+ """
3090
+ Recipient email — where the gift card code will be delivered on order completion.
3091
+ """
3092
+ recipientEmail: String
3093
+
3094
+ """Recipient display name shown in the gift card email."""
3095
+ recipientName: String
3096
+ }
3097
+
3028
3098
  """Gift card status"""
3029
3099
  enum GiftCardStatus {
3030
3100
  ACTIVE
@@ -3822,6 +3892,11 @@ type Mutation {
3822
3892
  """
3823
3893
  cartApplyGiftCard(input: CartApplyGiftCardInput!): CartApplyGiftCardPayload!
3824
3894
 
3895
+ """
3896
+ Clear all payment selection state on the cart in a single atomic operation. Use for accordion "back to method picker" flows w storefront UI. Idempotent — calling twice yields the same end state. Cart MUSI być `ACTIVE` (CONVERTED carts reject z `ALREADY_COMPLETED`).
3897
+ """
3898
+ cartClearPaymentSelection(input: CartClearPaymentSelectionInput!): CartClearPaymentSelectionPayload!
3899
+
3825
3900
  """
3826
3901
  Finalise the cart into an `Order`. The cart is locked and no longer accepts mutations. Payment is initiated separately via `paymentCreate` — check `order.canCreatePayment` to decide whether to render a "Pay now" button or send the buyer directly to the confirmation page (for offline methods such as cash on delivery). Rate-limited to 5 requests per minute per IP+shop; pass an `idempotencyKey` to guard against duplicate orders on retry.
3827
3902
  """
@@ -3848,7 +3923,7 @@ type Mutation {
3848
3923
  cartRemoveLines(id: ID!, lineIds: [ID!]!): CartRemoveLinesPayload!
3849
3924
 
3850
3925
  """
3851
- Select a payment method on the cart. Validates against the active shop payment methods and currency. The selection is finalised at `cartComplete`; payment itself is initiated via a separate `paymentCreate` mutation after the order is created.
3926
+ Select a payment method on the cart by category (BLIK, CARD, BANK_TRANSFER, ...). Backend resolves the preferred provider from `MerchantPaymentConfig` at `paymentCreate` time. Optional `preferredProviderCode` overrides the merchant priority when the buyer explicitly picks a gateway from `PaymentMethod.providersAvailable`. Optional `preferredInstrumentCode` enables instrument-level deep-link na gateway hosted page (BLIK ekran, mBank flow, etc.) — wymaga `preferredProviderCode`.
3852
3927
  """
3853
3928
  cartSelectPaymentMethod(input: CartSelectPaymentMethodInput!): CartSelectPaymentMethodPayload!
3854
3929
 
@@ -4316,9 +4391,14 @@ type PaymentCreatePayload {
4316
4391
  payment: PaymentSession
4317
4392
 
4318
4393
  """
4319
- Business / validation errors carrying a stable `PaymentErrorCode` in `code` (e.g. `ORDER_NOT_FOUND`, `ORDER_ALREADY_PAID`, `ORDER_NOT_PAYABLE`, `PAYMENT_PROVIDER_NOT_CONFIGURED`, `RETURN_URL_INVALID`, `PAYMENT_FAILED`).
4394
+ Business / validation errors carrying a stable `PaymentErrorCode` in `code` (e.g. `ORDER_NOT_FOUND`, `ORDER_ALREADY_PAID`, `ORDER_NOT_PAYABLE`, `PAYMENT_PROVIDER_NOT_CONFIGURED`, `RETURN_URL_INVALID`, `PAYMENT_FAILED`, `INSTRUMENT_PRESELECTION_FAILED`).
4320
4395
  """
4321
4396
  userErrors: [UserError!]!
4397
+
4398
+ """
4399
+ Non-blocking signals — backend state change context (e.g. instrument auto-cleared, server-side adjustment). Default empty array. Storefront branches per `code` for UI retry hints / analytics events. Added by payment-instrument-preselection-advanced Adv-1 Req 2.3.
4400
+ """
4401
+ warnings: [PaymentWarning!]!
4322
4402
  }
4323
4403
 
4324
4404
  """
@@ -4335,6 +4415,11 @@ enum PaymentInitiationFlow {
4335
4415
  A payment method offered to the buyer at checkout — what to render in the payment picker and pass to `cartSelectPaymentMethod`.
4336
4416
  """
4337
4417
  type PaymentMethod {
4418
+ """
4419
+ True when the buyer can actually pick this method right now. False when the resolving gateway is temporarily unavailable (incident/maintenance) or reported the method as disabled. Storefront UI should gray-out the tile when false instead of hiding it — gives merchants observability into routing failures.
4420
+ """
4421
+ available: Boolean!
4422
+
4338
4423
  """
4339
4424
  Optional buyer-facing description shown under the name (e.g. "Pay with your bank app").
4340
4425
  """
@@ -4350,6 +4435,11 @@ type PaymentMethod {
4350
4435
  """
4351
4436
  id: ID!
4352
4437
 
4438
+ """
4439
+ Concrete instruments exposed by gateway providers w obrębie tej method (BLIK code, branded banks, wallets, card brands). Null gdy żaden provider nie expose'uje granular data dla tej method. Empty array gdy gateway expose'uje ale wszystkie instruments są disabled lub po post-filter (cross-provider leak prevention). Storefront może wyrenderować listę i pass `instrumentCode` jako `preferredInstrumentCode` w `cartSelectPaymentMethod` → gateway deep-link na ten ekran. Added by payment-instrument-preselection core sprint Req 1.
4440
+ """
4441
+ instruments: [PaymentMethodInstrument!]
4442
+
4353
4443
  """
4354
4444
  True when the merchant has marked this method as the default. Pre-select it in the picker.
4355
4445
  """
@@ -4366,9 +4456,19 @@ type PaymentMethod {
4366
4456
  position: Float!
4367
4457
 
4368
4458
  """
4369
- Provider code (e.g. "payu", "stripe", "p24", "cash_on_delivery"). Identifies the integration behind the method; do not branch UI on it use `type` instead.
4459
+ Preferred provider code (UPPERCASE enum) that the backend will route to when the buyer picks this method type and does not specify `preferredProviderCode`. Populated only when at least one provider supports the type. Typed enum since core sprint payment-instrument-preselection (was `String` pre-v9.0).
4370
4460
  """
4371
- provider: String!
4461
+ preferredProvider: ProviderCode
4462
+
4463
+ """
4464
+ Provider code (e.g. `PAYU`, `STRIPE`, `PRZELEWY24`, `CASH_ON_DELIVERY`). Identifies the integration behind the method; do not branch UI on it — use `type` instead. Typed enum since core sprint payment-instrument-preselection (was `String` pre-v9.0).
4465
+ """
4466
+ provider: ProviderCode!
4467
+
4468
+ """
4469
+ Provider codes (UPPERCASE enum: `PAYU`, `PRZELEWY24`, ...) that can fulfil this method type for the current shop, ordered by merchant priority. Pre-select `preferredProvider`; expose the rest only when the buyer wants to choose explicitly. Single-element array when only one provider supports the type. Typed enum since core sprint payment-instrument-preselection (was `[String]` pre-v9.0).
4470
+ """
4471
+ providersAvailable: [ProviderCode!]
4372
4472
 
4373
4473
  """
4374
4474
  ISO 4217 currency codes the method accepts. Null when the method accepts the shop currency without restriction.
@@ -4379,6 +4479,72 @@ type PaymentMethod {
4379
4479
  Category of the method (CARD, BLIK, BANK_TRANSFER, CASH_ON_DELIVERY, OTHER). Drives iconography and copy.
4380
4480
  """
4381
4481
  type: PaymentMethodType!
4482
+
4483
+ """
4484
+ When `available` is false, this enum carries the diagnostic reason (GATEWAY_DOWN, GATEWAY_DISABLED, NO_INSTRUMENTS, CREDENTIALS_INVALID). Null when `available` is true. UI can render context-aware copy ("PayU is temporarily down" vs "Method not configured").
4485
+ """
4486
+ unavailableReason: PaymentMethodUnavailableReason
4487
+ }
4488
+
4489
+ """
4490
+ A single concrete instrument exposed by a gateway provider (e.g. BLIK code, mBank Pay-By-Link, Apple Pay) within a broader PaymentMethod. Pass `instrumentCode` jako `preferredInstrumentCode` w `cartSelectPaymentMethod` żeby gateway deep-link prosto na ten ekran.
4491
+ """
4492
+ type PaymentMethodInstrument {
4493
+ """
4494
+ Optional brand image URL (bank logo, wallet icon). Storefront może użyć jako tile artwork. Null gdy gateway nie expose'uje albo instrument nie ma brand visual (BLIK code).
4495
+ """
4496
+ brandImageUrl: String
4497
+
4498
+ """
4499
+ UX rendering hint — jak storefront powinien wyrenderować ten instrument (prominent button vs branded tile vs dropdown vs radio). Backend-agnostic mapping na visual treatment.
4500
+ """
4501
+ displayHint: PaymentMethodInstrumentDisplayHint!
4502
+
4503
+ """
4504
+ Buyer-facing display name (e.g. "BLIK", "mBank", "ING Bank Śląski", "Apple Pay"). Lokalizacja zazwyczaj PL/EN — multi-language defer post-v1.
4505
+ """
4506
+ displayName: String!
4507
+
4508
+ """
4509
+ True gdy instrument jest currently enabled w gateway live capabilities. Storefront może gray-out tile gdy false zamiast hide (observability dla merchant).
4510
+ """
4511
+ enabled: Boolean!
4512
+
4513
+ """
4514
+ Gateway-specific instrument identifier (PayU: `"blik"`/`"mb"`/`"c"`, P24: numeric ID string `"154"`). Pass jako `preferredInstrumentCode` w `cartSelectPaymentMethod`. Stabilne per provider — gateway nie renumeruje.
4515
+ """
4516
+ instrumentCode: String!
4517
+
4518
+ """
4519
+ Provider obsługujący ten instrument (UPPERCASE enum). Wymagane dla cross-provider dedupe (np. BLIK code dostępny zarówno przez PayU jak P24 — różne instrumenty mimo tej samej method type).
4520
+ """
4521
+ providerCode: ProviderCode!
4522
+
4523
+ """
4524
+ Semantic type klasyfikujący instrument w obrębie method (BLIK code vs bank vs wallet vs card brand). Storefront-facing dispatch dla per-instrument UI components.
4525
+ """
4526
+ type: PaymentMethodInstrumentType!
4527
+ }
4528
+
4529
+ """
4530
+ UX rendering hint dla payment instrument — storefront może przełączać między prominent button / branded tile / dropdown / radio per hint. Backend-agnostic mapping na visual treatment.
4531
+ """
4532
+ enum PaymentMethodInstrumentDisplayHint {
4533
+ BRANDED_TILE
4534
+ DROPDOWN_OPTION
4535
+ PROMINENT_BUTTON
4536
+ RADIO_OPTION
4537
+ }
4538
+
4539
+ """
4540
+ Klasyfikacja konkretnego instrumentu w obrębie PaymentMethod (BLIK kod vs bank vs wallet vs card brand). Storefront-facing typing dla per-instrument UI dispatch.
4541
+ """
4542
+ enum PaymentMethodInstrumentType {
4543
+ BANK
4544
+ BLIK_CODE
4545
+ CARD_BRAND
4546
+ OTHER
4547
+ WALLET
4382
4548
  }
4383
4549
 
4384
4550
  """
@@ -4392,6 +4558,16 @@ enum PaymentMethodType {
4392
4558
  OTHER
4393
4559
  }
4394
4560
 
4561
+ """
4562
+ Why a payment method is currently unavailable. GATEWAY_DOWN/DISABLED/NO_INSTRUMENTS are transient (gateway-side); CREDENTIALS_INVALID needs merchant action in the admin panel.
4563
+ """
4564
+ enum PaymentMethodUnavailableReason {
4565
+ CREDENTIALS_INVALID
4566
+ GATEWAY_DISABLED
4567
+ GATEWAY_DOWN
4568
+ NO_INSTRUMENTS
4569
+ }
4570
+
4395
4571
  """
4396
4572
  Payment session created for an order. Branch on `flow` to launch payment: ONLINE_REDIRECT → redirect to `redirectUrl`; ONLINE_EMBEDDED → render an in-page widget using `clientSecret`; INSTANT_DIRECT → the payment is already settled, check `status`.
4397
4573
  """
@@ -4450,6 +4626,33 @@ type PaymentSettings {
4450
4626
  paymentProviders: [String!]!
4451
4627
  }
4452
4628
 
4629
+ """
4630
+ Non-blocking signal emitted alongside `userErrors` — backend state change context (e.g. an auto-clear, a server-side adjustment) that the storefront may surface as a retry hint or analytics event. Always pre-translated by backend per shop locale.
4631
+ """
4632
+ type PaymentWarning {
4633
+ """
4634
+ Machine-readable code — branch on this to dispatch UI retry hints. Add a new code only when there is a distinct UX response.
4635
+ """
4636
+ code: PaymentWarningCode!
4637
+
4638
+ """
4639
+ Pre-translated user-facing message describing what happened (Polish-first per shop locale).
4640
+ """
4641
+ message: String!
4642
+
4643
+ """
4644
+ Optional additional hint string for UI dispatch — currently unused for `INSTRUMENT_CLEARED_FOR_RETRY` (semantic encoded in `message`). Reserved for future warning codes (e.g. `SLOW_GATEWAY_RESPONSE` → "Retry in 30s").
4645
+ """
4646
+ retryHint: String
4647
+ }
4648
+
4649
+ """
4650
+ Machine-readable code for `PaymentWarning.code`. Non-blocking signals from payment mutations — branch on this to dispatch UI retry hints. `INSTRUMENT_CLEARED_FOR_RETRY` indicates backend auto-cleared a preselected payment instrument after gateway rejection; next `paymentCreate` will land on the gateway default page.
4651
+ """
4652
+ enum PaymentWarningCode {
4653
+ INSTRUMENT_CLEARED_FOR_RETRY
4654
+ }
4655
+
4453
4656
  """
4454
4657
  A pickup point (parcel locker or staffed collection point) attached to a delivery address. The buyer picks it in the carrier widget; it is persisted on the cart shipping address and carried through to the order.
4455
4658
  """
@@ -5140,6 +5343,20 @@ enum ProductVisibility {
5140
5343
  PUBLIC
5141
5344
  }
5142
5345
 
5346
+ """
5347
+ Canonical payment provider identifier (UPPERCASE per GraphQL convention). Use for `Order.paymentMethod`, `Payment.provider`, `PaymentMethod.providersAvailable`, `PaymentMethod.preferredProvider`. Add new providers in `@doswiftly/commerce-policy/provider-codes.ts` SSOT registry.
5348
+ """
5349
+ enum ProviderCode {
5350
+ BANK_TRANSFER
5351
+ CASH_ON_DELIVERY
5352
+ GIFT_CARD
5353
+ MANUAL_PAYMENT
5354
+ PAYU
5355
+ PRZELEWY24
5356
+ STRIPE
5357
+ TEST_GATEWAY
5358
+ }
5359
+
5143
5360
  type Query {
5144
5361
  """List of all currencies supported by the system (ECB rates)"""
5145
5362
  allSupportedCurrencies: [Currency!]!
@@ -5150,7 +5367,7 @@ type Query {
5150
5367
  attributeOptionsSearch(input: AttributeOptionsSearchInput!): AttributeFilterValueConnection!
5151
5368
 
5152
5369
  """
5153
- Payment methods active for the current shop, plus the merchant default. Shop-level independent of cart contents in this iteration. Fetch once for the checkout payment step.
5370
+ Payment methods active for the current shop, plus the merchant default. Returns one row per `PaymentMethodType` (BLIK, CARD, BANK_TRANSFER, ...) with `providersAvailable` (provider codes sorted by merchant priority) and `preferredProvider` (the head of the list). Shop-level — independent of cart contents.
5154
5371
  """
5155
5372
  availablePaymentMethods: AvailablePaymentMethods!
5156
5373