@vtex/faststore 0.0.7 → 0.0.8

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.
Files changed (411) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/actions.json +152 -1
  3. package/dist/catalog.json +1264 -142
  4. package/dist/cli/index.d.ts +512 -63
  5. package/dist/cli/index.js +2098 -686
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/cli/server-runtime.js +44 -24
  8. package/dist/cli/server-runtime.js.map +1 -1
  9. package/dist/client.d.ts +5 -1
  10. package/dist/client.js +5 -1
  11. package/dist/components.d.ts +34 -7
  12. package/dist/components.js +38 -11
  13. package/dist/content-types.json +523 -0
  14. package/dist/core/dist/define-component.d.ts +6 -1
  15. package/dist/docs/account-access-gate.md +4 -4
  16. package/dist/docs/account-address-book.md +519 -0
  17. package/dist/docs/account-entry-point.md +1 -1
  18. package/dist/docs/account-menu.md +5 -5
  19. package/dist/docs/alert-dialog.md +2 -2
  20. package/dist/docs/billing-address.md +17 -9
  21. package/dist/docs/card-entry.md +37 -6
  22. package/dist/docs/cardholder-document.md +16 -14
  23. package/dist/docs/cart-item.md +1 -1
  24. package/dist/docs/cart.md +8 -8
  25. package/dist/docs/client-profile-fieldset.md +7 -5
  26. package/dist/docs/copy-text.md +84 -0
  27. package/dist/docs/document-field.md +8 -8
  28. package/dist/docs/footer-link-group.md +2 -2
  29. package/dist/docs/header-root.md +1 -1
  30. package/dist/docs/incentives.md +2 -2
  31. package/dist/docs/logo.md +5 -5
  32. package/dist/docs/my-account-profile.md +4 -4
  33. package/dist/docs/navigation-link-list.md +2 -2
  34. package/dist/docs/navigation-link.md +3 -3
  35. package/dist/docs/order-cancel.md +52 -0
  36. package/dist/docs/order-delivery-address.md +63 -0
  37. package/dist/docs/order-delivery-group.md +83 -0
  38. package/dist/docs/order-details-back.md +41 -0
  39. package/dist/docs/order-details-header.md +48 -0
  40. package/dist/docs/order-list-row.md +46 -0
  41. package/dist/docs/order-list-search.md +101 -0
  42. package/dist/docs/order-list-views.md +97 -0
  43. package/dist/docs/order-list.md +94 -0
  44. package/dist/docs/order-payment.md +94 -0
  45. package/dist/docs/order-placed-date.md +49 -0
  46. package/dist/docs/order-placed-payment-summary.md +13 -15
  47. package/dist/docs/order-placed.md +225 -0
  48. package/dist/docs/order-progress.md +88 -0
  49. package/dist/docs/order-status-badge.md +91 -0
  50. package/dist/docs/order-summary.md +53 -0
  51. package/dist/docs/payment-method-badges.md +14 -3
  52. package/dist/docs/place-order.md +13 -9
  53. package/dist/docs/saved-cards.md +2 -2
  54. package/dist/docs/select.md +19 -6
  55. package/dist/docs/session.md +1 -1
  56. package/dist/docs/shipping-address.md +1 -1
  57. package/dist/docs/sign-in-redirect.md +6 -6
  58. package/dist/docs/toast.md +7 -3
  59. package/dist/index.d.ts +6 -2
  60. package/dist/index.js +2 -1
  61. package/dist/internal/client.d.ts +6 -1
  62. package/dist/internal/client.js +7 -2
  63. package/dist/internal/server.d.ts +6 -2
  64. package/dist/internal/server.js +6 -2
  65. package/dist/matter/account-access-gate/account-access-gate.d.ts +2 -1
  66. package/dist/matter/account-access-gate/account-access-gate.js +19 -16
  67. package/dist/matter/account-access-gate/account-access-gate.js.map +1 -1
  68. package/dist/matter/account-address-book/account-address-book-delete.d.ts +60 -0
  69. package/dist/matter/account-address-book/account-address-book-delete.js +184 -0
  70. package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -0
  71. package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +19 -0
  72. package/dist/matter/account-address-book/account-address-book-deliverability.js +50 -0
  73. package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -0
  74. package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +42 -0
  75. package/dist/matter/account-address-book/account-address-book-form-parts.js +146 -0
  76. package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -0
  77. package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +25 -0
  78. package/dist/matter/account-address-book/account-address-book-profile-notice.js +72 -0
  79. package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -0
  80. package/dist/matter/account-address-book/account-address-book.d.ts +120 -0
  81. package/dist/matter/account-address-book/account-address-book.js +469 -0
  82. package/dist/matter/account-address-book/account-address-book.js.map +1 -0
  83. package/dist/matter/account-address-book/account-address-country-switch.js +59 -0
  84. package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -0
  85. package/dist/matter/account-address-book/account-address-country.d.ts +36 -0
  86. package/dist/matter/account-address-book/account-address-country.js +151 -0
  87. package/dist/matter/account-address-book/account-address-country.js.map +1 -0
  88. package/dist/matter/account-address-book/account-address-first-line.js +11 -0
  89. package/dist/matter/account-address-book/account-address-first-line.js.map +1 -0
  90. package/dist/matter/account-address-book/account-address-form-context.d.ts +55 -0
  91. package/dist/matter/account-address-book/account-address-form-context.js +14 -0
  92. package/dist/matter/account-address-book/account-address-form-context.js.map +1 -0
  93. package/dist/matter/account-address-book/account-address-form.d.ts +85 -0
  94. package/dist/matter/account-address-book/account-address-form.js +946 -0
  95. package/dist/matter/account-address-book/account-address-form.js.map +1 -0
  96. package/dist/matter/account-address-book/account-address-postal-autofill.js +189 -0
  97. package/dist/matter/account-address-book/account-address-postal-autofill.js.map +1 -0
  98. package/dist/matter/account-address-book/account-address-record.d.ts +26 -0
  99. package/dist/matter/account-address-book/account-address-record.js +138 -0
  100. package/dist/matter/account-address-book/account-address-record.js.map +1 -0
  101. package/dist/matter/account-entry-point/account-entry-point.js +11 -11
  102. package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
  103. package/dist/matter/account-menu/account-menu.d.ts +7 -3
  104. package/dist/matter/account-menu/account-menu.js +69 -28
  105. package/dist/matter/account-menu/account-menu.js.map +1 -1
  106. package/dist/matter/billing-address/billing-address.d.ts +30 -17
  107. package/dist/matter/billing-address/billing-address.js +128 -33
  108. package/dist/matter/billing-address/billing-address.js.map +1 -1
  109. package/dist/matter/breadcrumb/breadcrumb.js +2 -2
  110. package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
  111. package/dist/matter/card-entry/card-capture.js +4 -3
  112. package/dist/matter/card-entry/card-capture.js.map +1 -1
  113. package/dist/matter/card-entry/card-entry.d.ts +5 -3
  114. package/dist/matter/card-entry/card-entry.js +77 -27
  115. package/dist/matter/card-entry/card-entry.js.map +1 -1
  116. package/dist/matter/cardholder-document/cardholder-document.d.ts +10 -9
  117. package/dist/matter/cardholder-document/cardholder-document.js +36 -16
  118. package/dist/matter/cardholder-document/cardholder-document.js.map +1 -1
  119. package/dist/matter/cart/cart.d.ts +7 -2
  120. package/dist/matter/cart/cart.js +29 -26
  121. package/dist/matter/cart/cart.js.map +1 -1
  122. package/dist/matter/cart-item/cart-item.js +2 -2
  123. package/dist/matter/cart-item/cart-item.js.map +1 -1
  124. package/dist/matter/client-preferences/client-preferences-fieldset.js +1 -1
  125. package/dist/matter/client-profile-form/client-profile-fieldset.js +8 -5
  126. package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
  127. package/dist/matter/identity-edit/identity-edit.js +3 -3
  128. package/dist/matter/identity-edit/identity-edit.js.map +1 -1
  129. package/dist/matter/identity-summary/identity-summary.js +2 -2
  130. package/dist/matter/identity-summary/identity-summary.js.map +1 -1
  131. package/dist/matter/my-account-profile/my-account-profile.d.ts +3 -3
  132. package/dist/matter/my-account-profile/my-account-profile.js +4 -4
  133. package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
  134. package/dist/matter/order-cancel/order-cancel.d.ts +110 -0
  135. package/dist/matter/order-cancel/order-cancel.js +344 -0
  136. package/dist/matter/order-cancel/order-cancel.js.map +1 -0
  137. package/dist/matter/order-delivery-address/order-delivery-address.d.ts +73 -0
  138. package/dist/matter/order-delivery-address/order-delivery-address.js +172 -0
  139. package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -0
  140. package/dist/matter/order-delivery-group/order-delivery-group.d.ts +128 -0
  141. package/dist/matter/order-delivery-group/order-delivery-group.js +408 -0
  142. package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -0
  143. package/dist/matter/order-details-header/order-details-header.d.ts +104 -0
  144. package/dist/matter/order-details-header/order-details-header.js +190 -0
  145. package/dist/matter/order-details-header/order-details-header.js.map +1 -0
  146. package/dist/matter/order-list/customer-orders-filter.d.ts +12 -0
  147. package/dist/matter/order-list/customer-orders-filter.js +30 -0
  148. package/dist/matter/order-list/customer-orders-filter.js.map +1 -0
  149. package/dist/matter/order-list/order-list.d.ts +121 -0
  150. package/dist/matter/order-list/order-list.js +395 -0
  151. package/dist/matter/order-list/order-list.js.map +1 -0
  152. package/dist/matter/order-list-row/order-list-row.d.ts +44 -0
  153. package/dist/matter/order-list-row/order-list-row.js +127 -0
  154. package/dist/matter/order-list-row/order-list-row.js.map +1 -0
  155. package/dist/matter/order-list-search/order-list-search.d.ts +72 -0
  156. package/dist/matter/order-list-search/order-list-search.js +296 -0
  157. package/dist/matter/order-list-search/order-list-search.js.map +1 -0
  158. package/dist/matter/order-list-views/order-list-views.d.ts +65 -0
  159. package/dist/matter/order-list-views/order-list-views.js +154 -0
  160. package/dist/matter/order-list-views/order-list-views.js.map +1 -0
  161. package/dist/matter/order-payment/order-payment.d.ts +83 -0
  162. package/dist/matter/order-payment/order-payment.js +258 -0
  163. package/dist/matter/order-payment/order-payment.js.map +1 -0
  164. package/dist/matter/order-placed/order-placed-deliveries.d.ts +145 -0
  165. package/dist/matter/order-placed/order-placed-deliveries.js +380 -0
  166. package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -0
  167. package/dist/matter/order-placed/order-placed.d.ts +122 -0
  168. package/dist/matter/order-placed/order-placed.js +452 -0
  169. package/dist/matter/order-placed/order-placed.js.map +1 -0
  170. package/dist/matter/order-placed-date/order-placed-date.d.ts +45 -0
  171. package/dist/matter/order-placed-date/order-placed-date.js +92 -0
  172. package/dist/matter/order-placed-date/order-placed-date.js.map +1 -0
  173. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +5 -8
  174. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +29 -81
  175. package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
  176. package/dist/matter/order-progress/order-progress.d.ts +85 -0
  177. package/dist/matter/order-progress/order-progress.js +203 -0
  178. package/dist/matter/order-progress/order-progress.js.map +1 -0
  179. package/dist/matter/order-summary/order-summary.d.ts +81 -0
  180. package/dist/matter/order-summary/order-summary.js +192 -0
  181. package/dist/matter/order-summary/order-summary.js.map +1 -0
  182. package/dist/matter/payment/cardholder-document-rule.d.ts +35 -0
  183. package/dist/matter/payment/cardholder-document-rule.js +35 -0
  184. package/dist/matter/payment/cardholder-document-rule.js.map +1 -0
  185. package/dist/matter/payment/payment-card-capture.js +38 -23
  186. package/dist/matter/payment/payment-card-capture.js.map +1 -1
  187. package/dist/matter/payment/payment-controller.js +11 -0
  188. package/dist/matter/payment/payment-controller.js.map +1 -1
  189. package/dist/matter/payment/payment-method-badges.js +4 -2
  190. package/dist/matter/payment/payment-method-badges.js.map +1 -1
  191. package/dist/matter/payment/payment.js +11 -0
  192. package/dist/matter/payment/payment.js.map +1 -1
  193. package/dist/matter/payment/use-payment-method-selection.d.ts +39 -0
  194. package/dist/matter/payment/use-payment-method-selection.js +30 -2
  195. package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
  196. package/dist/matter/payment/use-payment-submit-gate.d.ts +16 -2
  197. package/dist/matter/payment/use-payment-submit-gate.js +42 -14
  198. package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
  199. package/dist/matter/place-order/place-order.d.ts +12 -7
  200. package/dist/matter/place-order/place-order.js +126 -103
  201. package/dist/matter/place-order/place-order.js.map +1 -1
  202. package/dist/matter/pricing/pricing.js +5 -5
  203. package/dist/matter/pricing/pricing.js.map +1 -1
  204. package/dist/matter/region/region.js +1 -1
  205. package/dist/matter/saved-cards/saved-cards.js +26 -15
  206. package/dist/matter/saved-cards/saved-cards.js.map +1 -1
  207. package/dist/matter/session/session.js +2 -2
  208. package/dist/matter/session/session.js.map +1 -1
  209. package/dist/matter/shipping-address/country-descriptors.d.ts +1 -0
  210. package/dist/matter/shipping-address/country-descriptors.js +23 -1
  211. package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
  212. package/dist/matter/shipping-address/shipping-address.js +62 -14
  213. package/dist/matter/shipping-address/shipping-address.js.map +1 -1
  214. package/dist/matter/shipping-simulator/shipping-simulator.d.ts +1 -1
  215. package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
  216. package/dist/matter/sign-in-redirect/sign-in-redirect.js +48 -10
  217. package/dist/matter/sign-in-redirect/sign-in-redirect.js.map +1 -1
  218. package/dist/matter/variant-selector/variant-selector.js +2 -2
  219. package/dist/matter/variant-selector/variant-selector.js.map +1 -1
  220. package/dist/particles/address-summary/address-summary.js +2 -2
  221. package/dist/particles/address-summary/address-summary.js.map +1 -1
  222. package/dist/particles/alert-dialog/alert-dialog.d.ts +5 -1
  223. package/dist/particles/alert-dialog/alert-dialog.js +5 -2
  224. package/dist/particles/alert-dialog/alert-dialog.js.map +1 -1
  225. package/dist/particles/copy-text/copy-text.d.ts +28 -0
  226. package/dist/particles/copy-text/copy-text.js +140 -0
  227. package/dist/particles/copy-text/copy-text.js.map +1 -0
  228. package/dist/particles/document-field/document-field.d.ts +34 -5
  229. package/dist/particles/document-field/document-field.js +115 -19
  230. package/dist/particles/document-field/document-field.js.map +1 -1
  231. package/dist/particles/field/field.js +1 -1
  232. package/dist/particles/field/field.js.map +1 -1
  233. package/dist/particles/footer-link-group/footer-link-group.d.ts +6 -2
  234. package/dist/particles/footer-link-group/footer-link-group.js +18 -7
  235. package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
  236. package/dist/particles/incentives/incentives.d.ts +6 -2
  237. package/dist/particles/incentives/incentives.js +7 -2
  238. package/dist/particles/incentives/incentives.js.map +1 -1
  239. package/dist/particles/logo/logo.d.ts +3 -2
  240. package/dist/particles/logo/logo.js +20 -8
  241. package/dist/particles/logo/logo.js.map +1 -1
  242. package/dist/particles/navigation-link/navigation-link.d.ts +2 -3
  243. package/dist/particles/navigation-link/navigation-link.js +4 -4
  244. package/dist/particles/navigation-link/navigation-link.js.map +1 -1
  245. package/dist/particles/navigation-link-list/navigation-link-list.d.ts +6 -2
  246. package/dist/particles/navigation-link-list/navigation-link-list.js +18 -7
  247. package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -1
  248. package/dist/particles/order-details-back/order-details-back.d.ts +28 -0
  249. package/dist/particles/order-details-back/order-details-back.js +52 -0
  250. package/dist/particles/order-details-back/order-details-back.js.map +1 -0
  251. package/dist/particles/order-status-badge/order-status-badge.d.ts +19 -0
  252. package/dist/particles/order-status-badge/order-status-badge.js +50 -0
  253. package/dist/particles/order-status-badge/order-status-badge.js.map +1 -0
  254. package/dist/particles/phone-field/phone-field.js +2 -2
  255. package/dist/particles/phone-field/phone-field.js.map +1 -1
  256. package/dist/particles/select/select.js +6 -6
  257. package/dist/particles/select/select.js.map +1 -1
  258. package/dist/particles/toast/toast.d.ts +1 -1
  259. package/dist/particles/toast/toast.js +32 -6
  260. package/dist/particles/toast/toast.js.map +1 -1
  261. package/dist/schema.graphql +1014 -28
  262. package/dist/sdk/actions/address-action-provider.d.ts +16 -0
  263. package/dist/sdk/actions/address-action-provider.js +20 -0
  264. package/dist/sdk/actions/address-action-provider.js.map +1 -0
  265. package/dist/sdk/actions/analytics-action-provider.js +1 -1
  266. package/dist/sdk/actions/index.d.ts +3 -1
  267. package/dist/sdk/actions/index.js +3 -1
  268. package/dist/sdk/actions/order-action-provider.d.ts +12 -0
  269. package/dist/sdk/actions/order-action-provider.js +16 -0
  270. package/dist/sdk/actions/order-action-provider.js.map +1 -0
  271. package/dist/sdk/actions/types.d.ts +6 -2
  272. package/dist/sdk/address/address-fields.js +38 -0
  273. package/dist/sdk/address/address-fields.js.map +1 -0
  274. package/dist/sdk/address/checkout-readiness.js +17 -0
  275. package/dist/sdk/address/checkout-readiness.js.map +1 -0
  276. package/dist/sdk/address/constants.js +60 -0
  277. package/dist/sdk/address/constants.js.map +1 -0
  278. package/dist/sdk/address/country-display.js +19 -0
  279. package/dist/sdk/address/country-display.js.map +1 -0
  280. package/dist/sdk/address/country-rules.js +30 -0
  281. package/dist/sdk/address/country-rules.js.map +1 -0
  282. package/dist/sdk/address/format-address.js +18 -0
  283. package/dist/sdk/address/format-address.js.map +1 -0
  284. package/dist/sdk/address/iso-countries.js +262 -0
  285. package/dist/sdk/address/iso-countries.js.map +1 -0
  286. package/dist/sdk/address/layouts.js +56 -0
  287. package/dist/sdk/address/layouts.js.map +1 -0
  288. package/dist/sdk/address/messages.js +97 -0
  289. package/dist/sdk/address/messages.js.map +1 -0
  290. package/dist/sdk/address/operations.d.ts +54 -0
  291. package/dist/sdk/address/operations.js +83 -0
  292. package/dist/sdk/address/operations.js.map +1 -0
  293. package/dist/sdk/address/postal-code-lookup-operations.js +23 -0
  294. package/dist/sdk/address/postal-code-lookup-operations.js.map +1 -0
  295. package/dist/sdk/address/postal-code.js +11 -0
  296. package/dist/sdk/address/postal-code.js.map +1 -0
  297. package/dist/sdk/address/schema.js +14 -0
  298. package/dist/sdk/address/schema.js.map +1 -0
  299. package/dist/sdk/address/server-fields.js +25 -0
  300. package/dist/sdk/address/server-fields.js.map +1 -0
  301. package/dist/sdk/address/switch-country.js +57 -0
  302. package/dist/sdk/address/switch-country.js.map +1 -0
  303. package/dist/sdk/address/types.d.ts +26 -0
  304. package/dist/sdk/address/use-address-actions.d.ts +29 -0
  305. package/dist/sdk/address/use-address-actions.js +247 -0
  306. package/dist/sdk/address/use-address-actions.js.map +1 -0
  307. package/dist/sdk/address/use-address-by-postal-code.js +57 -0
  308. package/dist/sdk/address/use-address-by-postal-code.js.map +1 -0
  309. package/dist/sdk/address/validate-address.js +62 -0
  310. package/dist/sdk/address/validate-address.js.map +1 -0
  311. package/dist/sdk/cache/storefront-cache.js +29 -4
  312. package/dist/sdk/cache/storefront-cache.js.map +1 -1
  313. package/dist/sdk/client/fetch-page-data.d.ts +11 -0
  314. package/dist/sdk/client/fetch-page-data.js +12 -1
  315. package/dist/sdk/client/fetch-page-data.js.map +1 -1
  316. package/dist/sdk/content/create-content-runtime.js +1 -8
  317. package/dist/sdk/content/create-content-runtime.js.map +1 -1
  318. package/dist/sdk/data/failed-fields.js +23 -0
  319. package/dist/sdk/data/failed-fields.js.map +1 -0
  320. package/dist/sdk/data/index.js +2 -2
  321. package/dist/sdk/data/page-reactive-data-root.d.ts +45 -7
  322. package/dist/sdk/data/page-reactive-data-root.js +88 -12
  323. package/dist/sdk/data/page-reactive-data-root.js.map +1 -1
  324. package/dist/sdk/data/reactive-list-item-data-provider.js +2 -2
  325. package/dist/sdk/generated/fragment-types.js +2 -0
  326. package/dist/sdk/generated/fragment-types.js.map +1 -1
  327. package/dist/sdk/generated/gql.js +3 -1
  328. package/dist/sdk/generated/gql.js.map +1 -1
  329. package/dist/sdk/generated/graphql.d.ts +8 -0
  330. package/dist/sdk/generated/graphql.js +212 -1
  331. package/dist/sdk/generated/graphql.js.map +1 -1
  332. package/dist/sdk/i18n/messages/en-US.js +138 -1
  333. package/dist/sdk/i18n/messages/en-US.json +138 -1
  334. package/dist/sdk/i18n/messages/en-US.json.d.ts +137 -0
  335. package/dist/sdk/i18n/messages/es-ES.js +138 -1
  336. package/dist/sdk/i18n/messages/es-ES.json +138 -1
  337. package/dist/sdk/i18n/messages/pt-BR.js +138 -1
  338. package/dist/sdk/i18n/messages/pt-BR.json +138 -1
  339. package/dist/sdk/navigation/current-page.js +30 -0
  340. package/dist/sdk/navigation/current-page.js.map +1 -0
  341. package/dist/sdk/navigation/not-found-log.d.ts +28 -0
  342. package/dist/sdk/navigation/not-found-log.js +133 -0
  343. package/dist/sdk/navigation/not-found-log.js.map +1 -0
  344. package/dist/sdk/navigation/path.js +25 -0
  345. package/dist/sdk/navigation/path.js.map +1 -0
  346. package/dist/sdk/navigation/redirect.d.ts +11 -0
  347. package/dist/sdk/navigation/redirect.js +22 -0
  348. package/dist/sdk/navigation/redirect.js.map +1 -0
  349. package/dist/sdk/navigation/report.js +70 -0
  350. package/dist/sdk/navigation/report.js.map +1 -0
  351. package/dist/sdk/navigation/resolve-storefront-href.d.ts +12 -0
  352. package/dist/sdk/navigation/resolve-storefront-href.js +214 -0
  353. package/dist/sdk/navigation/resolve-storefront-href.js.map +1 -0
  354. package/dist/sdk/navigation/route-identity-provider.d.ts +11 -0
  355. package/dist/sdk/navigation/route-identity-provider.js +20 -0
  356. package/dist/sdk/navigation/route-identity-provider.js.map +1 -0
  357. package/dist/sdk/navigation/route-map-provider.d.ts +19 -0
  358. package/dist/sdk/navigation/route-map-provider.js +29 -0
  359. package/dist/sdk/navigation/route-map-provider.js.map +1 -0
  360. package/dist/sdk/navigation/storefront-link.d.ts +16 -0
  361. package/dist/sdk/navigation/storefront-link.js +66 -0
  362. package/dist/sdk/navigation/storefront-link.js.map +1 -0
  363. package/dist/sdk/navigation/types.d.ts +45 -0
  364. package/dist/sdk/navigation/use-storefront-navigation.d.ts +26 -0
  365. package/dist/sdk/navigation/use-storefront-navigation.js +73 -0
  366. package/dist/sdk/navigation/use-storefront-navigation.js.map +1 -0
  367. package/dist/sdk/navigation/use-storefront-route.d.ts +26 -0
  368. package/dist/sdk/navigation/use-storefront-route.js +87 -0
  369. package/dist/sdk/navigation/use-storefront-route.js.map +1 -0
  370. package/dist/sdk/navigation/use-storefront-search-params.d.ts +11 -0
  371. package/dist/sdk/navigation/use-storefront-search-params.js +16 -0
  372. package/dist/sdk/navigation/use-storefront-search-params.js.map +1 -0
  373. package/dist/sdk/orders/completion-badge.d.ts +8 -0
  374. package/dist/sdk/orders/completion-badge.js +47 -0
  375. package/dist/sdk/orders/completion-badge.js.map +1 -0
  376. package/dist/sdk/orders/order-operations.d.ts +19 -0
  377. package/dist/sdk/orders/order-operations.js +21 -0
  378. package/dist/sdk/orders/order-operations.js.map +1 -0
  379. package/dist/sdk/orders/use-order-actions.d.ts +23 -0
  380. package/dist/sdk/orders/use-order-actions.js +62 -0
  381. package/dist/sdk/orders/use-order-actions.js.map +1 -0
  382. package/dist/sdk/payment/gateway-origin.js +26 -13
  383. package/dist/sdk/payment/gateway-origin.js.map +1 -1
  384. package/dist/sdk/payment/gateway.d.ts +14 -2
  385. package/dist/sdk/payment/gateway.js +32 -14
  386. package/dist/sdk/payment/gateway.js.map +1 -1
  387. package/dist/sdk/payment/operations.js +11 -0
  388. package/dist/sdk/payment/operations.js.map +1 -1
  389. package/dist/sdk/payment/submission-registry.d.ts +2 -1
  390. package/dist/sdk/payment/submission-registry.js +12 -8
  391. package/dist/sdk/payment/submission-registry.js.map +1 -1
  392. package/dist/sdk/payment/use-payment-actions.d.ts +5 -3
  393. package/dist/sdk/payment/use-payment-actions.js +5 -2
  394. package/dist/sdk/payment/use-payment-actions.js.map +1 -1
  395. package/dist/sdk/payment/use-place-order.d.ts +6 -3
  396. package/dist/sdk/payment/use-place-order.js +333 -143
  397. package/dist/sdk/payment/use-place-order.js.map +1 -1
  398. package/dist/sdk/seo/page-alternates.d.ts +55 -0
  399. package/dist/sdk/seo/page-alternates.js +132 -0
  400. package/dist/sdk/seo/page-alternates.js.map +1 -0
  401. package/dist/utils/own-value.js +19 -0
  402. package/dist/utils/own-value.js.map +1 -0
  403. package/dist/utils/safe-href.d.ts +4 -4
  404. package/dist/utils/safe-href.js +31 -22
  405. package/dist/utils/safe-href.js.map +1 -1
  406. package/package.json +5 -1
  407. package/skills/storefront-asset/SKILL.md +111 -0
  408. package/skills/storefront-asset/references/api-side.md +153 -0
  409. package/skills/storefront-asset/references/findings.md +40 -0
  410. package/skills/storefront-asset/references/ui-side.md +94 -0
  411. package/src/styles/tailwind.css +27 -0
@@ -128,23 +128,59 @@ function toMinorUnits(amount) {
128
128
  return Math.round(Number(amount) * 100);
129
129
  }
130
130
  /**
131
- * The one call into holder-owned code. A holder's continuation is specified to resolve `userErrors` —
132
- * `sendPayments` already collapses every gateway outcome to one — so a throw means its contract broke.
133
- * Only a sanitised error *name* is logged (T160): the closure that threw holds the card, and a message
134
- * or stack could echo it — and so, unsanitised, could `.name` itself, since it is a writable own
135
- * property. See `loggableErrorName()`.
131
+ * The one call into holder-owned code. A holder's continuation is specified to resolve a
132
+ * `PaymentSubmissionResult` — `sendPayments` already collapses every gateway outcome to one — so a throw,
133
+ * or a result that is not that shape, means its contract broke. Only a sanitised error *name* is logged
134
+ * (T160): the closure that threw holds the card, and a message or stack could echo it — and so,
135
+ * unsanitised, could `.name` itself, since it is a writable own property. See `loggableErrorName()`.
136
+ *
137
+ * T112 (Decision 6): the result is totalled here and fails closed. Anything that is not an object with an
138
+ * array `userErrors` — a nullish resolution, or the bare array the contract returned before this change —
139
+ * collapses to `{ reachedGateway: true, userErrors: [NETWORK_ERROR] }`, and a `reachedGateway` that is not
140
+ * a boolean is read as `true`: only a literal `false` may free the attempt, so a holder that omits the
141
+ * signal locks it rather than inviting a second payment. An empty `userErrors` is a success whatever the
142
+ * flag says. Each field is read once, into a local, and the result handed back is a fresh object — a
143
+ * getter that answers differently across reads has no second read to answer differently on.
136
144
  */
137
145
  async function invokeSubmission(submit, transaction) {
138
146
  try {
139
147
  const result = await submit(transaction);
140
148
  if (result == null) {
141
149
  console.error("[payment.placeOrder] the registered submission resolved with no result");
142
- return [NETWORK_ERROR];
150
+ return {
151
+ reachedGateway: true,
152
+ userErrors: [NETWORK_ERROR]
153
+ };
154
+ }
155
+ const { reachedGateway, userErrors } = result;
156
+ if (!Array.isArray(userErrors)) {
157
+ console.error("[payment.placeOrder] the registered submission resolved a result with no userErrors list");
158
+ return {
159
+ reachedGateway: true,
160
+ userErrors: [NETWORK_ERROR]
161
+ };
143
162
  }
144
- return result;
163
+ if (userErrors.length === 0) return {
164
+ reachedGateway: true,
165
+ userErrors: []
166
+ };
167
+ if (typeof reachedGateway !== "boolean") {
168
+ console.error("[payment.placeOrder] the registered submission resolved a non-boolean reachedGateway");
169
+ return {
170
+ reachedGateway: true,
171
+ userErrors
172
+ };
173
+ }
174
+ return {
175
+ reachedGateway,
176
+ userErrors
177
+ };
145
178
  } catch (error) {
146
179
  console.error("[payment.placeOrder] the registered submission threw", loggableErrorName(error));
147
- return [NETWORK_ERROR];
180
+ return {
181
+ reachedGateway: true,
182
+ userErrors: [NETWORK_ERROR]
183
+ };
148
184
  }
149
185
  }
150
186
  /**
@@ -161,6 +197,26 @@ function runPreflight(check) {
161
197
  }
162
198
  }
163
199
  /**
200
+ * Asks the registered missing-method explainer (T47) why nothing is selected. A hint, never a check
201
+ * (Decision 5): a throw, a non-object, or an object whose `code` or `message` is not a string all answer
202
+ * `null`, so the caller keeps the generic refusal. A throw logs only the sanitised error name — the
203
+ * closure that throws can see the typed number, so never its message.
204
+ */
205
+ function runMissingMethodExplainer(explain) {
206
+ try {
207
+ const explained = explain();
208
+ if (typeof explained !== "object" || explained === null) return null;
209
+ const { code, message } = explained;
210
+ return typeof code === "string" && typeof message === "string" ? {
211
+ code,
212
+ message
213
+ } : null;
214
+ } catch (error) {
215
+ console.error("[payment.placeOrder] the registered explainer threw", loggableErrorName(error));
216
+ return null;
217
+ }
218
+ }
219
+ /**
164
220
  * The `startTransaction` counterpart of `invokeSubmission`/`runPreflight` (fix pass, Medium finding):
165
221
  * before this, `run()` awaited `startTransaction()` directly, so a **rejection** — as opposed to a
166
222
  * resolved payload carrying `userErrors` — escaped past every one of `run()`'s own outcome branches
@@ -277,6 +333,49 @@ async function invokeGatewayCallback(gatewayCallback, orderGroup, attemptId) {
277
333
  };
278
334
  }
279
335
  /**
336
+ * The two codes the server sends today on `gatewayCallback`. Neither is a verdict on the order, so
337
+ * `callbackFreesAttempt` never frees an attempt that carries either (T110, Decision 3):
338
+ * `REDIRECT_REQUIRED` is a bank challenge, and `MISSING_TRANSACTION_COOKIES` means the card POST was
339
+ * already accepted while the callback never reached VTEX, so a second POST could authorize the card twice.
340
+ */
341
+ const REDIRECT_REQUIRED_CODE = "REDIRECT_REQUIRED";
342
+ const MISSING_TRANSACTION_COOKIES_CODE = "MISSING_TRANSACTION_COOKIES";
343
+ /** The entry's `code`, or `undefined` when it cannot be read (a `null` entry, a getter that throws). */
344
+ function readCode(userError) {
345
+ try {
346
+ return userError.code;
347
+ } catch {
348
+ return;
349
+ }
350
+ }
351
+ /** True when the entry carries a string `code` other than this package's own `NETWORK_ERROR`. Never throws. */
352
+ function carriesServerCode(userError) {
353
+ const code = readCode(userError);
354
+ return typeof code === "string" && code !== "NETWORK_ERROR";
355
+ }
356
+ /**
357
+ * T110: whether a `gatewayCallback` that reported `userErrors` frees the attempt for a fresh run. It does
358
+ * when the server sent a string `code`, none of the entries is a locked code (`REDIRECT_REQUIRED`,
359
+ * `MISSING_TRANSACTION_COOKIES`), and the result carries no `orderId`: an order the callback confirmed is
360
+ * never freed. Everything else keeps the attempt resume-only, because a payment that may have gone through
361
+ * must never be paid twice. Total, and never throws: a non-array, an empty list or an entry nobody can read
362
+ * frees nothing.
363
+ *
364
+ * Dormant today: the server sends only the two locked codes, so no real callback frees an attempt yet.
365
+ * The rule fires for a server-coded error the server does not send yet (task T225 will). It fails open on
366
+ * a code it does not know (spec AC-5: no per-code table); a future allowlist of the codes that really are
367
+ * declines belongs to T225, not to this hook.
368
+ */
369
+ function callbackFreesAttempt(callback) {
370
+ const { orderId, userErrors } = callback;
371
+ if (orderId != null) return false;
372
+ if (!Array.isArray(userErrors)) return false;
373
+ return userErrors.some((userError) => carriesServerCode(userError)) && !userErrors.some((userError) => {
374
+ const code = readCode(userError);
375
+ return code === REDIRECT_REQUIRED_CODE || code === MISSING_TRANSACTION_COOKIES_CODE;
376
+ });
377
+ }
378
+ /**
280
379
  * T176 (FR-2, FR-3): what the caller reads from a `gatewayCallback` that reported `userErrors`, on both
281
380
  * paths that issue it. The gateway already accepted the card POST by then, so a result made only of this
282
381
  * package's own collapse — `PAYMENT_NETWORK_ERROR_CODE`, which `usePaymentActions` and
@@ -292,14 +391,7 @@ function reconcileCallbackUserErrors(userErrors) {
292
391
  try {
293
392
  if (!Array.isArray(userErrors)) return [PLACE_ORDER_UNCONFIRMED_ERROR];
294
393
  if (userErrors.length === 0) return userErrors;
295
- return userErrors.some((userError) => {
296
- try {
297
- const code = userError.code;
298
- return typeof code === "string" && code !== "NETWORK_ERROR";
299
- } catch {
300
- return false;
301
- }
302
- }) ? userErrors : [PLACE_ORDER_UNCONFIRMED_ERROR];
394
+ return userErrors.some((userError) => carriesServerCode(userError)) ? userErrors : [PLACE_ORDER_UNCONFIRMED_ERROR];
303
395
  } catch {
304
396
  return [PLACE_ORDER_UNCONFIRMED_ERROR];
305
397
  }
@@ -332,6 +424,165 @@ function generateAttemptId() {
332
424
  function writeAttemptIfCurrent(setAttempt, attemptId, next) {
333
425
  setAttempt?.((prev) => prev !== null && prev.attemptId === attemptId && prev.phase !== "settled" ? next : prev);
334
426
  }
427
+ /** The record an attempt carries once nothing was paid: a fresh full sequence is legal next time. */
428
+ function refusedRecord(attemptId) {
429
+ return {
430
+ attemptId,
431
+ phase: "refused",
432
+ orderGroup: null,
433
+ orderId: null
434
+ };
435
+ }
436
+ /**
437
+ * The record `resume()` writes once its one `gatewayCallback` answered: `refused` when the retry rule
438
+ * freed the attempt, `unresolved` for any other error, `settled` with the order id on success.
439
+ */
440
+ function resumedRecord(current, callback, failed, freed) {
441
+ if (freed) return refusedRecord(current.attemptId);
442
+ if (failed) return {
443
+ ...current,
444
+ phase: "unresolved"
445
+ };
446
+ return {
447
+ ...current,
448
+ phase: "settled",
449
+ orderId: callback.orderId
450
+ };
451
+ }
452
+ /**
453
+ * The terminal record `run()`'s `catch` re-asserts: the `settled` one a throw may have interrupted, else
454
+ * `unresolved` once the card was handed over, else `refused`. A failed leg writes the same pair, with
455
+ * no placed attempt: `refused` when it freed the attempt, `unresolved` (keeping the order group) otherwise.
456
+ */
457
+ function recoveryRecord(attemptId, placedAttempt, handedOver, settledOrderGroup) {
458
+ if (placedAttempt !== null) return placedAttempt;
459
+ return handedOver ? {
460
+ attemptId,
461
+ phase: "unresolved",
462
+ orderGroup: settledOrderGroup,
463
+ orderId: null
464
+ } : refusedRecord(attemptId);
465
+ }
466
+ /**
467
+ * `run()`'s recovery write, guarded because it goes through the same caller-supplied `setAttempt` that
468
+ * may be what threw in the first place: nothing further can be tried once the writer itself is broken, so
469
+ * it is logged (name only, FR-7) and the caller returns its result either way.
470
+ */
471
+ function writeRecoveryRecord(setAttempt, attemptId, record) {
472
+ try {
473
+ writeAttemptIfCurrent(setAttempt, attemptId, record);
474
+ } catch (writeError) {
475
+ console.error("[payment.placeOrder] the place-order recovery write threw", attemptId, loggableErrorName(writeError));
476
+ }
477
+ }
478
+ /** `run()`'s refusal before any request: nothing was paid and the card never left the browser. */
479
+ function refusalBeforeOpening(userErrors) {
480
+ return {
481
+ orderId: null,
482
+ userErrors,
483
+ reachedGateway: false
484
+ };
485
+ }
486
+ function refused(userErrors) {
487
+ return {
488
+ kind: "refused",
489
+ result: refusalBeforeOpening(userErrors)
490
+ };
491
+ }
492
+ /**
493
+ * T47 (Decision 2/4/5): the holder may know a more specific reason than "choose a method". Asked only
494
+ * with nothing selected, and never before the checks that follow, so the order of checks cannot change.
495
+ * Only the opaque refusal comes back, and only its code is logged.
496
+ */
497
+ function refuseMissingMethod({ path, resolveMissingMethodExplainer }) {
498
+ const explain = path === null ? null : resolveMissingMethodExplainer(path);
499
+ const explained = explain === null ? null : runMissingMethodExplainer(explain);
500
+ if (explained !== null) {
501
+ console.error("[payment.placeOrder] no payment method is selected, and the registered explainer named why", explained.code);
502
+ return refused([explained]);
503
+ }
504
+ console.error("[payment.placeOrder] no payment method is selected");
505
+ return refused([MISSING_METHOD_ERROR]);
506
+ }
507
+ /**
508
+ * Every synchronous refusal `run()` resolves before anything is opened, in their original order: no
509
+ * registered submission, no selected method, the submit gate, then the holder's own pre-flight. A
510
+ * transaction nothing can complete is dangling state on the order form. The first two causes are one
511
+ * state to a shopper and differ only in the log.
512
+ */
513
+ function checkSubmissionPreconditions({ channel, selectedMethod, submitGate }) {
514
+ const { path, resolve, resolvePreflight } = channel;
515
+ const submit = path === null ? null : resolve(path);
516
+ if (submit === null) {
517
+ console.error("[payment.placeOrder] no submission is registered for the entry path", path ?? "none");
518
+ return refused([MISSING_SUBMISSION_ERROR]);
519
+ }
520
+ if (selectedMethod === null) return refuseMissingMethod(channel);
521
+ if (submitGate) {
522
+ console.error("[payment.placeOrder] a client-side gate refused the submission", submitGate.code);
523
+ return refused([submitGate]);
524
+ }
525
+ const preflight = path === null ? null : resolvePreflight(path);
526
+ if (preflight) {
527
+ const refusals = runPreflight(preflight);
528
+ if (refusals.length > 0) {
529
+ console.error("[payment.placeOrder] the registered pre-flight refused the submission", refusals[0]?.code);
530
+ return refused(refusals);
531
+ }
532
+ }
533
+ return {
534
+ kind: "ready",
535
+ submit,
536
+ method: selectedMethod
537
+ };
538
+ }
539
+ /**
540
+ * `run()`'s first backend leg: opens the transaction and settles its payload. Either refusal records
541
+ * `refused` — nothing was paid, so a fresh full sequence stays legal next time — through
542
+ * `writeAttemptIfCurrent`, not a plain write: the caller's closure may be running after its own CTA
543
+ * unmounted (NFR-3), so a newer completion for the same attempt must win instead.
544
+ */
545
+ async function openTransaction(startTransaction, setAttempt, attemptId) {
546
+ const payload = await invokeStartTransaction(startTransaction);
547
+ if (payload.userErrors.length > 0) {
548
+ writeAttemptIfCurrent(setAttempt, attemptId, refusedRecord(attemptId));
549
+ return {
550
+ kind: "refused",
551
+ result: refusalBeforeOpening(payload.userErrors)
552
+ };
553
+ }
554
+ const settled = settleTransaction(payload);
555
+ if (settled === null) {
556
+ writeAttemptIfCurrent(setAttempt, attemptId, refusedRecord(attemptId));
557
+ return {
558
+ kind: "refused",
559
+ result: refusalBeforeOpening([INVALID_TRANSACTION_ERROR])
560
+ };
561
+ }
562
+ return {
563
+ kind: "opened",
564
+ settled
565
+ };
566
+ }
567
+ /** The descriptor `run()` hands to the registered submission. Nothing in it is sensitive. */
568
+ function buildTransaction({ settled, method, selectedInstallment, billingAddressDifferent }) {
569
+ return {
570
+ gatewayUrl: settled.gatewayUrl,
571
+ transactionId: settled.transactionId,
572
+ merchantName: settled.merchantName,
573
+ orderGroup: settled.orderGroup,
574
+ userProfileId: settled.userProfileId,
575
+ paymentSystem: method.id,
576
+ groupName: method.groupName,
577
+ currencyCode: settled.value.currencyCode,
578
+ valueInCents: settled.valueInCents,
579
+ referenceValueInCents: settled.referenceValueInCents,
580
+ installments: selectedInstallment?.count ?? 1,
581
+ installmentsValueInCents: selectedInstallment && selectedInstallment.count !== 1 ? toMinorUnits(selectedInstallment.value.amount) : settled.valueInCents,
582
+ interestRate: selectedInstallment?.interestRate ?? 0,
583
+ ...billingAddressDifferent == null ? {} : { billingAddressDifferent }
584
+ };
585
+ }
335
586
  /**
336
587
  * T29 (Decision 3, FR-3): the only path back into a `sent`/`unresolved` attempt — `gatewayCallback` is
337
588
  * the sole call it ever issues. Module scope, not a `useCallback` inside the hook (fix pass, Low
@@ -342,13 +593,17 @@ function writeAttemptIfCurrent(setAttempt, attemptId, next) {
342
593
  * still have read. Hoisting here makes the claim actually true: none of those three is even
343
594
  * *importable* from a bare module-level function that takes only `gatewayCallback`/`setAttempt`/
344
595
  * `setPlacing`/`current` as arguments — a resume is safe by construction, not by convention.
596
+ *
597
+ * T110: a callback the retry rule frees records `refused`, as `run()` does, so the next click is a fresh
598
+ * full run. This function still issues nothing but `gatewayCallback`.
345
599
  */
346
600
  async function resume(gatewayCallback, setAttempt, setPlacing, current) {
347
601
  if (!gatewayCallback || current.orderGroup === null) {
348
602
  console.error("[payment.placeOrder] cannot resume an attempt with no order group");
349
603
  return {
350
604
  orderId: null,
351
- userErrors: [NETWORK_ERROR]
605
+ userErrors: [NETWORK_ERROR],
606
+ reachedGateway: true
352
607
  };
353
608
  }
354
609
  writeAttemptIfCurrent(setAttempt, current.attemptId, {
@@ -360,30 +615,27 @@ async function resume(gatewayCallback, setAttempt, setPlacing, current) {
360
615
  const failed = callback.userErrors.length > 0;
361
616
  const result = failed ? {
362
617
  orderId: null,
363
- userErrors: reconcileCallbackUserErrors(callback.userErrors)
618
+ userErrors: reconcileCallbackUserErrors(callback.userErrors),
619
+ reachedGateway: true
364
620
  } : {
365
621
  orderId: callback.orderId,
366
- userErrors: []
622
+ userErrors: [],
623
+ reachedGateway: true
367
624
  };
625
+ const freed = failed && callbackFreesAttempt(callback);
368
626
  try {
369
- writeAttemptIfCurrent(setAttempt, current.attemptId, failed ? {
370
- ...current,
371
- phase: "unresolved"
372
- } : {
373
- ...current,
374
- phase: "settled",
375
- orderId: callback.orderId
376
- });
627
+ writeAttemptIfCurrent(setAttempt, current.attemptId, resumedRecord(current, callback, failed, freed));
377
628
  } catch (error) {
378
629
  console.error("[payment.placeOrder] the resume record write threw", current.attemptId, loggableErrorName(error));
379
630
  }
380
631
  return result;
381
632
  }
382
633
  function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDifferent, submitGate }) {
383
- const { path, resolve, resolvePreflight } = usePaymentSubmission();
634
+ const { path, resolve, resolvePreflight, resolveMissingMethodExplainer } = usePaymentSubmission();
384
635
  const [placing, setPlacing] = useState(false);
385
636
  const [userErrors, setUserErrors] = useState([]);
386
637
  const [orderId, setOrderId] = useState(null);
638
+ const [reachedGateway, setReachedGateway] = useState(null);
387
639
  const inFlight = useRef(null);
388
640
  const startTransaction = $actions?.payment?.startTransaction;
389
641
  const gatewayCallback = $actions?.payment?.gatewayCallback;
@@ -397,42 +649,22 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
397
649
  console.error("[payment.placeOrder] the payment action namespace is not injected");
398
650
  return {
399
651
  orderId: null,
400
- userErrors: [NETWORK_ERROR]
652
+ userErrors: [NETWORK_ERROR],
653
+ reachedGateway: false
401
654
  };
402
655
  }
403
- const submit = path === null ? null : resolve(path);
404
- if (submit === null) {
405
- console.error("[payment.placeOrder] no submission is registered for the entry path", path ?? "none");
406
- return {
407
- orderId: null,
408
- userErrors: [MISSING_SUBMISSION_ERROR]
409
- };
410
- }
411
- if (selectedMethod === null) {
412
- console.error("[payment.placeOrder] no payment method is selected");
413
- return {
414
- orderId: null,
415
- userErrors: [MISSING_METHOD_ERROR]
416
- };
417
- }
418
- if (submitGate) {
419
- console.error("[payment.placeOrder] a client-side gate refused the submission", submitGate.code);
420
- return {
421
- orderId: null,
422
- userErrors: [submitGate]
423
- };
424
- }
425
- const preflight = path === null ? null : resolvePreflight(path);
426
- if (preflight) {
427
- const refusals = runPreflight(preflight);
428
- if (refusals.length > 0) {
429
- console.error("[payment.placeOrder] the registered pre-flight refused the submission", refusals[0]?.code);
430
- return {
431
- orderId: null,
432
- userErrors: refusals
433
- };
434
- }
435
- }
656
+ const verdict = checkSubmissionPreconditions({
657
+ channel: {
658
+ path,
659
+ resolve,
660
+ resolvePreflight,
661
+ resolveMissingMethodExplainer
662
+ },
663
+ selectedMethod,
664
+ submitGate
665
+ });
666
+ if (verdict.kind === "refused") return verdict.result;
667
+ const { submit, method } = verdict;
436
668
  let handedOver = false;
437
669
  let settledOrderGroup = null;
438
670
  let placedAttempt = null;
@@ -446,32 +678,9 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
446
678
  });
447
679
  try {
448
680
  setPlacing(true);
449
- const payload = await invokeStartTransaction(startTransaction);
450
- if (payload.userErrors.length > 0) {
451
- writeAttemptIfCurrent(setAttempt, attemptId, {
452
- attemptId,
453
- phase: "refused",
454
- orderGroup: null,
455
- orderId: null
456
- });
457
- return {
458
- orderId: null,
459
- userErrors: payload.userErrors
460
- };
461
- }
462
- const settled = settleTransaction(payload);
463
- if (settled === null) {
464
- writeAttemptIfCurrent(setAttempt, attemptId, {
465
- attemptId,
466
- phase: "refused",
467
- orderGroup: null,
468
- orderId: null
469
- });
470
- return {
471
- orderId: null,
472
- userErrors: [INVALID_TRANSACTION_ERROR]
473
- };
474
- }
681
+ const opened = await openTransaction(startTransaction, setAttempt, attemptId);
682
+ if (opened.kind === "refused") return opened.result;
683
+ const { settled } = opened;
475
684
  settledOrderGroup = settled.orderGroup;
476
685
  writeAttemptIfCurrent(setAttempt, attemptId, {
477
686
  attemptId,
@@ -479,35 +688,23 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
479
688
  orderGroup: settled.orderGroup,
480
689
  orderId: null
481
690
  });
482
- const transaction = {
483
- gatewayUrl: settled.gatewayUrl,
484
- transactionId: settled.transactionId,
485
- merchantName: settled.merchantName,
486
- orderGroup: settled.orderGroup,
487
- userProfileId: settled.userProfileId,
488
- paymentSystem: selectedMethod.id,
489
- groupName: selectedMethod.groupName,
490
- currencyCode: settled.value.currencyCode,
491
- valueInCents: settled.valueInCents,
492
- referenceValueInCents: settled.referenceValueInCents,
493
- installments: selectedInstallment?.count ?? 1,
494
- installmentsValueInCents: selectedInstallment && selectedInstallment.count !== 1 ? toMinorUnits(selectedInstallment.value.amount) : settled.valueInCents,
495
- interestRate: selectedInstallment?.interestRate ?? 0,
496
- ...billingAddressDifferent != null ? { billingAddressDifferent } : {}
497
- };
691
+ const transaction = buildTransaction({
692
+ settled,
693
+ method,
694
+ selectedInstallment,
695
+ billingAddressDifferent
696
+ });
498
697
  handedOver = true;
499
698
  const submissionErrors = await invokeSubmission(submit, transaction);
500
- if (submissionErrors.length > 0) {
699
+ if (submissionErrors.userErrors.length > 0) {
700
+ const freed = submissionErrors.reachedGateway === false;
701
+ handedOver = !freed;
501
702
  outcome = {
502
703
  orderId: null,
503
- userErrors: submissionErrors
704
+ userErrors: submissionErrors.userErrors,
705
+ reachedGateway: !freed
504
706
  };
505
- writeAttemptIfCurrent(setAttempt, attemptId, {
506
- attemptId,
507
- phase: "unresolved",
508
- orderGroup: settled.orderGroup,
509
- orderId: null
510
- });
707
+ writeAttemptIfCurrent(setAttempt, attemptId, recoveryRecord(attemptId, null, handedOver, settled.orderGroup));
511
708
  return outcome;
512
709
  }
513
710
  writeAttemptIfCurrent(setAttempt, attemptId, {
@@ -520,14 +717,11 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
520
717
  if (callback.userErrors.length > 0) {
521
718
  outcome = {
522
719
  orderId: null,
523
- userErrors: reconcileCallbackUserErrors(callback.userErrors)
720
+ userErrors: reconcileCallbackUserErrors(callback.userErrors),
721
+ reachedGateway: true
524
722
  };
525
- writeAttemptIfCurrent(setAttempt, attemptId, {
526
- attemptId,
527
- phase: "unresolved",
528
- orderGroup: settled.orderGroup,
529
- orderId: null
530
- });
723
+ handedOver = !callbackFreesAttempt(callback);
724
+ writeAttemptIfCurrent(setAttempt, attemptId, recoveryRecord(attemptId, null, handedOver, settled.orderGroup));
531
725
  return outcome;
532
726
  }
533
727
  placedAttempt = {
@@ -538,7 +732,8 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
538
732
  };
539
733
  outcome = {
540
734
  orderId: callback.orderId,
541
- userErrors: []
735
+ userErrors: [],
736
+ reachedGateway: true
542
737
  };
543
738
  track?.({
544
739
  name: "purchase",
@@ -552,24 +747,11 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
552
747
  return outcome;
553
748
  } catch (error) {
554
749
  console.error("[payment.placeOrder] the place-order sequence threw", attemptId, loggableErrorName(error));
555
- try {
556
- writeAttemptIfCurrent(setAttempt, attemptId, placedAttempt ?? (handedOver ? {
557
- attemptId,
558
- phase: "unresolved",
559
- orderGroup: settledOrderGroup,
560
- orderId: null
561
- } : {
562
- attemptId,
563
- phase: "refused",
564
- orderGroup: null,
565
- orderId: null
566
- }));
567
- } catch (writeError) {
568
- console.error("[payment.placeOrder] the place-order recovery write threw", attemptId, loggableErrorName(writeError));
569
- }
750
+ writeRecoveryRecord(setAttempt, attemptId, recoveryRecord(attemptId, placedAttempt, handedOver, settledOrderGroup));
570
751
  return outcome ?? {
571
752
  orderId: null,
572
- userErrors: [NETWORK_ERROR]
753
+ userErrors: [NETWORK_ERROR],
754
+ reachedGateway: handedOver
573
755
  };
574
756
  }
575
757
  }, [
@@ -579,6 +761,7 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
579
761
  path,
580
762
  resolve,
581
763
  resolvePreflight,
764
+ resolveMissingMethodExplainer,
582
765
  selectedMethod,
583
766
  selectedInstallment,
584
767
  billingAddressDifferent,
@@ -590,28 +773,33 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
590
773
  const settleSequence = (sequence) => {
591
774
  setUserErrors([]);
592
775
  setOrderId(null);
776
+ setReachedGateway(null);
593
777
  const settle = (result) => {
594
778
  inFlight.current = null;
595
779
  setPlacing(false);
596
780
  setUserErrors(result.userErrors);
597
781
  setOrderId(result.orderId);
782
+ setReachedGateway(result.reachedGateway);
598
783
  return result;
599
784
  };
600
785
  const outcome = sequence.then(settle, () => settle({
601
786
  orderId: null,
602
- userErrors: [NETWORK_ERROR]
787
+ userErrors: [NETWORK_ERROR],
788
+ reachedGateway: true
603
789
  }));
604
790
  inFlight.current = outcome;
605
791
  return outcome;
606
792
  };
607
793
  if (attempt) {
608
- if (attempt.phase === "settled") return Promise.resolve({
794
+ if (attempt.phase === "settled") return settleSequence(Promise.resolve({
609
795
  orderId: attempt.orderId,
610
- userErrors: []
611
- });
796
+ userErrors: [],
797
+ reachedGateway: true
798
+ }));
612
799
  if (attempt.phase === "opening" || attempt.phase === "finalizing") return settleSequence(Promise.resolve({
613
800
  orderId: attempt.orderId,
614
- userErrors: [PLACE_ORDER_IN_FLIGHT_ERROR]
801
+ userErrors: [PLACE_ORDER_IN_FLIGHT_ERROR],
802
+ reachedGateway: true
615
803
  }));
616
804
  if (attempt.phase === "sent" || attempt.phase === "unresolved") return settleSequence(resume(gatewayCallback, setAttempt, setPlacing, attempt));
617
805
  }
@@ -626,12 +814,14 @@ function usePlaceOrder({ $data, $actions, attempt, setAttempt, billingAddressDif
626
814
  placeOrder,
627
815
  placing,
628
816
  userErrors,
629
- orderId
817
+ orderId,
818
+ reachedGateway
630
819
  }), [
631
820
  placeOrder,
632
821
  placing,
633
822
  userErrors,
634
- orderId
823
+ orderId,
824
+ reachedGateway
635
825
  ]);
636
826
  }
637
827
  //#endregion