@vtex/faststore 0.0.4 → 0.0.6
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/CHANGELOG.md +67 -0
- package/dist/actions.json +181 -0
- package/dist/catalog.json +1595 -481
- package/dist/client.d.ts +2 -1
- package/dist/client.js +2 -1
- package/dist/components.d.ts +31 -7
- package/dist/components.js +35 -13
- package/dist/content-types.json +73 -0
- package/dist/docs/access-code-sign-in.md +1 -1
- package/dist/docs/account-access-gate.md +153 -0
- package/dist/docs/account-entry-point.md +1 -2
- package/dist/docs/account-menu.md +164 -0
- package/dist/docs/address-summary.md +24 -3
- package/dist/docs/alert-dialog.md +204 -0
- package/dist/docs/billing-address.md +284 -0
- package/dist/docs/buy-button.md +1 -1
- package/dist/docs/card-entry.md +250 -0
- package/dist/docs/cardholder-document.md +142 -0
- package/dist/docs/cart.md +1 -1
- package/dist/docs/client-preferences-fieldset.md +148 -0
- package/dist/docs/client-preferences.md +2 -1
- package/dist/docs/client-profile-fieldset.md +184 -0
- package/dist/docs/client-profile.md +1 -1
- package/dist/docs/document-field.md +58 -4
- package/dist/docs/field.md +317 -0
- package/dist/docs/form.md +307 -0
- package/dist/docs/identity-edit.md +6 -6
- package/dist/docs/identity-summary.md +5 -5
- package/dist/docs/installments.md +248 -0
- package/dist/docs/my-account-profile.md +1 -0
- package/dist/docs/order-placed-payment-summary.md +138 -0
- package/dist/docs/payment-method-badges.md +232 -0
- package/dist/docs/payment-methods.md +1 -0
- package/dist/docs/payment.md +218 -0
- package/dist/docs/phone-field.md +58 -4
- package/dist/docs/place-order.md +157 -0
- package/dist/docs/save-card.md +186 -0
- package/dist/docs/saved-cards.md +218 -0
- package/dist/docs/select.md +465 -0
- package/dist/docs/session.md +1 -1
- package/dist/docs/shipping-address.md +110 -258
- package/dist/docs/sign-in-redirect.md +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/internal/client.d.ts +3 -1
- package/dist/internal/client.js +3 -1
- package/dist/matter/access-code-sign-in/access-code-sign-in.js +9 -8
- package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -1
- package/dist/matter/account-access-gate/account-access-gate.d.ts +86 -0
- package/dist/matter/account-access-gate/account-access-gate.js +283 -0
- package/dist/matter/account-access-gate/account-access-gate.js.map +1 -0
- package/dist/matter/account-access-gate/sign-out-intent.d.ts +17 -0
- package/dist/matter/account-access-gate/sign-out-intent.js +62 -0
- package/dist/matter/account-access-gate/sign-out-intent.js.map +1 -0
- package/dist/matter/account-entry-point/account-entry-point.js +2 -2
- package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
- package/dist/matter/account-menu/account-menu.d.ts +88 -0
- package/dist/matter/account-menu/account-menu.js +246 -0
- package/dist/matter/account-menu/account-menu.js.map +1 -0
- package/dist/matter/billing-address/billing-address.d.ts +165 -0
- package/dist/matter/billing-address/billing-address.js +408 -0
- package/dist/matter/billing-address/billing-address.js.map +1 -0
- package/dist/matter/card-entry/card-capture.d.ts +25 -0
- package/dist/matter/card-entry/card-capture.js +25 -0
- package/dist/matter/card-entry/card-capture.js.map +1 -0
- package/dist/matter/card-entry/card-entry.d.ts +120 -0
- package/dist/matter/card-entry/card-entry.js +832 -0
- package/dist/matter/card-entry/card-entry.js.map +1 -0
- package/dist/matter/cardholder-document/cardholder-document.d.ts +45 -0
- package/dist/matter/cardholder-document/cardholder-document.js +70 -0
- package/dist/matter/cardholder-document/cardholder-document.js.map +1 -0
- package/dist/matter/cart/cart.d.ts +1 -1
- package/dist/matter/cart/cart.js +2 -2
- package/dist/matter/cart/cart.js.map +1 -1
- package/dist/matter/client-preferences/client-preferences-fieldset.d.ts +77 -0
- package/dist/matter/client-preferences/client-preferences-fieldset.js +299 -0
- package/dist/matter/client-preferences/client-preferences-fieldset.js.map +1 -0
- package/dist/matter/client-preferences/client-preferences.d.ts +3 -5
- package/dist/matter/client-preferences/client-preferences.js +6 -6
- package/dist/matter/client-preferences/client-preferences.js.map +1 -1
- package/dist/matter/client-profile/client-profile.d.ts +4 -6
- package/dist/matter/client-profile/client-profile.js +9 -6
- package/dist/matter/client-profile/client-profile.js.map +1 -1
- package/dist/matter/client-profile-form/client-profile-fieldset.d.ts +119 -0
- package/dist/matter/client-profile-form/client-profile-fieldset.js +488 -0
- package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -0
- package/dist/matter/delivery-options/delivery-options.js.map +1 -1
- package/dist/matter/identity-edit/identity-edit.js +2 -2
- package/dist/matter/identity-edit/identity-edit.js.map +1 -1
- package/dist/matter/identity-summary/identity-summary.js +2 -2
- package/dist/matter/identity-summary/identity-summary.js.map +1 -1
- package/dist/matter/installments/installments-select.d.ts +42 -0
- package/dist/matter/installments/installments-select.js +167 -0
- package/dist/matter/installments/installments-select.js.map +1 -0
- package/dist/matter/installments/installments.d.ts +58 -0
- package/dist/matter/installments/installments.js +176 -0
- package/dist/matter/installments/installments.js.map +1 -0
- package/dist/matter/installments/use-installments-selection.d.ts +29 -0
- package/dist/matter/installments/use-installments-selection.js +95 -0
- package/dist/matter/installments/use-installments-selection.js.map +1 -0
- package/dist/matter/my-account-profile/my-account-profile.js +5 -5
- package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +63 -0
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +305 -0
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -0
- package/dist/matter/payment/payment-card-capture.d.ts +19 -0
- package/dist/matter/payment/payment-card-capture.js +129 -0
- package/dist/matter/payment/payment-card-capture.js.map +1 -0
- package/dist/matter/payment/payment-controller.d.ts +24 -0
- package/dist/matter/payment/payment-controller.js +107 -0
- package/dist/matter/payment/payment-controller.js.map +1 -0
- package/dist/matter/payment/payment-method-badges.d.ts +57 -0
- package/dist/matter/payment/payment-method-badges.js +192 -0
- package/dist/matter/payment/payment-method-badges.js.map +1 -0
- package/dist/matter/payment/payment.d.ts +89 -0
- package/dist/matter/payment/payment.js +263 -0
- package/dist/matter/payment/payment.js.map +1 -0
- package/dist/matter/payment/use-payment-method-selection.d.ts +302 -0
- package/dist/matter/payment/use-payment-method-selection.js +458 -0
- package/dist/matter/payment/use-payment-method-selection.js.map +1 -0
- package/dist/matter/payment/use-payment-submit-gate.d.ts +111 -0
- package/dist/matter/payment/use-payment-submit-gate.js +144 -0
- package/dist/matter/payment/use-payment-submit-gate.js.map +1 -0
- package/dist/matter/place-order/place-order.d.ts +74 -0
- package/dist/matter/place-order/place-order.js +379 -0
- package/dist/matter/place-order/place-order.js.map +1 -0
- package/dist/matter/product-list/product-list.d.ts +1 -0
- package/dist/matter/product-list/product-list.js.map +1 -1
- package/dist/matter/product-shelf/product-shelf.d.ts +1 -0
- package/dist/matter/product-shelf/product-shelf.js +2 -0
- package/dist/matter/product-shelf/product-shelf.js.map +1 -1
- package/dist/matter/region/region.js +1 -1
- package/dist/matter/region/region.js.map +1 -1
- package/dist/matter/save-card/save-card.d.ts +49 -0
- package/dist/matter/save-card/save-card.js +188 -0
- package/dist/matter/save-card/save-card.js.map +1 -0
- package/dist/matter/saved-cards/saved-cards.d.ts +79 -0
- package/dist/matter/saved-cards/saved-cards.js +387 -0
- package/dist/matter/saved-cards/saved-cards.js.map +1 -0
- package/dist/matter/shipping-address/country-descriptors.js +20 -10
- package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
- package/dist/matter/shipping-address/shipping-address.d.ts +113 -174
- package/dist/matter/shipping-address/shipping-address.js +481 -792
- package/dist/matter/shipping-address/shipping-address.js.map +1 -1
- package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
- package/dist/matter/variant-selector/variant-selector.js +1 -1
- package/dist/particles/address-summary/address-summary.d.ts +24 -0
- package/dist/particles/address-summary/address-summary.js +83 -2
- package/dist/particles/address-summary/address-summary.js.map +1 -1
- package/dist/particles/alert-dialog/alert-dialog.d.ts +68 -0
- package/dist/particles/alert-dialog/alert-dialog.js +187 -0
- package/dist/particles/alert-dialog/alert-dialog.js.map +1 -0
- package/dist/particles/checkbox/checkbox.d.ts +7 -3
- package/dist/particles/checkbox/checkbox.js +4 -1
- package/dist/particles/checkbox/checkbox.js.map +1 -1
- package/dist/particles/document-field/document-field.d.ts +48 -5
- package/dist/particles/document-field/document-field.js +189 -32
- package/dist/particles/document-field/document-field.js.map +1 -1
- package/dist/particles/field/bound-field-registry.js +52 -0
- package/dist/particles/field/bound-field-registry.js.map +1 -0
- package/dist/particles/field/field.d.ts +116 -0
- package/dist/particles/field/field.js +497 -6
- package/dist/particles/field/field.js.map +1 -1
- package/dist/particles/fieldset/fieldset.js +2 -2
- package/dist/particles/fieldset/fieldset.js.map +1 -1
- package/dist/particles/footer-social/footer-social.js +1 -1
- package/dist/particles/form/form.d.ts +104 -0
- package/dist/particles/form/form.js +485 -0
- package/dist/particles/form/form.js.map +1 -0
- package/dist/particles/incentives/incentives.js +1 -1
- package/dist/particles/phone-field/phone-field.d.ts +38 -10
- package/dist/particles/phone-field/phone-field.js +183 -39
- package/dist/particles/phone-field/phone-field.js.map +1 -1
- package/dist/particles/postal-code-field/postal-code-field.js +2 -2
- package/dist/particles/postal-code-field/postal-code-field.js.map +1 -1
- package/dist/particles/select/field-select.d.ts +43 -0
- package/dist/particles/select/field-select.js +150 -0
- package/dist/particles/select/field-select.js.map +1 -0
- package/dist/particles/select/select.d.ts +2 -0
- package/dist/particles/select/select.js.map +1 -1
- package/dist/particles/shared/compose-refs.js +21 -0
- package/dist/particles/shared/compose-refs.js.map +1 -0
- package/dist/schema.graphql +701 -2
- package/dist/sdk/actions/analytics-action-provider.d.ts +15 -0
- package/dist/sdk/actions/analytics-action-provider.js +19 -0
- package/dist/sdk/actions/analytics-action-provider.js.map +1 -0
- package/dist/sdk/actions/cart-action-provider.d.ts +1 -1
- package/dist/sdk/actions/cart-action-provider.js +1 -1
- package/dist/sdk/actions/cart-action-provider.js.map +1 -1
- package/dist/sdk/actions/index.d.ts +3 -1
- package/dist/sdk/actions/index.js +3 -1
- package/dist/sdk/actions/payment-action-provider.d.ts +22 -0
- package/dist/sdk/actions/payment-action-provider.js +26 -0
- package/dist/sdk/actions/payment-action-provider.js.map +1 -0
- package/dist/sdk/actions/session-action-provider.d.ts +1 -1
- package/dist/sdk/actions/session-action-provider.js +1 -1
- package/dist/sdk/actions/session-action-provider.js.map +1 -1
- package/dist/sdk/actions/shipping-action-provider.d.ts +1 -1
- package/dist/sdk/actions/shipping-action-provider.js +1 -1
- package/dist/sdk/actions/shipping-action-provider.js.map +1 -1
- package/dist/sdk/actions/types.d.ts +6 -2
- package/dist/sdk/analytics/analytics-destination.d.ts +43 -0
- package/dist/sdk/analytics/analytics-destination.js +90 -0
- package/dist/sdk/analytics/analytics-destination.js.map +1 -0
- package/dist/sdk/analytics/use-analytics-actions.d.ts +57 -0
- package/dist/sdk/analytics/use-analytics-actions.js +108 -0
- package/dist/sdk/analytics/use-analytics-actions.js.map +1 -0
- package/dist/sdk/cache/storefront-cache.js +1 -1
- package/dist/sdk/cache/storefront-cache.js.map +1 -1
- package/dist/sdk/cart/operations.d.ts +4 -4
- package/dist/sdk/cart/operations.js +1 -1
- package/dist/sdk/cart/operations.js.map +1 -1
- package/dist/sdk/cart/optimistic.js +1 -1
- package/dist/sdk/cart/optimistic.js.map +1 -1
- package/dist/sdk/cart/use-cart-actions.d.ts +1 -1
- package/dist/sdk/cart/use-cart-actions.js +4 -4
- package/dist/sdk/cart/use-cart-actions.js.map +1 -1
- package/dist/sdk/cart/use-cart-validate-on-open.js +1 -1
- package/dist/sdk/cart/use-cart-validate-on-open.js.map +1 -1
- package/dist/sdk/cart/write-gate.js +1 -1
- package/dist/sdk/cart/write-gate.js.map +1 -1
- package/dist/sdk/data/entity-resolution-context.js +31 -0
- package/dist/sdk/data/entity-resolution-context.js.map +1 -0
- package/dist/sdk/data/entity-subscriber.js +18 -8
- package/dist/sdk/data/entity-subscriber.js.map +1 -1
- package/dist/sdk/data/index.js +1 -0
- package/dist/sdk/data/page-reactive-data-root.d.ts +38 -2
- package/dist/sdk/data/page-reactive-data-root.js +4 -2
- package/dist/sdk/data/page-reactive-data-root.js.map +1 -1
- package/dist/sdk/data/reactive-data-provider.d.ts +1 -1
- package/dist/sdk/data/reactive-data-provider.js +8 -4
- package/dist/sdk/data/reactive-data-provider.js.map +1 -1
- package/dist/sdk/data/reactive-list-item-data-provider.d.ts +1 -1
- package/dist/sdk/data/reactive-list-item-data-provider.js +13 -5
- package/dist/sdk/data/reactive-list-item-data-provider.js.map +1 -1
- package/dist/sdk/data/use-reactive-data-settled.js +39 -0
- package/dist/sdk/data/use-reactive-data-settled.js.map +1 -0
- package/dist/sdk/data/use-reactive-entity.js +6 -2
- package/dist/sdk/data/use-reactive-entity.js.map +1 -1
- package/dist/sdk/generated/fragment-types.js +2 -0
- package/dist/sdk/generated/fragment-types.js.map +1 -1
- package/dist/sdk/generated/gql.js +2 -1
- package/dist/sdk/generated/gql.js.map +1 -1
- package/dist/sdk/generated/graphql.js +85 -1
- package/dist/sdk/generated/graphql.js.map +1 -1
- package/dist/sdk/i18n/messages/en-US.js +3 -0
- package/dist/sdk/i18n/messages/en-US.json +3 -0
- package/dist/sdk/i18n/messages/en-US.json.d.ts +3 -0
- package/dist/sdk/i18n/messages/es-ES.js +3 -0
- package/dist/sdk/i18n/messages/es-ES.json +3 -0
- package/dist/sdk/i18n/messages/pt-BR.js +3 -0
- package/dist/sdk/i18n/messages/pt-BR.json +3 -0
- package/dist/sdk/identity/operations.js.map +1 -1
- package/dist/sdk/identity/use-identity-actions.d.ts +1 -1
- package/dist/sdk/identity/use-identity-actions.js +3 -2
- package/dist/sdk/identity/use-identity-actions.js.map +1 -1
- package/dist/sdk/payment/gateway-origin.js +35 -0
- package/dist/sdk/payment/gateway-origin.js.map +1 -0
- package/dist/sdk/payment/gateway.d.ts +85 -0
- package/dist/sdk/payment/gateway.js +183 -0
- package/dist/sdk/payment/gateway.js.map +1 -0
- package/dist/sdk/payment/operations.d.ts +52 -0
- package/dist/sdk/payment/operations.js +223 -0
- package/dist/sdk/payment/operations.js.map +1 -0
- package/dist/sdk/payment/security-code-mask.js +71 -0
- package/dist/sdk/payment/security-code-mask.js.map +1 -0
- package/dist/sdk/payment/submission-registry.d.ts +33 -0
- package/dist/sdk/payment/submission-registry.js +58 -0
- package/dist/sdk/payment/submission-registry.js.map +1 -0
- package/dist/sdk/payment/use-payment-actions.d.ts +78 -0
- package/dist/sdk/payment/use-payment-actions.js +276 -0
- package/dist/sdk/payment/use-payment-actions.js.map +1 -0
- package/dist/sdk/payment/use-place-order.d.ts +65 -0
- package/dist/sdk/payment/use-place-order.js +640 -0
- package/dist/sdk/payment/use-place-order.js.map +1 -0
- package/dist/sdk/session/auth-operations.d.ts +1 -1
- package/dist/sdk/session/auth-operations.js.map +1 -1
- package/dist/sdk/session/use-session-actions.d.ts +1 -1
- package/dist/sdk/session/use-session-actions.js.map +1 -1
- package/dist/sdk/session/use-session-revalidation.js +65 -0
- package/dist/sdk/session/use-session-revalidation.js.map +1 -0
- package/dist/sdk/shipping/option-select-operations.d.ts +1 -1
- package/dist/sdk/shipping/option-select-operations.js.map +1 -1
- package/dist/sdk/shipping/request-timeout.js +1 -1
- package/dist/sdk/shipping/request-timeout.js.map +1 -1
- package/dist/sdk/shipping/shipping-operations.d.ts +1 -1
- package/dist/sdk/shipping/shipping-operations.js.map +1 -1
- package/dist/sdk/shipping/use-shipping-actions.d.ts +2 -2
- package/dist/sdk/shipping/use-shipping-actions.js +1 -1
- package/dist/sdk/shipping/use-shipping-actions.js.map +1 -1
- package/dist/sdk/state/cart.d.ts +3 -4
- package/dist/sdk/state/cart.js +6 -7
- package/dist/sdk/state/cart.js.map +1 -1
- package/dist/utils/loggable-error-name.js +49 -0
- package/dist/utils/loggable-error-name.js.map +1 -0
- package/dist/utils/resolve-authored-copy.js +18 -0
- package/dist/utils/resolve-authored-copy.js.map +1 -0
- package/dist/utils/safe-href.js +3 -3
- package/dist/utils/safe-href.js.map +1 -1
- package/dist/utils/substitute-template.js +33 -0
- package/dist/utils/substitute-template.js.map +1 -0
- package/package.json +2 -1
- package/src/styles/tailwind.css +34 -0
- package/dist/docs/client-profile-form.md +0 -192
- package/dist/matter/client-profile-form/client-profile-form.d.ts +0 -126
- package/dist/matter/client-profile-form/client-profile-form.js +0 -662
- package/dist/matter/client-profile-form/client-profile-form.js.map +0 -1
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { defineActions } from "../../core/dist/actions/registry.js";
|
|
3
|
+
import "../../core/dist/index.js";
|
|
4
|
+
import { PAYMENT_BILLING_ADDRESS_UPDATE, PAYMENT_GATEWAY_CALLBACK, PAYMENT_INSTALLMENT_SELECT, PAYMENT_METHOD_SELECT, PAYMENT_NETWORK_ERROR_CODE, PAYMENT_START_TRANSACTION } from "./operations.js";
|
|
5
|
+
import { loggableErrorName } from "../../utils/loggable-error-name.js";
|
|
6
|
+
import { CLIENT_PREFERENCES_UPDATE } from "../identity/operations.js";
|
|
7
|
+
import { PAYMENT_GATEWAY_USER_ERROR, postPaymentsToGateway } from "./gateway.js";
|
|
8
|
+
import { useMutation } from "@apollo/client/react";
|
|
9
|
+
import { useCallback, useMemo } from "react";
|
|
10
|
+
//#region src/sdk/payment/use-payment-actions.ts
|
|
11
|
+
const NETWORK_ERROR = {
|
|
12
|
+
code: PAYMENT_NETWORK_ERROR_CODE,
|
|
13
|
+
message: "Unable to complete the request. Please try again."
|
|
14
|
+
};
|
|
15
|
+
/** Mirrors the resolver's own nulled-fields constant, so one added field is nulled in one place. */
|
|
16
|
+
const EMPTY_START_TRANSACTION = {
|
|
17
|
+
transactionId: null,
|
|
18
|
+
merchantName: null,
|
|
19
|
+
gatewayUrl: null,
|
|
20
|
+
orderGroup: null,
|
|
21
|
+
userProfileId: null,
|
|
22
|
+
value: null,
|
|
23
|
+
valueInCents: null,
|
|
24
|
+
referenceValueInCents: null
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The `payment` namespace hook. Registered with the first-party action registry via `paymentActions`
|
|
28
|
+
* below; the compiler-emitted `PaymentActionProvider` calls it and threads the narrowed methods into
|
|
29
|
+
* each consumer's `$actions.payment`. Writes persist purely through the normalized-cache merge of each
|
|
30
|
+
* mutation response — no refetch, no imperative cache write.
|
|
31
|
+
*/
|
|
32
|
+
function usePaymentActions() {
|
|
33
|
+
const [methodSelectMutation] = useMutation(PAYMENT_METHOD_SELECT);
|
|
34
|
+
const [installmentSelectMutation] = useMutation(PAYMENT_INSTALLMENT_SELECT);
|
|
35
|
+
const [billingAddressMutation] = useMutation(PAYMENT_BILLING_ADDRESS_UPDATE);
|
|
36
|
+
const [preferencesMutation] = useMutation(CLIENT_PREFERENCES_UPDATE);
|
|
37
|
+
const [startTransactionMutation] = useMutation(PAYMENT_START_TRANSACTION);
|
|
38
|
+
const [gatewayCallbackMutation] = useMutation(PAYMENT_GATEWAY_CALLBACK);
|
|
39
|
+
const setMethod = useCallback(async (input) => {
|
|
40
|
+
try {
|
|
41
|
+
return (await methodSelectMutation({ variables: { input } })).data?.paymentMethodSelect.userErrors ?? [];
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error("[payment.setMethod] paymentMethodSelect failed", loggableErrorName(error));
|
|
44
|
+
return [NETWORK_ERROR];
|
|
45
|
+
}
|
|
46
|
+
}, [methodSelectMutation]);
|
|
47
|
+
const setInstallments = useCallback(async (count) => {
|
|
48
|
+
try {
|
|
49
|
+
return (await installmentSelectMutation({ variables: { input: { count } } })).data?.paymentInstallmentSelect.userErrors ?? [];
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error("[payment.setInstallments] paymentInstallmentSelect failed", loggableErrorName(error));
|
|
52
|
+
return [NETWORK_ERROR];
|
|
53
|
+
}
|
|
54
|
+
}, [installmentSelectMutation]);
|
|
55
|
+
const setBillingAddress = useCallback(async (input) => {
|
|
56
|
+
try {
|
|
57
|
+
return (await billingAddressMutation({ variables: { input } })).data?.paymentBillingAddressUpdate.userErrors ?? [];
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error("[payment.setBillingAddress] paymentBillingAddressUpdate failed", loggableErrorName(error));
|
|
60
|
+
return [NETWORK_ERROR];
|
|
61
|
+
}
|
|
62
|
+
}, [billingAddressMutation]);
|
|
63
|
+
const saveCard = useCallback(async (enabled) => {
|
|
64
|
+
try {
|
|
65
|
+
return (await preferencesMutation({ variables: { input: { savePersonalData: enabled } } })).data?.clientPreferencesUpdate?.userErrors ?? [];
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error("[payment.saveCard] clientPreferencesUpdate failed", loggableErrorName(error));
|
|
68
|
+
return [NETWORK_ERROR];
|
|
69
|
+
}
|
|
70
|
+
}, [preferencesMutation]);
|
|
71
|
+
const startTransaction = useCallback(async () => {
|
|
72
|
+
try {
|
|
73
|
+
const payload = (await startTransactionMutation()).data?.paymentStartTransaction;
|
|
74
|
+
return {
|
|
75
|
+
transactionId: payload?.transactionId ?? null,
|
|
76
|
+
merchantName: payload?.merchantName ?? null,
|
|
77
|
+
gatewayUrl: payload?.gatewayUrl ?? null,
|
|
78
|
+
orderGroup: payload?.orderGroup ?? null,
|
|
79
|
+
userProfileId: payload?.userProfileId ?? null,
|
|
80
|
+
value: payload?.value ?? null,
|
|
81
|
+
valueInCents: payload?.valueInCents ?? null,
|
|
82
|
+
referenceValueInCents: payload?.referenceValueInCents ?? null,
|
|
83
|
+
userErrors: payload?.userErrors ?? []
|
|
84
|
+
};
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.error("[payment.startTransaction] paymentStartTransaction failed", loggableErrorName(error));
|
|
87
|
+
return {
|
|
88
|
+
...EMPTY_START_TRANSACTION,
|
|
89
|
+
userErrors: [NETWORK_ERROR]
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}, [startTransactionMutation]);
|
|
93
|
+
const gatewayCallback = useCallback(async (orderGroup) => {
|
|
94
|
+
try {
|
|
95
|
+
const payload = (await gatewayCallbackMutation({ variables: { input: { orderGroup } } })).data?.paymentGatewayCallback;
|
|
96
|
+
return {
|
|
97
|
+
orderId: payload?.orderId ?? null,
|
|
98
|
+
userErrors: payload?.userErrors ?? []
|
|
99
|
+
};
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error("[payment.gatewayCallback] paymentGatewayCallback failed", loggableErrorName(error));
|
|
102
|
+
return {
|
|
103
|
+
orderId: null,
|
|
104
|
+
userErrors: [NETWORK_ERROR]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}, [gatewayCallbackMutation]);
|
|
108
|
+
const sendPayments = useCallback(async (request) => {
|
|
109
|
+
try {
|
|
110
|
+
return await postPaymentsToGateway(request);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error("[payment.sendPayments] gateway request failed", loggableErrorName(error));
|
|
113
|
+
return [PAYMENT_GATEWAY_USER_ERROR];
|
|
114
|
+
}
|
|
115
|
+
}, []);
|
|
116
|
+
return useMemo(() => ({
|
|
117
|
+
setMethod,
|
|
118
|
+
setInstallments,
|
|
119
|
+
setBillingAddress,
|
|
120
|
+
saveCard,
|
|
121
|
+
startTransaction,
|
|
122
|
+
gatewayCallback,
|
|
123
|
+
sendPayments
|
|
124
|
+
}), [
|
|
125
|
+
setMethod,
|
|
126
|
+
setInstallments,
|
|
127
|
+
setBillingAddress,
|
|
128
|
+
saveCard,
|
|
129
|
+
startTransaction,
|
|
130
|
+
gatewayCallback,
|
|
131
|
+
sendPayments
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
defineActions({
|
|
135
|
+
namespace: "payment",
|
|
136
|
+
description: "Mutation-backed payment writes against the VTEX orderForm paymentData/invoiceData, plus a façade that posts card data directly to the payment gateway (never through our GraphQL layer or cache).",
|
|
137
|
+
provider: {
|
|
138
|
+
name: "PaymentActionProvider",
|
|
139
|
+
importPath: "@vtex/faststore/internal/client"
|
|
140
|
+
},
|
|
141
|
+
methods: {
|
|
142
|
+
setMethod: {
|
|
143
|
+
description: "Select a payment method, optionally identifying a new card by BIN or a saved card by account (async/pessimistic). Resolves the payload userErrors.",
|
|
144
|
+
payload: [
|
|
145
|
+
{
|
|
146
|
+
name: "methodId",
|
|
147
|
+
type: "string"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "bin",
|
|
151
|
+
type: "string",
|
|
152
|
+
optional: true
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "accountId",
|
|
156
|
+
type: "string",
|
|
157
|
+
optional: true
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
setInstallments: {
|
|
162
|
+
description: "Select an installment count for the current method (async/pessimistic). The response recomputes the cart total with interest. Resolves the payload userErrors.",
|
|
163
|
+
payload: [{
|
|
164
|
+
name: "count",
|
|
165
|
+
type: "number"
|
|
166
|
+
}]
|
|
167
|
+
},
|
|
168
|
+
setBillingAddress: {
|
|
169
|
+
description: "Persist the billing address, or fall back to the delivery address with sameAsDelivery (async/pessimistic). Resolves the payload userErrors.",
|
|
170
|
+
payload: [
|
|
171
|
+
{
|
|
172
|
+
name: "sameAsDelivery",
|
|
173
|
+
type: "boolean"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "addressType",
|
|
177
|
+
type: "string",
|
|
178
|
+
optional: true
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "postalCode",
|
|
182
|
+
type: "string",
|
|
183
|
+
optional: true
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: "country",
|
|
187
|
+
type: "string",
|
|
188
|
+
optional: true
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "street",
|
|
192
|
+
type: "string",
|
|
193
|
+
optional: true
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "number",
|
|
197
|
+
type: "string",
|
|
198
|
+
optional: true
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: "complement",
|
|
202
|
+
type: "string",
|
|
203
|
+
optional: true
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: "neighborhood",
|
|
207
|
+
type: "string",
|
|
208
|
+
optional: true
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: "city",
|
|
212
|
+
type: "string",
|
|
213
|
+
optional: true
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: "state",
|
|
217
|
+
type: "string",
|
|
218
|
+
optional: true
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: "reference",
|
|
222
|
+
type: "string",
|
|
223
|
+
optional: true
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
saveCard: {
|
|
228
|
+
description: "Record the data-storage consent a saved card requires, reusing the existing clientPreferencesUpdate write. Does not itself save the card — the save flag and label travel on sendPayments.",
|
|
229
|
+
payload: [{
|
|
230
|
+
name: "enabled",
|
|
231
|
+
type: "boolean"
|
|
232
|
+
}]
|
|
233
|
+
},
|
|
234
|
+
startTransaction: {
|
|
235
|
+
description: "Open a VTEX transaction from the persisted payment selection. Takes no arguments; resolves the transaction identifiers the gateway call needs.",
|
|
236
|
+
payload: []
|
|
237
|
+
},
|
|
238
|
+
gatewayCallback: {
|
|
239
|
+
description: "Finalize the transaction after the gateway accepted the card. Resolves the payload userErrors.",
|
|
240
|
+
payload: [{
|
|
241
|
+
name: "orderGroup",
|
|
242
|
+
type: "string"
|
|
243
|
+
}]
|
|
244
|
+
},
|
|
245
|
+
sendPayments: {
|
|
246
|
+
description: "Façade: post the card directly from the browser to the payment gateway. Issues no GraphQL operation and writes nothing to the cache. The card number and CVV are runtime-only arguments and are deliberately absent from this payload — they are never a bindable field (RFC D13).",
|
|
247
|
+
payload: [
|
|
248
|
+
{
|
|
249
|
+
name: "gatewayUrl",
|
|
250
|
+
type: "string"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "transactionId",
|
|
254
|
+
type: "string"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: "merchantName",
|
|
258
|
+
type: "string"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "orderGroup",
|
|
262
|
+
type: "string"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: "userProfileId",
|
|
266
|
+
type: "string"
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
use: usePaymentActions
|
|
272
|
+
});
|
|
273
|
+
//#endregion
|
|
274
|
+
export { usePaymentActions };
|
|
275
|
+
|
|
276
|
+
//# sourceMappingURL=use-payment-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-payment-actions.js","names":[],"sources":["../../../src/sdk/payment/use-payment-actions.ts"],"sourcesContent":["'use client';\n\nimport { useMutation } from '@apollo/client/react';\nimport { defineActions } from '@vtex/fs-core';\nimport { useCallback, useMemo } from 'react';\nimport { loggableErrorName } from '../../utils/loggable-error-name.js';\nimport { CLIENT_PREFERENCES_UPDATE } from '../identity/operations.js';\nimport { PAYMENT_GATEWAY_USER_ERROR, postPaymentsToGateway, type SendPaymentsRequest } from './gateway.js';\nimport {\n PAYMENT_BILLING_ADDRESS_UPDATE,\n PAYMENT_GATEWAY_CALLBACK,\n PAYMENT_INSTALLMENT_SELECT,\n PAYMENT_METHOD_SELECT,\n PAYMENT_NETWORK_ERROR_CODE,\n PAYMENT_START_TRANSACTION,\n type PaymentBillingAddressUpdateInput,\n type PaymentMethodSelectInput,\n type PaymentMoney,\n type PaymentUserError,\n} from './operations.js';\n\n/**\n * The `payment` action namespace — the sanctioned client write surface for credit-card payment\n * (specs/payment-action-namespace.md; docs/features/credit-card/rfc.md § D12;\n * docs/storefront-core/adr-0010-actions-own-the-write-side.md).\n *\n * Six mutation-backed methods run the write model T3 shipped (`checkout/schema.graphql` § 11), except\n * `saveCard`, which reuses the already-shipped `clientPreferencesUpdate` document this package owns —\n * there is no `paymentSaveCard` mutation and T3 decided there must not be one. All six are\n * async/pessimistic: the handler awaits the mutation and only the server-confirmed payload changes the\n * cache. Each is stateless (no reactive vars, no module state), resolves its payload `userErrors` (empty\n * on success), and never throws for an expected outcome; an infrastructure failure (transport or an\n * upstream GraphQLError) is caught and collapsed to one synthetic `NETWORK_ERROR` userError with no\n * per-code branching, mirroring `useShippingActions`.\n *\n * `sendPayments` is the seventh method and the odd one: a **façade** (ADR-0010's sanctioned flavor,\n * alongside `notifications`) that posts card data from the browser straight to the payment gateway,\n * touching neither our GraphQL layer nor the normalized cache. It is catalogued like any other method —\n * per D12, hiding a write route with no read-back would cost discoverability without protecting\n * anything, and the compiler wants to *see* which components reference it. What is deliberately absent\n * from the catalog is the card data itself: no `payload` entry below names a card number, CVV, expiry,\n * or holder name, so there is no schema-bindable name for the editor or the agent to map a value onto\n * (RFC D13). The card reaches the handler as a runtime argument from the card-entry component's local\n * state (T7), and `gateway.ts` — which has no Apollo import — is the only module that touches it.\n */\n\n/**\n * Everything `usePlaceOrder` (T13) needs to assemble `PaymentGatewayTransaction`, minus the five\n * fields that come from the `Payment` read model. Every field is nullable because a payload carrying\n * `userErrors` nulls all of them (T18 Decision 4), so a complete descriptor is only guaranteed once\n * `userErrors` is empty *and* the payload passes the caller's completeness check.\n */\nexport type PaymentStartTransactionResult = Readonly<{\n transactionId: string | null;\n merchantName: string | null;\n /** Gateway origin. Nullable, and never interpolated into a URL before `isTrustedGatewayOrigin`. */\n gatewayUrl: string | null;\n orderGroup: string | null;\n userProfileId: string | null;\n /** Display decimal. The gateway body's unit is `valueInCents`. */\n value: PaymentMoney | null;\n valueInCents: number | null;\n referenceValueInCents: number | null;\n userErrors: readonly PaymentUserError[];\n}>;\n\nexport type PaymentGatewayCallbackResult = Readonly<{\n orderId: string | null;\n userErrors: readonly PaymentUserError[];\n}>;\n\nexport type PaymentActions = Readonly<{\n /** Select a payment method, optionally identifying a new card's BIN or a saved card's account. */\n setMethod: (input: PaymentMethodSelectInput) => Promise<readonly PaymentUserError[]>;\n /** Select an installment count for the current method. The response carries the recomputed cart total. */\n setInstallments: (count: number) => Promise<readonly PaymentUserError[]>;\n /** Persist the billing address, or fall back to the delivery address (`sameAsDelivery: true`). */\n setBillingAddress: (input: PaymentBillingAddressUpdateInput) => Promise<readonly PaymentUserError[]>;\n /**\n * Record the data-storage consent a saved card requires, over the existing `clientPreferencesUpdate`.\n * This does not by itself save the card: the save flag and label travel on `sendPayments`'s card\n * argument (RFC D5's two halves). The boolean passes through unchanged — whether unchecking should\n * revoke a consent an unrelated opt-in component may have granted is T10's decision, and its spec must\n * state one (Gap 4 in specs/payment-action-namespace.md).\n */\n saveCard: (enabled: boolean) => Promise<readonly PaymentUserError[]>;\n /** Open a VTEX transaction from the persisted selection. Resolves the payload the gateway call needs. */\n startTransaction: () => Promise<PaymentStartTransactionResult>;\n /** Finalize the transaction after the gateway accepted the card. */\n gatewayCallback: (orderGroup: string) => Promise<PaymentGatewayCallbackResult>;\n /**\n * Façade: post the card straight to the payment gateway. Issues no GraphQL operation and writes\n * nothing to the cache. Resolves one `GATEWAY_ERROR` userError when the gateway rejects the call.\n */\n sendPayments: (request: SendPaymentsRequest) => Promise<readonly PaymentUserError[]>;\n}>;\n\nconst NETWORK_ERROR: PaymentUserError = {\n code: PAYMENT_NETWORK_ERROR_CODE,\n message: 'Unable to complete the request. Please try again.',\n};\n\n/** Mirrors the resolver's own nulled-fields constant, so one added field is nulled in one place. */\nconst EMPTY_START_TRANSACTION = {\n transactionId: null,\n merchantName: null,\n gatewayUrl: null,\n orderGroup: null,\n userProfileId: null,\n value: null,\n valueInCents: null,\n referenceValueInCents: null,\n} as const;\n\n/**\n * The `payment` namespace hook. Registered with the first-party action registry via `paymentActions`\n * below; the compiler-emitted `PaymentActionProvider` calls it and threads the narrowed methods into\n * each consumer's `$actions.payment`. Writes persist purely through the normalized-cache merge of each\n * mutation response — no refetch, no imperative cache write.\n */\nexport function usePaymentActions(): PaymentActions {\n const [methodSelectMutation] = useMutation(PAYMENT_METHOD_SELECT);\n const [installmentSelectMutation] = useMutation(PAYMENT_INSTALLMENT_SELECT);\n const [billingAddressMutation] = useMutation(PAYMENT_BILLING_ADDRESS_UPDATE);\n const [preferencesMutation] = useMutation(CLIENT_PREFERENCES_UPDATE);\n const [startTransactionMutation] = useMutation(PAYMENT_START_TRANSACTION);\n const [gatewayCallbackMutation] = useMutation(PAYMENT_GATEWAY_CALLBACK);\n\n const setMethod = useCallback<PaymentActions['setMethod']>(\n async (input) => {\n try {\n const result = await methodSelectMutation({ variables: { input } });\n return result.data?.paymentMethodSelect.userErrors ?? [];\n } catch (error) {\n // Log only the error name — the input carries the card's BIN, and a variable-coercion error's\n // message echoes the offending value (`got invalid value … at \"input.bin\"`).\n console.error('[payment.setMethod] paymentMethodSelect failed', loggableErrorName(error));\n return [NETWORK_ERROR];\n }\n },\n [methodSelectMutation],\n );\n\n const setInstallments = useCallback<PaymentActions['setInstallments']>(\n async (count) => {\n try {\n const result = await installmentSelectMutation({ variables: { input: { count } } });\n return result.data?.paymentInstallmentSelect.userErrors ?? [];\n } catch (error) {\n console.error('[payment.setInstallments] paymentInstallmentSelect failed', loggableErrorName(error));\n return [NETWORK_ERROR];\n }\n },\n [installmentSelectMutation],\n );\n\n const setBillingAddress = useCallback<PaymentActions['setBillingAddress']>(\n async (input) => {\n try {\n const result = await billingAddressMutation({ variables: { input } });\n return result.data?.paymentBillingAddressUpdate.userErrors ?? [];\n } catch (error) {\n // Log only the error name — the message can echo the submitted address (PII).\n console.error('[payment.setBillingAddress] paymentBillingAddressUpdate failed', loggableErrorName(error));\n return [NETWORK_ERROR];\n }\n },\n [billingAddressMutation],\n );\n\n const saveCard = useCallback<PaymentActions['saveCard']>(\n async (enabled) => {\n try {\n const result = await preferencesMutation({ variables: { input: { savePersonalData: enabled } } });\n return result.data?.clientPreferencesUpdate?.userErrors ?? [];\n } catch (error) {\n console.error('[payment.saveCard] clientPreferencesUpdate failed', loggableErrorName(error));\n return [NETWORK_ERROR];\n }\n },\n [preferencesMutation],\n );\n\n const startTransaction = useCallback<PaymentActions['startTransaction']>(async () => {\n try {\n const result = await startTransactionMutation();\n const payload = result.data?.paymentStartTransaction;\n return {\n transactionId: payload?.transactionId ?? null,\n merchantName: payload?.merchantName ?? null,\n gatewayUrl: payload?.gatewayUrl ?? null,\n orderGroup: payload?.orderGroup ?? null,\n userProfileId: payload?.userProfileId ?? null,\n value: payload?.value ?? null,\n valueInCents: payload?.valueInCents ?? null,\n referenceValueInCents: payload?.referenceValueInCents ?? null,\n userErrors: payload?.userErrors ?? [],\n };\n } catch (error) {\n console.error('[payment.startTransaction] paymentStartTransaction failed', loggableErrorName(error));\n return { ...EMPTY_START_TRANSACTION, userErrors: [NETWORK_ERROR] };\n }\n }, [startTransactionMutation]);\n\n const gatewayCallback = useCallback<PaymentActions['gatewayCallback']>(\n async (orderGroup) => {\n try {\n const result = await gatewayCallbackMutation({ variables: { input: { orderGroup } } });\n const payload = result.data?.paymentGatewayCallback;\n return { orderId: payload?.orderId ?? null, userErrors: payload?.userErrors ?? [] };\n } catch (error) {\n console.error('[payment.gatewayCallback] paymentGatewayCallback failed', loggableErrorName(error));\n return { orderId: null, userErrors: [NETWORK_ERROR] };\n }\n },\n [gatewayCallbackMutation],\n );\n\n const sendPayments = useCallback<PaymentActions['sendPayments']>(async (request) => {\n try {\n return await postPaymentsToGateway(request);\n } catch (error) {\n // Log the error NAME ONLY. The request carries a card number and CVV, and a thrown fetch error's\n // message can echo the URL or the body — nothing on this path is ever serialized to a log.\n console.error('[payment.sendPayments] gateway request failed', loggableErrorName(error));\n return [PAYMENT_GATEWAY_USER_ERROR];\n }\n }, []);\n\n return useMemo(\n () => ({\n setMethod,\n setInstallments,\n setBillingAddress,\n saveCard,\n startTransaction,\n gatewayCallback,\n sendPayments,\n }),\n [setMethod, setInstallments, setBillingAddress, saveCard, startTransaction, gatewayCallback, sendPayments],\n );\n}\n\n/**\n * Declares the `payment` action namespace — the single source of truth for its method/payload metadata,\n * runtime provider, and `use` hook (mirrors `cartActions`, `shippingActions`). The native catalog\n * builder (`scripts/build-catalog.mjs`) statically reads this call to emit `actions.json`; at runtime\n * `PaymentActionProvider` calls `usePaymentActions` directly.\n *\n * `sendPayments`'s `payload` lists only the non-sensitive transaction descriptor's identifiers.\n * `ActionPayloadField` is the surface a schema-bindable name would come from, so the card fields'\n * absence here is the mechanical form of RFC D13: card number and CVV are never expressed as a declared\n * action payload. The `SendPaymentsRequest` type in `gateway.ts` is the source of truth for the real\n * call shape.\n */\nexport const paymentActions = defineActions({\n namespace: 'payment',\n description:\n 'Mutation-backed payment writes against the VTEX orderForm paymentData/invoiceData, plus a façade that posts card data directly to the payment gateway (never through our GraphQL layer or cache).',\n provider: { name: 'PaymentActionProvider', importPath: '@vtex/faststore/internal/client' },\n methods: {\n setMethod: {\n description:\n 'Select a payment method, optionally identifying a new card by BIN or a saved card by account (async/pessimistic). Resolves the payload userErrors.',\n payload: [\n { name: 'methodId', type: 'string' },\n { name: 'bin', type: 'string', optional: true },\n { name: 'accountId', type: 'string', optional: true },\n ],\n },\n setInstallments: {\n description:\n 'Select an installment count for the current method (async/pessimistic). The response recomputes the cart total with interest. Resolves the payload userErrors.',\n payload: [{ name: 'count', type: 'number' }],\n },\n setBillingAddress: {\n description:\n 'Persist the billing address, or fall back to the delivery address with sameAsDelivery (async/pessimistic). Resolves the payload userErrors.',\n payload: [\n { name: 'sameAsDelivery', type: 'boolean' },\n { name: 'addressType', type: 'string', optional: true },\n { name: 'postalCode', type: 'string', optional: true },\n { name: 'country', type: 'string', optional: true },\n { name: 'street', type: 'string', optional: true },\n { name: 'number', type: 'string', optional: true },\n { name: 'complement', type: 'string', optional: true },\n { name: 'neighborhood', type: 'string', optional: true },\n { name: 'city', type: 'string', optional: true },\n { name: 'state', type: 'string', optional: true },\n { name: 'reference', type: 'string', optional: true },\n ],\n },\n saveCard: {\n description:\n 'Record the data-storage consent a saved card requires, reusing the existing clientPreferencesUpdate write. Does not itself save the card — the save flag and label travel on sendPayments.',\n payload: [{ name: 'enabled', type: 'boolean' }],\n },\n startTransaction: {\n description:\n 'Open a VTEX transaction from the persisted payment selection. Takes no arguments; resolves the transaction identifiers the gateway call needs.',\n payload: [],\n },\n gatewayCallback: {\n description: 'Finalize the transaction after the gateway accepted the card. Resolves the payload userErrors.',\n payload: [{ name: 'orderGroup', type: 'string' }],\n },\n sendPayments: {\n description:\n 'Façade: post the card directly from the browser to the payment gateway. Issues no GraphQL operation and writes nothing to the cache. The card number and CVV are runtime-only arguments and are deliberately absent from this payload — they are never a bindable field (RFC D13).',\n payload: [\n { name: 'gatewayUrl', type: 'string' },\n { name: 'transactionId', type: 'string' },\n { name: 'merchantName', type: 'string' },\n { name: 'orderGroup', type: 'string' },\n { name: 'userProfileId', type: 'string' },\n ],\n },\n },\n use: usePaymentActions,\n});\n"],"mappings":"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"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { PaymentMoney } from "./operations.js";
|
|
2
|
+
import "../actions/types.js";
|
|
3
|
+
//#region src/sdk/payment/use-place-order.d.ts
|
|
4
|
+
export type PlaceOrderInstallment = Readonly<{
|
|
5
|
+
count: number;
|
|
6
|
+
/** Per-installment amount, as a display decimal. The gateway's unit is minor units. */
|
|
7
|
+
value: PaymentMoney;
|
|
8
|
+
interestRate: number;
|
|
9
|
+
}>;
|
|
10
|
+
export type PlaceOrderMethod = Readonly<{
|
|
11
|
+
id: string;
|
|
12
|
+
groupName: string;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* The `Payment` slice T14's fragment forwards (arity-1, ADR-0015) — the same convention as
|
|
16
|
+
* `PaymentSectionData`. These five values are the part of the descriptor `paymentStartTransaction`
|
|
17
|
+
* does not carry: T18 deliberately did not re-project the read model onto a write payload.
|
|
18
|
+
*/
|
|
19
|
+
export type PlaceOrderData = {
|
|
20
|
+
selectedMethodId?: string | null;
|
|
21
|
+
selectedInstallment?: PlaceOrderInstallment | null;
|
|
22
|
+
methods?: readonly PlaceOrderMethod[];
|
|
23
|
+
} | null;
|
|
24
|
+
/**
|
|
25
|
+
* How far an order attempt got. The phase, not an error code, is what says whether money may already
|
|
26
|
+
* have moved — an aborted card POST and a refused transaction both surface as the same userError, and
|
|
27
|
+
* only this distinguishes them.
|
|
28
|
+
*/
|
|
29
|
+
export type PlaceOrderAttemptPhase =
|
|
30
|
+
/** `startTransaction` issued or resolved. Nothing has been paid. */
|
|
31
|
+
'opening' |
|
|
32
|
+
/** A leg refused before the card left the browser. A fresh full attempt is legal. */
|
|
33
|
+
'refused' |
|
|
34
|
+
/** The continuation resolved with no userErrors — the card reached the gateway. */
|
|
35
|
+
'sent' |
|
|
36
|
+
/** The card's fate is unknown: the continuation threw, or the POST was aborted, or a finalization
|
|
37
|
+
* did not resolve. Treated exactly like `sent`. */
|
|
38
|
+
'unresolved' |
|
|
39
|
+
/** `gatewayCallback` is in flight for this attempt's order group. */
|
|
40
|
+
'finalizing' |
|
|
41
|
+
/** `gatewayCallback` resolved with no userErrors. Terminal. */
|
|
42
|
+
'settled';
|
|
43
|
+
export type PlaceOrderAttempt = Readonly<{
|
|
44
|
+
/** Identity that outlives any one mount. Not `useId()` — that is per-instance and resets. */
|
|
45
|
+
attemptId: string;
|
|
46
|
+
phase: PlaceOrderAttemptPhase;
|
|
47
|
+
/** Resolved by `startTransaction`; the only key a resume needs. Null before `opening` settles. */
|
|
48
|
+
orderGroup: string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Resolved by `gatewayCallback`. Not an independent identifier: the resolver returns
|
|
51
|
+
* `orderId: input.orderGroup` (`checkout/index.ts:1965`), echoing the argument back, because the
|
|
52
|
+
* upstream success response body is discarded. So `orderId === orderGroup` on every success today.
|
|
53
|
+
*/
|
|
54
|
+
orderId: string | null;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Fix pass (High finding, race #2): widened past a plain value so a write can be made conditional on
|
|
58
|
+
* whatever the shared attempt actually is *at write time* — the primitive `useState` already exposes
|
|
59
|
+
* this (its setter has always accepted an updater function; only this package's own declared type
|
|
60
|
+
* stopped a caller from using that form). A plain value remains valid; every existing caller that
|
|
61
|
+
* never needed the guard is unaffected.
|
|
62
|
+
*/
|
|
63
|
+
export type SetPlaceOrderAttempt = (update: PlaceOrderAttempt | null | ((prev: PlaceOrderAttempt | null) => PlaceOrderAttempt | null)) => void;
|
|
64
|
+
//#endregion
|
|
65
|
+
//# sourceMappingURL=use-place-order.d.ts.map
|