Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

# Payment System Testing

A self-built mock payment system with full-stack automated test coverage — a Node.js/Express payment API, a simple checkout UI, and automated tests at both the UI (Playwright) and API (RestAssured) layers.

## Why This Project Exists

Real payment gateway sandboxes (Stripe, Razorpay, Easebuzz) require regional access, PAN verification, or merchant onboarding before issuing test credentials. This project sidesteps that by implementing a small, self-contained mock payment system — enabling realistic payment test-case design (success, decline, insufficient funds) without any external dependency, while providing full visibility into how the system being tested actually works.

## Project Structure


MockPaymentAPI/              → Node.js + Express backend

    server.js                   REST API: POST /payments, GET /payments/:id

    public/checkout.html        Simple checkout UI (vanilla JS, calls the API)



PaymentSystemAutomation/     → Java test automation

    src/main/java/pages/

        CheckoutPage.java        Page Object for the checkout UI

    src/test/java/tests/

        CheckoutTest.java        Playwright UI tests

        ApiTests.java             RestAssured API tests

    pom.xml

## Tech Stack

- **Node.js + Express** — mock payment backend

- **Vanilla JavaScript** — minimal checkout UI, calling the API via fetch()

- **Playwright for Java** — UI test automation

- **RestAssured** — API test automation

- **TestNG** — test framework and assertions

- **Maven** — Java dependency management

## Simulated Payment Scenarios

The API simulates outcomes based on the card number submitted, mirroring how real payment gateway test modes behave:

| Card Number | Simulated Outcome | HTTP Status |

|---|---|---|

| 4111111111111111 | Success | 201 Created |

| 4000000000000002 | Declined | 402 Payment Required |

| 4000000000009995 | Insufficient Funds | 402 Payment Required |

| Any other value | Invalid Card | 402 Payment Required |

## Test Coverage

**UI Tests (Playwright)** — CheckoutTest.java

- Successful payment completes and displays the correct status

- Declined payment is correctly reflected on the checkout page

- Insufficient funds scenario is correctly reflected on the checkout page

**API Tests (RestAssured)** — ApiTests.java

- POST /payments returns 201 and status: success for a valid card

- POST /payments returns 402 and status: declined for a decline-simulating card

- POST /payments returns 402 and status: insufficient\_funds for that scenario

## Running the Project

**1. Start the backend:**


cd MockPaymentAPI

npm install

node server.js

Runs at http://localhost:3000. Checkout UI available at http://localhost:3000/checkout.html.

**2. Run the automated tests (with the backend running):**

Open PaymentSystemAutomation in Eclipse as a Maven project, then run CheckoutTest and ApiTests as TestNG Tests.

## Notes

Built to practice realistic payment-domain test design — covering positive and negative payment flows — while demonstrating both UI and API automation skills using two different tools (Playwright and RestAssured) against the same underlying system.

About

Self-built mock payment API (Node.js/Express) with full-stack test automation — UI testing via Playwright, API testing via RestAssured, covering success/decline/insufficient-funds payment flows.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages