@whop/elements-react-native 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +179 -0
- package/android/build.gradle +64 -0
- package/android/consumer-rules.pro +3 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/java/com/whop/elements/WhopAddressSuggestionsModule.kt +102 -0
- package/android/src/main/java/com/whop/elements/WhopAuthSessionModule.kt +126 -0
- package/android/src/main/java/com/whop/elements/WhopElementsPackage.kt +39 -0
- package/android/src/main/java/com/whop/elements/WhopPayButtonManager.kt +74 -0
- package/android/src/main/java/com/whop/elements/WhopPayButtonPressEvent.kt +17 -0
- package/android/src/main/java/com/whop/elements/WhopPayButtonView.kt +178 -0
- package/android/src/main/java/com/whop/elements/WhopPlatformPayModule.kt +212 -0
- package/assets/whop-wordmark-dark.png +0 -0
- package/assets/whop-wordmark-dark@2x.png +0 -0
- package/assets/whop-wordmark-dark@3x.png +0 -0
- package/assets/whop-wordmark-light.png +0 -0
- package/assets/whop-wordmark-light@2x.png +0 -0
- package/assets/whop-wordmark-light@3x.png +0 -0
- package/ios/Package.swift +59 -0
- package/ios/Sources/ElementsReactNative/WhopAddressSuggestionsImpl.swift +189 -0
- package/ios/Sources/ElementsReactNative/WhopAuthSessionImpl.swift +106 -0
- package/ios/Sources/ElementsReactNative/WhopPayButtonImpl.swift +89 -0
- package/ios/Sources/ElementsReactNative/WhopPlatformPayImpl.swift +181 -0
- package/ios/generated/WhopAddressSuggestionsModule.h +11 -0
- package/ios/generated/WhopAddressSuggestionsModule.mm +46 -0
- package/ios/generated/WhopAuthSessionModule.h +11 -0
- package/ios/generated/WhopAuthSessionModule.mm +45 -0
- package/ios/generated/WhopElementsShims.h +35 -0
- package/ios/generated/WhopPayButtonComponentView.h +12 -0
- package/ios/generated/WhopPayButtonComponentView.mm +82 -0
- package/ios/generated/WhopPlatformPayModule.h +11 -0
- package/ios/generated/WhopPlatformPayModule.mm +51 -0
- package/lib/module/api/client.js +139 -0
- package/lib/module/api/client.js.map +1 -0
- package/lib/module/api/client.test.js +137 -0
- package/lib/module/api/client.test.js.map +1 -0
- package/lib/module/api/types.js +2 -0
- package/lib/module/api/types.js.map +1 -0
- package/lib/module/controller/actions.js +148 -0
- package/lib/module/controller/actions.js.map +1 -0
- package/lib/module/controller/actions.test.js +102 -0
- package/lib/module/controller/actions.test.js.map +1 -0
- package/lib/module/controller/store.js +158 -0
- package/lib/module/controller/store.js.map +1 -0
- package/lib/module/core/address/country-data.js +1370 -0
- package/lib/module/core/address/country-data.js.map +1 -0
- package/lib/module/core/address/country-name.js +38 -0
- package/lib/module/core/address/country-name.js.map +1 -0
- package/lib/module/core/address/country-names.generated.js +249 -0
- package/lib/module/core/address/country-names.generated.js.map +1 -0
- package/lib/module/core/address/engine.js +245 -0
- package/lib/module/core/address/engine.js.map +1 -0
- package/lib/module/core/address/engine.test.js +216 -0
- package/lib/module/core/address/engine.test.js.map +1 -0
- package/lib/module/core/address/form-state.js +409 -0
- package/lib/module/core/address/form-state.js.map +1 -0
- package/lib/module/core/address/form-state.test.js +516 -0
- package/lib/module/core/address/form-state.test.js.map +1 -0
- package/lib/module/core/address/places.js +36 -0
- package/lib/module/core/address/places.js.map +1 -0
- package/lib/module/core/address/required-coverage.test.js +57 -0
- package/lib/module/core/address/required-coverage.test.js.map +1 -0
- package/lib/module/core/address/suggest.js +102 -0
- package/lib/module/core/address/suggest.js.map +1 -0
- package/lib/module/core/address/suggest.test.js +156 -0
- package/lib/module/core/address/suggest.test.js.map +1 -0
- package/lib/module/core/address/use-suggestions.js +33 -0
- package/lib/module/core/address/use-suggestions.js.map +1 -0
- package/lib/module/core/payments/address-change.js +91 -0
- package/lib/module/core/payments/address-change.js.map +1 -0
- package/lib/module/core/payments/billing-merge.js +62 -0
- package/lib/module/core/payments/billing-merge.js.map +1 -0
- package/lib/module/core/payments/browser-info.js +42 -0
- package/lib/module/core/payments/browser-info.js.map +1 -0
- package/lib/module/core/payments/bt.js +151 -0
- package/lib/module/core/payments/bt.js.map +1 -0
- package/lib/module/core/payments/bt.test.js +23 -0
- package/lib/module/core/payments/bt.test.js.map +1 -0
- package/lib/module/core/payments/currency.js +37 -0
- package/lib/module/core/payments/currency.js.map +1 -0
- package/lib/module/core/payments/detail.js +159 -0
- package/lib/module/core/payments/detail.js.map +1 -0
- package/lib/module/core/payments/detail.test.js +225 -0
- package/lib/module/core/payments/detail.test.js.map +1 -0
- package/lib/module/core/payments/errors.js +115 -0
- package/lib/module/core/payments/errors.js.map +1 -0
- package/lib/module/core/payments/mint.js +89 -0
- package/lib/module/core/payments/mint.js.map +1 -0
- package/lib/module/core/payments/plan.js +131 -0
- package/lib/module/core/payments/plan.js.map +1 -0
- package/lib/module/core/payments/refusals.js +17 -0
- package/lib/module/core/payments/refusals.js.map +1 -0
- package/lib/module/core/payments/secure-fields.js +87 -0
- package/lib/module/core/payments/secure-fields.js.map +1 -0
- package/lib/module/core/payments/tax-id-catalog.js +616 -0
- package/lib/module/core/payments/tax-id-catalog.js.map +1 -0
- package/lib/module/core/payments/wallet-contact.js +42 -0
- package/lib/module/core/payments/wallet-contact.js.map +1 -0
- package/lib/module/core/payments/wallet-contact.test.js +77 -0
- package/lib/module/core/payments/wallet-contact.test.js.map +1 -0
- package/lib/module/elements/address.js +467 -0
- package/lib/module/elements/address.js.map +1 -0
- package/lib/module/elements/branding.js +114 -0
- package/lib/module/elements/branding.js.map +1 -0
- package/lib/module/elements/card-fields/context.js +254 -0
- package/lib/module/elements/card-fields/context.js.map +1 -0
- package/lib/module/elements/card-fields/fields.js +309 -0
- package/lib/module/elements/card-fields/fields.js.map +1 -0
- package/lib/module/elements/card-fields/index.js +30 -0
- package/lib/module/elements/card-fields/index.js.map +1 -0
- package/lib/module/elements/card.js +107 -0
- package/lib/module/elements/card.js.map +1 -0
- package/lib/module/elements/email.js +84 -0
- package/lib/module/elements/email.js.map +1 -0
- package/lib/module/elements/payment/declared-fields.js +186 -0
- package/lib/module/elements/payment/declared-fields.js.map +1 -0
- package/lib/module/elements/payment/index.js +448 -0
- package/lib/module/elements/payment/index.js.map +1 -0
- package/lib/module/elements/payment/wallet.js +132 -0
- package/lib/module/elements/payment/wallet.js.map +1 -0
- package/lib/module/elements/tax-id.js +100 -0
- package/lib/module/elements/tax-id.js.map +1 -0
- package/lib/module/i18n/catalogs.js +103 -0
- package/lib/module/i18n/catalogs.js.map +1 -0
- package/lib/module/i18n/index.js +45 -0
- package/lib/module/i18n/index.js.map +1 -0
- package/lib/module/index.js +27 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/namespace.js +174 -0
- package/lib/module/namespace.js.map +1 -0
- package/lib/module/native/index.js +128 -0
- package/lib/module/native/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/provider.js +56 -0
- package/lib/module/provider.js.map +1 -0
- package/lib/module/specs/NativeWhopAddressSuggestions.js +6 -0
- package/lib/module/specs/NativeWhopAddressSuggestions.js.map +1 -0
- package/lib/module/specs/NativeWhopAuthSession.js +10 -0
- package/lib/module/specs/NativeWhopAuthSession.js.map +1 -0
- package/lib/module/specs/NativeWhopPlatformPay.js +10 -0
- package/lib/module/specs/NativeWhopPlatformPay.js.map +1 -0
- package/lib/module/specs/WhopPayButtonNativeComponent.ts +22 -0
- package/lib/module/theme/appearance.js +85 -0
- package/lib/module/theme/appearance.js.map +1 -0
- package/lib/module/theme/appearance.test.js +124 -0
- package/lib/module/theme/appearance.test.js.map +1 -0
- package/lib/module/theme/provider.js +25 -0
- package/lib/module/theme/provider.js.map +1 -0
- package/lib/module/theme/resolve.js +69 -0
- package/lib/module/theme/resolve.js.map +1 -0
- package/lib/module/theme/scales.generated.js +419 -0
- package/lib/module/theme/scales.generated.js.map +1 -0
- package/lib/module/ui/element-frame.js +83 -0
- package/lib/module/ui/element-frame.js.map +1 -0
- package/lib/module/ui/payment-method-icon.js +69 -0
- package/lib/module/ui/payment-method-icon.js.map +1 -0
- package/lib/module/ui/primitives.js +266 -0
- package/lib/module/ui/primitives.js.map +1 -0
- package/lib/module/ui/select.js +281 -0
- package/lib/module/ui/select.js.map +1 -0
- package/lib/module/ui/suggestions.js +71 -0
- package/lib/module/ui/suggestions.js.map +1 -0
- package/lib/module/ui/whop-logo.js +42 -0
- package/lib/module/ui/whop-logo.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/api/client.d.ts +87 -0
- package/lib/typescript/src/api/client.d.ts.map +1 -0
- package/lib/typescript/src/api/types.d.ts +175 -0
- package/lib/typescript/src/api/types.d.ts.map +1 -0
- package/lib/typescript/src/controller/actions.d.ts +42 -0
- package/lib/typescript/src/controller/actions.d.ts.map +1 -0
- package/lib/typescript/src/controller/store.d.ts +90 -0
- package/lib/typescript/src/controller/store.d.ts.map +1 -0
- package/lib/typescript/src/core/address/country-data.d.ts +4 -0
- package/lib/typescript/src/core/address/country-data.d.ts.map +1 -0
- package/lib/typescript/src/core/address/country-name.d.ts +2 -0
- package/lib/typescript/src/core/address/country-name.d.ts.map +1 -0
- package/lib/typescript/src/core/address/country-names.generated.d.ts +2 -0
- package/lib/typescript/src/core/address/country-names.generated.d.ts.map +1 -0
- package/lib/typescript/src/core/address/engine.d.ts +97 -0
- package/lib/typescript/src/core/address/engine.d.ts.map +1 -0
- package/lib/typescript/src/core/address/form-state.d.ts +144 -0
- package/lib/typescript/src/core/address/form-state.d.ts.map +1 -0
- package/lib/typescript/src/core/address/places.d.ts +23 -0
- package/lib/typescript/src/core/address/places.d.ts.map +1 -0
- package/lib/typescript/src/core/address/suggest.d.ts +47 -0
- package/lib/typescript/src/core/address/suggest.d.ts.map +1 -0
- package/lib/typescript/src/core/address/use-suggestions.d.ts +3 -0
- package/lib/typescript/src/core/address/use-suggestions.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/address-change.d.ts +52 -0
- package/lib/typescript/src/core/payments/address-change.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/billing-merge.d.ts +39 -0
- package/lib/typescript/src/core/payments/billing-merge.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/browser-info.d.ts +12 -0
- package/lib/typescript/src/core/payments/browser-info.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/bt.d.ts +55 -0
- package/lib/typescript/src/core/payments/bt.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/currency.d.ts +7 -0
- package/lib/typescript/src/core/payments/currency.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/detail.d.ts +53 -0
- package/lib/typescript/src/core/payments/detail.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/errors.d.ts +62 -0
- package/lib/typescript/src/core/payments/errors.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/mint.d.ts +74 -0
- package/lib/typescript/src/core/payments/mint.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/plan.d.ts +69 -0
- package/lib/typescript/src/core/payments/plan.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/refusals.d.ts +12 -0
- package/lib/typescript/src/core/payments/refusals.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/secure-fields.d.ts +33 -0
- package/lib/typescript/src/core/payments/secure-fields.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/tax-id-catalog.d.ts +481 -0
- package/lib/typescript/src/core/payments/tax-id-catalog.d.ts.map +1 -0
- package/lib/typescript/src/core/payments/wallet-contact.d.ts +40 -0
- package/lib/typescript/src/core/payments/wallet-contact.d.ts.map +1 -0
- package/lib/typescript/src/elements/address.d.ts +55 -0
- package/lib/typescript/src/elements/address.d.ts.map +1 -0
- package/lib/typescript/src/elements/branding.d.ts +18 -0
- package/lib/typescript/src/elements/branding.d.ts.map +1 -0
- package/lib/typescript/src/elements/card-fields/context.d.ts +67 -0
- package/lib/typescript/src/elements/card-fields/context.d.ts.map +1 -0
- package/lib/typescript/src/elements/card-fields/fields.d.ts +15 -0
- package/lib/typescript/src/elements/card-fields/fields.d.ts.map +1 -0
- package/lib/typescript/src/elements/card-fields/index.d.ts +21 -0
- package/lib/typescript/src/elements/card-fields/index.d.ts.map +1 -0
- package/lib/typescript/src/elements/card.d.ts +21 -0
- package/lib/typescript/src/elements/card.d.ts.map +1 -0
- package/lib/typescript/src/elements/email.d.ts +31 -0
- package/lib/typescript/src/elements/email.d.ts.map +1 -0
- package/lib/typescript/src/elements/payment/declared-fields.d.ts +43 -0
- package/lib/typescript/src/elements/payment/declared-fields.d.ts.map +1 -0
- package/lib/typescript/src/elements/payment/index.d.ts +37 -0
- package/lib/typescript/src/elements/payment/index.d.ts.map +1 -0
- package/lib/typescript/src/elements/payment/wallet.d.ts +39 -0
- package/lib/typescript/src/elements/payment/wallet.d.ts.map +1 -0
- package/lib/typescript/src/elements/tax-id.d.ts +41 -0
- package/lib/typescript/src/elements/tax-id.d.ts.map +1 -0
- package/lib/typescript/src/i18n/catalogs.d.ts +7 -0
- package/lib/typescript/src/i18n/catalogs.d.ts.map +1 -0
- package/lib/typescript/src/i18n/index.d.ts +17 -0
- package/lib/typescript/src/i18n/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +42 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/namespace.d.ts +36 -0
- package/lib/typescript/src/namespace.d.ts.map +1 -0
- package/lib/typescript/src/native/index.d.ts +62 -0
- package/lib/typescript/src/native/index.d.ts.map +1 -0
- package/lib/typescript/src/provider.d.ts +37 -0
- package/lib/typescript/src/provider.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeWhopAddressSuggestions.d.ts +13 -0
- package/lib/typescript/src/specs/NativeWhopAddressSuggestions.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeWhopAuthSession.d.ts +20 -0
- package/lib/typescript/src/specs/NativeWhopAuthSession.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeWhopPlatformPay.d.ts +24 -0
- package/lib/typescript/src/specs/NativeWhopPlatformPay.d.ts.map +1 -0
- package/lib/typescript/src/specs/WhopPayButtonNativeComponent.d.ts +21 -0
- package/lib/typescript/src/specs/WhopPayButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/theme/appearance.d.ts +71 -0
- package/lib/typescript/src/theme/appearance.d.ts.map +1 -0
- package/lib/typescript/src/theme/provider.d.ts +11 -0
- package/lib/typescript/src/theme/provider.d.ts.map +1 -0
- package/lib/typescript/src/theme/resolve.d.ts +19 -0
- package/lib/typescript/src/theme/resolve.d.ts.map +1 -0
- package/lib/typescript/src/theme/scales.generated.d.ts +18 -0
- package/lib/typescript/src/theme/scales.generated.d.ts.map +1 -0
- package/lib/typescript/src/ui/element-frame.d.ts +32 -0
- package/lib/typescript/src/ui/element-frame.d.ts.map +1 -0
- package/lib/typescript/src/ui/payment-method-icon.d.ts +21 -0
- package/lib/typescript/src/ui/payment-method-icon.d.ts.map +1 -0
- package/lib/typescript/src/ui/primitives.d.ts +94 -0
- package/lib/typescript/src/ui/primitives.d.ts.map +1 -0
- package/lib/typescript/src/ui/select.d.ts +25 -0
- package/lib/typescript/src/ui/select.d.ts.map +1 -0
- package/lib/typescript/src/ui/suggestions.d.ts +15 -0
- package/lib/typescript/src/ui/suggestions.d.ts.map +1 -0
- package/lib/typescript/src/ui/whop-logo.d.ts +4 -0
- package/lib/typescript/src/ui/whop-logo.d.ts.map +1 -0
- package/package.json +121 -0
- package/scripts/check-swift.sh +27 -0
- package/scripts/codegen-shims.mjs +409 -0
- package/scripts/gen-country-names.mjs +58 -0
- package/scripts/gen-theme.mjs +124 -0
- package/scripts/gen-wordmark.mjs +68 -0
- package/scripts/mirror.mjs +112 -0
- package/src/api/client.ts +202 -0
- package/src/api/types.ts +166 -0
- package/src/controller/actions.ts +197 -0
- package/src/controller/store.ts +201 -0
- package/src/core/address/country-data.ts +927 -0
- package/src/core/address/country-name.ts +36 -0
- package/src/core/address/country-names.generated.ts +246 -0
- package/src/core/address/engine.ts +349 -0
- package/src/core/address/form-state.ts +479 -0
- package/src/core/address/places.ts +39 -0
- package/src/core/address/suggest.ts +153 -0
- package/src/core/address/use-suggestions.ts +37 -0
- package/src/core/payments/address-change.ts +121 -0
- package/src/core/payments/billing-merge.ts +91 -0
- package/src/core/payments/browser-info.ts +43 -0
- package/src/core/payments/bt.ts +176 -0
- package/src/core/payments/currency.ts +54 -0
- package/src/core/payments/detail.ts +204 -0
- package/src/core/payments/errors.ts +171 -0
- package/src/core/payments/mint.ts +130 -0
- package/src/core/payments/plan.ts +198 -0
- package/src/core/payments/refusals.ts +24 -0
- package/src/core/payments/secure-fields.ts +85 -0
- package/src/core/payments/tax-id-catalog.ts +320 -0
- package/src/core/payments/wallet-contact.ts +56 -0
- package/src/elements/address.tsx +570 -0
- package/src/elements/branding.tsx +87 -0
- package/src/elements/card-fields/context.tsx +310 -0
- package/src/elements/card-fields/fields.tsx +281 -0
- package/src/elements/card-fields/index.tsx +37 -0
- package/src/elements/card.tsx +101 -0
- package/src/elements/email.tsx +100 -0
- package/src/elements/payment/declared-fields.tsx +238 -0
- package/src/elements/payment/index.tsx +497 -0
- package/src/elements/payment/wallet.tsx +155 -0
- package/src/elements/tax-id.tsx +143 -0
- package/src/i18n/catalogs.ts +100 -0
- package/src/i18n/index.tsx +46 -0
- package/src/index.ts +68 -0
- package/src/namespace.tsx +231 -0
- package/src/native/index.ts +173 -0
- package/src/provider.tsx +76 -0
- package/src/specs/NativeWhopAddressSuggestions.ts +14 -0
- package/src/specs/NativeWhopAuthSession.ts +21 -0
- package/src/specs/NativeWhopPlatformPay.ts +25 -0
- package/src/specs/WhopPayButtonNativeComponent.ts +22 -0
- package/src/theme/appearance.ts +150 -0
- package/src/theme/provider.tsx +28 -0
- package/src/theme/resolve.ts +68 -0
- package/src/theme/scales.generated.ts +427 -0
- package/src/ui/element-frame.tsx +94 -0
- package/src/ui/payment-method-icon.tsx +55 -0
- package/src/ui/primitives.tsx +269 -0
- package/src/ui/select.tsx +255 -0
- package/src/ui/suggestions.tsx +69 -0
- package/src/ui/whop-logo.tsx +37 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Chromium libaddressinput format engine, ported AS DATA from the developer-platform
|
|
3
|
+
* address-form fork (parse-remote-country-data). Three deliberate fixes over the fork:
|
|
4
|
+
* - `zipRegex` is ENFORCED (validateAddressForm) — it was parsed-but-dead there;
|
|
5
|
+
* - per-country `upper` flags apply at EMIT (emitAddress), never scattered through the UI;
|
|
6
|
+
* - ISO2 is the ONE country boundary — uppercased once at the edge (normalizeCountry), and the
|
|
7
|
+
* subdivision iso codes read the dataset's real `sub_isoids` key (the fork read a
|
|
8
|
+
* `sub_iso_codes` field that never existed in the data).
|
|
9
|
+
*/
|
|
10
|
+
export interface RemoteCountryData {
|
|
11
|
+
/** Field order + availability: %-prefixed tokens (%N %O %A %C %S %Z %D %X, %n = newline)
|
|
12
|
+
* mixed with literal text the postal service prints ("SE-", "SINGAPORE"). */
|
|
13
|
+
fmt?: string;
|
|
14
|
+
/** Latin variant of fmt for countries whose native script is non-latin. */
|
|
15
|
+
lfmt?: string;
|
|
16
|
+
/** Required-field flag characters (e.g. "ACSZ"). */
|
|
17
|
+
require?: string;
|
|
18
|
+
/** Fields the postal service expects uppercased (e.g. "CS"). */
|
|
19
|
+
upper?: string;
|
|
20
|
+
/** Country-level postal-code regex (unanchored in the dataset). */
|
|
21
|
+
zip?: string;
|
|
22
|
+
/** Example postal codes, comma-separated. */
|
|
23
|
+
zipex?: string;
|
|
24
|
+
zip_name_type?: string;
|
|
25
|
+
state_name_type?: string;
|
|
26
|
+
/** Subdivision keys / display names / latin names / iso codes, '~'-separated. */
|
|
27
|
+
sub_keys?: string;
|
|
28
|
+
sub_names?: string;
|
|
29
|
+
sub_lnames?: string;
|
|
30
|
+
sub_isoids?: string;
|
|
31
|
+
}
|
|
32
|
+
type FormatFieldType = 'name' | 'organization' | 'line1' | 'city' | 'state' | 'postal_code' | 'dependent_locality' | 'sorting_code';
|
|
33
|
+
export interface StateOption {
|
|
34
|
+
key: string;
|
|
35
|
+
name: string;
|
|
36
|
+
iso?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface FormatField {
|
|
39
|
+
type: FormatFieldType;
|
|
40
|
+
required: boolean;
|
|
41
|
+
upper: boolean;
|
|
42
|
+
postalPlaceholder?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CountryFormat {
|
|
45
|
+
country: string;
|
|
46
|
+
fields: FormatField[];
|
|
47
|
+
zipRegex?: string;
|
|
48
|
+
stateOptions: StateOption[];
|
|
49
|
+
stateLabel: StateLabelKind;
|
|
50
|
+
postalLabel: PostalLabelKind;
|
|
51
|
+
}
|
|
52
|
+
declare const STATE_LABELS: readonly ["province", "state", "county", "area", "emirate", "island", "parish", "prefecture", "oblast", "department", "do_si"];
|
|
53
|
+
export type StateLabelKind = (typeof STATE_LABELS)[number];
|
|
54
|
+
declare const POSTAL_LABELS: readonly ["postal", "zip", "pin", "eircode"];
|
|
55
|
+
export type PostalLabelKind = (typeof POSTAL_LABELS)[number];
|
|
56
|
+
export declare function normalizeCountry(code: string | undefined): string | undefined;
|
|
57
|
+
export declare function parseCountryFormat(countryCode: string, rawData: RemoteCountryData | undefined): CountryFormat;
|
|
58
|
+
/**
|
|
59
|
+
* Statically imported, unlike the web element's lazy chunk.
|
|
60
|
+
*
|
|
61
|
+
* Metro produces one bundle with no async chunks, so a dynamic `import()` fails at runtime with
|
|
62
|
+
* "Could not load bundle". Nothing is saved by deferring it either: the data ships in the bundle
|
|
63
|
+
* either way.
|
|
64
|
+
*/
|
|
65
|
+
export declare function loadCountryCatalog(): Promise<Record<string, RemoteCountryData>>;
|
|
66
|
+
export declare function postalCodeMatches(zipRegex: string | undefined, value: string): boolean;
|
|
67
|
+
export interface EmittedAddress {
|
|
68
|
+
name?: string;
|
|
69
|
+
first_name?: string;
|
|
70
|
+
last_name?: string;
|
|
71
|
+
organization?: string;
|
|
72
|
+
organization_type?: 'business' | 'individual';
|
|
73
|
+
line1?: string;
|
|
74
|
+
line2?: string;
|
|
75
|
+
city?: string;
|
|
76
|
+
state?: string;
|
|
77
|
+
postal_code?: string;
|
|
78
|
+
country: string;
|
|
79
|
+
}
|
|
80
|
+
/** The ONE emit boundary: trims, applies the country's upper flags, uppercases ISO2, and maps
|
|
81
|
+
* internal values onto the frozen contract keys (postal_code naming matches ctok
|
|
82
|
+
* billing_details 1:1). Empty values are dropped except the always-present country. */
|
|
83
|
+
export declare function emitAddress(format: CountryFormat, values: {
|
|
84
|
+
name?: string;
|
|
85
|
+
first_name?: string;
|
|
86
|
+
last_name?: string;
|
|
87
|
+
organization?: string;
|
|
88
|
+
organization_type?: 'business' | 'individual' | '';
|
|
89
|
+
line1?: string;
|
|
90
|
+
line2?: string;
|
|
91
|
+
city?: string;
|
|
92
|
+
state?: string;
|
|
93
|
+
postal_code?: string;
|
|
94
|
+
}): EmittedAddress;
|
|
95
|
+
export declare function currencyCountry(currency: string | undefined): string | undefined;
|
|
96
|
+
export {};
|
|
97
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../../../src/core/address/engine.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AAEH,MAAM,WAAW,iBAAiB;IAChC;kFAC8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;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,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAOtF;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAaD;;wFAEwF;AACxF,wBAAgB,WAAW,CACzB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,EAAE,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACA,cAAc,CA4BhB;AAuDD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEhF"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { CountryFormat, EmittedAddress } from './engine.js';
|
|
2
|
+
/**
|
|
3
|
+
* The address form's ONE state atom (useReducer shape) + the schema-driven central validator.
|
|
4
|
+
* Country lives IN the atom; hydration is ONE seed (defaultValues > detected IP country >
|
|
5
|
+
* currency-country hint > US) computed before first paint; reveal-vs-autofill is reducer
|
|
6
|
+
* state, not component-local flags. Pure module — the jsdom suites drive it directly.
|
|
7
|
+
*/
|
|
8
|
+
import type { ParsedPlaceAddress } from './places.js';
|
|
9
|
+
export type AddressValueKey = 'name' | 'first_name' | 'last_name' | 'organization' | 'line1' | 'line2' | 'city' | 'state' | 'postal_code';
|
|
10
|
+
export type AddressValues = Partial<Record<AddressValueKey, string>>;
|
|
11
|
+
export interface CustomFieldSpec {
|
|
12
|
+
key: string;
|
|
13
|
+
label: string;
|
|
14
|
+
type: 'text' | 'select' | 'date' | 'phone';
|
|
15
|
+
position: 'after_name' | 'after_organization' | 'before_country' | 'after_address';
|
|
16
|
+
required?: boolean;
|
|
17
|
+
options?: string[];
|
|
18
|
+
format?: string;
|
|
19
|
+
autocomplete?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AddressFormConfig {
|
|
22
|
+
mode: 'billing' | 'shipping';
|
|
23
|
+
layout: 'compact' | 'full';
|
|
24
|
+
scope: 'minimal' | 'full';
|
|
25
|
+
name: 'combined' | 'split' | 'none';
|
|
26
|
+
organization: 'none' | 'name' | 'name_with_type';
|
|
27
|
+
line2: 'toggle' | 'always' | 'never';
|
|
28
|
+
autocomplete: boolean;
|
|
29
|
+
allowedCountries?: string[];
|
|
30
|
+
customFields?: CustomFieldSpec[];
|
|
31
|
+
/** Composed-mode method floor: contract keys the selected payment method additionally
|
|
32
|
+
* requires (unioned into the visible + required set). */
|
|
33
|
+
requiredFloor?: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface AddressSeedInput {
|
|
36
|
+
defaultValues?: {
|
|
37
|
+
name?: string;
|
|
38
|
+
address?: Partial<EmittedAddress>;
|
|
39
|
+
};
|
|
40
|
+
detectedCountry?: string;
|
|
41
|
+
countryHint?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface AddressFormState {
|
|
44
|
+
country: string;
|
|
45
|
+
values: AddressValues;
|
|
46
|
+
organizationType: 'business' | 'individual' | '';
|
|
47
|
+
custom: Record<string, string>;
|
|
48
|
+
revealed: boolean;
|
|
49
|
+
line2Open: boolean;
|
|
50
|
+
selecting: boolean;
|
|
51
|
+
touched: Partial<Record<string, boolean>>;
|
|
52
|
+
showAllErrors: boolean;
|
|
53
|
+
}
|
|
54
|
+
export type AddressFormAction = {
|
|
55
|
+
type: 'edit';
|
|
56
|
+
field: AddressValueKey;
|
|
57
|
+
value: string;
|
|
58
|
+
autofilled?: boolean;
|
|
59
|
+
} | {
|
|
60
|
+
type: 'edit-custom';
|
|
61
|
+
key: string;
|
|
62
|
+
value: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: 'set-organization-type';
|
|
65
|
+
value: 'business' | 'individual' | '';
|
|
66
|
+
} | {
|
|
67
|
+
type: 'set-country';
|
|
68
|
+
country: string;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'begin-select';
|
|
71
|
+
} | {
|
|
72
|
+
type: 'select-failed';
|
|
73
|
+
} | {
|
|
74
|
+
type: 'apply-place';
|
|
75
|
+
parsed: ParsedPlaceAddress;
|
|
76
|
+
allowed: string[];
|
|
77
|
+
} | {
|
|
78
|
+
type: 'reveal';
|
|
79
|
+
autofill?: boolean;
|
|
80
|
+
} | {
|
|
81
|
+
type: 'toggle-line2';
|
|
82
|
+
} | {
|
|
83
|
+
type: 'blur';
|
|
84
|
+
field: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: 'show-errors';
|
|
87
|
+
};
|
|
88
|
+
export declare function allowedCountryList(config: AddressFormConfig, catalogCountries: string[]): string[];
|
|
89
|
+
export declare function seedAddressForm(config: AddressFormConfig, seed: AddressSeedInput, catalogCountries: string[]): AddressFormState;
|
|
90
|
+
export declare function addressFormReducer(state: AddressFormState, action: AddressFormAction): AddressFormState;
|
|
91
|
+
export type AddressErrorCode = 'required' | 'invalid';
|
|
92
|
+
export interface AddressValidation {
|
|
93
|
+
errors: Partial<Record<string, AddressErrorCode>>;
|
|
94
|
+
complete: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface FieldPlan {
|
|
97
|
+
/** Address-grid fields in the country format's order, filtered to the config scope. */
|
|
98
|
+
gridFields: Array<'line1' | 'city' | 'state' | 'postal_code'>;
|
|
99
|
+
required: ReadonlySet<string>;
|
|
100
|
+
}
|
|
101
|
+
/** The commit-point allow gate ([] = unrestricted): a restrictive list declines a foreign OR
|
|
102
|
+
* country-less parse — unknown provenance must not land foreign locality data under the locked
|
|
103
|
+
* ISO2. Shared by the reducer arm and the placeSelected reaction (which must know BEFORE
|
|
104
|
+
* reducing whether to mark the commit `placed` — a declined pick must not bump placeSeq). */
|
|
105
|
+
/** The Places-gate allow list: [] = unrestricted. DISTINCT from allowedCountryList (the
|
|
106
|
+
* country-select options, which falls back to the whole catalog) — feeding that catalog
|
|
107
|
+
* fallback into placeAllowed would wrongly decline catalog-missing territories on
|
|
108
|
+
* unrestricted configs. */
|
|
109
|
+
/**
|
|
110
|
+
* The floor a scope implies, which is what makes `scope="minimal"` mean anything.
|
|
111
|
+
*
|
|
112
|
+
* Minimal renders EXACTLY the floor, so an empty floor renders an empty grid: the element shipped a
|
|
113
|
+
* country select and nothing else, and a buyer could complete that form while the card confirm then
|
|
114
|
+
* refused at the AVS check for a postal code never collected. Web wires the same value at
|
|
115
|
+
* apps/web/src/elements/payments/address.tsx:317.
|
|
116
|
+
*/
|
|
117
|
+
export declare function requiredFloorFor(scope: AddressFormConfig['scope']): string[] | undefined;
|
|
118
|
+
export declare function placeAllowList(config: AddressFormConfig, catalogCountries: string[]): string[];
|
|
119
|
+
export declare function placeAllowed(allowed: string[], parsed: ParsedPlaceAddress): boolean;
|
|
120
|
+
/** The schema for a (country, config) pair: which grid fields exist and which fields are
|
|
121
|
+
* required. Full scope = the country format's fields (its `require` flags) ∪ the floor;
|
|
122
|
+
* minimal scope = EXACTLY the floor (plus country, the form's spine). */
|
|
123
|
+
export declare function planFields(config: AddressFormConfig, format: CountryFormat): FieldPlan;
|
|
124
|
+
export declare function validateAddressForm(config: AddressFormConfig, format: CountryFormat, state: AddressFormState): AddressValidation;
|
|
125
|
+
/** Compact = city and postal share ONE row (format order within it), state below. */
|
|
126
|
+
export declare function pairedGridRows(gridFields: FieldPlan['gridFields']): Array<Array<'city' | 'state' | 'postal_code'>>;
|
|
127
|
+
/** Box-shadows follow the element's OWN border-radius, so the compact group's rounded
|
|
128
|
+
* container cannot round the focus/invalid rings its cells paint — first- and last-row cells
|
|
129
|
+
* carry their corner radii themselves (7px = the container's 8px radius minus its 1px
|
|
130
|
+
* border), each cell of a two-column row rounding only its outer corner. Derived from the
|
|
131
|
+
* same config + field plan that orders the rows: country formats drop and reorder fields,
|
|
132
|
+
* and until the grid reveals the visible group ends at line1. */
|
|
133
|
+
export declare function compactCellCorners(config: AddressFormConfig, gridFields: FieldPlan['gridFields'], visible: {
|
|
134
|
+
line2: boolean;
|
|
135
|
+
revealed: boolean;
|
|
136
|
+
}): Record<string, string>;
|
|
137
|
+
export interface AddressSnapshot {
|
|
138
|
+
complete: boolean;
|
|
139
|
+
address: EmittedAddress;
|
|
140
|
+
custom: Record<string, string>;
|
|
141
|
+
errors: Partial<Record<string, AddressErrorCode>>;
|
|
142
|
+
}
|
|
143
|
+
export declare function snapshotAddressForm(config: AddressFormConfig, format: CountryFormat, state: AddressFormState): AddressSnapshot;
|
|
144
|
+
//# sourceMappingURL=form-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-state.d.ts","sourceRoot":"","sources":["../../../../../src/core/address/form-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAU,CAAC;AAC9D;;;;;GAKG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAU,CAAC;AAInD,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,YAAY,GACZ,WAAW,GACX,cAAc,GACd,OAAO,GACP,OAAO,GACP,MAAM,GACN,OAAO,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D,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,gBAAgB,GACtB,iBAAiB,CA0BnB;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,UAAU,EAAE,SAAS,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC,CAAC,CAOlH;AAKD;;;;;kEAKkE;AAClE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE,SAAS,CAAC,YAAY,CAAC,EACnC,OAAO,EAAE;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GAC7C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0BxB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;CACnD;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,gBAAgB,GACtB,eAAe,CA4BjB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** A resolved suggestion, in the same wire keys the address form emits. */
|
|
2
|
+
export interface ParsedPlaceAddress {
|
|
3
|
+
line1?: string;
|
|
4
|
+
line2?: string;
|
|
5
|
+
city?: string;
|
|
6
|
+
state?: string;
|
|
7
|
+
postal_code?: string;
|
|
8
|
+
country?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The country the buyer is dialling from, used as the address form's default before the buyer picks
|
|
12
|
+
* one. A miss falls through to `countryHint` and then US.
|
|
13
|
+
*
|
|
14
|
+
* Cloudflare's trace endpoint, which is what the web element reads — it uses the same-origin
|
|
15
|
+
* `/cdn-cgi/trace` because every rail it ships on sits behind Cloudflare. A native app has no
|
|
16
|
+
* origin, so this asks whop.com for the same thing.
|
|
17
|
+
*
|
|
18
|
+
* The previous port invented `https://whop.com/api/geo/`, which has never existed: it 404s (and
|
|
19
|
+
* `/api/geo` merely redirects to the same 404), so detection silently failed for every buyer and
|
|
20
|
+
* the form always opened on US.
|
|
21
|
+
*/
|
|
22
|
+
export declare function detectIpCountry(timeoutMs?: number): Promise<string | undefined>;
|
|
23
|
+
//# sourceMappingURL=places.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"places.d.ts","sourceRoot":"","sources":["../../../../../src/core/address/places.ts"],"names":[],"mappings":"AAGA,2EAA2E;AAC3E,MAAM,WAAW,kBAAkB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,SAAS,SAAO,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAanF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ParsedPlaceAddress } from './places.js';
|
|
2
|
+
/** One row in the suggestion list. Display only — components arrive from `resolve`. */
|
|
3
|
+
export interface AddressSuggestion {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
/** The raw components a resolved pick carries, before per-country composition. */
|
|
8
|
+
export interface RawComponents {
|
|
9
|
+
streetNumber?: string;
|
|
10
|
+
street?: string;
|
|
11
|
+
/** Set only when the platform had no street components but did name the place. */
|
|
12
|
+
line1?: string;
|
|
13
|
+
city?: string;
|
|
14
|
+
state?: string;
|
|
15
|
+
postalCode?: string;
|
|
16
|
+
country?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function composeLine1(streetNumber: string | undefined, street: string | undefined, country: string | undefined): string | undefined;
|
|
19
|
+
/** The suggestion rows a `suggest` call returned. */
|
|
20
|
+
export declare function parseSuggestions(json: string): AddressSuggestion[];
|
|
21
|
+
/**
|
|
22
|
+
* A resolved pick, in the wire keys the address form emits.
|
|
23
|
+
*
|
|
24
|
+
* `formCountry` backfills a resolve that names no country, which both geocoders do occasionally.
|
|
25
|
+
* Without it `composeLine1` orders the street as if it were number-last, and `placeAllowed` rejects
|
|
26
|
+
* a country-less parse whenever an allow list is active — so the pick silently no-ops.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseComponents(json: string, formCountry?: string): ParsedPlaceAddress | null;
|
|
29
|
+
/**
|
|
30
|
+
* A geocoder's subdivision, as the catalog key the address engine validates against.
|
|
31
|
+
*
|
|
32
|
+
* The engine keys subdivisions by `sub_key` and builds each option's display name by joining the
|
|
33
|
+
* native and latin names — `[names[i] || key, latinNames[i]].join(' — ')` at
|
|
34
|
+
* core/address/engine.ts:141, so Tokyo's option is key `東京都` and name `東京都 — Tokyo`. A geocoder
|
|
35
|
+
* answers with ONE of those halves and never the joined form, so matching the whole `name` string
|
|
36
|
+
* misses every country whose catalog carries both scripts.
|
|
37
|
+
*
|
|
38
|
+
* An unmatched value resolves to undefined rather than to itself: it would render the state Select
|
|
39
|
+
* on its placeholder while still being emitted, so `apply-place` writing '' and surfacing the
|
|
40
|
+
* required-state error is the honest outcome.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveSubdivision(value: string | undefined, options: {
|
|
43
|
+
key: string;
|
|
44
|
+
name: string;
|
|
45
|
+
iso?: string;
|
|
46
|
+
}[]): string | undefined;
|
|
47
|
+
//# sourceMappingURL=suggest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../src/core/address/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAU,CAAC;AAEnD,uFAAuF;AACvF,MAAM,WAAW,iBAAiB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACd;AAED,kFAAkF;AAClF,MAAM,WAAW,aAAa;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AA2CD,wBAAgB,YAAY,CAC3B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,GAAG,SAAS,CAMpB;AAED,qDAAqD;AACrD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAclE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAuB7F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,GACpD,MAAM,GAAG,SAAS,CAKpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-suggestions.d.ts","sourceRoot":"","sources":["../../../../../src/core/address/use-suggestions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAW,CAAC;AAMnD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,iBAAiB,EAAE,CA2B1F"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { EmittedAddress } from '../address/engine.js';
|
|
2
|
+
/**
|
|
3
|
+
* The postal address the payment element's `addressChange` event carries: every place-identifying
|
|
4
|
+
* field the billing block collects, with the optionality the form itself has. Only `country` is
|
|
5
|
+
* guaranteed — each country's format collects its own field set (no state in the Netherlands, no
|
|
6
|
+
* postal code in Ireland, no line2 unless the buyer fills one), so a key is absent whenever the
|
|
7
|
+
* form did not collect a value for it. Name, organization, and email are not part of an address
|
|
8
|
+
* and stay off this event.
|
|
9
|
+
*/
|
|
10
|
+
export interface PostalAddress {
|
|
11
|
+
line1?: string;
|
|
12
|
+
line2?: string;
|
|
13
|
+
city?: string;
|
|
14
|
+
state?: string;
|
|
15
|
+
postal_code?: string;
|
|
16
|
+
country: string;
|
|
17
|
+
}
|
|
18
|
+
export interface AddressChange {
|
|
19
|
+
complete: boolean;
|
|
20
|
+
address: PostalAddress;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A buyer typing a postal code produces one form snapshot per keystroke, and the consumer turns
|
|
24
|
+
* every emit into a tax quote or a shipping-rate lookup — one network call per character is the
|
|
25
|
+
* failure mode this guards. 300ms is the settle window: longer than the gap between keystrokes at
|
|
26
|
+
* any real typing speed (so a whole postal code collapses into ONE emit), short enough that the
|
|
27
|
+
* quote is back before the buyer reaches the pay button. TRAILING edge only — a leading emit would
|
|
28
|
+
* fire on the first character, which is the one value guaranteed to be useless.
|
|
29
|
+
*/
|
|
30
|
+
export declare const ADDRESS_CHANGE_DEBOUNCE_MS = 300;
|
|
31
|
+
export declare function postalAddressOf(address: EmittedAddress): PostalAddress;
|
|
32
|
+
export interface AddressChangePublisher {
|
|
33
|
+
publish: (owner: string, change: AddressChange) => void;
|
|
34
|
+
/**
|
|
35
|
+
* The owner's block stopped being the address in force before its queued change settled — drop
|
|
36
|
+
* it. Scoped to the OWNER, not to the change object: a deselected block can still deliver one
|
|
37
|
+
* last snapshot in the very commit that deselects it (the form dispatches from a child effect,
|
|
38
|
+
* which flushes before this block's own), so a queue keyed on the change would miss the one
|
|
39
|
+
* actually in flight. A no-op once another block has queued its own — whichever order the two
|
|
40
|
+
* blocks' effects run in during a switch.
|
|
41
|
+
*/
|
|
42
|
+
abandon: (owner: string) => void;
|
|
43
|
+
}
|
|
44
|
+
export declare const AddressChangePublishProvider: import("react").Provider<AddressChangePublisher>;
|
|
45
|
+
export declare function usePublishAddressChange(): AddressChangePublisher;
|
|
46
|
+
/**
|
|
47
|
+
* ELEMENT-SCOPED on purpose: every method tile mounts its own billing block, so the debounce
|
|
48
|
+
* timer and the last-emitted memory have to be shared across them — a per-block memory would
|
|
49
|
+
* suppress the republish that a tile switch back to an earlier address depends on.
|
|
50
|
+
*/
|
|
51
|
+
export declare function useAddressChangePublisher(emit: (change: AddressChange) => void): AddressChangePublisher;
|
|
52
|
+
//# sourceMappingURL=address-change.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-change.d.ts","sourceRoot":"","sources":["../../../../../src/core/payments/address-change.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAmB,CAAC;AAIxD;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAI9C,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAOtE;AAUD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IACxD;;;;;;;OAOG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAOD,eAAO,MAAM,4BAA4B,kDAAuC,CAAC;AAEjF,wBAAgB,uBAAuB,IAAI,sBAAsB,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,sBAAsB,CAkCvG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The billing-details precedence merge for the confirm rail: explicit
|
|
3
|
+
* `createConfirmationToken({ billingDetails })` input > standalone address element values >
|
|
4
|
+
* the payment element's internal billing block. Applied twice along the cascade (controller
|
|
5
|
+
* merges the address element under the input; the payment element merges its block under the
|
|
6
|
+
* result) — scalars merge field-level, the address object is ATOMIC per source (a mixed-source
|
|
7
|
+
* address would be incoherent), which keeps the two applications associative.
|
|
8
|
+
*/
|
|
9
|
+
import type { EmittedAddress } from '../address/engine.js';
|
|
10
|
+
interface BillingAddressBag {
|
|
11
|
+
country?: string;
|
|
12
|
+
line1?: string;
|
|
13
|
+
line2?: string;
|
|
14
|
+
city?: string;
|
|
15
|
+
state?: string;
|
|
16
|
+
postal_code?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface BillingDetailsBag {
|
|
19
|
+
email?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
phone?: string;
|
|
22
|
+
address?: BillingAddressBag;
|
|
23
|
+
}
|
|
24
|
+
export interface CollectedAddressSnapshot {
|
|
25
|
+
complete: boolean;
|
|
26
|
+
completeWithoutPhone?: boolean;
|
|
27
|
+
phoneRequired?: boolean;
|
|
28
|
+
address: EmittedAddress;
|
|
29
|
+
phone?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Merge a collected form snapshot UNDER an explicit billing-details bag. When the collected
|
|
33
|
+
* form is the address source actually being used and it is incomplete, the merge throws — a
|
|
34
|
+
* confirm over a half-filled form must fail loud, exactly like the surfaces' own validation
|
|
35
|
+
* (an explicit complete input keeps winning silently).
|
|
36
|
+
*/
|
|
37
|
+
export declare function mergeBillingWithCollected(explicit: BillingDetailsBag | undefined, collected: CollectedAddressSnapshot | undefined): BillingDetailsBag | undefined;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=billing-merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing-merge.d.ts","sourceRoot":"","sources":["../../../../../src/core/payments/billing-merge.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAmB,CAAC;AAExD,UAAU,iBAAiB;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAyBD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,EACvC,SAAS,EAAE,wBAAwB,GAAG,SAAS,GAC9C,iBAAiB,GAAG,SAAS,CAsB/B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BrowserInfo } from '../../api/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The React Native counterpart of the web element's `browser_info` capture.
|
|
4
|
+
*
|
|
5
|
+
* The field names are the wire's, because the backend feeds them to 3DS, which was specified for
|
|
6
|
+
* browsers. An app has no `navigator`, so each value is the nearest honest platform fact rather
|
|
7
|
+
* than a fabricated browser one — omitted where there is no honest answer.
|
|
8
|
+
*/
|
|
9
|
+
export declare function capturedBrowserInfo(): BrowserInfo;
|
|
10
|
+
/** The one platform read; kept separate so the locale default can reuse it. */
|
|
11
|
+
export declare function deviceLocale(): string | undefined;
|
|
12
|
+
//# sourceMappingURL=browser-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-info.d.ts","sourceRoot":"","sources":["../../../../../src/core/payments/browser-info.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAiB,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,WAAW,CAcjD;AAOD,+EAA+E;AAC/E,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CASjD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { useBasisTheory } from '@basis-theory/react-native-elements';
|
|
2
|
+
import type { WhopClient } from '../../api/client.js';
|
|
3
|
+
import type { PaymentTokenizationErrorCode } from './errors.js';
|
|
4
|
+
/** The package re-exports the hook but not its return type, so derive it rather than reach into a
|
|
5
|
+
* deep path that could move. */
|
|
6
|
+
export type BasisTheoryElements = NonNullable<ReturnType<typeof useBasisTheory>['bt']>;
|
|
7
|
+
/** The opaque handle a Basis Theory element hands out. It carries an id and a formatter, never the
|
|
8
|
+
* value the buyer typed — which is the whole isolation guarantee. */
|
|
9
|
+
export interface CardRefs {
|
|
10
|
+
number: unknown;
|
|
11
|
+
expiryMonth: unknown;
|
|
12
|
+
expiryYear: unknown;
|
|
13
|
+
cvc: unknown;
|
|
14
|
+
}
|
|
15
|
+
export type CardFieldFailure = 'incomplete' | 'invalid' | undefined;
|
|
16
|
+
export interface CardFieldFailures {
|
|
17
|
+
number?: CardFieldFailure;
|
|
18
|
+
expiry?: CardFieldFailure;
|
|
19
|
+
cvc?: CardFieldFailure;
|
|
20
|
+
}
|
|
21
|
+
export interface CardTokenizationFailure {
|
|
22
|
+
ok: false;
|
|
23
|
+
code: PaymentTokenizationErrorCode;
|
|
24
|
+
message: string;
|
|
25
|
+
fields?: CardFieldFailures;
|
|
26
|
+
}
|
|
27
|
+
export type CardTokenizationResult = {
|
|
28
|
+
ok: true;
|
|
29
|
+
token: string;
|
|
30
|
+
} | CardTokenizationFailure;
|
|
31
|
+
/**
|
|
32
|
+
* Assemble one Basis Theory card token from the three field refs.
|
|
33
|
+
*
|
|
34
|
+
* This is the web ceremony (`card-fields/bt.ts`) with the frame hops removed: a BT session anchors
|
|
35
|
+
* a nonce-derived container, the number seeds an ephemeral token into it, the Whop backend
|
|
36
|
+
* authorizes the session for that container alone, and the remaining fields patch in under the
|
|
37
|
+
* session key. The web element splits these across three iframes and threads a serializable grant
|
|
38
|
+
* between them; here all three refs live in one realm, so the grant never leaves this function.
|
|
39
|
+
*
|
|
40
|
+
* The ceremony is kept rather than collapsed into a single create because it is what the
|
|
41
|
+
* card-assembly Basis Theory application is configured to permit: the backend authorizes
|
|
42
|
+
* `token:update` scoped to `starts_with` the derived container, for ten minutes.
|
|
43
|
+
*/
|
|
44
|
+
export declare function tokenizeCard(bt: BasisTheoryElements, refs: CardRefs, command: {
|
|
45
|
+
accountId: string;
|
|
46
|
+
publicKey: string;
|
|
47
|
+
}, sdk: WhopClient): Promise<CardTokenizationResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Must byte-match the backend's `Digest::SHA256.hexdigest` — lowercase hex, no separators.
|
|
50
|
+
*
|
|
51
|
+
* `@noble/hashes` UTF-8 encodes a string input itself, which is also why this does not reach for
|
|
52
|
+
* `TextEncoder`: React Native has no DOM and does not guarantee one.
|
|
53
|
+
*/
|
|
54
|
+
export declare function sha256Hex(value: string): string;
|
|
55
|
+
//# sourceMappingURL=bt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bt.d.ts","sourceRoot":"","sources":["../../../../../src/core/payments/bt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAU,CAAC;AAE7D;iCACiC;AACjC,MAAM,MAAM,mBAAmB,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAEvF;sEACsE;AACtE,MAAM,WAAW,QAAQ;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,OAAO,CAAC;CACb;AAED,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpE,MAAM,WAAW,iBAAiB;IACjC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACvC,EAAE,EAAE,KAAK,CAAC;IACV,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,MAAM,sBAAsB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,uBAAuB,CAAC;AAI3F;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CACjC,EAAE,EAAE,mBAAmB,EACvB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EACjD,GAAG,EAAE,UAAU,GACb,OAAO,CAAC,sBAAsB,CAAC,CA2EjC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function currencyMinorDigits(currency: string): number;
|
|
2
|
+
/** Major-unit decimal (how money rides the wire) → the minor-unit integer a charge takes, on the
|
|
3
|
+
* backend's factor above — never Intl's. toFixed(4) first (kills float-scale artifacts like
|
|
4
|
+
* 29.99×100 → 2998.999…), then trunc (a genuinely sub-minor fraction never rounds the charge UP). */
|
|
5
|
+
export declare function toMinorUnits(majorAmount: number, currency: string): number;
|
|
6
|
+
export declare function currencyDisplayDigits(currency: string): number;
|
|
7
|
+
//# sourceMappingURL=currency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../../../src/core/payments/currency.ts"],"names":[],"mappings":"AAgCA,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK5D;AAED;;sGAEsG;AACtG,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1E;AAKD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAI9D"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PaymentMethodConfigurationShape, PaymentMethodTypeResource } from '../../api/types.js';
|
|
2
|
+
export type MatrixEntry = PaymentMethodTypeResource & {
|
|
3
|
+
next_action_render_modes?: string[];
|
|
4
|
+
supports_fresh_collection?: boolean;
|
|
5
|
+
submit_button?: {
|
|
6
|
+
label?: string;
|
|
7
|
+
kind?: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type { PaymentMethodConfigurationShape };
|
|
11
|
+
/**
|
|
12
|
+
* Which checkout is asking. The matrix leaves out methods that do not serve the named surface, and
|
|
13
|
+
* the axis is who BUILT the checkout, not where it runs.
|
|
14
|
+
*
|
|
15
|
+
* A React Native mount is `direct_checkout`: it owns its own presentation the way a first-party
|
|
16
|
+
* whop.com document does, and unlike an iframe it can hand a full-page step to the system browser.
|
|
17
|
+
* Sending `external_checkout` would drop every `full_page`-only method from the list.
|
|
18
|
+
*/
|
|
19
|
+
export type CheckoutSurface = 'direct_checkout' | 'embedded_checkout' | 'modal_checkout' | 'external_checkout';
|
|
20
|
+
declare const TEMPLATES: readonly ["redirect", "bnpl_confirm", "bank_connect", "bank_wire", "wallet_sheet", "none"];
|
|
21
|
+
export type DetailTemplate = (typeof TEMPLATES)[number];
|
|
22
|
+
export interface WalletAvailability {
|
|
23
|
+
applePay?: boolean;
|
|
24
|
+
googlePay?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function detailTemplate(entry: MatrixEntry): DetailTemplate;
|
|
27
|
+
export declare function passesConfiguration(type: string, configuration: PaymentMethodConfigurationShape | undefined, platformDefault?: boolean): boolean;
|
|
28
|
+
/** The entry's category-keyed config block, read generically. */
|
|
29
|
+
export declare function methodConfigBlock(entry: MatrixEntry): Record<string, unknown>;
|
|
30
|
+
export declare function methodTokenizerKey(entry: MatrixEntry): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the entry is offered for this charge on this surface.
|
|
33
|
+
*
|
|
34
|
+
* Amount-gated methods are excluded outright rather than rendered disabled, and every absent field
|
|
35
|
+
* reads as unrestricted so an older matrix keeps its behavior.
|
|
36
|
+
*/
|
|
37
|
+
export declare function presentMethod(entry: MatrixEntry, currency: string, amount: number, setupFutureUsage: 'off_session' | 'on_session' | undefined, walletAvailability: WalletAvailability | undefined, configuration: PaymentMethodConfigurationShape | undefined, surface: CheckoutSurface, country?: string): boolean;
|
|
38
|
+
/** Listed types take their list position; unlisted types share the tail rank, so a stable sort
|
|
39
|
+
* preserves their incoming order. */
|
|
40
|
+
export declare function orderRank(type: string, order: readonly string[]): number;
|
|
41
|
+
export declare function formatMinorAmount(amount: number, currency: string, locale: string): string;
|
|
42
|
+
export declare function fieldLabel(name: string): string;
|
|
43
|
+
/** A declared field's country-keyed pattern, `*` as the fallback. Never throws on a bad pattern. */
|
|
44
|
+
export declare function fieldMatches(formats: Record<string, string> | undefined, country: string | undefined, value: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The billing countries a method constrains the buyer to, or null when it constrains nothing.
|
|
47
|
+
*
|
|
48
|
+
* `*` anywhere in the entry's per-currency list means unrestricted, and so does an empty list — a
|
|
49
|
+
* method that names countries names ALL of the ones it serves. The address element intersects the
|
|
50
|
+
* result with the integrator's own `allowedCountries` rather than replacing it.
|
|
51
|
+
*/
|
|
52
|
+
export declare function methodBillingCountries(entry: Pick<PaymentMethodTypeResource, 'currencies'> | undefined, currency: string): string[] | null;
|
|
53
|
+
//# sourceMappingURL=detail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detail.d.ts","sourceRoot":"","sources":["../../../../../src/core/payments/detail.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,+BAA+B,EAAE,yBAAyB,EAAE,MAAM,oBAAiB,CAAC;AAGlG,MAAM,MAAM,WAAW,GAAG,yBAAyB,GAAG;IACrD,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IACpC,yBAAyB,CAAC,EAAE,OAAO,CAAC;I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