Skip to content

ci: add NEXT_PUBLIC_TRANSAK_* env vars to preview and cloudfront deploys - #653

Closed
victhorbi wants to merge 2 commits into
mainfrom
ci/transak-env-workflows
Closed

ci: add NEXT_PUBLIC_TRANSAK_* env vars to preview and cloudfront deploys#653
victhorbi wants to merge 2 commits into
mainfrom
ci/transak-env-workflows

Conversation

@victhorbi

@victhorbi victhorbi commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Description

deploy-preview.yaml runs via pull_request_target, which uses the workflow definition from main — not the PR branch. The Transak env vars added in PR #649 are therefore ignored unless they're on main too.

This PR adds the Transak environment variables to both deploy workflows on main:

  • deploy-preview.yaml: NEXT_PUBLIC_TRANSAK_API_KEY, NEXT_PUBLIC_TRANSAK_API_URL, NEXT_PUBLIC_TRANSAK_ENVIRONMENT: 'staging'
  • deploy-cloudfront.yaml: same plus NEXT_PUBLIC_TRANSAK_ENVIRONMENT: 'production'

These are consumed at build time by the homepage's VechainKitProviderWrapper to wire the kit's Built-in Buy VET button and point it at the deployed mini-server (lambda).

Helper PR for #649 — no code changes, only CI env.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Transak environment configuration for payment-related experiences during both production and preview deployments.
    • Production builds now use the live configuration, while preview builds use the staging configuration for safer testing.
    • Ensures Transak API settings align with the correct deployment environment so transaction flows connect reliably.

Comment thread .github/workflows/deploy-cloudfront.yaml
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3207632d-518e-4701-b196-94c9a1ce8ac3

📥 Commits

Reviewing files that changed from the base of the PR and between 3093969 and 808f04a.

📒 Files selected for processing (2)
  • .github/workflows/deploy-cloudfront.yaml
  • .github/workflows/deploy-preview.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/deploy-preview.yaml
  • .github/workflows/deploy-cloudfront.yaml

📝 Walkthrough

Walkthrough

The deployment workflows now expose Transak configuration during production and preview builds. Production uses secret values and the production environment. Preview uses the staging key and staging environment.

Changes

Transak deployment configuration

Layer / File(s) Summary
Configure Transak build environments
.github/workflows/deploy-cloudfront.yaml, .github/workflows/deploy-preview.yaml
The CloudFront workflow provides the Transak API key, API URL, and production environment. The preview workflow provides the staging API key and staging environment while retaining the API URL.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

  • vechain/vechain-kit#649: Configures the Transak environment variables used by deployment and on-ramp integration.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the addition of Transak environment variables to the preview and CloudFront deployment workflows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/transak-env-workflows

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 8.92 MB

ℹ️ View Unchanged
Filename Size
packages/vechain-kit/dist/assets 4.1 kB
packages/vechain-kit/dist/assets-BpQtJMK4.mjs 51.4 kB
packages/vechain-kit/dist/assets-BpQtJMK4.mjs.map 74.7 kB
packages/vechain-kit/dist/assets-qmvJ4lSm.cjs 59 kB
packages/vechain-kit/dist/assets-qmvJ4lSm.cjs.map 76.2 kB
packages/vechain-kit/dist/assets/index.cjs 717 B
packages/vechain-kit/dist/assets/index.d.cts 973 B
packages/vechain-kit/dist/assets/index.d.mts 973 B
packages/vechain-kit/dist/assets/index.mjs 719 B
packages/vechain-kit/dist/index-B9WQ_M7W.d.mts 186 kB
packages/vechain-kit/dist/index-B9WQ_M7W.d.mts.map 49.5 kB
packages/vechain-kit/dist/index-BYfc-9J5.d.mts 5.63 kB
packages/vechain-kit/dist/index-BYfc-9J5.d.mts.map 2.99 kB
packages/vechain-kit/dist/index-C4tYDnC4.d.cts 186 kB
packages/vechain-kit/dist/index-C4tYDnC4.d.cts.map 50.8 kB
packages/vechain-kit/dist/index-C8Uj8ple.d.cts 5.63 kB
packages/vechain-kit/dist/index-C8Uj8ple.d.cts.map 2.99 kB
packages/vechain-kit/dist/index.cjs 1.15 MB
packages/vechain-kit/dist/index.cjs.map 2.86 MB
packages/vechain-kit/dist/index.d.cts 24.5 kB
packages/vechain-kit/dist/index.d.mts 24.5 kB
packages/vechain-kit/dist/index.mjs 1.1 MB
packages/vechain-kit/dist/index.mjs.map 2.8 MB
packages/vechain-kit/dist/utils 4.1 kB
packages/vechain-kit/dist/utils-Bf4wG_2j.cjs 27.4 kB
packages/vechain-kit/dist/utils-Bf4wG_2j.cjs.map 68.2 kB
packages/vechain-kit/dist/utils-Y7vw7K0X.mjs 22.2 kB
packages/vechain-kit/dist/utils-Y7vw7K0X.mjs.map 67.5 kB
packages/vechain-kit/dist/utils/index.cjs 2.02 kB
packages/vechain-kit/dist/utils/index.d.cts 3.1 kB
packages/vechain-kit/dist/utils/index.d.mts 3.1 kB
packages/vechain-kit/dist/utils/index.mjs 2.04 kB

compressed-size-action

- deploy-preview uses NEXT_PUBLIC_TRANSAK_API_KEY_STAGING
- deploy-cloudfront uses NEXT_PUBLIC_TRANSAK_API_KEY_PROD

Keeps the prod site inert (Buy hidden) until the production key exists:
key absent = transak config disabled in the example wrapper.
Comment thread .github/workflows/deploy-cloudfront.yaml
Comment thread .github/workflows/deploy-preview.yaml
@victhorbi

Copy link
Copy Markdown
Collaborator Author

Changes moved into PR #649

@victhorbi victhorbi closed this Aug 5, 2026
Vombato added a commit that referenced this pull request Aug 5, 2026
- deploy-preview uses NEXT_PUBLIC_TRANSAK_API_KEY_STAGING
- deploy-cloudfront uses NEXT_PUBLIC_TRANSAK_API_KEY_PROD

Keeps the prod site inert (Buy hidden) until the production key exists.
Re-applies 808f04a, lost when #653 was folded into this branch.
victhorbi added a commit that referenced this pull request Aug 6, 2026
* feat: add fiat and crypto subscription payment components

- Add useBuyCrypto, useFiatCheckout, useSubscription, useSubscriptionCheckout hooks
- Add FiatCheckoutModal, PayWithFiatButton, SubscribeButton, SubscriptionCheckoutModal components
- Add FiatOnramp content in AccountModal
- Add subscription demo in PaymentsDemo example
- Add crypto payment method to SubscriptionCheckout (VET/ERC20)
- Extend SubscriptionPlan type with optional cryptoPayment field
- Add i18n translation keys for fiat/crypto payments
- Fix Privy v3 compatibility (optional clientId, cross-app-connect deps)
- Mock fallback for useSubscription when API base URL not configured
- Add Solana deps to root workspace (Privy v3 transitive)

* feat: switch fiat onramp from Privy/Stripe to Transak (native VET support)

BREAKS: Replaces useBuyCrypto, useFiatCheckout, FiatCheckoutModal,
PayWithFiatButton, FiatOnrampContent with Transak equivalents.

Adds:
- useTransakCheckout hook (dual-mode widget URL: apiKey-only for
  sandbox, widgetUrlBuilder for production)
- TransakCheckoutModal, PayWithTransakButton components
- TransakOnrampContent in AccountModal
- @transak/ui-js-sdk dependency
- transak config on VeChainKitProvider
- Subscription fiat path opens Transak to fund, then creates sub

Removes:
- Privy useAddFunds / useBuyCrypto dependency
- @stripe/crypto peer dep
- All Privy/Stripe-specific translations

* fix: keep Transak modal open on success + remove dead code in subscribe

- PayWithTransakButton: isOpen stays true on 'success' so the success
  screen is visible; only closes when user dismisses
- useSubscriptionCheckout: removed unreachable createSubscription
  fallthrough (was only reachable for crypto-without-cryptoPayment,
  an impossible UI state); replaced with a clear error

* fix: auto-hide 'Buy' quick action when transak.apiKey is not configured

Without this, the Buy button rendered unconditionally and only
threw 'Transak is not configured' after the user filled the form
and clicked Continue. Now it stays hidden unless the developer
passes a transak config to VeChainKitProvider.

* feat: gate 'Pay with Card' on transak.apiKey presence

When the developer does not pass a Transak API key to VeChainKitProvider,
kit-internal UI no longer surfaces fiat-only options:

- useSubscriptionCheckout: derives hasFiat from config; default
  paymentMethod for non-crypto plans is 'crypto' when fiat is unavailable
- SubscriptionCheckoutModal: 'Pay with Card' tab hidden unless hasFiat;
  plans with neither crypto nor fiat show an info note instead of the
  Subscribe button
- en.json: 'No payment method available for this plan.' key

* feat: require Transak Secure Widget URL flow

Transak deprecated direct widget URLs (apiKey in the query string);
widgets now only load from a sessionId-based URL minted by the Create
Widget URL API (POST /api/v2/auth/session), called from the partner
backend with the API secret.

- TransakConfig.widgetUrlBuilder is now required; apiKey optional
- useTransakCheckout: removed buildDirectUrl fallback, errors clearly
  when widgetUrlBuilder is missing
- hasFiat / Buy quick-action gating now checks widgetUrlBuilder
- example: /api/transak/widget-url route does refresh-token ->
  create-widget-url with x-user-ip; wrapper wires widgetUrlBuilder
- .env.example: TRANSAK_API_KEY / TRANSAK_API_SECRET server vars

* fix: embed Transak widget in host modal to stop focus flicker

The Transak SDK's default behavior appends its own full-screen overlay to
document.body, outside the Chakra modal. Chakra's focus trap then detects
focus escaping the modal and pulls it back whenever the user clicks into
Transak's inputs, causing the email field to constantly lose focus.

- useTransakCheckout: pass containerId so the widget renders as an iframe
  inside the host modal; expose TRANSAK_WIDGET_CONTAINER_ID; replace the
  SDK's close() with cleanup() (which actually removes the iframe in
  container mode) and clear the container on open/close/unmount
- TransakCheckoutModal: render the embed container during processing and
  disable the modal focus trap (allowExternalFocus) while the widget is
  active

* fix: lower demo amount to Transak minimum and fix widget scrollbars

- Demo/button/hook/modal defaults changed from $50 to $20 (Transak's
  minimum card order), so sandbox testing is cheaper
- TransakCheckoutModal: widget container height is now viewport-aware
  (calc(100vh - 240px), 420-620px) and mobile uses a near-fullscreen
  bottom sheet, so the widget's own scroll is the only scrollbar instead
  of a double scrollbar (modal + iframe)

* fix: lower default Transak amount to $10 minimum

Transak's minimum order with light KYC is $10; the demo and component
defaults now use it instead of $20.

* fix: theme standalone Transak/subscription modals and fix cross-app-connect Privy config

* feat: auto-derive Transak environment from connected network

* docs: add Transak on-ramp backend setup guide

* chore: remove half-implemented subscription flow, revert Privy to v2, restore typecheck gate

- Remove useSubscription, useSubscriptionCheckout, SubscriptionModal,
  SubscriptionCheckoutModal, SubscribeButton and stripe-subscriptions docs
  (full signed-typed-message subscription flow lands in a follow-up PR)
- Revert @privy-io/react-auth to 2.25.0 and @privy-io/cross-app-provider to
  ^0.3.4 in kit and cross-app-connect; drop root Solana deps; restore v2
  provider shapes (Privy v3 bump deferred to its own PR)
- Restore tsc --noEmit gate in kit build and add Typecheck step to CI
- Remove subscription-only i18n keys

* fix: address CodeRabbit findings on Transak checkout and reference route

- Add 10s timeouts to outbound Transak API calls and an in-memory rate
  limit on the widget-url route (unauthenticated minting protection)
- Guard instanceRef assignment with the generation counter so a stale
  widget never overwrites the active instance
- Validate walletAddress with isAddress before building the widget URL
- Return to the form step when the Transak widget closes without success
- Fix docs: fence language and valid JSON request example

* feat(next-template): allow overriding the Transak mini-server URL via NEXT_PUBLIC_TRANSAK_API_URL

* feat(homepage): wire Transak onramp + pass env vars to preview deploy

- Add transak prop to homepage VechainKitProviderWrapper (same pattern as
  next-template): Buy VET button appears in AccountModal when
  NEXT_PUBLIC_TRANSAK_API_KEY is set, calling the mini-server at
  NEXT_PUBLIC_TRANSAK_API_URL
- Pass NEXT_PUBLIC_TRANSAK_API_KEY and NEXT_PUBLIC_TRANSAK_API_URL through
  deploy-preview.yaml so the homepage preview build inlines them
- Document both vars in examples/homepage/.env.example

* chore: trigger preview redeploy with Transak env vars

* feat: wire Transak environment + add mandatory integration requirements docs

- Both providers (homepage + next-template) pass
  NEXT_PUBLIC_TRANSAK_ENVIRONMENT in the fetch body (not as top-level
  config prop) to the mini-server
- deploy-preview.yaml: NEXT_PUBLIC_TRANSAK_ENVIRONMENT='staging'
- deploy-cloudfront.yaml: NEXT_PUBLIC_TRANSAK_ENVIRONMENT='production'
- docs/recipes/transak-onramp.md: section 6 with credential isolation,
  x-api-key, x-user-ip, backend IP whitelisting, CORS, rate limiting,
  partner onboarding checklist; env vars table updated

* ci: split Transak API key secret per environment

- deploy-preview uses NEXT_PUBLIC_TRANSAK_API_KEY_STAGING
- deploy-cloudfront uses NEXT_PUBLIC_TRANSAK_API_KEY_PROD

Keeps the prod site inert (Buy hidden) until the production key exists.
Re-applies 808f04a, lost when #653 was folded into this branch.

* fix: harden rate-limit IP resolution + guard stale generation in transak checkout catch

- widget-url route: resolveClientIp prefers x-real-ip (written by trusted
  proxies, unspoofable from the client) over the leftmost x-forwarded-for
  entry; falls back to 'unknown' bucket when no public IP is available so
  attackers cannot trivially rotate headers to bypass the rate limit.
- useTransakCheckout open(): guard the catch block with genRef.current !== gen
  so a superseded generation does not overwrite the active generation's
  error/status (matches the guard already used before instance assignment).

---------

Co-authored-by: Luca Bandini <luca.bandini@vechain.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants