@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,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// ported verbatim from frontend/apps/web/src/elements/payments/lib/errors.ts — keep in sync when the web element changes
|
|
4
|
+
|
|
5
|
+
import { WhopError } from "../../api/client.js";
|
|
6
|
+
/** The plan/inline charge-config refusals — CODED like the framework's lifecycle refusals
|
|
7
|
+
* (switch on `code`, never string-match). The message carries the code prefix too because a
|
|
8
|
+
* wire boot failure (`controller-failed`) delivers the MESSAGE alone to the handle's onError. */
|
|
9
|
+
export class ChargeConfigError extends Error {
|
|
10
|
+
constructor(code, message) {
|
|
11
|
+
super(`[${code}] ${message}`);
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.name = 'ChargeConfigError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** The merchant-of-record refusal. `BRANDING_NOT_MOUNTED` remains in the error-code contract for
|
|
17
|
+
* clients compiled against 1.0.0-beta.1; the compatibility runtime only emits `BRANDING_HIDDEN`
|
|
18
|
+
* when a mounted notice has been CSS-hidden or shrunk. */
|
|
19
|
+
export class BrandingRequiredError extends Error {
|
|
20
|
+
constructor(code, message) {
|
|
21
|
+
super(`[${code}] ${message}`);
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.name = 'BrandingRequiredError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** The `select` action's refusals — the same coded shape as ChargeConfigError (switch on `code`;
|
|
27
|
+
* the message carries the code prefix because the wire rpc rail delivers the message alone). */
|
|
28
|
+
export class SelectError extends Error {
|
|
29
|
+
constructor(code, message) {
|
|
30
|
+
super(`[${code}] ${message}`);
|
|
31
|
+
this.code = code;
|
|
32
|
+
this.name = 'SelectError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** The secure declared-field refusals (a secure value could not be tokenized, so the confirm
|
|
36
|
+
* never ran) — the same coded shape as the other refusal families. */
|
|
37
|
+
export class SecureFieldError extends Error {
|
|
38
|
+
constructor(code, message) {
|
|
39
|
+
super(`[${code}] ${message}`);
|
|
40
|
+
this.code = code;
|
|
41
|
+
this.name = 'SecureFieldError';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const tokenizationStageByCode = {
|
|
45
|
+
card_fields_not_ready: 'card_fields',
|
|
46
|
+
card_tokenizer_session_failed: 'card_tokenizer_session',
|
|
47
|
+
card_number_validation_failed: 'card_number',
|
|
48
|
+
card_number_tokenization_failed: 'card_number',
|
|
49
|
+
card_session_authorization_failed: 'card_session_authorization',
|
|
50
|
+
card_expiry_validation_failed: 'card_expiry',
|
|
51
|
+
card_expiry_tokenization_failed: 'card_expiry',
|
|
52
|
+
card_cvc_validation_failed: 'card_cvc',
|
|
53
|
+
card_cvc_tokenization_failed: 'card_cvc',
|
|
54
|
+
confirmation_token_create_failed: 'confirmation_token_create'
|
|
55
|
+
};
|
|
56
|
+
export class PaymentTokenizationError extends Error {
|
|
57
|
+
constructor(code, message) {
|
|
58
|
+
super(`[${code}] ${message}`);
|
|
59
|
+
this.code = code;
|
|
60
|
+
this.failureStage = tokenizationStageByCode[code];
|
|
61
|
+
this.buyerMessage = message;
|
|
62
|
+
this.name = 'PaymentTokenizationError';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export function paymentTokenizationFailureOf(error) {
|
|
66
|
+
if (error instanceof PaymentTokenizationError) {
|
|
67
|
+
return {
|
|
68
|
+
code: error.code,
|
|
69
|
+
failureStage: error.failureStage,
|
|
70
|
+
message: error.buyerMessage
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const message = error instanceof Error ? error.message : '';
|
|
74
|
+
const match = /^\[([a-z_]+)\] ([\s\S]*)$/.exec(message);
|
|
75
|
+
const code = match?.[1];
|
|
76
|
+
if (!code || !Object.hasOwn(tokenizationStageByCode, code)) return undefined;
|
|
77
|
+
const typedCode = code;
|
|
78
|
+
return {
|
|
79
|
+
code: typedCode,
|
|
80
|
+
failureStage: tokenizationStageByCode[typedCode],
|
|
81
|
+
message: match[2] ?? ''
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function paymentTokenizationBuyerMessage(error, fallback) {
|
|
85
|
+
return paymentTokenizationFailureOf(error)?.message ?? (error instanceof Error && error.message ? error.message : fallback);
|
|
86
|
+
}
|
|
87
|
+
/** handleNextAction's posture refusal (a full_page-only step reached a document that cannot
|
|
88
|
+
* navigate the whole tab, so nothing ran) — the same coded shape as the other refusal
|
|
89
|
+
* families. */
|
|
90
|
+
export class NextActionError extends Error {
|
|
91
|
+
constructor(code, message) {
|
|
92
|
+
super(`[${code}] ${message}`);
|
|
93
|
+
this.code = code;
|
|
94
|
+
this.name = 'NextActionError';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Whether a caught error is this family's refusal for `code`, wherever it was caught: the
|
|
99
|
+
* structured `code` survives an in-process throw, and the `[CODE]` message prefix is the
|
|
100
|
+
* family's own WIRE encoding — the rpc rail re-mints a rejection from `.message` alone, which
|
|
101
|
+
* is the whole reason these constructors bake the code into the message. Decoding the prefix
|
|
102
|
+
* here is reading that contract, not string-matching prose. */
|
|
103
|
+
export function isNextActionRefusal(error, code) {
|
|
104
|
+
if (error?.code === code) return true;
|
|
105
|
+
const message = error instanceof Error ? error.message : '';
|
|
106
|
+
return message.startsWith(`[${code}]`);
|
|
107
|
+
}
|
|
108
|
+
export function apiErrorMessage(err, fallback) {
|
|
109
|
+
if (err instanceof WhopError) {
|
|
110
|
+
const body = err.body;
|
|
111
|
+
return body?.error?.message ?? `${fallback} (${err.statusCode})`;
|
|
112
|
+
}
|
|
113
|
+
return err instanceof Error ? err.message : fallback;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WhopError","ChargeConfigError","Error","constructor","code","message","name","BrandingRequiredError","SelectError","SecureFieldError","tokenizationStageByCode","card_fields_not_ready","card_tokenizer_session_failed","card_number_validation_failed","card_number_tokenization_failed","card_session_authorization_failed","card_expiry_validation_failed","card_expiry_tokenization_failed","card_cvc_validation_failed","card_cvc_tokenization_failed","confirmation_token_create_failed","PaymentTokenizationError","failureStage","buyerMessage","paymentTokenizationFailureOf","error","match","exec","Object","hasOwn","undefined","typedCode","paymentTokenizationBuyerMessage","fallback","NextActionError","isNextActionRefusal","startsWith","apiErrorMessage","err","body","statusCode"],"sourceRoot":"../../../../src","sources":["core/payments/errors.ts"],"mappings":";;AAAA;;AAEA,SAASA,SAAS,QAAQ,qBAAkB;AAQ5C;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,SAASC,KAAK,CAAC;EAG3CC,WAAWA,CAACC,IAA2B,EAAEC,OAAe,EAAE;IACxD,KAAK,CAAC,IAAID,IAAI,KAAKC,OAAO,EAAE,CAAC;IAC7B,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACE,IAAI,GAAG,mBAAmB;EACjC;AACF;AAIA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,SAASL,KAAK,CAAC;EAG/CC,WAAWA,CAACC,IAA+B,EAAEC,OAAe,EAAE;IAC5D,KAAK,CAAC,IAAID,IAAI,KAAKC,OAAO,EAAE,CAAC;IAC7B,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACE,IAAI,GAAG,uBAAuB;EACrC;AACF;AAIA;AACA;AACA,OAAO,MAAME,WAAW,SAASN,KAAK,CAAC;EAGrCC,WAAWA,CAACC,IAAqB,EAAEC,OAAe,EAAE;IAClD,KAAK,CAAC,IAAID,IAAI,KAAKC,OAAO,EAAE,CAAC;IAC7B,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACE,IAAI,GAAG,aAAa;EAC3B;AACF;AAIA;AACA;AACA,OAAO,MAAMG,gBAAgB,SAASP,KAAK,CAAC;EAG1CC,WAAWA,CAACC,IAA0B,EAAEC,OAAe,EAAE;IACvD,KAAK,CAAC,IAAID,IAAI,KAAKC,OAAO,EAAE,CAAC;IAC7B,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACE,IAAI,GAA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,UAAU,GAAG;EAClE;EACA,OAAOF,GAAG,YAAYpC,KAAK,GAAGoC,GAAG,CAACjC,OAAO,GAAG4B,QAAQ;AACtD","ignoreList":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// ported verbatim from frontend/apps/web/src/elements/payments/lib/mint.ts — keep in sync when the web element changes
|
|
4
|
+
|
|
5
|
+
import { capturedBrowserInfo } from "./browser-info.js";
|
|
6
|
+
import { PaymentTokenizationError, apiErrorMessage } from "./errors.js";
|
|
7
|
+
|
|
8
|
+
/** The collected bag a surface's `collect` verb returns — everything the CONTROLLER needs to
|
|
9
|
+
* mint: the assembled payment_method slice, the surface-validated billing block, and any
|
|
10
|
+
* declared inputs that belong on billing_details. Serializable — it crosses the surface's
|
|
11
|
+
* frame into the controller frame. */
|
|
12
|
+
|
|
13
|
+
/** The ONE confirmation-token mint — run by the CONTROLLER's internal action only, in the
|
|
14
|
+
* controller frame, with the controller's sdk + accountId/returnUrl/setupFutureUsage context.
|
|
15
|
+
* (Exception: WhopPaymentRequest tokenizes + mints host-side — it must run without a mounted
|
|
16
|
+
* controller.) */
|
|
17
|
+
export async function mintConfirmationToken(sdk, context, paymentMethod, billingDetails, billingExtra) {
|
|
18
|
+
if (!context.accountId) throw new Error('No seller account is in scope for this surface');
|
|
19
|
+
// A SAVED reference states less than a collected one, and the API REFUSES the difference rather
|
|
20
|
+
// than ignoring it: the type is read off the stored row, and consent to store was given when the
|
|
21
|
+
// method was first saved. Sending either back is a 400 telling us the element misread the flow —
|
|
22
|
+
// so the type is dropped from the body (it is still returned to the caller from the selection)
|
|
23
|
+
// and `setup_future_usage` never rides along. A BALANCE reference keeps its type (single-valued,
|
|
24
|
+
// server-verified) but is never vaulted, so the attested consent is refused there too.
|
|
25
|
+
const saved = paymentMethod.category === 'saved';
|
|
26
|
+
const referenced = saved || paymentMethod.category === 'balance';
|
|
27
|
+
const {
|
|
28
|
+
type: _selectedType,
|
|
29
|
+
...savedPayload
|
|
30
|
+
} = paymentMethod;
|
|
31
|
+
const token = await sdk.confirmationTokens.create({
|
|
32
|
+
account_id: context.accountId,
|
|
33
|
+
// The generated params type CLOSES payment_method over the category blocks, but the
|
|
34
|
+
// design of record sends method-DECLARED dynamic fields as top-level keys (INVENTORY
|
|
35
|
+
// backend obligation: the schema must admit them; strong params must not drop them).
|
|
36
|
+
payment_method: saved ? savedPayload : paymentMethod,
|
|
37
|
+
billing_details: {
|
|
38
|
+
...billingDetails,
|
|
39
|
+
...billingExtra
|
|
40
|
+
},
|
|
41
|
+
return_url: context.returnUrl,
|
|
42
|
+
setup_future_usage: referenced ? undefined : context.setupFutureUsage,
|
|
43
|
+
browser_info: capturedBrowserInfo()
|
|
44
|
+
}).catch(err => {
|
|
45
|
+
throw new PaymentTokenizationError('confirmation_token_create_failed', apiErrorMessage(err, 'collection failed'));
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
confirmationToken: token.id,
|
|
49
|
+
type: paymentMethod.type
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function validateBillingEmail(billing) {
|
|
53
|
+
if (!billing?.email) throw new Error('billingDetails.email is required');
|
|
54
|
+
return {
|
|
55
|
+
...billing,
|
|
56
|
+
email: billing.email
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function assertCardBilling(billing) {
|
|
60
|
+
if (!billing.name) throw new Error('billingDetails.name is required for card payments');
|
|
61
|
+
}
|
|
62
|
+
/** The framework's CODED lifecycle refusals (`childRefusal`, controller-core): switch on
|
|
63
|
+
* `code`, never string-match — the message is the human channel. */
|
|
64
|
+
export function isChildRefusal(err) {
|
|
65
|
+
const code = err?.code;
|
|
66
|
+
return code === 'CHILD_NOT_CREATED' || code === 'CHILD_DESTROYED';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The delegation cascade: COLLECTION belongs to the active surface, tried in precedence order —
|
|
71
|
+
* payment element, fused card element, exploded card-fields unit; each validates its own
|
|
72
|
+
* requirements and returns the serializable collected bag, and the CONTROLLER mints from it.
|
|
73
|
+
* Occupancy is DECIDED, not caught: `.created` (the advisory claim-axis probe) picks the live
|
|
74
|
+
* face; a coded lifecycle refusal (the check→invoke race — a face destroyed in between) falls
|
|
75
|
+
* through to the next; a live surface's own error re-throws untouched — its refusal is the
|
|
76
|
+
* answer.
|
|
77
|
+
*/
|
|
78
|
+
export async function collectThroughLiveSurface(surfaces, input) {
|
|
79
|
+
for (const surface of [surfaces.payment, surfaces.card, surfaces.cardFields]) {
|
|
80
|
+
if (!surface.created) continue;
|
|
81
|
+
try {
|
|
82
|
+
return await surface.collect(input);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
if (!isChildRefusal(err)) throw err;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
throw new Error('Mount a collection surface first — the payment element, the card element, or the card-fields unit');
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=mint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["capturedBrowserInfo","PaymentTokenizationError","apiErrorMessage","mintConfirmationToken","sdk","context","paymentMethod","billingDetails","billingExtra","accountId","Error","saved","category","referenced","type","_selectedType","savedPayload","token","confirmationTokens","create","account_id","payment_method","billing_details","return_url","returnUrl","setup_future_usage","undefined","setupFutureUsage","browser_info","catch","err","confirmationToken","id","validateBillingEmail","billing","email","assertCardBilling","name","isChildRefusal","code","collectThroughLiveSurface","surfaces","input","surface","payment","card","cardFields","created","collect"],"sourceRoot":"../../../../src","sources":["core/payments/mint.ts"],"mappings":";;AAAA;;AAIA,SAASA,mBAAmB,QAAQ,mBAAgB;AACpD,SAASC,wBAAwB,EAAEC,eAAe,QAAQ,aAAU;;AAepE;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA,OAAO,eAAeC,qBAAqBA,CACzCC,GAAe,EACfC,OAAoB,EACpBC,aAA2E,EAC3EC,cAAkC,EAClCC,YAAqC,EACiB;E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,EAAQ;EACnE,IAAI,CAACA,OAAO,CAACG,IAAI,EAAE,MAAM,IAAI3B,KAAK,CAAC,mDAAmD,CAAC;AACzF;AAmBA;AACA;AACA,OAAO,SAAS4B,cAAcA,CAACR,GAAY,EAAW;EACpD,MAAMS,IAAI,GAAIT,GAAG,EAAgCS,IAAI;EACrD,OAAOA,IAAI,KAAK,mBAAmB,IAAIA,IAAI,KAAK,iBAAiB;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,yBAAyBA,CAC7CC,QAA4B,EAC5BC,KAAc,EACa;EAC3B,KAAK,MAAMC,OAAO,IAAI,CAACF,QAAQ,CAACG,OAAO,EAAEH,QAAQ,CAACI,IAAI,EAAEJ,QAAQ,CAACK,UAAU,CAAC,EAAE;IAC5E,IAAI,CAACH,OAAO,CAACI,OAAO,EAAE;IACtB,IAAI;MACF,OAAQ,MAAMJ,OAAO,CAACK,OAAO,CAACN,KAAK,CAAC;IACtC,CAAC,CAAC,OAAOZ,GAAG,EAAE;MACZ,IAAI,CAACQ,cAAc,CAACR,GAAG,CAAC,EAAE,MAAMA,GAAG;IACrC;EACF;EACA,MAAM,IAAIpB,KAAK,CAAC,mGAAmG,CAAC;AACtH","ignoreList":[]}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// ported verbatim from frontend/apps/web/src/elements/payments/lib/plan.ts — keep in sync when the web element changes
|
|
4
|
+
|
|
5
|
+
import { currencyMinorDigits } from "./currency.js";
|
|
6
|
+
import { ChargeConfigError, apiErrorMessage } from "./errors.js";
|
|
7
|
+
|
|
8
|
+
/** The widened props bag both runtimes hand to the charge resolution — the controller seed's
|
|
9
|
+
* `ctx.props` and the host sources' live props view are each one branch of the plan-vs-inline
|
|
10
|
+
* union, so every key is optional here and `chargeInputOf` decides which branch is in force. */
|
|
11
|
+
|
|
12
|
+
/** `config = resolve(plan)`: the ONE normalized charge config every downstream path consumes —
|
|
13
|
+
* the inline props ARE the degenerate case (`plan` undefined, fields verbatim), and a plan is
|
|
14
|
+
* a preset that resolves to this same shape. */
|
|
15
|
+
|
|
16
|
+
/** The optionless statics-rail boot (`WhopElements.payments.handleNextAction` — the namespace
|
|
17
|
+
* handle mounts with an EMPTY options bag): no charge input exists and none is needed, the
|
|
18
|
+
* static flow never collects. Collection-face projections refuse on it, loudly. */
|
|
19
|
+
|
|
20
|
+
export const UNCONFIGURED_CHARGE = Object.freeze({
|
|
21
|
+
configured: false,
|
|
22
|
+
plan: undefined,
|
|
23
|
+
currency: undefined,
|
|
24
|
+
amount: undefined,
|
|
25
|
+
setupFutureUsage: undefined,
|
|
26
|
+
paymentMethodConfiguration: undefined
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/** ZERO charge inputs mounted — the only shape that resolves to UNCONFIGURED_CHARGE; any
|
|
30
|
+
* PARTIAL config still throws the loud ChargeConfigError (a half-config is a consumer bug). */
|
|
31
|
+
export function chargeless(props) {
|
|
32
|
+
return props.accountId === undefined && props.plan === undefined && props.currency === undefined && props.amount === undefined && props.paymentMethodConfiguration === undefined;
|
|
33
|
+
}
|
|
34
|
+
/** The plan-XOR-inline gate: `plan` alongside any inline charge key is a conflict, and neither
|
|
35
|
+
* is a missing config — both refuse LOUDLY with a coded `ChargeConfigError`. */
|
|
36
|
+
export function chargeInputOf(props) {
|
|
37
|
+
const input = {
|
|
38
|
+
accountId: props.accountId,
|
|
39
|
+
plan: props.plan,
|
|
40
|
+
currency: props.currency,
|
|
41
|
+
amount: props.amount,
|
|
42
|
+
setupFutureUsage: props.setupFutureUsage,
|
|
43
|
+
paymentMethodConfiguration: props.paymentMethodConfiguration
|
|
44
|
+
};
|
|
45
|
+
if (input.plan !== undefined) {
|
|
46
|
+
const inlineKeys = ['currency', 'amount', 'paymentMethodConfiguration'].filter(key => input[key] !== undefined);
|
|
47
|
+
if (inlineKeys.length > 0) {
|
|
48
|
+
throw new ChargeConfigError('PLAN_INLINE_CONFLICT', `Pass a plan OR an inline charge config, never both — ${inlineKeys.join(', ')} conflict with plan ${input.plan}. The plan resolves to the same shape client-side.`);
|
|
49
|
+
}
|
|
50
|
+
return input;
|
|
51
|
+
}
|
|
52
|
+
if (input.currency === undefined || input.amount === undefined) {
|
|
53
|
+
throw new ChargeConfigError('CHARGE_CONFIG_MISSING', 'Pass a plan id, or an inline charge config with both currency and amount — neither is mounted.');
|
|
54
|
+
}
|
|
55
|
+
return input;
|
|
56
|
+
}
|
|
57
|
+
export function inlineCharge(input) {
|
|
58
|
+
return {
|
|
59
|
+
configured: true,
|
|
60
|
+
plan: undefined,
|
|
61
|
+
currency: (input.currency ?? '').toLowerCase(),
|
|
62
|
+
amount: input.amount ?? 0,
|
|
63
|
+
setupFutureUsage: input.setupFutureUsage,
|
|
64
|
+
paymentMethodConfiguration: input.paymentMethodConfiguration
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The slice of the SDK's own plan the charge resolution reads — the schema is the author,
|
|
69
|
+
* nothing hand-typed to drift. `effective_payment_method_configuration` is the GOVERNING
|
|
70
|
+
* configuration resolved server-side through every layer; `null` means platform defaults, and
|
|
71
|
+
* there is no fallback to the plan's own editable override — the backend publishing the field
|
|
72
|
+
* deploys BENEATH this code by PR stacking. */
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Normalize a retrieved plan into the inline shape. The plan's `account_id` must MATCH the
|
|
76
|
+
* mounted `accountId` — the handle's account stays the mount key, and a foreign plan is a coded
|
|
77
|
+
* refusal, never a silent re-key. A renewing plan attests `off_session` save-consent unless the
|
|
78
|
+
* consumer set the attestation explicitly (the charge vaults the method for renewals).
|
|
79
|
+
*/
|
|
80
|
+
export function chargeFromPlan(resource, input) {
|
|
81
|
+
const planId = resource.id ?? input.plan;
|
|
82
|
+
const planAccount = resource.account?.id;
|
|
83
|
+
if (!planAccount || planAccount !== input.accountId) {
|
|
84
|
+
throw new ChargeConfigError('PLAN_ACCOUNT_MISMATCH', `Plan ${planId} belongs to ${planAccount ?? 'no account'}, not the mounted accountId ${input.accountId} — mount the element on the plan's own account.`);
|
|
85
|
+
}
|
|
86
|
+
const currency = resource.currency?.toLowerCase();
|
|
87
|
+
const initialPrice = resource.initial_price;
|
|
88
|
+
if (!currency || typeof initialPrice !== 'number' || !Number.isFinite(initialPrice)) {
|
|
89
|
+
throw new ChargeConfigError('PLAN_RESOLUTION_FAILED', `Plan ${planId} resolved without a currency and initial price.`);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
configured: true,
|
|
93
|
+
plan: planId,
|
|
94
|
+
currency,
|
|
95
|
+
// Truncate, never round — the backend's Utils.amount_in_cents is (amount.to_d * factor).to_i;
|
|
96
|
+
// toFixed(4) re-quantizes the float product to the exact decimal before the truncate.
|
|
97
|
+
amount: Math.trunc(Number((initialPrice * 10 ** currencyMinorDigits(currency)).toFixed(4))),
|
|
98
|
+
setupFutureUsage: input.setupFutureUsage ?? (resource.plan_type === 'renewal' ? 'off_session' : undefined),
|
|
99
|
+
// The GOVERNING configuration, resolved server-side — the same read a session mount gets
|
|
100
|
+
// from its own payment_method_configuration. A null answer is trusted as platform defaults;
|
|
101
|
+
// the elements NEVER re-derive a configuration layer client-side. Sliced to exactly the
|
|
102
|
+
// three known keys.
|
|
103
|
+
paymentMethodConfiguration: slicedConfiguration(resource.effective_payment_method_configuration)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function slicedConfiguration(configuration) {
|
|
107
|
+
if (!configuration) return undefined;
|
|
108
|
+
return {
|
|
109
|
+
enabled: configuration.enabled,
|
|
110
|
+
disabled: configuration.disabled,
|
|
111
|
+
include_platform_defaults: configuration.include_platform_defaults
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** The one charge resolution. Inline props resolve with no network; a plan costs one GET. */
|
|
116
|
+
export async function resolveCharge(client, props) {
|
|
117
|
+
// The statics rail's lazy open-handle boots with an EMPTY options bag and DOES run the
|
|
118
|
+
// h.sync charge gate — a chargeless boot resolves the unconfigured sentinel there exactly
|
|
119
|
+
// like the controller seed does. Partial config still throws.
|
|
120
|
+
if (chargeless(props)) return UNCONFIGURED_CHARGE;
|
|
121
|
+
const input = chargeInputOf(props);
|
|
122
|
+
if (input.plan === undefined) return inlineCharge(input);
|
|
123
|
+
let plan;
|
|
124
|
+
try {
|
|
125
|
+
plan = await client.plans.retrieve(input.plan);
|
|
126
|
+
} catch (err) {
|
|
127
|
+
throw new ChargeConfigError('PLAN_RESOLUTION_FAILED', apiErrorMessage(err, `plan ${input.plan} could not be resolved`));
|
|
128
|
+
}
|
|
129
|
+
return chargeFromPlan(plan, input);
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["currencyMinorDigits","ChargeConfigError","apiErrorMessage","UNCONFIGURED_CHARGE","Object","freeze","configured","plan","undefined","currency","amount","setupFutureUsage","paymentMethodConfiguration","chargeless","props","accountId","chargeInputOf","input","inlineKeys","filter","key","length","join","inlineCharge","toLowerCase","chargeFromPlan","resource","planId","id","planAccount","account","initialPrice","initial_price","Number","isFinite","Math","trunc","toFixed","plan_type","slicedConfiguration","effective_payment_method_configuration","configuration","enabled","disabled","include_platform_defaults","resolveCharge","client","plans","retrieve","err"],"sourceRoot":"../../../../src","sources":["core/payments/plan.ts"],"mappings":";;AAAA;;AAKA,SAASA,mBAAmB,QAAQ,eAAY;AAChD,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,aAAU;;AAE7D;AACA;AACA;;AAUA;AACA;AACA;;AAUA;AACA;AACA;;AAYA,OAAO,MAAMC,mBAAuC,GAAGC,MAAM,CAACC,MAAM,CAAC;EACnEC,UAAU,EAAE,KAAK;EACjBC,IAAI,EAAEC,SAAS;EACfC,QAAQ,EAAED,SAAS;EACnBE,MAAM,EAAEF,SAAS;EACjBG,gBAAgB,EAAEH,SAAS;EAC3BI,0BAA0B,EAA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
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Refusals that exist only on React Native, kept out of the ported `errors.ts` so that file stays a
|
|
5
|
+
* clean mirror of the web element's.
|
|
6
|
+
*
|
|
7
|
+
* Every one is coded, so a caller switches on `code` and never string-matches a message.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export class PaymentsRefusalError extends Error {
|
|
11
|
+
constructor(code, message) {
|
|
12
|
+
super(`[${code}] ${message}`);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.name = 'PaymentsRefusalError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=refusals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PaymentsRefusalError","Error","constructor","code","message","name"],"sourceRoot":"../../../../src","sources":["core/payments/refusals.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAO,MAAMA,oBAAoB,SAASC,KAAK,CAAC;EAG/CC,WAAWA,CAACC,IAAyB,EAAEC,OAAe,EAAE;IACvD,KAAK,CAAC,IAAID,IAAI,KAAKC,OAAO,EAAE,CAAC;IAC7B,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACE,IAAI,GAAG,sBAAsB;EACnC;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// ported verbatim from frontend/apps/web/src/elements/payments/lib/secure-fields.ts — keep in sync when the web element changes
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The secure declared-field rail (payment-api.md §4): a matrix field marked `secure: true`
|
|
7
|
+
* renders as a Basis Theory hosted text element wearing the suite's input chrome, so the raw
|
|
8
|
+
* value NEVER exists in our JavaScript — at collect time the selected method's element
|
|
9
|
+
* INSTANCES are tokenized into ONE Basis Theory token intent, keyed by field name
|
|
10
|
+
* (`{ type: 'token', data: { bank_account: <element> } }`; BT interpolates each element's value
|
|
11
|
+
* server-side, producing exactly the legacy checkout's additional-data shape, so the
|
|
12
|
+
* checkout.com mandate interpolation `$.data.<name>` consumes it unchanged), and the category
|
|
13
|
+
* payload carries `{ token }`. The create rides the web-elements SDK's element path under the
|
|
14
|
+
* method's config-block publishable key (`tokenizer` + `public_key`, the card block's source).
|
|
15
|
+
* Intents expire on BT's default clock (24h) — the confirm consumes one long before that.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { SecureFieldError } from "./errors.js";
|
|
19
|
+
|
|
20
|
+
/** A hosted text element instance. Opaque by construction — it carries an id and a formatter, never
|
|
21
|
+
* the value the buyer typed. */
|
|
22
|
+
|
|
23
|
+
const BT_TOKEN_INTENTS_URL = 'https://api.basistheory.com/token-intents';
|
|
24
|
+
|
|
25
|
+
/** Applied by BT inside the hosted element at tokenization (String.replace semantics):
|
|
26
|
+
* whitespace stripped — buyers type the spaced IBAN print format, the electronic format rides. */
|
|
27
|
+
export const secureValueTransform = /\s+/g;
|
|
28
|
+
|
|
29
|
+
// BT runs the validation regex against the value AS TYPED, while `transform` applies only at
|
|
30
|
+
// tokenization (developers.basistheory.com/docs/sdks/web/web-elements/components). The matrix
|
|
31
|
+
// publishes both truths ready to use: `input_formats` (what a buyer may type — whitespace
|
|
32
|
+
// tolerant, authored star-height 1 because BT's frame rejects nested quantifiers as unsafe)
|
|
33
|
+
// and `formats` (the stored electronic value, the fallback where no typing tolerance is
|
|
34
|
+
// declared). Patterns ride verbatim — the backend is the only author.
|
|
35
|
+
export function secureFieldValidation(field) {
|
|
36
|
+
const typed = Object.values(field.input_formats ?? {});
|
|
37
|
+
const patterns = typed.length > 0 ? typed : Object.values(field.formats ?? {});
|
|
38
|
+
if (patterns.length === 0) return undefined;
|
|
39
|
+
try {
|
|
40
|
+
return new RegExp(patterns.map(pattern => `(?:${pattern})`).join('|'));
|
|
41
|
+
} catch {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Raw-data token intents ride BT's REST surface with the publishable key — the wallet sheets'
|
|
47
|
+
* leg alone (Google's tokenizationData.token is a raw string, no hosted element exists to
|
|
48
|
+
* reference). */
|
|
49
|
+
export async function createRawTokenIntent(publicKey, data) {
|
|
50
|
+
const response = await fetch(BT_TOKEN_INTENTS_URL, {
|
|
51
|
+
method: 'POST',
|
|
52
|
+
headers: {
|
|
53
|
+
'BT-API-KEY': publicKey,
|
|
54
|
+
'Content-Type': 'application/json'
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify({
|
|
57
|
+
type: 'token',
|
|
58
|
+
data
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
if (!response.ok) throw new Error(`token intent creation failed (${response.status})`);
|
|
62
|
+
const intent = await response.json().catch(() => null);
|
|
63
|
+
if (!intent?.id) throw new Error('token intent creation returned no id');
|
|
64
|
+
return intent.id;
|
|
65
|
+
}
|
|
66
|
+
export async function tokenizeSecureFields(bt, elements,
|
|
67
|
+
/** The method's OWN config-block key. Passed per call because Basis Theory's client is a
|
|
68
|
+
* module-level singleton — the first key constructed wins for the whole process. */
|
|
69
|
+
apiKey) {
|
|
70
|
+
if (!bt) {
|
|
71
|
+
throw new SecureFieldError('SECURE_FIELD_TOKENIZER_UNAVAILABLE', 'This method declares a secure field but its tokenizer is not available');
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const intent = await bt.tokenIntents.create({
|
|
75
|
+
type: 'token',
|
|
76
|
+
data: elements
|
|
77
|
+
}, {
|
|
78
|
+
apiKey
|
|
79
|
+
});
|
|
80
|
+
if (!intent?.id) throw new Error('token intent creation returned no id');
|
|
81
|
+
return intent.id;
|
|
82
|
+
} catch (err) {
|
|
83
|
+
const detail = err instanceof Error && err.message ? `: ${err.message}` : '';
|
|
84
|
+
throw new SecureFieldError('SECURE_FIELD_TOKENIZE_FAILED', `Secure field tokenization failed${detail}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=secure-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SecureFieldError","BT_TOKEN_INTENTS_URL","secureValueTransform","secureFieldValidation","field","typed","Object","values","input_formats","patterns","length","formats","undefined","RegExp","map","pattern","join","createRawTokenIntent","publicKey","data","response","fetch","method","headers","body","JSON","stringify","type","ok","Error","status","intent","json","catch","id","tokenizeSecureFields","bt","elements","apiKey","tokenIntents","create","err","detail","message"],"sourceRoot":"../../../../src","sources":["core/payments/secure-fields.ts"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,gBAAgB,QAAQ,aAAU;;AAE3C;AACA;;AAGA,MAAMC,oBAAoB,GAAG,2CAA2C;;AAExE;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAG,MAAM;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,KAGrC,EAAsB;EACrB,MAAMC,KAAK,GAAGC,MAAM,CAACC,MAAM,CAACH,KAAK,CAACI,aAAa,IAAI,CAAC,CAAC,CAAC;EACtD,MAAMC,QAAQ,GAAGJ,KAAK,CAACK,MAAM,GAAG,CAAC,GAAGL,KAAK,GAAGC,MAAM,CAACC,MAAM,CAACH,KAAK,CAACO,OAAO,IAAI,CAAC,CAAC,CAAC;EAC9E,IAAIF,QAAQ,CAACC,MAAM,KAAK,CAAC,EAAE,OAAOE,SAAS;EAC3C,IAAI;IACF,OAAO,IAAIC,MAAM,CAACJ,QAAQ,CAACK,GAAG,CAAEC,OAAO,IAAK,MAAMA,OAAO,GAAG,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC;EAC1E,CAAC,CAAC,MAAM;IACN,OAAOJ,SAAS;EAClB;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeK,oBAAoBA,CAACC,SAAiB,EAAEC,IAAa,EAAmB;EAC5F,MAAMC,QAAQ,GAAG,MAAMC,KAAK,C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