Skip to content

React Components

Reference for all GoPayLocal React SDK components — PPPBanner, PPPPrice, PPPPriceFormatted, and more.

All components must be rendered inside a GoPayLocalProvider. They automatically read PPP data from context.

Renders a discount banner with the visitor’s PPP information. Renders nothing if no discount is available.

import { GoPayLocalProvider, PPPBanner } from '@gopaylocal/react';
function App() {
return (
<GoPayLocalProvider apiKey="gpl_pk_live_abc123">
<PPPBanner position="bottom-right" />
<PricingPage />
</GoPayLocalProvider>
);
}
PropTypeDefaultDescription
position'top' | 'bottom' | 'bottom-left' | 'bottom-right'API config value or 'bottom-right'Banner position
backgroundColorstringAPI config valueBanner background color
fontColorstringAPI config valueBanner text color
borderRadiusstring'8px' for floatingCSS border radius
fontSizestring'14px'CSS font size
showCloseIconbooleantrueWhether to show the close button
noStylesbooleanfalseRender without default styles (for custom styling)
classNamestringAdditional CSS class name
onClose() => voidCallback when dismissed

Use noStyles to render the banner with data attributes instead of inline styles, so you can style it with your own CSS:

<PPPBanner noStyles className="my-banner" />

The unstyled version renders with these data attributes:

  • data-gopaylocal-banner — root element
  • data-gopaylocal-flag — flag emoji
  • data-gopaylocal-message — message text
  • data-gopaylocal-cta — CTA button
  • data-gopaylocal-close — close button

The simplest price component. Renders the localized, discounted price as a single formatted string.

import { PPPPrice } from '@gopaylocal/react';
<PPPPrice price={99.99} />
// India: "₹4,999"
// US: "$99.99"
// Germany: "€92.99"
PropTypeDefaultDescription
pricenumber(required)Base price in your default currency
localizebooleantrueConvert to visitor’s local currency
showDecimalbooleanWhether to show decimal digits
currencyDisplay'symbol' | 'code' | 'name''symbol'How to display the currency
classNamestringCSS class name
<PPPPrice price={99.99} currencyDisplay="symbol" /> // "₹4,999"
<PPPPrice price={99.99} currencyDisplay="code" /> // "INR 4,999"
<PPPPrice price={99.99} currencyDisplay="name" /> // "4,999 Indian rupees"

Like PPPPrice but with advanced formatting options, including the ability to show the original (pre-discount) price for strikethrough displays.

import { PPPPriceFormatted } from '@gopaylocal/react';
<div>
<s><PPPPriceFormatted price={99.99} isOriginalDisplay /></s>
{' '}
<PPPPriceFormatted price={99.99} />
</div>
// Renders: <s>₹7,499</s> ₹4,999
PropTypeDefaultDescription
pricenumber(required)Base price
isOriginalDisplaybooleanfalseShow the original (non-discounted) price
localizebooleantrueConvert to local currency
showDecimalbooleanWhether to show decimals
minimumDecimalDigitsnumberMinimum decimal digits
maximumDecimalDigitsnumberMaximum decimal digits
currencyDisplay'symbol' | 'code' | 'name''symbol'Currency display mode
classNamestringCSS class name

Renders only the integer part of the localized price. Use with PPPPriceDecimal and PPPCurrencySymbol for custom price layouts.

import { PPPPriceInteger, PPPPriceDecimal, PPPCurrencySymbol } from '@gopaylocal/react';
<span className="price">
<PPPCurrencySymbol />
<PPPPriceInteger price={99.99} />
<sup>
.<PPPPriceDecimal price={99.99} />
</sup>
</span>
// Renders: ₹4,999<sup>.00</sup>
PropTypeDefaultDescription
pricenumber(required)Base price
localizebooleantrueConvert to local currency
classNamestringCSS class name

Renders only the decimal part of the localized price. Returns null if there is no decimal portion.

import { PPPPriceDecimal } from '@gopaylocal/react';
<PPPPriceDecimal price={99.99} />
// Renders: "99" (or null for zero-decimal currencies like JPY)
PropTypeDefaultDescription
pricenumber(required)Base price
localizebooleantrueConvert to local currency
minimumDecimalDigitsnumberMinimum decimal digits
maximumDecimalDigitsnumberMaximum decimal digits
classNamestringCSS class name

Renders the visitor’s local currency symbol.

import { PPPCurrencySymbol } from '@gopaylocal/react';
<PPPCurrencySymbol />
// India: "₹"
// US: "$"
// Japan: "¥"
// EU: "€"
PropTypeDefaultDescription
classNamestringCSS class name

Renders the visitor’s local currency code (ISO 4217).

import { PPPCurrencyCode } from '@gopaylocal/react';
<PPPCurrencyCode />
// India: "INR"
// US: "USD"
// Japan: "JPY"
PropTypeDefaultDescription
classNamestringCSS class name

Combine the granular components for full control:

import {
PPPCurrencySymbol,
PPPPriceInteger,
PPPPriceDecimal,
PPPPriceFormatted,
usePPP,
} from '@gopaylocal/react';
function CustomPrice({ price }: { price: number }) {
const { hasDiscount } = usePPP();
return (
<div className="price-display">
{hasDiscount && (
<s className="original-price">
<PPPPriceFormatted price={price} isOriginalDisplay />
</s>
)}
<span className="current-price">
<PPPCurrencySymbol />
<span className="price-integer">
<PPPPriceInteger price={price} />
</span>
<sup className="price-decimal">
.<PPPPriceDecimal price={price} />
</sup>
</span>
</div>
);
}