Skip to content

Feat/checkout sessions#459

Open
aqt-dev wants to merge 4 commits intomainfrom
feat/checkout-sessions
Open

Feat/checkout sessions#459
aqt-dev wants to merge 4 commits intomainfrom
feat/checkout-sessions

Conversation

@aqt-dev
Copy link
Contributor

@aqt-dev aqt-dev commented Feb 13, 2026

No description provided.

aqt-dev and others added 4 commits February 8, 2026 23:05
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the checkoutSession prop is provided, fiat orders are created via
POST /checkout-sessions instead of POST /orders. The backend creates
the order internally, so existing polling and payment UI continue to
work unchanged. The redirect URL on completion uses the session's
resolved success_url directly (no order ID appended).

Components updated: AnySpend, AnySpendCustom, AnySpendCustomExactIn
Also updated: OrderDetails redirect logic, useAnyspendFlow hook

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Documents the full checkout sessions integration including
component prop usage, hooks API, service methods, and types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aqt-dev aqt-dev requested a review from a team as a code owner February 13, 2026 04:10
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @aqt-dev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new "Checkout Sessions" feature to the AnySpend SDK, designed to streamline the payment process for merchants by offering a Stripe-like experience. It enables merchants to easily create payment sessions, redirect users to hosted payment pages, and manage post-payment redirects. The changes encompass new API endpoints, dedicated React hooks for both session creation and polling, and seamless integration into existing AnySpend UI components, significantly simplifying the implementation of fiat payment flows.

Highlights

  • New Checkout Session Feature: Introduced Stripe-like checkout sessions, allowing merchants to create sessions, redirect users to hosted payment pages, and verify results.
  • Comprehensive SDK Integration: Added new React hooks (useCreateCheckoutSession, useCheckoutSession, useAnyspendCreateCheckoutSessionOrder) and integrated checkout session support into core AnySpend components (, , ) via a new checkoutSession prop.
  • Backend API and Service Methods: Implemented new createCheckoutSession and getCheckoutSession service methods in the AnySpend SDK, along with corresponding TypeScript types, to interact with the backend checkout session API.
  • Enhanced Order Details: Modified the OrderDetails component to correctly handle redirect URLs for checkout sessions, ensuring proper post-payment navigation.
  • Detailed Documentation: Provided extensive documentation (checkout-sessions.md) outlining integration options, API usage, and session lifecycle.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • packages/sdk/src/anyspend/docs/checkout-sessions.md
    • Added new documentation detailing the checkout sessions feature, including integration options, API reference, and type definitions.
  • packages/sdk/src/anyspend/index.ts
    • Exported new TypeScript types related to checkout sessions.
  • packages/sdk/src/anyspend/react/components/AnySpend.tsx
    • Integrated useAnyspendCreateCheckoutSessionOrder hook, added checkoutSession prop, and updated fiat order creation logic to conditionally use checkout sessions.
  • packages/sdk/src/anyspend/react/components/AnySpendCustom.tsx
    • Incorporated useAnyspendCreateCheckoutSessionOrder hook, added checkoutSession prop, and adjusted fiat order creation to support checkout sessions.
  • packages/sdk/src/anyspend/react/components/AnySpendCustomExactIn.tsx
    • Included useAnyspendCreateCheckoutSessionOrder hook, added checkoutSession prop, and modified fiat order creation to leverage checkout sessions.
  • packages/sdk/src/anyspend/react/components/common/OrderDetails.tsx
    • Introduced isCheckoutSession prop and updated the redirect URL handling logic to accommodate checkout session flows.
  • packages/sdk/src/anyspend/react/hooks/index.ts
    • Exported new React hooks: useAnyspendCreateCheckoutSessionOrder, useCheckoutSession, and useCreateCheckoutSession.
  • packages/sdk/src/anyspend/react/hooks/useAnyspendCreateCheckoutSessionOrder.ts
    • Added a new hook for creating orders via checkout sessions, abstracting the POST /checkout-sessions API call.
  • packages/sdk/src/anyspend/react/hooks/useAnyspendFlow.ts
    • Integrated useAnyspendCreateCheckoutSessionOrder hook, added checkoutSession prop, and updated order creation logic to support checkout sessions.
  • packages/sdk/src/anyspend/react/hooks/useCheckoutSession.ts
    • Added a new hook for polling the status of a checkout session.
  • packages/sdk/src/anyspend/react/hooks/useCreateCheckoutSession.ts
    • Added a new hook for initiating the creation of a checkout session.
  • packages/sdk/src/anyspend/services/anyspend.ts
    • Implemented new service methods createCheckoutSession and getCheckoutSession for interacting with the backend checkout session API.
  • packages/sdk/src/anyspend/types/checkoutSession.ts
    • Added new TypeScript interfaces and types for checkout session requests, responses, and the CheckoutSession object.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive checkout sessions feature, similar to Stripe, which is a great addition. The implementation spans across new documentation, hooks, services, and component updates. The code is generally well-structured. My review focuses on improving type safety by removing any types and addressing a couple of potentially unsafe type assertions that could lead to runtime errors. I've also included a minor suggestion to improve the new documentation.

dstTokenAddress: getDstToken().address,
srcFiatAmount: srcAmountOnRamp,
onramp: {
vendor: vendor as "coinbase" | "stripe-web2" | "none",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There's a potentially unsafe type assertion here. The vendor variable can be "stripe", but the type for checkout session creation (useAnyspendCreateCheckoutSessionOrder) does not include "stripe". This could lead to runtime errors if a user selects a payment method that resolves to the "stripe" vendor. Instead of casting, it would be safer to handle this case explicitly, for example by preventing the checkout session flow for unsupported vendors or mapping them to a supported one if applicable.

dstTokenAddress: dstToken.address,
srcFiatAmount: onrampAmount,
onramp: {
vendor: onramp.vendor as "coinbase" | "stripe-web2" | "none",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to another component, there's a risky type assertion here. The onramp.vendor can be "stripe", which is not a supported vendor for checkout sessions. This could cause runtime failures. Please add a check to handle unsupported vendors for the checkout session flow instead of just casting the type.

| Property | Type | Description |
|----------|------|-------------|
| `createSession` | `(params: CreateCheckoutSessionRequest) => void` | Trigger session creation |
| `createSessionAsync` | `(params: CreateCheckoutSessionRequest) => Promise` | Async version |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The return type for createSessionAsync is documented as a generic Promise. For better clarity and type safety in the documentation, it would be beneficial to specify the resolved value's type, which appears to be Promise<CheckoutSession>.

Suggested change
| `createSessionAsync` | `(params: CreateCheckoutSessionRequest) => Promise` | Async version |
| `createSessionAsync` | `(params: CreateCheckoutSessionRequest) => Promise<CheckoutSession>` | Async version |


export type UseAnyspendCreateCheckoutSessionOrderProps = {
checkoutSession: CheckoutSessionConfig;
onSuccess?: (data: any) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The data parameter in the onSuccess callback is typed as any. To improve type safety and developer experience, it should be explicitly typed as CreateCheckoutSessionResponse. You'll need to import this type from ../../types/checkoutSession.

Suggested change
onSuccess?: (data: any) => void;
onSuccess?: (data: CreateCheckoutSessionResponse) => void;

error,
} = useMutation({
mutationFn: (params: CreateCheckoutSessionRequest) => anyspendService.createCheckoutSession(params),
onSuccess: data => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The data parameter is implicitly any. For better type safety, please explicitly type it as CreateCheckoutSessionResponse.

Suggested change
onSuccess: data => {
onSuccess: (data: CreateCheckoutSessionResponse) => {

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.

1 participant