---
# System prepended metadata

title: China Payment Gateway

---

# China Payment Gateway

## Abstract

The goal of this project is to create a payment gateway with which companies, especially companies with a small or no business presence in China, can accept payments to the three most popular Chinese payment providers: Alipay, WeChatPay and UnionPay. This is achieved by wrapping the aforementioned payment providers in a custom API in order to allow easy integration with 3rd party ecommerce systems such as Magento or WooCommerce.


## Definitions

* users are businesses using the China Payment Gateway
* end users are the customers of the users


## Stated Goals

* offer an api for payments
* provide a hosted web flow for checkout in the vein of Paypal Checkout
* provide a management backend to users to
    * manage their transactions and refunds
    * manage their end users
* provide an administration backend to globally
    * manage users
    * manage end users
    * manage transactions and refunds
    * manage SMS and Email Templates
* allow end users to optionally save their information in the system
* multilingual frontend: zh-CN (default) and en-US frontend (backend is en-US)
* tax handling
* discount handling


## Future Goals

* logistics tracking integration
* returns
* insurance


## Non Goals

These items are outside the current scope of work

* plugins/extensions for third party systems


## Dependencies Managed by TMO Group

* sim card for management of 3rd party accounts
* a merchant account for each of AliPay, WeChatPay and UnionPay, hooked up to above sim card
* an aliyun account hooked up to above simcard
* domain on above aliyun account
* Corporate Identity Examples


## Timeline

We divide our time into 2 week sprints, so we have 6 sprints divided into 4 phases:

1. Planning
    1. detailed planning, user stories & scaffolding
2. Development I
    2. user and end user management
    3. API interface
3. Development II
    4. end user web flows and management platform (user, admin)
    5. payment and notification integrations
3. Testing
    6. finalization & testing

### Deliverables 

After each phase, deliverables are due:

1. Planning: User Stories, Detailed Architecture
2. Development I: API interface (testable with curl and similar)
3. Development II: Web interface (testable with web browser)
4. Testing: Finished Product


## Architecture

The architecture uses a modern container based approach with custom business logic written mostly in node.js (TypeScript) in order to allow for easy developer onboarding and rapid development while assuring high confidence around safety and correctness

### Backend

* PostgreSQL as canonical data store
* Express.js
* TypeScript
* [Ory Kratos](https://github.com/ory/kratos)

### Frontend

* Svelte with SSR (Sapper)
* TypeScript


## Deployment

### Development Environment

For local development we use Docker compose with the following containers

* PostgreSQL
* ORY Kratos
* Node.js with local code mounted

### Staging & Production Environments

Both staging and production environments are setup the same way to have a high fidelity testing environment.

Aliyun (China) is the chosen cloud provider.

The services used are:

* [RDS (PostgreSQL)](https://www.aliyun.com/product/rds/postgresql)
* [ECI](https://www.aliyun.com/product/eci)
* [SMS](https://www.aliyun.com/product/sms)
* [Direct Mail](https://www.aliyun.com/product/directmail)

Further, Aliyun is used to manage DNS for the domain
