<div id="integration-guide">

<div class="ig-section">
<div class="ig-section-header"> 
<div class="ig-section-icon" style="background:#f0faf0;color:#16a34a;"><i class="fas fa-user-plus"></i></div>
<h2>Register Your Merchants</h2>
</div>
<p class="ig-section-desc">Set up your partner account and implement the merchant registration flow. Teya sends each merchant's credentials to your registration webhook so you can take payments on their behalf.</p>

<!-- Partner account -->
<div class="ig-subsection">
<h3>1. Set up your partner account</h3>
<div class="ig-flow-steps">
<div class="ig-flow-step"><span class="ig-flow-step-num">1</span> Coordinate with Teya to set up a <strong>partner test account</strong> and a Staging company/store</div>
<span class="ig-flow-arrow"><i class="fas fa-arrow-right"></i></span>
<div class="ig-flow-step"><span class="ig-flow-step-num">2</span> Get access to the <strong>plugin registration endpoints</strong></div>
<span class="ig-flow-arrow"><i class="fas fa-arrow-right"></i></span>
<div class="ig-flow-step"><span class="ig-flow-step-num">3</span> Implement the <strong>registration webhook</strong> endpoint on your platform</div>
</div>
</div>

<!-- Registration flow -->
<div class="ig-subsection">
<h3>2. Merchant registration flow</h3>
<p>When a merchant chooses to connect Teya in your platform:</p>
<div class="ig-flow-steps">
<div class="ig-flow-step"><span class="ig-flow-step-num">1</span> Redirect merchant to Teya registration page</div>
<span class="ig-flow-arrow"><i class="fas fa-arrow-right"></i></span>
<div class="ig-flow-step"><span class="ig-flow-step-num">2</span> Merchant signs in with Teya ID & selects store</div>
<span class="ig-flow-arrow"><i class="fas fa-arrow-right"></i></span>
<div class="ig-flow-step"><span class="ig-flow-step-num">3</span> Teya sends credentials to your <code>registrationWebhook</code></div>
<span class="ig-flow-arrow"><i class="fas fa-arrow-right"></i></span>
<div class="ig-flow-step"><span class="ig-flow-step-num">4</span> Verify signature, store credentials, enable payments</div>
</div>

<p>Build the registration URL using the appropriate environment endpoint and append these query parameters:</p>
<table class="ig-comparison">
<thead>
<tr><th>Parameter</th><th>Required</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td><code>registrationWebhook</code></td><td>Yes</td><td>HTTPS URL that receives <code>store_id</code>, <code>client_id</code>, <code>client_secret</code>, and <code>payment_webhook_public_key</code></td></tr>
<tr><td><code>paymentsWebhook</code></td><td>Recommended</td><td>HTTPS URL to receive payment events</td></tr>
<tr><td><code>pluginType</code></td><td>Yes</td><td>Identifier for your platform (e.g. <code>WOOCOMMERCE</code>, <code>SHOPIFY</code>) See notes below for use in development and production</td></tr>
<tr><td><code>pluginVersion</code></td><td>No</td><td>Your plugin version (e.g. <code>1.0.0</code>)</td></tr>
<tr><td><code>state</code></td><td>Recommended</td><td>An opaque string you generate (e.g. a random nonce or session token). Teya returns it unchanged in the signed registration webhook payload so you can verify the callback originated from a request you initiated (CSRF protection). We recommend expiring the state after 10 minutes if no callback is received from Teya</td></tr>
</tbody>
</table>

```admonition
icon: fas fa-info-circle
title: Plugin type for production
content: During development, use <code>TESTING</code> as the <code>pluginType</code>. When you are ready to go live, contact us at partnersupport@teya.com to be assigned a dedicated ENUM for your plugin.
```

<h4>Example: Registration URL</h4>

```text
https://business.teya.xyz/ecom/plugin-registration
  ?registrationWebhook=https://yourplatform.com/api/teya/register
  &paymentsWebhook=https://yourplatform.com/api/teya/webhooks
  &pluginType=TESTING
  &pluginVersion=1.0.0
  &state=a1b2c3d4e5f6
```



<p>Redirect the merchant to this URL. After the merchant signs in and selects their store, Teya POSTs credentials to your <code>registrationWebhook</code>.</p>

<h4>Example: Registration webhook payload</h4>
<p>Teya POSTs the following JSON to your <code>registrationWebhook</code> endpoint. Verify the <code>x-teya-signature</code> header (SHA256withRSA, Base64 encoded) before trusting the payload.</p>

```json
{
  "store_id": "550e8400-e29b-41d4-a716-446655440000",
  "client_id": "ecom_abc123",
  "client_secret": "secret_xyz789",
  "payment_webhook_public_key": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqh...\n-----END PUBLIC KEY-----",
  "state": "a1b2c3d4e5f6"
}
```

<p>Your endpoint should return <code>200 OK</code> to acknowledge receipt. Verify that <code>state</code> matches the value you originally sent in the registration URL before trusting the payload. The <code>store_id</code> identifies the store the merchant selected, so you can link the credentials to the correct store. Store the credentials securely and use them to authenticate API requests on behalf of this merchant.</p>

```admonition
icon: fas fa-exclamation-triangle
title: Keep credentials secure
content: Store <code>client_secret</code> and <code>payment_webhook_public_key</code> in encrypted configuration or a secrets store. Never expose them in client-side code.
```

```admonition
icon: fas fa-key
title: A separate Client ID and Client Secret per merchant
content: Unlike POSLink credentials, these aren't shared across your merchant base. Each merchant gets its own Client ID and Client Secret via this webhook - keep each merchant's credentials separate and don't reuse one set across multiple merchants.
```
</div>

<!-- Deactivate credentials -->
<div class="ig-subsection">
<h3>3. Deactivate credentials</h3>
<p>Every registration creates a brand new pair of credentials. Teya does not reuse or replace the old ones, so a store that registers twice ends up with two working sets of credentials.</p>
<p>Call the deactivation endpoint whenever a set of credentials is no longer needed - for example when a merchant disconnects Teya in your platform, uninstalls your plugin, or registers the same store again.</p>
<p>Deactivating a registration:</p>
<ul>
<li>Revokes the <code>client_id</code> and <code>client_secret</code>, so they can no longer be used to get an access token</li>
<li>Deletes the webhooks created during that registration, so no more payment events are sent to the endpoint you registered</li>
</ul>

<h4>Example: Deactivate a registration</h4>

```bash
curl -X DELETE 'https://api.teya.xyz/v1/ecommerce/registrations/current' \
  -H 'Authorization: Bearer <access_token>'
```

<p>There is no ID in the path. The endpoint always acts on the registration behind the access token you send, so use the credentials you want to deactivate to request that token.</p>

<table class="ig-comparison">
<thead>
<tr><th>Response</th><th>Meaning</th></tr>
</thead>
<tbody>
<tr><td><code>204</code></td><td>The credentials were deactivated and the webhooks were deleted</td></tr>
<tr><td><code>401</code></td><td>The access token is missing or invalid</td></tr>
<tr><td><code>403</code></td><td>The token is missing the <code>ecommerce/registrations/current</code> scope, or the credentials were already deactivated</td></tr>
</tbody>
</table>

```admonition
icon: fas fa-exclamation-triangle
title: Deactivation cannot be undone
content: Once credentials are deactivated they cannot be brought back. To reconnect the store, send the merchant through the registration flow again to get a new pair of credentials.
```
</div>

<!-- API URLs -->
<div class="ig-subsection">
<h3>4. API URLs</h3>
<table class="ig-comparison">
<thead>
<tr><th>Service</th><th>Staging</th><th>Production</th></tr>
</thead>
<tbody>
<tr><td><strong>Online Payments API</strong></td><td><code>https://api.teya.xyz</code></td><td><code>https://api.teya.com</code></td></tr>
<tr><td><strong>OAuth</strong></td><td><code>https://id.teya.xyz/oauth/v2/oauth-token</code></td><td><code>https://id.teya.com/oauth/v2/oauth-token</code></td></tr>
<tr><td><strong>Registration</strong></td><td><code>https://business.teya.xyz/ecom/plugin-registration</code></td><td><code>https://business.teya.com/ecom/plugin-registration</code></td></tr>
<tr><td><strong>Signature Public Key</strong></td><td><code>https://cdn.teya.xyz/dynamic/4eb143f2/public-key</code></td><td><code>https://cdn.teya.com/dynamic/4eb143f2/public-key</code></td></tr>
</tbody>
</table>
</div>

<!-- Scopes -->
<div class="ig-subsection">
<h3>5. Required scopes by product</h3>
<p>Request the scopes for the products you integrate as a space-separated string in your OAuth token request.</p>

<h4>Pay By Link</h4>
<p><code>scope: 'payment-links/create payment-links/id/get payment-links/id/update ecommerce/registrations/current'</code></p>
<table class="ig-comparison">
<thead>
<tr><th>Scope</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td><code>payment-links/create</code></td><td>Create a payment link</td></tr>
<tr><td><code>payment-links/id/get</code></td><td>Get payment link by ID</td></tr>
<tr><td><code>payment-links/id/update</code></td><td>Update a payment link</td></tr>
<tr><td><code>ecommerce/registrations/current</code></td><td>Deactivate the registration and its credentials</td></tr>
</tbody>
</table>

<h4>Hosted Checkout</h4>
<p><code>scope: 'checkout/sessions/create checkout/sessions/id/get refunds/create ecommerce/registrations/current'</code></p>
<table class="ig-comparison">
<thead>
<tr><th>Scope</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td><code>checkout/sessions/create</code></td><td>Create a hosted checkout session</td></tr>
<tr><td><code>checkout/sessions/id/get</code></td><td>Get hosted checkout session by ID</td></tr>
<tr><td><code>refunds/create</code></td><td>Issue a refund for a completed payment</td></tr>
<tr><td><code>ecommerce/registrations/current</code></td><td>Deactivate the registration and its credentials</td></tr>
</tbody>
</table>

<h4>Embedded Components: Checkout</h4>
<table class="ig-comparison">
<thead>
<tr><th>Scope</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td><code>checkout/sessions/create</code></td><td>Create a checkout session for the SDK</td></tr>
<tr><td><code>checkout/sessions/id/get</code></td><td>Get checkout session by ID</td></tr>
<tr><td><code>ecommerce/registrations/current</code></td><td>Deactivate the registration and its credentials</td></tr>
</tbody>
</table>

<h4>Embedded Components: Card, Split Card, Apple Pay</h4>
<table class="ig-comparison">
<thead>
<tr><th>Scope</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td><code>transactions/online/create</code></td><td>Process an online transaction</td></tr>
<tr><td><code>transactions/online/id/get</code></td><td>Get online transaction details</td></tr>
<tr><td><code>checkout/sessions/create</code></td><td>Create a session for the SDK</td></tr>
<tr><td><code>ecommerce/registrations/current</code></td><td>Deactivate the registration and its credentials</td></tr>
</tbody>
</table>
</div>

<!-- Related -->
<div class="ig-subsection">
<h3>Next steps</h3>
<ul>
<li><a href="/partners/online-payments/pay-by-link/api">Pay By Link via API</a> - Create payment links programmatically</li>
<li><a href="/partners/online-payments/hosted-checkout/get-started">Hosted Checkout</a> - Redirect customers to a Teya-hosted payment page</li>
<li><a href="/partners/online-payments/embedded-components/overview">Embedded Components</a> - Embed payment fields in your own UI</li>
<li><a href="/partners/online-payments/webhooks">Webhooks</a> - Receive payment notifications</li>
<li><a href="/partners/online-payments/testing">Testing</a> - Test cards and integration checklist</li>
<li><a href="/apis/online-payments/apis">API Reference</a> - Full API endpoint documentation</li>
</ul>
</div>

</div>
</div>
