ButtonDynamicPrice

The main class for creating payment buttons with dynamic pricing.


Constructor

new ButtonDynamicPrice(config)

Creates a new payment button instance.

Parameters

Parameter
Type
Required
Description

config

ButtonDynamicPriceConfig

Yes

Configuration object

Config Object

interface ButtonDynamicPriceConfig {
  price: number;              // Payment amount
  apiKey: string;             // Your KiraPay API key
  customOrderId?: string;     // Custom order identifier
  title?: string;             // Button text
  className?: string;         // CSS class name
  style?: object;             // Inline styles
  loading?: boolean;          // Initial loading state
}
import { ButtonDynamicPrice } from 'kirapay-merchant-sdk';

const button = new ButtonDynamicPrice(config);

Config Properties

Properties
Type
Required
Description

price

number

YES

The payment amount in USD

apiKey

string

YES

Your KiraPay merchant API key

customOrderId

string

NO

Custom identifier to track orders in your system

title

string

NO

Text displayed on the button

className

string

NO

CSS class name(s) to apply to the button

style

object

NO

Inline CSS styles for the button

loading

boolean

NO

Initial loading state of the button

Example: Complete Configuration

const button = new ButtonDynamicPrice({
  // Required
  price: 99.99,
  apiKey: "test_your_api_key_here",

  // Optional
  customOrderId: "order_2024_001",
  title: "Buy Premium Plan - $99.99",
  className: "premium-button",
  style: {
    backgroundColor: '#10b981',
    color: 'white',
    padding: '16px 40px',
    fontSize: '18px',
    fontWeight: '600',
    borderRadius: '12px',
    border: 'none',
    boxShadow: '0 4px 12px rgba(16, 185, 129, 0.3)',
    transition: 'all 0.3s ease'
  },
  loading: false
});

Available Style Properties:

Property
Type
Example

backgroundColor

string

'#007bff', 'rgb(0, 123, 255)'

color

string

'white', '#ffffff'

padding

string

'12px 24px', '1rem 2rem'

fontSize

string

'16px', '1rem'

fontWeight

string/number

'bold', 600

borderRadius

string

'8px', '0.5rem'

border

string

'2px solid #007bff', 'none'

cursor

string

'pointer'

boxShadow

string

'0 2px 4px rgba(0,0,0,0.1)'

width

string

'100%', '200px'

maxWidth

string

'400px'

Last updated

Was this helpful?