Migrating from B-Gateway to Embedded Components
For partners and platforms whose systems send payments to B-Gateway (the Borgun payment gateway web service, SOAP/XML; also written BGateway or Greiðslugátt) on behalf of the merchants you serve. The first half is a summary you can forward; the second half is the developer guide.
Who this guide is for
- Your systems send XML requests such as
getAuthorizationtogateway01.borgun.is, with a B-Gateway username and password. - Card numbers reach your own servers: your checkout form collects them, or your systems hold card numbers or virtual card numbers (
9910…) and send them on to B-Gateway. - You use the same
getAuthorizationcall for payments where a customer is checking out and for charges you run later without them (subscriptions, instalments, top-ups). You may also run 3D Secure throughget3DSAuthenticationor your own or a third-party MPI.
/api/payment (the RPG payment API), redirects to securepay.borgun.is, and payment URLs created in advance each have their own guide.
Why migrate, and what you gain
B-Gateway runs on Teya's legacy platform, which is retiring in early 2027. The new platform is an upgrade, not a like-for-like swap: it removes the parts of a B-Gateway integration that cost the most to build and maintain.
Your options
Checkout component Recommended — the closest match to a B-Gateway checkout with the least to maintain. The customer stays on your page; one block provides card fields, pay button, 3D Secure, Apple Pay and currency conversion. This guide follows it.
- Card component — a single card field inside your own form with your own pay button. See Embedded Components.
- Hosted Checkout — the customer is redirected to a Teya page and back. Least code, different customer experience; the steps below apply, with one change at Step 3. See Hosted Checkout.
- Direct API — your servers send card data to Teya, as with B-Gateway today. Card data stays on your systems, so the PCI DSS obligations that come with it (SAQ D) stay with you, and Teya runs 3D Secure on the transaction flow while you display the challenge. Check with Teya before choosing this path, and tell us if you run your own or a third-party MPI today. See the B-Gateway reference.
What the migration involves
This is a small development project, and the result is less code than you have today: the SOAP client, the card form, any 3D Secure flow and batch handling are all removed. B-Gateway keeps working in parallel until you switch it off. If most of your payments are subscriptions or charges on cards you hold, step 5 and the charging of saved cards are the bulk of the work; the one-off checkout still comes first, because it is how new cards get saved from now on. Stored cards move on their own track, without any customer re-entering a card.
MerchantID you hold for each, so credentials can be set up store by store. (3) Which of them charge cards without the customer present (virtual card numbers from B-Gateway, or card numbers you store), use pre-authorisations, or use any other B-Gateway features (telephone or keyed orders, reports pulled from B-Gateway, Dynamic Descriptors, detail or itinerary data). Each changes the plan.
Developer guide
How a B-Gateway integration maps onto a checkout session, Hosted Checkout or the Checkout component, and token payments, with the one request you need at each step.
How it works: before and after
Today (B-Gateway)
- Your checkout form collects the card number, expiry and security code; they reach your server.
- If you run 3D Secure, your server calls
get3DSAuthenticationor your own MPI, sends the customer to the bank and getsCAVV/UCAF/XIDback. - Your server sends
getAuthorization(SOAP/XML, username and password,Processor,MerchantID,TransType,RRN) with the card or a virtual card number, plus 3D Secure values if you have them, and readsActionCode. The same call is used whether or not the customer is present. - For subscriptions, you keep a virtual card number from
getVirtualCardand later sendgetAuthorizationwith it, without the customer. - Refunds and cancellations reference the original
DateAndTime+RRN; batches close at midnight GMT or onnewBatch.
After (new platform)
- Your server gets a short-lived access token and creates a checkout session for the amount. To save the card for later, it adds
save_payment_method: true. - Your page mounts the Checkout component with the session token (or, with Hosted Checkout, redirects the customer to a Teya page). Teya collects the card and runs 3D Secure.
- A signed webhook confirms the payment to your server. When the card was saved, it carries the token.
- For subscriptions, your server charges the token later with
POST /v3/transactions/online, marked as merchant-initiated. - Refunds reference the
transaction_id. There are no batches.
The biggest change: card numbers no longer pass through your systems, and each payment is either a checkout session (customer present) or a charge on a saved card (merchant-initiated). The SOAP client, the card form, any 3D Secure flow, getVirtualCard and batch handling are all deleted.
Before you start
1. Sort your payments
List every place your code calls getAuthorization and decide, for each one, whether a customer is present. On B-Gateway the same request serves both; on the new platform they are different calls:
- A customer typing a card now (your checkout): a checkout session, then the Checkout component (Steps 2–3). 3D Secure runs for you.
- A charge on a stored card without the customer (subscription, instalment, top-up, pay-later):
POST /v3/transactions/onlineon a saved token, declared merchant-initiated (Step 6). No 3D Secure, immediate result. - Saving a card for later without charging it: a zero-amount
ACCOUNT_VERIFICATIONsession withsave_payment_method(Step 2).
Every item on your list becomes either a session or a token charge. A charge without the customer is only possible on a card they saved with you, so if you hold card numbers that were never saved through Teya, see Stored cards & recurring before you plan Step 6.
2. Credentials
Each store gets its own client_id, client_secret, store_id and webhook public key; together they replace the B-Gateway username, password, Processor and MerchantID you hold per merchant. Merchants come onto the new platform through the registration flow, which issues their credentials to you. If you hold B-Gateway credentials for many merchants, talk to your Teya partner contact about the approach before you start. For staging, ask for a development store. Never mix staging and production credentials. See Authenticate.
Card saving (tokenization) is enabled by default on every store, but enrolment can take up to 48 hours after the store is created. Until then, sessions with save_payment_method succeed but return no token. If that persists after 48 hours, contact support.
3. Environments
Staging is api.teya.xyz / id.teya.xyz / business.teya.xyz; production is the same hosts on .com. With Embedded Components, staging also needs developmentMode: true in the SDK. Full table on Hosted Checkout Get Started.
4. Webhook
Teya sends a signed payment.succeeded.v1 event to a public HTTPS endpoint with no authentication on it. Register the URL per store when the store is set up; you receive a public key per webhook for verifying signatures. Only successful customer payments produce a webhook today; refunds, captures and token charges return their outcome in the API response. See Webhooks.
5. Find the legacy code
Search for gateway01.borgun.is, borgun.is, getAuthorization, cancelAuthorization, get3DSAuthentication, getVirtualCard, newBatch, getTransactionList, TransType, TrAmount, TrCurrency, RRN, AuthCode, ActionCode, Processor, CAVV, UCAF, XID, SecurityLevelInd, lifecycleID, the XML namespace tempuri.org/getAuthorization.xsd, and stored 16-digit values starting 9910. Code based on the B-Gateway demo clients (BGatewayDemoNet, BGatewayDemoPhp, BGatewayDemoPython) follows the same pattern. Each hit is a line on the to-do list. If you send TerminalID 2 (ecommerce with 3D Secure) or CAVV / UCAF values, you run 3D Secure today: also check the MPI configuration behind it.
6. Ground rules
What replaces what
The calls and fields a B-Gateway developer has to change. The B-Gateway reference covers every operation, including reporting and the ones with no equivalent.
| B-Gateway today | New platform | What it means for you |
|---|---|---|
| Username + password on every call | client_id + client_secret → short-lived Bearer token | Cache and refresh from expires_in (currently 15 min in production, 24 h in staging). |
Processor, MerchantID, TerminalID (1 ecommerce, 2 ecommerce with 3D Secure, 3 recurring, 4 mail/telephone order) | store_id | One identifier per store, sent in the request body. What the terminal said about the payment is now said by the request itself: a session for customer-present payments, initiator + recurring_payment_type for the rest. |
getAuthorization, TransType 1 | POST /v2/checkout/sessions, type: "SALE" + the Checkout component | The server sends intent only: amount, currency, reference. No card data, no 3D Secure values. |
getAuthorization, TransType 5 | type: "PRE_AUTHORISATION" on the same endpoint | See Pre-authorisations below. |
TransType 1 with a pre-authorisation's AuthCode | POST /v1/transactions/{id}/capture, {"amount": n} | Once per authorisation; the remainder is released. |
TransType 3 by DateAndTime + RRN | POST /v3/refunds with transaction_id, or the Business Portal | Same semantics: partial, multiple, total ≤ original. |
TransType 4, cancelAuthorization | POST /v3/refunds on the uncaptured payment | A refund before capture reverses the authorisation. No partial reversal; no open-batch rule. |
get3DSAuthentication / own MPI; CAVV, UCAF, XID, SecurityLevelInd (if you send them) | Gone: 3D Secure runs inside Hosted Checkout and the component | Delete the whole flow if you have one, including MerchantReturnURL handling. If you don't run 3D Secure today, there is nothing to delete. |
PAN, ExpDate, CVC2; your card form | Gone: entered on the Teya page or in Teya-hosted fields | Delete the card form and every place card data is logged or stored. |
getVirtualCard | save_payment_method: true on the session; token_response.token_id in the webhook | Saving happens inside the payment, or a zero-amount ACCOUNT_VERIFICATION. |
getAuthorization with a virtual card number (or a card number you store), customer absent | POST /v3/transactions/online, initiator: "MERCHANT", payment_method.type: "TOKEN" | See Step 6. Virtual numbers you already hold move later; see Stored cards & recurring. Card numbers you store yourself have no import: talk to your Teya partner contact. |
lifecycleID | Not sent | The platform links later charges to the first payment for you. |
TrAmount: 2 implied decimals, including ISK (100 ISK = 10000) | amount.value: minor units per ISO 4217; ISK has no subunit (100 ISK = 100) | If you charge in ISK, divide B-Gateway amounts by 100: the most likely silent bug. Other currencies are unchanged (€49.90 is 4990 on both). |
TrCurrency: ISO numeric (352) | amount.currency: ISO alphabetic ("ISK") | Lookup change. |
RRN (12 characters), DateAndTime | merchant_reference (free-form) + optional metadata; no timestamp | Write the legacy RRN into metadata during the transition if it helps reconciliation. |
ActionCode (000 = approved) | payment_status (SUCCESS / FAILED) on the session | Declines show in the checkout and the customer retries in place. |
Batches, newBatch, Batch / Transaction numbers | None | Delete. Key your records on transaction_id. |
getTransactionList, settlement and dispute lists | GET /v2/checkout/sessions/{session_id} for one payment; the Business Portal for the rest | See the reference for each report. |
| B-Online | Business Portal | Credentials, webhooks, refunds, transaction visibility. |
Step-by-step
Steps 1–5 take one-off payments end to end; Step 6 adds charging a saved card. Samples are cURL and minimal JavaScript; other languages are on the Embedded Checkout Get Started page.
Step 1 — Fetch an access token (server)
Exchange client_id + client_secret for a Bearer token. This replaces sending a username and password on every call: cache the token per environment and refresh it before expires_in runs out or on a 401. Scopes for this guide: checkout/sessions/create, checkout/sessions/id/get, refunds/create. Add captures/create for pre-authorisations and transactions/online/create for charging saved cards.
curl -X POST https://id.teya.xyz/oauth/v2/oauth-token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=$TEYA_CLIENT_ID" \
-d "client_secret=$TEYA_CLIENT_SECRET" \
-d "scope=checkout/sessions/create checkout/sessions/id/get refunds/create transactions/online/create"
{ "access_token": "eyJhbGciOiJSUzI1NiJ9...", "token_type": "Bearer", "expires_in": 900 }
Full reference: Authenticate.
Step 2 — Create a checkout session (server)
When the customer clicks Pay, your server describes the payment. This replaces getAuthorization, but the body carries no card data and no 3D Secure values; only the intent. For a subscription sign-up, add save_payment_method: true so the card is saved during this payment.
curl -X POST https://api.teya.xyz/v2/checkout/sessions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"store_id": "123e4567-e89b-12d3-a456-426614174000",
"type": "SALE",
"amount": { "value": 4990, "currency": "ISK" },
"merchant_reference": "INV-2026-00042",
"save_payment_method": true,
"success_url": "https://yourstore.com/order/success",
"cancel_url": "https://yourstore.com/checkout",
"metadata": { "legacy_rrn": "ACME00012345" }
}'
{
"session_id": "14411456-79c8-4d8c-8498-f01907093b83",
"session_token": "eyJhbGciOiJSUzI1NiJ9...",
"session_status": "ACTIVE"
}
Things to get right
amount.valueis an integer in minor units per ISO 4217: 4,990 ISK is4990, not B-Gateway's499000; €49.90 is4990on both.Idempotency-Keyis unique per order attempt; retries with the same key can't create duplicate sessions. This replaces looking up an unknown result withgetTransactionList.- To save a card without charging it (a "add a card" or free-trial flow), send
type: "ACCOUNT_VERIFICATION"withamount.value: 0andsave_payment_method: true. This replaces the zero-amount pre-authorisation. - Record the customer's consent to store the card before you save it. See Card on File.
- Create the session when the customer clicks Pay, not when the cart loads: sessions expire.
- The
session_tokenin the response is what your page needs for the component (Step 3).success_urlandcancel_urlare only used by Hosted Checkout.
Full reference: Embedded Checkout, API Reference.
Step 3 — Mount the Checkout component (frontend)
Install @teyaproduct/teya-blocks-js, initialise the SDK with the session_token from your backend, and mount the component. It replaces your card form and your 3D Secure redirect: the fields are Teya-hosted, so card data never enters your page or your server.
import { initTeyaBlocks } from '@teyaproduct/teya-blocks-js';
// 1. Ask your backend for a session (Step 2)
const { session_token } = await (await fetch('/api/teya-session', { method: 'POST' })).json();
// 2. Initialise the SDK
const teya = await initTeyaBlocks(session_token, {
locale: 'is',
// Routes SDK calls to Teya staging. Remove for production.
developmentMode: true,
});
// 3. Mount the checkout: card fields, pay button, 3D Secure, Apple Pay, DCC included
const checkout = teya.elements.create('checkout', {
onSuccess: () => { window.location.href = '/order/confirmation'; },
onError: (error) => console.error('Payment failed', error),
});
checkout.mount('#checkout-container');
Things to get right
- A staging session token only works with
developmentMode: true; a production token only works without it. - Return only
session_tokento the browser through a small endpoint of your own; never the access token or the Client Secret. - For your own form layout and pay button, use the Card component instead; everything else is the same.
Using Hosted Checkout instead? Skip the SDK: send the browser to the session_url returned with the session, exactly as returned. The customer pays on Teya's page and lands on your success_url or cancel_url; the redirect carries no payment data, so Steps 4 and 5 are unchanged. See Hosted Checkout Get Started.
Full reference: SDK Initialization and Embedded Checkout.
Step 4 — Look up the session (server)
The webhook (Step 5) is the source of truth for fulfilment. As a fallback (customer closed the browser, webhook delayed, payment failed), look the session up by ID. This replaces reading ActionCode and polling getTransactionList.
curl https://api.teya.xyz/v2/checkout/sessions/$SESSION_ID \
-H "Authorization: Bearer $ACCESS_TOKEN"
{
"session_id": "14411456-79c8-4d8c-8498-f01907093b83",
"session_status": "COMPLETED",
"payment_status": "SUCCESS",
"type": "SALE",
"amount": { "value": 4990, "currency": "ISK" },
"merchant_reference": "INV-2026-00042",
"transaction_id": "tr_72302a4d-b2f9-4663-93f8-d9260e5370c8"
}
Things to get right: session_status runs ACTIVE → PROCESSING → COMPLETED or EXPIRED; trust payment_status only once COMPLETED. Store the transaction_id: it is the key for refunds, replacing DateAndTime + RRN. Full reference: API Reference.
Step 5 — Receive and verify the webhook (server)
Teya POSTs a signed payment.succeeded.v1 event to your registered URL when a payment succeeds, whether or not the customer comes back to your site. Verify x-teya-signature (SHA256withRSA, Base64) over the raw request body with the public key issued for this webhook, before parsing anything. When the card was saved, the event carries the token.
{
"event": "payment.succeeded.v1",
"timestamp": "2026-10-05T12:04:22Z",
"data": {
"transaction_id": "tr_72302a4d-b2f9-4663-93f8-d9260e5370c8",
"session_id": "14411456-79c8-4d8c-8498-f01907093b83",
"merchant_reference": "INV-2026-00042",
"amount": { "value": 4990, "currency": "ISK" },
"status": "SUCCESS",
"token_response": { "token_id": "1e2d4f80-9c3e-4f5b-83aa-9e8d2b6a6c49", "token_status": "SUCCESS" }
}
}
Things to get right
- Store
data.token_response.token_idagainst the customer. It replaces the virtual card number in your subscription records.token_responseisnullwhen no card was saved. - Be idempotent: the same event can arrive more than once. Return
200promptly and do slow work asynchronously. - Register the route before any JSON body parser so you verify the raw bytes; check your handler with the Webhook Signature Validator.
Full reference: Webhooks.
Step 6 — Charge a saved card later (server)
For each subscription or instalment due, charge the token without the customer present. This replaces getAuthorization with a virtual card number and no 3D Secure values. Declare it as merchant-initiated: there is no 3D Secure and the result is immediate and final.
curl -X POST https://api.teya.xyz/v3/transactions/online \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Idempotency-Key: sub-8812-2026-11" \
-d '{
"store_id": "123e4567-e89b-12d3-a456-426614174000",
"type": "SALE",
"initiator": "MERCHANT",
"amount": { "value": 4990, "currency": "ISK" },
"payment_method": {
"type": "TOKEN",
"token": {
"token_id": "1e2d4f80-9c3e-4f5b-83aa-9e8d2b6a6c49",
"recurring_payment_type": "RECURRING"
}
}
}'
{
"type": "ONLINE_TRANSACTION",
"online_transaction": {
"transaction_id": "tr_9f2c1a70-4d88-4b3e-91ad-6c7e2f5b8d40",
"status": "SUCCESS",
"status_reason": null
}
}
Things to get right
recurring_payment_type:RECURRINGfor a fixed schedule,INSTALLMENTfor a fixed number of payments,CARD_ON_FILEfor unscheduled charges.- Use one
Idempotency-Keyper customer per billing period, so a re-run of your billing job can't charge twice. - Retry declines only for temporary reasons (
status_reasonsuch asINSUFFICIENT_FUNDSorTEMPORARY_ISSUE_RETRY); the full list is on Charge a Saved Payment Method. - Virtual card numbers you already hold are charged on B-Gateway, unchanged, until your stored cards are moved. See Stored cards & recurring.
- If your systems hold real card numbers rather than virtual card numbers, there is no import for them: talk to your Teya partner contact before planning this step.
Full reference: Charge a Saved Payment Method.
After the payment
Each operation returns its outcome in the synchronous API response; there is no webhook for refunds or captures today, so record the response.
Refunds
Replaces TransType 3 and cancelAuthorization: partial and multiple refunds, total ≤ original, referenced by transaction_id instead of DateAndTime + RRN. 201 is processed; 202 is still processing: retry with the same Idempotency-Key. Staff can also refund from the Business Portal. Payments taken on B-Gateway before you switch stay refundable in B-Online.
curl -X POST https://api.teya.xyz/v3/refunds \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{ "transaction_id": "tr_72302a4d-b2f9-4663-93f8-d9260e5370c8", "amount": 1000 }'
See Payment Actions.
Pre-authorisations
Skip this if you only send TransType 1 without an AuthCode. Create the session with type: "PRE_AUTHORISATION"; the checkout is unchanged and the funds are held (no currency conversion on pre-authorisations). Capture with POST /v1/transactions/{id}/capture and {"amount": n}: any amount up to the authorised total, but exactly once. The remainder is released, so capture the final amount; this also replaces the partial reversal (TransType 4). To cancel, refund the uncaptured payment; untouched holds expire on their own. See Payment Actions.
Using other features
Batches, transaction and settlement reports, telephone or keyed orders, Dynamic Descriptors and detail or itinerary data each have their own answer on the new platform, and some depend on your set-up. If you use any of them, contact Teya support with your specific case before you migrate, so we can check it with you. The B-Gateway reference lists every operation and where it lives now.
Testing and going live
Test in staging with the cards on the Testing page; frictionless, challenge and declined scenarios are all there. If your development machine isn't publicly reachable, tunnel it so staging webhooks can reach you.
Definition of done
COMPLETED / SUCCESS401 by refreshing the tokensave_payment_method and an ACCOUNT_VERIFICATION both return a token_id in the webhook; a merchant-initiated charge on that token succeedsGo live
- Set up production credentials and the production webhook for each merchant store, and store the credentials and public key per store. If a merchant saves cards, set the store up early: card saving is on by default but enrolment can take up to 48 hours.
- Swap hosts by config (
.xyz→.com) and, for Embedded Components, removedevelopmentMode. - Process one small real payment end to end: payment → webhook → refund.
- Run B-Gateway in parallel for a day or two behind a flag; watch logs, webhook deliveries and the Business Portal. New cards are now saved on the new platform; existing virtual card numbers keep being charged on B-Gateway until they are moved.
- Move your saved cards with Stored cards & recurring.
- Retire the legacy integration: delete the SOAP client, card form, 3D Secure flow,
getVirtualCardand batch code. Remove stored card numbers and card data from your systems and logs. Teya retires the B-Gateway usernames and passwords for you; there is nothing to request.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Charged amount is 100× too big (ISK) | B-Gateway's two-implied-decimals convention carried over | Divide legacy ISK amounts by 100 |
422 creating a session | Numeric currency code (352) or a non-integer amount | Alphabetic currency; integer amount.value in minor units |
401 on API calls | Access token expired; unlike a B-Gateway password it is short-lived | Refresh from expires_in; retry once on 401 |
403 | Missing scope, e.g. transactions/online/create for saved-card charges | Add the scope to the token request (Step 1) |
409 | Same Idempotency-Key, different body | Unique key per order attempt or billing period; reuse only for retries of the identical request |
Payment succeeds but no token_id in the webhook | save_payment_method missing, or the store was created less than 48 hours ago and tokenization enrolment is still pending | Send save_payment_method: true; wait for enrolment, then contact support if it persists |
400 charging a 9910… value as TOKEN | A legacy virtual card number sent as a Teya token | Keep charging it on B-Gateway until your stored cards are moved, then use LEGACY_TOKEN. See Stored cards |
| A refund can't find the payment | Legacy DateAndTime + RRN used as the reference | Refund by transaction_id; refund B-Gateway payments in B-Online |
| Webhook never arrives | URL not public, no valid certificate, auth on the endpoint, or non-200 responses | Public HTTPS, no auth, return 200 after processing |
| Signature verification fails | Parsed body re-serialised, or the wrong key | Verify the raw body; use the key issued for this webhook in this environment |
| Payment succeeded but not in the Business Portal | Wrong environment | Staging payments are in business.teya.xyz, production in business.teya.com |
Next steps
- B-Gateway reference - Every B-Gateway operation and its replacement
- Stored cards & recurring - Move your virtual card numbers once one-off payments are live
- Embedded Checkout / Hosted Checkout - Quickstarts in your language
- Charge a Saved Payment Method - Token payments and decline handling
- Testing - Test cards and integration checklist