> For the complete documentation index, see [llms.txt](https://docs.iyzico.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.iyzico.com/en/getting-started/preliminaries/testing-and-validation.md). Agents can also search and read this documentation through its [MCP server](https://docs.iyzico.com/~gitbook/mcp).

# Testing and Validation

## Test Strategy and Approach

Before going live with the iyzico integration, it is recommended to test all payment flows end to end in the sandbox environment, and to run only a low-amount smoke test in the live environment. It is recommended to run the tests in four layers:

{% stepper %}
{% step %}

## Unit tests

It is recommended to test signature generation, amount formatting, `conversationId` generation and the response mapping code.
{% endstep %}

{% step %}

## Integration tests

It is recommended to make real calls to the sandbox API and to verify the test card and the expected `status` / `errorCode` for each scenario.
{% endstep %}

{% step %}

## End-to-end (E2E) tests

It is recommended to run the Checkout Form, Pay with iyzico or 3DS flow from start to finish in the browser, and to check the order status, including the callback and webhook.
{% endstep %}

{% step %}

## UAT and live smoke test

It is recommended that the business team approves the scenarios, and that a low-amount payment + refund is made in the live environment with a real card.
{% endstep %}
{% endstepper %}

**Key principles:**

* In every test, it is recommended to check both the `status` field (`success` / `failure`) in the iyzico response and the order status in your own system; receiving HTTP 200 alone should not be considered a success.
* It is recommended to send a unique `conversationId` with every request and to check that the same value is returned in the response.
* It is possible, and recommended, to always confirm the payment result by querying iyzico (retrieve/webhook).
* It is recommended to narrow the test scope according to the products used in the project (e.g., if only Checkout Form is used, Non-3DS API scenarios can be excluded from the scope).

## Test Environment and Credentials

It is recommended to run all tests against `https://sandbox-api.iyzipay.com` using the `sandbox-` prefixed API and Secret Key pair of your sandbox account. The live environment uses `https://api.iyzipay.com` and completely different keys (Live vs Sandbox).

**Environment rules:**

* Payments with real cards cannot be made in the sandbox; only test cards work.
* The expiry date and CVC of test cards can be arbitrary, but the format must be correct and the date must be in the future (e.g., `12/2030`, `123`).
* It is recommended to keep API keys not in code but in an environment variable or secret manager, and to store sandbox and live keys in separate configuration profiles.
* For webhook tests, your application must have an externally reachable HTTPS URL.

| Component                     | Sandbox value                                        | Source                      |
| ----------------------------- | ---------------------------------------------------- | --------------------------- |
| API Base URL                  | `https://sandbox-api.iyzipay.com`                    | Live vs Sandbox             |
| Merchant panel (registration) | `https://sandbox-merchant.iyzipay.com/auth/register` | Sandbox                     |
| API Key / Secret Key          | In the panel: Settings > Company Settings > API Keys | Sandbox                     |
| 3DS / SMS password            | Always `283126`                                      | Sandbox                     |
| Test cards                    | Successful, foreign and error-producing cards        | Test Cards                  |
| Authentication                | HMACSHA256 signed header                             | HMACSHA256 Authentication   |
| Ready-made requests           | Postman collection, GitHub                           | Postman Collections, GitHub |

## Test Cases and Expected Results

It is recommended to record each test case with the fields below. It is recommended that the "expected result" always includes both the iyzico response and the state in your own system.

| Field                    | Description                                   | Example                                                                |
| ------------------------ | --------------------------------------------- | ---------------------------------------------------------------------- |
| Test ID                  | Group prefix + sequence number                | `TC-NEG-03`                                                            |
| Title                    | One-line name of the scenario                 | Payment with insufficient funds                                        |
| Precondition             | Required data and state                       | 1 item in the cart, 3DS-off flow                                       |
| Test data                | Card, amount, installment                     | `4111111111111129`, 100.00 TRY, 1 installment                          |
| Steps                    | Steps to be performed                         | BIN check, pay, etc.                                                   |
| Expected iyzico response | `status`, `errorCode`, `errorGroup`           | `failure`, `10051`, `NOT_SUFFICIENT_FUNDS`                             |
| Expected system state    | Order, stock, email, log                      | Order `PAYMENT_FAILED`, stock not decreased, clear message to the user |
| Actual result            | Filled in during the test                     | —                                                                      |
| Result                   | Pass / Fail / Blocked                         | —                                                                      |
| Evidence                 | Screenshot, request/response log, `paymentId` | —                                                                      |

**Test ID prefixes and scenario groups:**

| Prefix   | Group                              | Section |
| -------- | ---------------------------------- | ------- |
| `TC-POS` | Successful payment                 | 11.4    |
| `TC-NEG` | Erroneous and failed payment       | 11.5    |
| `TC-3DS` | 3D Secure                          | 11.6    |
| `TC-REF` | Cancellation and refund            | 11.7    |
| `TC-WH`  | Webhook and asynchronous events    | 11.8    |
| `TC-IDM` | Idempotency and duplicate requests | 11.9    |
| `TC-REG` | Regression                         | 11.10   |
| `TC-UAT` | User acceptance                    | 11.12   |

For the list of error codes and the messages to show to users: Error Codes.

## Positive Payment Scenarios

A successful payment is expected to pass when iyzico returns `status: success` (and additionally `paymentStatus: SUCCESS` in Checkout Form and PWI queries), the order is marked as paid, and the Retrieve query gives the same result. Full list of cards: Test Cards.

| Test ID     | Scenario                              | Test data                               | How to test                                                                                               | Expected result                                                                                      |
| ----------- | ------------------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| `TC-POS-01` | Single payment with credit card       | `5528790000000008` (Halkbank MC Credit) | It is recommended to pay with 1 installment via Checkout Form or API                                      | `success`; `paymentId` recorded; order `PAID`                                                        |
| `TC-POS-02` | Payment with debit card               | `5890040000000016` (Akbank MC Debit)    | It is recommended to make a single payment via the 3DS flow                                               | `success`; `cardType` in the response indicates a debit card                                         |
| `TC-POS-03` | Installment payment                   | `5528790000000008`, 3 installments      | It is recommended to first retrieve the options via Installment and BIN Query, then select 3 installments | `installment: 3`; `paidPrice` includes the installment fee                                           |
| `TC-POS-04` | Troy card                             | `9792030000000000` (QNB Troy Credit)    | It is recommended to make a single payment                                                                | `success`; `cardAssociation: TROY`                                                                   |
| `TC-POS-05` | American Express                      | `374427000000003`, 4-digit CVC          | It is recommended to make a single payment                                                                | `success`; error 15 is received with a 3-digit CVC                                                   |
| `TC-POS-06` | Foreign card                          | `5400010000000004` (Non-Turkish Credit) | It is recommended to make a single payment                                                                | `success` if foreign cards are enabled on the account; `10221` and a message to the user if disabled |
| `TC-POS-07` | Different currency (if used)          | `currency: USD` / `EUR`                 | It is recommended to make a single payment                                                                | `currency` in the response is the same as in the request                                             |
| `TC-POS-08` | Multiple items in the cart            | 3 `basketItem`, total = `price`         | It is recommended to make the payment                                                                     | `success`; a `paymentTransactionId` is returned for each item and stored                             |
| `TC-POS-09` | Payment with saved card (if used)     | `cardUserKey` + `cardToken`             | It is recommended to first save the card, then pay with the token                                         | `success`; card number is not stored in your system (Card Storage)                                   |
| `TC-POS-10` | Pay with iyzico (PWI) (if used)       | Sandbox iyzico account, SMS `283126`    | It is recommended to be redirected to the PWI page, pay, and return to the callback                       | Retrieve result `success`; order `PAID`                                                              |
| `TC-POS-11` | Pre-authorization + capture (if used) | `5528790000000008`                      | It is recommended to start the pre-authorization, then perform the capture                                | Pre-authorization `success`; amount collected after capture                                          |

**For every successful scenario, it is additionally recommended to check that:**

* `price`, `paidPrice`, `currency` and `conversationId` in the response match the request.
* The response signature is verified (Verifying the Response Signature).
* The payment appears in the sandbox merchant panel with the same amount and status.
* The confirmation email / screen is shown to the customer; stock and accounting records are updated.

## Negative and Failure Scenarios

In failure scenarios, the goal is to correctly capture the `status: failure` + `errorCode` values returned by iyzico, to not treat the order as paid, and to show a clear message to the user. Code mappings are taken from the Error Codes page; the cards are from the "Error-Producing Cards" table on the Test Cards page.

### A. Bank decline scenarios (error-producing test cards)

| Test ID     | Scenario                    | Test card          | Expected errorCode / errorGroup                                         | Behavior to show to the user                                |
| ----------- | --------------------------- | ------------------ | ----------------------------------------------------------------------- | ----------------------------------------------------------- |
| `TC-NEG-01` | Insufficient funds          | `4111111111111129` | `10051` / `NOT_SUFFICIENT_FUNDS`                                        | "Card limit insufficient"; trying another card is suggested |
| `TC-NEG-02` | Do not honour               | `4129111111111111` | `10005` / `DO_NOT_HONOUR`                                               | Contacting the bank is suggested                            |
| `TC-NEG-03` | Invalid transaction         | `4128111111111112` | `10012` / `INVALID_TRANSACTION`                                         | Generic decline message                                     |
| `TC-NEG-04` | Lost card                   | `4127111111111113` | `10041` / `LOST_CARD`                                                   | Generic decline message without details                     |
| `TC-NEG-05` | Stolen card                 | `4126111111111114` | `10043` / `STOLEN_CARD`                                                 | Generic decline message without details                     |
| `TC-NEG-06` | Expired card                | `4125111111111115` | `10054` / `EXPIRED_CARD`                                                | "The card has expired"                                      |
| `TC-NEG-07` | Invalid CVC                 | `4124111111111116` | `10084` / `INVALID_CVC2`                                                | The user is asked to re-enter the CVC                       |
| `TC-NEG-08` | Not permitted to cardholder | `4123111111111117` | `10057` / `NOT_PERMITTED_TO_CARDHOLDER`                                 | Contacting the bank is suggested                            |
| `TC-NEG-09` | Not permitted to terminal   | `4122111111111118` | `10058` / `NOT_PERMITTED_TO_TERMINAL`                                   | Generic error; opening a support ticket is suggested        |
| `TC-NEG-10` | Fraud suspect               | `4121111111111119` | `10034` / `FRAUD_SUSPECT`                                               | Generic decline message without details                     |
| `TC-NEG-11` | Pickup card                 | `4120111111111110` | `10041` / `PICKUP_CARD`                                                 | Generic decline message without details                     |
| `TC-NEG-12` | Generic bank error          | `4130111111111118` | `failure` (recording the code returned on the first run is recommended) | "Payment could not be processed, please try again"          |

### B. Request and validation errors

| Test ID     | Scenario                     | How to trigger                                                                  | Expected result                    |
| ----------- | ---------------------------- | ------------------------------------------------------------------------------- | ---------------------------------- |
| `TC-NEG-13` | Invalid card number          | It is recommended to send a number that fails the Luhn check                    | `12` – Invalid card number         |
| `TC-NEG-14` | Past expiry date             | It is recommended to send a past year in `expireYear`                           | `13` / `14`                        |
| `TC-NEG-15` | Wrong CVC length             | It is recommended to send a 2-digit CVC                                         | `15` – Invalid cvc                 |
| `TC-NEG-16` | Basket total mismatch        | It is recommended to send a `basketItem` total different from `price`           | `5062`                             |
| `TC-NEG-17` | Zero or negative item price  | It is recommended to send `basketItem.price = 0`                                | `5050`                             |
| `TC-NEG-18` | Missing required field       | It is recommended to leave `buyer.email` / `gsmNumber` / `identityNumber` empty | `3` / `25` / `8`                   |
| `TC-NEG-19` | Invalid signature            | It is recommended to deliberately provide a wrong secret key                    | `1000` – Invalid signature         |
| `TC-NEG-20` | Environment / key mismatch   | It is recommended to use a sandbox key with the live URL                        | `1001` – API credentials not found |
| `TC-NEG-21` | Installments with debit card | It is recommended to try a debit card + 3 installments                          | `10218`                            |
| `TC-NEG-22` | Debit card without 3DS       | It is recommended to try a Non-3DS payment with a debit card                    | `10217` (depends on the bank)      |

### C. System and flow errors

* **`TC-NEG-23` – Timeout:** It is recommended to set the client timeout very low (e.g., 1 ms). Expected: the order stays `PENDING`, then the actual status is determined via Payment Query or webhook; the user is not charged a second time.
* **`TC-NEG-24` – User closes the Checkout Form:** It is recommended to open the form and close the tab without paying. Expected: the order does not become `PAID`; cancellation works when the token expires.
* **`TC-NEG-25` – Callback manipulation:** It is recommended to send a request to the callback URL with a fake token / `status=success`. Expected: the system performs a Retrieve query and, since the result is `failure`, does not confirm the order.
* **`TC-NEG-26` – Amount manipulation:** It is recommended to change the price on the client side. Expected: the amount is recalculated on the server; if the `paidPrice` in Retrieve does not match the order amount, the order is not confirmed and an alarm is raised.

## 3D Secure Test Scenarios

The 3DS flow has two steps: 3DS Initialize returns the bank verification HTML, and after the user verifies, the bank POSTs to your callback URL and you finalize the payment with 3DS Complete (`/payment/3dsecure/auth` or the recommended `/payment/v2/3dsecure/auth`). In the sandbox, the SMS password is always `283126`. If Checkout Form is used, the 3DS steps are handled inside the form; it is recommended to test the same scenarios by checking the CF Query result.

| Test ID     | Scenario                            | Test data                        | How to test                                                                                | Expected result                                                                       |
| ----------- | ----------------------------------- | -------------------------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
| `TC-3DS-01` | Successful 3DS verification         | `5528790000000008`, SMS `283126` | It is recommended to follow Init → bank page → enter SMS → callback → Auth                 | In the callback `status=success`, `mdStatus=1`; Auth response `success`; order `PAID` |
| `TC-3DS-02` | Wrong SMS code                      | Same card, SMS `000000`          | It is recommended to enter a wrong code on the verification page                           | Verification fails; Auth is not called; order `PAYMENT_FAILED`                        |
| `TC-3DS-03` | `mdStatus = 0`                      | `4131111111111117`               | It is recommended to run the full flow                                                     | In the callback `mdStatus=0`; the system does not call Auth and rejects the payment   |
| `TC-3DS-04` | `mdStatus = 4`                      | `4141111111111115`               | It is recommended to run the full flow                                                     | `mdStatus=4`; since only 1 is accepted, the payment is considered failed              |
| `TC-3DS-05` | 3DS initialization error            | `4151111111111112`               | It is recommended to send the Init request                                                 | Init `failure`; error message to the user; bank page does not open                    |
| `TC-3DS-06` | User abandons the verification page | Successful card                  | It is recommended to close the tab on the bank page                                        | The transaction stays in `INIT_3DS`; order remains unpaid; timeout cleanup runs       |
| `TC-3DS-07` | Auth with wrong `paymentId`         | Fake `paymentId`                 | It is recommended to manipulate the Auth request                                           | `5087` – Payment record not found                                                     |
| `TC-3DS-08` | v2 Auth amount mismatch             | `paidPrice` different from Init  | It is recommended to send a different amount to `/payment/v2/3dsecure/auth`                | `failure`; order is not confirmed                                                     |
| `TC-3DS-09` | Callback arrives twice              | Successful card                  | It is recommended to resend (replay) the callback request                                  | Auth is called once; the second request returns the existing result (see 11.9)        |
| `TC-3DS-10` | 3DS with debit card                 | `5890040000000016`               | It is recommended to run the full flow                                                     | `success`; the `10217` error received in Non-3DS is not received here                 |
| `TC-3DS-11` | Mobile browser / WebView            | Successful card                  | It is recommended to try the full flow on iOS Safari, Android Chrome and an in-app WebView | The bank page opens correctly; the session is not lost after the callback             |

**Additional checks:** It is recommended that the callback endpoint accepts only POST; that the `signature` in the Auth response is verified (Verifying the Response Signature); and that the product is not shipped if `fraudStatus` is `0` (under review).

## Refund and Cancellation Scenarios

Cancellation (`/payment/cancel`) is performed on the same day, with `paymentId`, and for the full amount only; refund (`/payment/refund`) is performed within 365 days with `paymentTransactionId`, fully or partially. Refund V2 (`/v2/payment/refund`) performs the same operation via `paymentId`. Source: Cancel and Refund.

| Test ID     | Scenario                                  | How to test                                                                                          | Expected result                                                                                                                  |
| ----------- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `TC-REF-01` | Same-day full cancellation                | It is recommended to make a successful payment and send a cancel with `paymentId` on the same day    | `success`; `price` = payment amount; order `CANCELLED`; stock restored                                                           |
| `TC-REF-02` | Full refund (per item)                    | It is recommended to send a refund for the item's `paidPrice` amount for each `paymentTransactionId` | Each item `success`; order `REFUNDED`                                                                                            |
| `TC-REF-03` | Partial refund                            | It is recommended to refund only 1 item in a 3-item cart                                             | Only that item is refunded; order `PARTIALLY_REFUNDED`                                                                           |
| `TC-REF-04` | Consecutive partial refunds               | It is recommended to refund the same item in two parts (e.g., 40 + 60)                               | Both `success`; total refund = item amount                                                                                       |
| `TC-REF-05` | Over-refund                               | It is recommended to send a `price` greater than the remaining refundable amount                     | `failure`; no refund record is created in the system                                                                             |
| `TC-REF-06` | Refund V2                                 | It is recommended to call `/v2/payment/refund` with `paymentId` and amount                           | `success`; iyzico selects the item itself; your item records are reconciled via Retrieve                                         |
| `TC-REF-07` | Payment that cannot be cancelled/refunded | It is recommended to pay with card `5406670000000009`, then try to cancel and refund                 | Payment `success`, cancel and refund `failure`; notification to the operations team                                              |
| `TC-REF-08` | Cancel with wrong `paymentId`             | It is recommended to use a non-existent `paymentId`                                                  | `5086` – Payment record not found                                                                                                |
| `TC-REF-09` | Cancel an already cancelled payment again | It is recommended to send a second cancel after `TC-REF-01`                                          | `failure`; the amount is not refunded a second time                                                                              |
| `TC-REF-10` | Refund on a failed payment                | It is recommended to send a refund for an item of a payment that is `failure`                        | `failure` or the request is blocked in your system                                                                               |
| `TC-REF-11` | `reason` field                            | It is recommended to send `reason: BUYER_REQUEST` + `description`                                    | `success`; the reason is visible in the panel                                                                                    |
| `TC-REF-12` | Same-day refund (instead of cancel)       | It is recommended to send a refund on the payment day                                                | Depending on the bank, `10223` (end of day must be completed) may be returned; the system redirects to cancellation in this case |

**Checkpoints:** It is recommended that the Retrieve query shows the up-to-date status after refund/cancellation; that the accounting record and customer notification are created; and that retry logic runs if the `retryable` field in the response is `true`, and falls to manual review if `false`. If refund to balance is used: Refund to iyzico Account.

## Webhook and Asynchronous Event Testing

iyzico sends a JSON POST to your webhook URL 10–15 seconds after the payment attempt; until it receives a 2xx response, it retries 3 more times at 15-minute intervals. The signature arrives in the `X-IYZ-SIGNATURE-V3` header (V1 and V2 are no longer supported), and to enable the webhook signature feature on your account you need to contact <entegrasyon@iyzico.com>. Source: Webhook, Webhook FAQ.

### Preparation

{% stepper %}
{% step %}

## Configure the webhook URL

It is recommended to enter your HTTPS webhook URL in the sandbox panel under Settings > Company Settings > Merchant Notifications (and the subscription notification URL as well, if subscriptions are used).
{% endstep %}

{% step %}

## Log incoming requests

It is recommended to make sure your webhook endpoint logs the incoming raw body and headers.
{% endstep %}

{% step %}

## Implement signature verification

It is recommended to implement signature verification according to the format used:

* **Direct format (Non-3DS / 3DS):** `secretKey + iyziEventType + paymentId + paymentConversationId + status`
* **HPP format (Checkout Form / PWI):** `secretKey + iyziEventType + iyziPaymentId + token + paymentConversationId + status`
* In both formats HMACSHA256 is used and the result is compared as hex.
  {% endstep %}
  {% endstepper %}

| Test ID    | Scenario                            | How to test                                                                                | Expected result                                                                                                                          |
| ---------- | ----------------------------------- | ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `TC-WH-01` | Successful payment notification     | It is recommended to run `TC-POS-01` and wait 15 sec                                       | `status: SUCCESS` webhook received; signature verified; endpoint returned 2xx; if the order is already `PAID`, the status did not change |
| `TC-WH-02` | Failed payment notification         | It is recommended to run `TC-NEG-01`                                                       | `status: FAILURE` received; order `PAYMENT_FAILED`                                                                                       |
| `TC-WH-03` | Webhook arrives without callback    | It is recommended to temporarily disable the callback endpoint and make a payment          | The order became `PAID` via webhook + Retrieve; the user sees the correct status upon return                                             |
| `TC-WH-04` | Invalid signature                   | It is recommended to send the webhook via Postman with a fake signature                    | The request is rejected (e.g., 401), the order does not change, a security log is created                                                |
| `TC-WH-05` | Missing signature header            | It is recommended to send a POST without the header                                        | The request is rejected                                                                                                                  |
| `TC-WH-06` | Retry                               | It is recommended to set the endpoint to return 500, make a payment, then fix it           | iyzico resends; 2xx after the fix; the event is processed once                                                                           |
| `TC-WH-07` | Same notification twice             | It is recommended to send the same payload twice                                           | The second one gets 2xx but is not processed (deduplication via `iyziReferenceCode` / `paymentId`)                                       |
| `TC-WH-08` | Out-of-order events                 | It is recommended to send `SUCCESS` first, then an older-dated `INIT_THREEDS`              | The order does not regress from `PAID` (`iyziEventTime` / status precedence)                                                             |
| `TC-WH-09` | Intermediate states                 | It is recommended to abandon the page at 3DS (`TC-3DS-06`)                                 | Intermediate states such as `INIT_THREEDS` do not make the order `PAID`                                                                  |
| `TC-WH-10` | Unknown order                       | It is recommended to send with a `paymentConversationId` that does not exist in the system | 2xx is returned, a warning is logged, no error is thrown                                                                                 |
| `TC-WH-11` | Response time                       | It is recommended to measure while the endpoint is doing heavy work                        | The endpoint returns 2xx quickly; processing is done asynchronously in a queue                                                           |
| `TC-WH-12` | Subscription notification (if used) | It is recommended to start a subscription in the sandbox                                   | `subscription.order.success` / `failure` is received; verified with the subscription signature format                                    |

{% hint style="warning" %}
The webhook alone is not the source of truth. After a notification is received, it is recommended to confirm the result with Payment Query or CF Query. It is recommended that a nightly reconciliation job closes orders that remain `PENDING` by querying them, and that this job is also tested (Reconciliation Files).
{% endhint %}

## Idempotency and Duplicate Request Testing

Most iyzico services are not idempotent; if the same payment request is sent twice, two separate charges may occur. For this reason, it is recommended to build and test duplicate protection on your side. Fields iyzico recommends for matching: the `conversationId` / `basketId` you generate, and the `token` and `paymentId` generated by iyzico (Matching).

**Expected design (the rules the tests are based on):**

* It is recommended to have a single payment attempt record and a unique `conversationId` per order, and not to start a new attempt while an open attempt exists for the same order (unique constraint or lock in the DB).
* It is recommended that callback and webhook handlers change the status only once for the same `paymentId` / `token`.
* It is recommended not to blindly resend the payment request after a timeout; a query should be made first.

| Test ID     | Scenario                     | How to test                                                                                    | Expected result                                                                                                                      |
| ----------- | ---------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `TC-IDM-01` | Double click                 | It is recommended to click the "Pay" button twice quickly                                      | Only one request goes to iyzico; the button locks on the first click; single charge                                                  |
| `TC-IDM-02` | Parallel request             | It is recommended to send two payment requests for the same order concurrently (with a script) | One is processed, the other is rejected or returns the existing result; a single payment in the panel                                |
| `TC-IDM-03` | Page refresh / back button   | It is recommended to refresh the callback page after payment and go back in the browser        | No new payment starts; the order status page is shown                                                                                |
| `TC-IDM-04` | Retry after timeout          | It is recommended to trigger the system's retry after a client timeout                         | A Payment Query is made before the retry; if the payment already exists, no new request is sent                                      |
| `TC-IDM-05` | Callback replay              | It is recommended to resend the successful callback with the same parameters                   | 3DS Auth / CF Retrieve is processed once; order and stock are updated once                                                           |
| `TC-IDM-06` | Webhook + callback race      | It is recommended to trigger the webhook and callback at the same time                         | Single state transition; single email; single accounting record                                                                      |
| `TC-IDM-07` | Same refund twice            | It is recommended to send the refund request twice for the same item                           | Your system blocks the second one or iyzico rejects it with the remaining amount check; total refund does not exceed the item amount |
| `TC-IDM-08` | `conversationId` duplication | It is recommended to force the same `conversationId` on two different orders                   | Sending a duplicate `conversationId` does not return an error; uniqueness is not checked                                             |
| `TC-IDM-09` | Same Checkout Form token     | It is recommended to reopen the form with the same token after the first successful payment    | Each token is specific to one form; a payment cannot be triggered with the token information                                         |

**Verification method:** After each test, it is recommended to check in the sandbox merchant panel and with the Reporting Service that there is only a single successful payment for the relevant `basketId` / `conversationId`.

## Regression Testing

It is recommended to run an automated regression set against the sandbox for every change that touches the payment code, dependencies (iyzipay SDK version) or the cart/order module, and not to release if the set is red.

**Changes that trigger regression:**

* iyzipay SDK or HTTP client version update (sample code links are available on the relevant docs.iyzico.com pages).
* Changes announced by iyzico (e.g., the webhook signature moving to V3, the 3DS Auth v2 endpoint, HMACSHA256 authentication).
* Changes to price calculation, installments, campaigns, currency or basket structure.
* Changes to callback/webhook URLs, server, proxy or TLS configuration.

| Layer                           | Scope                                                          | When it runs                                 | Duration target |
| ------------------------------- | -------------------------------------------------------------- | -------------------------------------------- | --------------- |
| Smoke (`TC-REG-SMOKE`)          | `TC-POS-01`, `TC-NEG-01`, `TC-3DS-01`, `TC-REF-01`, `TC-WH-01` | On every pull request and after every deploy | < 5 min         |
| Full regression (`TC-REG-FULL`) | All automatable cases in 11.4–11.9                             | Nightly and before a release candidate       | < 45 min        |
| Manual regression               | 3DS bank page, mobile/WebView, Checkout Form appearance        | Major releases and SDK updates               | 1 business day  |

**Automation notes:** It is recommended to pass the 3DS bank page in the sandbox using browser automation (Playwright/Cypress) by entering SMS `283126`; to generate a new `conversationId` on every run; and to limit the number of parallel runs so as not to hit sandbox rate limits (Limits).

## Test Evidence and Defect Management

It is recommended to store evidence for each test case in such a way that another person can re-verify the result from the iyzico panel and logs.

**Evidence to collect:**

* Test ID, date/time, environment, tester and application version (commit/build no.).
* iyzico request and response JSON (card number masked except the first 6 + last 4 digits; CVC must never be logged).
* `conversationId`, `paymentId`, `paymentTransactionId`, `token` values.
* Screenshot or video: payment form, 3DS page, result page, transaction detail in the sandbox merchant panel.
* For webhooks: the raw payload received, the headers and the HTTP code returned by the endpoint.

**Defect record:**

| Field                     | Content                                                                                |
| ------------------------- | -------------------------------------------------------------------------------------- |
| Title                     | Test ID + short description (e.g., "TC-WH-07: duplicate webhook sends a second email") |
| Steps / expected / actual | Copied from the test case                                                              |
| Evidence                  | The evidence package above                                                             |
| Severity                  | S1–S4 (below)                                                                          |
| Source                    | Your code / iyzico / bank / test data                                                  |

| Severity      | Definition                                                                       | Example                                                 | Blocks go-live?        |
| ------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------- | ---------------------- |
| S1 – Critical | Loss of money, double charge, confirming an unpaid order, security vulnerability | Order confirmed with a fake callback                    | Yes                    |
| S2 – High     | Main flow not working, no workaround                                             | Order stays `PENDING` after 3DS                         | Yes                    |
| S3 – Medium   | Flow works but there is a wrong message/status                                   | A generic error message is shown for insufficient funds | No, a plan is required |
| S4 – Low      | Visual or text issue                                                             | Button alignment is broken                              | No                     |

For defects believed to originate from iyzico, it is recommended to send them to <entegrasyon@iyzico.com> together with `conversationId`, `paymentId`, request time and request/response (Error Codes, FAQ – Error Messages).

## User Acceptance Testing (UAT)

UAT is where the business team and the operations team apply real usage scenarios in the staging environment (with sandbox keys) and give the "we can open this flow to customers" approval. It is recommended not to start UAT before the technical tests (11.4–11.10) are completed.

**Participants:** Product owner, finance/accounting, customer service, QA (facilitator).

| Test ID     | User scenario                                                | Who tests        | Acceptance criteria                                                              |
| ----------- | ------------------------------------------------------------ | ---------------- | -------------------------------------------------------------------------------- |
| `TC-UAT-01` | Customer shops with a single credit card payment             | Product owner    | The flow is clear; the confirmation page and email show the correct amount       |
| `TC-UAT-02` | Customer selects installment payment                         | Product owner    | Installment options and installment fee are shown correctly                      |
| `TC-UAT-03` | Customer's card is declined and they retry with another card | Customer service | The error message is clear; the cart is not lost on the second attempt           |
| `TC-UAT-04` | 3DS verification is done on mobile                           | Product owner    | The bank page opens, the result page is shown on return                          |
| `TC-UAT-05` | Customer service cancels an order                            | Customer service | Cancellation/refund can be done from the admin panel; the customer is notified   |
| `TC-UAT-06` | Partial refund (refund of one product)                       | Customer service | Only the selected product amount is refunded                                     |
| `TC-UAT-07` | End-of-day reconciliation                                    | Finance          | System report totals match the sandbox merchant panel / reporting service totals |
| `TC-UAT-08` | Suspicious transaction (`fraudStatus = 0`)                   | Operations       | The order is not released for shipping, it is placed in the review queue         |

**Live verification (production smoke test):** After deployment with live keys, it is recommended to make a low-amount (e.g., 1 TRY) payment with a real card, verify webhook reception, and cancel it on the same day. Sandbox test cards do not work in the live environment. For iyzico's go-live steps: Integration Checklist.

## Testing Sign-Off Criteria

It is recommended to go live with the integration when all the criteria below are met.

**Exit criteria:**

* 100% of the cases in 11.4–11.9 have been run; those excluded from scope are listed with their justification.
* 100% of the critical cases (all `TC-POS`, `TC-3DS-01..05`, `TC-REF-01..03`, `TC-WH-01..04`, all `TC-IDM`) have passed.
* There are no open S1 and S2 defects; there is a dated resolution plan for S3 defects.
* The regression set (smoke + full) is green on the latest build.
* Response signature and webhook `X-IYZ-SIGNATURE-V3` verification are active and tested.
* It has been checked that logs contain no full card number or CVC.
* Live API keys, the live base URL (`https://api.iyzipay.com`) and the live webhook URL are configured; the sandbox key is not present in the live configuration.
* UAT scenarios (`TC-UAT-01..08`) have been approved by the business team.
* The live smoke test (payment + webhook + cancellation) was successful.
* A rollback plan and live monitoring/alerting (payment error rate, number of `PENDING` orders) are ready.
