<div id="integration-guide">

<div class="ig-section">
<div class="ig-section-header">
<div class="ig-section-icon embedded-components"><i class="fas fa-paint-brush"></i></div>
<h2>Customize Card Element</h2>
</div>
<p class="ig-section-desc">Customise the Card Element's appearance using theme presets, CSS variables, custom rules, and element-specific options.</p>

<div class="ig-subsection">
<h3>Element Options</h3>

<table class="ig-comparison">
<thead>
<tr>
<th>Option</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr><td><code>hideIcon</code></td><td><code>boolean</code></td><td>Hide the card brand icon</td></tr>
<tr><td><code>iconStyle</code></td><td><code>'solid' | 'default'</code></td><td>Card brand icon style</td></tr>
<tr><td><code>showInlineErrors</code></td><td><code>boolean</code></td><td>Show validation errors inline (default: true)</td></tr>
<tr><td><code>showAcceptedBrands</code></td><td><code>boolean</code></td><td>Show accepted card brand logos</td></tr>
<tr><td><code>disabled</code></td><td><code>boolean</code></td><td>Disable user input</td></tr>
</tbody>
</table>
</div>

<div class="ig-subsection">
<h3>Theme Presets</h3>
<p>Six built-in theme presets are available:</p>

```javascript
const teya = await initTeyaBlocks('session-token', {
  appearance: {
    theme: 'default', // default | dark | minimal | rounded | compact | bold
  },
});
```
</div>

<div class="ig-subsection">
<h3>Theme Variables</h3>
<p>Override individual CSS variables using <code>appearance.variables</code>:</p>

```javascript
const teya = await initTeyaBlocks('session-token', {
  appearance: {
    variables: {
      colorPrimary: '#0055ff',
      colorBackground: '#ffffff',
      colorText: '#333333',
      colorDanger: '#dc3545',
      borderRadius: '8px',
      fontFamily: 'Inter, sans-serif',
      fontSizeBase: '16px',
    },
  },
});
```
</div>

<div class="ig-subsection">
<h3>Custom CSS Rules</h3>

```javascript
const teya = await initTeyaBlocks('session-token', {
  appearance: {
    rules: {
      '.Input': { border: '1px solid #ccc', padding: '12px' },
      '.Input:focus': { borderColor: '#0055ff' },
      '.Input--invalid': { borderColor: '#dc3545' },
      '.Label': { fontWeight: '600' },
    },
  },
});
```
</div>

<div class="ig-subsection">
<h3>Callbacks</h3>

<table class="ig-comparison">
<thead>
<tr>
<th>Callback</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr><td><code>onReady</code></td><td>Fired when the element is ready for input</td></tr>
<tr><td><code>onChange</code></td><td>Fired when element state changes</td></tr>
<tr><td><code>onFocus</code></td><td>Fired when the element gains focus</td></tr>
<tr><td><code>onBlur</code></td><td>Fired when the element loses focus</td></tr>
<tr><td><code>onSuccess</code></td><td>Fired on successful payment</td></tr>
<tr><td><code>onError</code></td><td>Fired on payment failure</td></tr>
<tr><td><code>onTokenRefresh</code></td><td>Called when session token needs refreshing</td></tr>
</tbody>
</table>

<h4>Handling common flows</h4>

<p><strong>Payment success:</strong> The <code>onSuccess</code> callback receives a <code>PaymentSubmitResponse</code> with a <code>payment_id</code>. Redirect the customer to a confirmation page or update your UI.</p>

<p><strong>Payment error:</strong> The <code>onError</code> callback receives an error object with <code>message</code> and optional <code>code</code>. Display the error to the customer and allow them to retry.</p>

<p><strong>3D Secure:</strong> 3DS challenges are handled automatically by the SDK. The challenge modal appears within the card element iframe. No additional code is needed - the <code>onSuccess</code> or <code>onError</code> callback fires after the challenge completes.</p>

<p><strong>Dynamic Currency Conversion (DCC):</strong> If DCC is enabled for your store, the SDK may offer the customer a choice of currencies. Use the DCC callbacks (<code>onDccOffered</code>, <code>onDccSelectionRequired</code>, <code>onDccSelected</code>) to track the customer's currency preference. The final payment amount reflects their choice.</p>

<p><strong>Updating the pay button:</strong> Use the <code>onChange</code> callback to enable/disable your submit button based on <code>event.complete</code>. This ensures the button is only clickable when all fields are valid.</p>
</div>

<div class="ig-subsection">
<h3>Fonts &amp; Locales</h3>
<p>See the <a href="/partners/online-payments/embedded-components/checkout/customize">Embedded Checkout Customize</a> page for the full list of built-in fonts and supported locales - they apply to all elements.</p>
</div>

</div>
</div>
