Migrate your RPG Credentials

This guide is for partners who process payments via RPG on their merchants' behalf. Individual merchants don't need this — they can generate fresh credentials in the Teya Business Portal. To transact on the new ecommerce platform you need new client credentials, issued per store. You can obtain them by implementing the merchant registration flow, which is ideal for newly onboarding merchants. But to avoid disrupting your existing merchants or asking them to re-onboard, we have built a credentials exchange API that accepts RPG credentials and issues new ones.

1. How migration works

1 Call the credentials exchange endpoint with the merchant's RPG private key
2 Store the returned Client ID and Client Secret securely
3 Switch the merchant's integration to the new Teya APIs
4 Verify payments and webhooks, then retire the RPG key

Repeat the exchange once per merchant store. Each store gets its own pair of credentials.

Production only
The exchange endpoint is available in production only, because it authenticates against live RPG credentials.

2. Exchange RPG credentials

Exchange a merchant's RPG private key for new ecommerce credentials:

POST https://ecom-gateway.teya.com/v1/ecommerce/legacy/credentials

Authentication

HTTP Basic with the merchant's existing RPG private key — the same scheme you already use for payments on RPG. The username is the private key exactly as it was provided to you; the password field is ignored.

Request

The body is optional. Provide webhook_url to register a payments webhook for the store — an endpoint on your platform where Teya sends a real-time notification when a payment succeeds (see Webhooks). It must be HTTPS with a publicly resolvable hostname, and it is what produces payment_webhook_public_key in the response.

Provide plugin_metadata if the merchant integrates through a plugin — it decides the application name recorded for the new credentials.

{
  "webhook_url": "https://partner.example.com/teya/payments",
  "plugin_metadata": {
    "plugin_type": "ACME_SHOP",
    "plugin_version": "1.0.0"
  }
}
FieldRequiredDescription
webhook_urlNoPayments webhook to register for the store. Must be HTTPS with a publicly resolvable hostname
plugin_metadataNoThe way for Teya to identify you as a partner. It helps us track partner usage, and debug and identify issues with your integration
plugin_metadata.plugin_typeYes, when plugin_metadata is suppliedThe plugin the merchant integrates through, for example ACME_SHOP. When you begin your integration, Teya will assign an ENUM for you
plugin_metadata.plugin_versionNoThe version of the plugin

Example: Exchange credentials

curl -X POST 'https://ecom-gateway.teya.com/v1/ecommerce/legacy/credentials' \
  -u '<private_key>:' \
  -H 'Content-Type: application/json' \
  -d '{
    "webhook_url": "https://partner.example.com/teya/payments",
    "plugin_metadata": {"plugin_type": "ACME_SHOP", "plugin_version": "1.0.0"}
  }'

Response

payment_webhook_public_key is null when no webhook_url was supplied.

{
  "mid": "9256684",
  "store_id": "3f2b8c14-7d5e-4a91-b8c2-9e1f0a6d4b73",
  "client_id": "ecom_direct_8f41c9",
  "client_secret": "cs_live_2Hq9...redacted",
  "payment_webhook_public_key": "-----BEGIN PUBLIC KEY-----..."
}
FieldDescription
midThe RPG merchant ID the key authenticated as
store_idThe Teya store mapped to that merchant ID
client_idOAuth client ID for the new ecommerce APIs
client_secretOAuth client secret for the new ecommerce APIs. Returned once and never stored — this is the only time it is available
payment_webhook_public_keyPublic key for verifying payment webhook signatures; null if no webhook_url was supplied
ResponseMeaning
200Credentials issued, and webhook registered when webhook_url was supplied
400The supplied webhook_url or plugin_metadata cannot be used
401The credentials are missing, malformed, or were rejected
422The credentials are valid but the merchant is not eligible for migration
500A service the flow depends on could not be reached

Error codes

Error responses carry a JSON body with a code and a human-readable description:

{
  "code": "MERCHANT_NOT_MAPPED",
  "description": "Not yet available for this merchant."
}
CodeStatusMeaning
INVALID_WEBHOOK400The webhook_url is not HTTPS or not publicly resolvable
BAD_REQUEST400The plugin_metadata is invalid — for example, plugin_type is missing or not a supported value
UNAUTHORISED401The RPG key is missing, malformed, unknown or disabled
MERCHANT_NOT_MAPPED422The merchant ID is not yet mapped to a Teya store — migration is not yet available for this merchant
SUBSCRIPTION_NOT_FOUND422The store does not have an active ecommerce subscription
INTERNAL_SERVER_ERROR500Credential verification is temporarily unavailable — retry later
Keep credentials secure
Store client_secret and payment_webhook_public_key in encrypted configuration or a secrets store. Never expose them in client-side code.

3. Use your new credentials

Exchange the client_id and client_secret for an access token, then call the Online Payments API on the merchant's behalf:

curl -X POST 'https://id.teya.com/oauth/v2/oauth-token' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=client_credentials' \
  -d 'client_id=<client_id>' \
  -d 'client_secret=<client_secret>' \
  -d 'scope=<scopes for your products>'

The scopes you need depend on the products you integrate — see Required scopes by product.

Next steps