Skip to content
FRAGMENT
G SDKs#

Backend

#

FRAGMENT publishes SDKs in:

  • TypeScript
  • Go
  • Python
  • Ruby

The SDKs are open-source, implement authentication, and come with predefined GraphQL queries to help you get started.


Install the SDK for your language:

npm install --save @fragment-dev/node-client

Each SDK's README covers initialization, query generation, and usage:


To create an SDK in a language not listed above:

  1. Use the FRAGMENT CLI to generate GraphQL queries from your Schema:

    fragment get-schema \
      --output=schema.jsonc &&\
    fragment gen-graphql \
      --path=schema.jsonc \
      --output=queries.graphql

    Learn about the different options you can provide to gen-graphql in its reference section.

  2. Generate a type-safe SDK using a GraphQL codegen tool for your language. Provide the FRAGMENT API GraphQL schema as input.

  3. Implement authentication and error handling.

Frontend

#

FRAGMENT publishes Payment Elements, a React SDK that collects card details in your frontend. It needs React 17, 18 or 19.

Install the SDK:

npm install --save @fragment-dev/payment-elements
Theming#

Pass a theme to PaymentElements to change how the card form looks. Every field is optional, and a field you leave out keeps FRAGMENT's default:

Checkout.tsx
<PaymentElements
  theme={{
    appearance: 'light',
    colors: { text: 'rgb(20 20 20)', error: 'rgb(200 30 30)' },
    fontFamily: 'Inter, sans-serif',
    fontSize: '16px',
    borderRadius: '8px',
  }}
>
  {/* PaymentSession or PaymentMethodSetupSession */}
</PaymentElements>
FieldEffect
appearancelight or dark. Defaults to dark when <html> has the dark class.
colorstext, mutedText, inputBackground, inputFocusBackground, surface, border, error.
fontFamilyA font family the payment frame already has. The frame loads no web font from your page.
fontSizeA size in px, such as 16px. The line height follows it.
borderRadiusThe corner radius of the fields, the rows and the address suggestions.

The fields render in a frame that cannot read your page's CSS custom properties, so pass literal colors.