Detect declined sessions (200 + Status:Error); theme Sessions screen

- startParkingSession: server returns HTTP 200 even on a declined charge — now
  detect Response.Status:"Error" and throw the gateway reason (e.g. "DECLINED")
  so the app shows the failure instead of a false "Parked!"
- Confirmed the session request format is correct (server processed it); expand
  StartParkingSessionResponse with the real fields (OriginalErrorMessage, etc.)
- Theme SessionsScreen (was black-on-black in dark mode)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Hank 2026-07-06 12:25:14 -07:00
parent 7ec7ae9200
commit 1c597ec471
3 changed files with 52 additions and 22 deletions

View file

@ -598,13 +598,20 @@ export class ParkSmarterClient {
MeterTypeId: params.meterTypeId,
};
if (params.bleEncBytes) body.BleEncBytes = params.bleEncBytes;
return this.unwrap(
this.http.request<T.StartParkingSessionResponse>({
method: 'POST',
path: '/api/Session',
body,
}),
);
return this.http
.request<T.StartParkingSessionResponse>({ method: 'POST', path: '/api/Session', body })
.then((res) => {
// The server returns HTTP 200 even when the charge is declined, signalling
// failure via Response.Status:"Error" (+ OriginalErrorMessage like "DECLINED").
const env = res.data?.Response as { Status?: string; Message?: string } | undefined;
if (env?.Status === 'Error') {
throw new Error(
(env.Message || 'Payment failed.') +
(res.data?.OriginalErrorMessage ? ` (${res.data.OriginalErrorMessage})` : ''),
);
}
return res.data;
});
}
/** GET /api/ParkingSession — currently active sessions. */

View file

@ -452,8 +452,29 @@ export interface StartParkingSessionParams {
bleEncBytes?: string;
}
/**
* POST /api/Session. CONFIRMED via live capture. Returns HTTP 200 even on a
* declined charge check `Response.Status === 'Error'` (the client does this and
* throws). `OriginalErrorMessage` carries the gateway reason (e.g. "DECLINED").
*/
export interface StartParkingSessionResponse {
BleEncBytes?: string;
Response?: ResponseEnvelope;
BleEncBytes?: string | null;
PBPParkingSessionId?: number;
OriginalErrorMessage?: string;
StartTime?: string | null;
EndTime?: string | null;
TimePurchased?: string | null;
ZoneID?: number | string | null;
Zone?: string | null;
SpaceID?: number | string | null;
Space?: string | null;
VehicleNumber?: string | null;
Lat?: number | null;
Long?: number | null;
TransactionFee?: string | number | null;
Amount?: string | number | null;
AmountCharged?: string | number | null;
[key: string]: unknown;
}