Skip to main content
Primer Checkout React Native SDK is currently in beta (v3.0.0-beta.1). The API is subject to change before the stable release.
The card form detects the card network from the digits the shopper types. The hooks and components on this page read the detected network, let the shopper choose a network on a co-badged card, and show the networks your session accepts. All of them must be inside PrimerCheckoutProvider. They don’t need PrimerCardFormProvider. The detected network comes from the native SDK’s BIN data, which exists only while the card form is active: after start() on usePrimerPaymentMethod('PAYMENT_CARD'), or inside PrimerCheckoutSheet.

usePrimerCardNetwork

Returns the detected network with its traits and icon.
The return type is exported as UseCardNetworkReturn.
  • descriptor starts as the default descriptor on every network change and updates when the native SDK returns the traits. It stays the default when the native SDK has no traits for the network or the lookup fails.
  • iconSource is only for the detected network. For the icons of other networks, use PrimerCardNetworkSelector or PrimerAcceptedCardNetworks.

usePrimerCardNetworkSelection

Returns the networks of a co-badged card and lets you record the shopper’s choice.
The return type is exported as UsePrimerCardNetworkSelectionReturn.
  • The choice is sent with the card data until the shopper changes the card number to one whose detected networks no longer include it. The SDK then drops the choice and selectedNetwork returns to null.
  • Without a choice, no network is sent with the card data.
  • The choice is also dropped when the card form stops being active.

Building your own selector

PrimerCardNumberInput, and so PrimerCardForm, already contains the co-badged selector. Build your own selector, or use PrimerCardNetworkSelector, only in a layout with your own card number field. Otherwise the shopper sees two selectors.

CardNetworkDetails

A network in usePrimerCardNetworkSelection. All fields are read-only.

PrimerCardNetworkSelector

The co-badged network selector that PrimerCardNumberInput shows inside the card number field. Render it yourself only next to your own card number field. The props type is exported as PrimerCardNetworkSelectorProps. The selector reads usePrimerCardNetworkSelection() and renders one of three states: A badge shows the network’s icon. Without an icon it shows a two-letter abbreviation, for example CB for Cartes Bancaires, or a generic card image when there is no abbreviation.

PrimerAcceptedCardNetworks

A horizontal row of small chips for the card networks your session accepts. Add it to your own layout, for example above the card number.
  • Without networks, it shows acceptedCardNetworks from usePrimerCheckout(): the networks the session accepts, in order. The SDK loads them when the checkout is ready and again when the client session changes.
  • Each chip shows the network’s icon, or a two-letter abbreviation while there is no icon.
  • It renders nothing while the list is empty or not loaded yet.
  • Duplicate networks are shown once, in the order given.
The props type is exported as PrimerAcceptedCardNetworksProps.

CardNetworkId

The identifiers of the networks the SDK knows:

BinData

The BIN data the native SDK reports for the card number. Read it from usePrimerCardForm().binData or the onBinDataChange option of usePrimerCardForm. The type is exported as BinData. BinDataStatus is also exported. CardNetwork, also exported, describes one detected network:

See also

usePrimerCardForm

Card form state, including binData and descriptor.

Card inputs

PrimerCardNumberInput and its built-in selector.

PrimerCardForm

The card fields in a fixed layout.

Display card network

Show the detected card network as the shopper types.