improved environment management
This commit is contained in:
70
README.md
70
README.md
@@ -1,52 +1,50 @@
|
||||
# qpay-peak-flutter
|
||||
|
||||
## Switch from Test to Live Environment
|
||||
## Environment Switching (Test vs Live)
|
||||
|
||||
This project currently reads runtime API settings from `assets/.env` and loads Mastercard Checkout for web from `web/index.html`.
|
||||
Environment selection is command-driven with `--dart-define=APP_ENV=...`.
|
||||
|
||||
Use the checklist below before building for production.
|
||||
- `APP_ENV=test` loads `assets/.env.test`
|
||||
- `APP_ENV=live` loads `assets/.env.live`
|
||||
- If `APP_ENV` is not provided, default is `test`
|
||||
|
||||
### 1) Update API and simulation flags (`assets/.env`)
|
||||
For web, Mastercard Checkout is loaded dynamically from `GATEWAY_SCRIPT_URL` in the active env file, so `web/index.html` no longer needs manual test/live script edits.
|
||||
|
||||
In `assets/.env`, make sure the active (uncommented) values are set for live:
|
||||
### Env files
|
||||
|
||||
```dotenv
|
||||
BASE_URL=https://peakapi.qantra.co.zw/api
|
||||
SIMULATE_PAYMENT_SUCCESS=false
|
||||
Set environment-specific values in:
|
||||
|
||||
- `assets/.env.test`
|
||||
- `assets/.env.live`
|
||||
|
||||
Supported keys:
|
||||
|
||||
- `BASE_URL`
|
||||
- `CLIENTID`
|
||||
- `SIMULATE_PAYMENT_SUCCESS`
|
||||
- `GATEWAY_SCRIPT_URL`
|
||||
|
||||
### Run in Test
|
||||
|
||||
```bash
|
||||
flutter run --dart-define=APP_ENV=test
|
||||
```
|
||||
|
||||
Notes:
|
||||
- Keep only one active `BASE_URL` line.
|
||||
- `SIMULATE_PAYMENT_SUCCESS` must be `false` in live to avoid fake-success payment flows.
|
||||
### Run in Live
|
||||
|
||||
### 2) Update Mastercard Checkout script (`web/index.html`)
|
||||
|
||||
In `web/index.html`, switch the checkout script from test to live:
|
||||
|
||||
```html
|
||||
<script src="https://na.gateway.mastercard.com/static/checkout/checkout.min.js"></script>
|
||||
```bash
|
||||
flutter run --dart-define=APP_ENV=live
|
||||
```
|
||||
|
||||
And ensure the test script is not active:
|
||||
### Build in Live
|
||||
|
||||
```html
|
||||
<!-- <script src="https://test-gateway.mastercard.com/static/checkout/checkout.min.js"></script> -->
|
||||
```bash
|
||||
flutter build web --dart-define=APP_ENV=live
|
||||
flutter build apk --dart-define=APP_ENV=live
|
||||
```
|
||||
|
||||
### 3) Quick pre-release verification
|
||||
### Quick pre-release checks
|
||||
|
||||
Before release, confirm:
|
||||
- `assets/.env` points to the live API URL.
|
||||
- `assets/.env` has `SIMULATE_PAYMENT_SUCCESS=false`.
|
||||
- `web/index.html` loads `na.gateway.mastercard.com` (not `test-gateway.mastercard.com`).
|
||||
|
||||
## Switch back to Test
|
||||
|
||||
To return to test:
|
||||
- Restore the test `BASE_URL` in `assets/.env`.
|
||||
- Set `SIMULATE_PAYMENT_SUCCESS=true` (only if needed for local testing).
|
||||
- Re-enable the test checkout script in `web/index.html`.
|
||||
|
||||
## Source of Truth
|
||||
|
||||
If environment settings change in future, update this README section together with `assets/.env` and `web/index.html` so release steps stay accurate.
|
||||
- Confirm `assets/.env.live` points to the live API (`BASE_URL`).
|
||||
- Confirm `assets/.env.live` has `SIMULATE_PAYMENT_SUCCESS=false`.
|
||||
- Confirm `assets/.env.live` uses live gateway script URL in `GATEWAY_SCRIPT_URL`.
|
||||
|
||||
Reference in New Issue
Block a user