@grabjs/superapp-sdk 2.0.0-beta.23 → 2.0.0-beta.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -155
- package/api-reference/api.json +43962 -0
- package/dist/index.d.ts +2140 -2608
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +14 -9
- package/skills/SKILL.md +405 -0
- package/api-reference/json/api.json +0 -27688
- package/api-reference/markdown/README.md +0 -194
- package/api-reference/markdown/classes/BaseModule.md +0 -123
- package/api-reference/markdown/classes/CameraModule.md +0 -177
- package/api-reference/markdown/classes/CheckoutModule.md +0 -181
- package/api-reference/markdown/classes/ContainerModule.md +0 -751
- package/api-reference/markdown/classes/DeviceCapabilityModule.md +0 -161
- package/api-reference/markdown/classes/FileModule.md +0 -178
- package/api-reference/markdown/classes/IdentityModule.md +0 -299
- package/api-reference/markdown/classes/LocaleModule.md +0 -161
- package/api-reference/markdown/classes/LocationModule.md +0 -239
- package/api-reference/markdown/classes/MediaModule.md +0 -219
- package/api-reference/markdown/classes/PlatformModule.md +0 -162
- package/api-reference/markdown/classes/ProfileModule.md +0 -224
- package/api-reference/markdown/classes/ScopeModule.md +0 -219
- package/api-reference/markdown/classes/StorageModule.md +0 -608
- package/api-reference/markdown/classes/SystemWebViewKitModule.md +0 -177
- package/api-reference/markdown/classes/UserAttributesModule.md +0 -164
- package/api-reference/markdown/functions/isClientError.md +0 -37
- package/api-reference/markdown/functions/isErrorResponse.md +0 -40
- package/api-reference/markdown/functions/isRedirection.md +0 -37
- package/api-reference/markdown/functions/isServerError.md +0 -37
- package/api-reference/markdown/functions/isSuccess.md +0 -39
- package/api-reference/markdown/globals.md +0 -176
- package/api-reference/markdown/interfaces/GrabAppInfo.md +0 -23
- package/api-reference/markdown/interfaces/InvokeOptions.md +0 -63
- package/api-reference/markdown/interfaces/Version.md +0 -23
- package/api-reference/markdown/interfaces/WrappedModule.md +0 -51
- package/api-reference/markdown/type-aliases/AuthorizeRequest.md +0 -79
- package/api-reference/markdown/type-aliases/AuthorizeResponse.md +0 -58
- package/api-reference/markdown/type-aliases/AuthorizeResult.md +0 -33
- package/api-reference/markdown/type-aliases/BackResponse.md +0 -37
- package/api-reference/markdown/type-aliases/BackResult.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeClientError.md +0 -9
- package/api-reference/markdown/type-aliases/BridgeError.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeRedirection.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeResponse.md +0 -40
- package/api-reference/markdown/type-aliases/BridgeServerError.md +0 -8
- package/api-reference/markdown/type-aliases/BridgeStatusCode.md +0 -7
- package/api-reference/markdown/type-aliases/BridgeStream.md +0 -29
- package/api-reference/markdown/type-aliases/BridgeStreamHandlers.md +0 -25
- package/api-reference/markdown/type-aliases/BridgeSuccessResponse.md +0 -14
- package/api-reference/markdown/type-aliases/ClearAuthorizationArtifactsResponse.md +0 -18
- package/api-reference/markdown/type-aliases/ClearAuthorizationArtifactsResult.md +0 -8
- package/api-reference/markdown/type-aliases/CloseResponse.md +0 -37
- package/api-reference/markdown/type-aliases/CloseResult.md +0 -8
- package/api-reference/markdown/type-aliases/DRMContentConfig.md +0 -34
- package/api-reference/markdown/type-aliases/DRMPlaybackEvent.md +0 -43
- package/api-reference/markdown/type-aliases/DownloadFileRequest.md +0 -32
- package/api-reference/markdown/type-aliases/DownloadFileResponse.md +0 -48
- package/api-reference/markdown/type-aliases/DownloadFileResult.md +0 -11
- package/api-reference/markdown/type-aliases/ErrorResponse.md +0 -32
- package/api-reference/markdown/type-aliases/FetchEmailResponse.md +0 -58
- package/api-reference/markdown/type-aliases/FetchEmailResult.md +0 -21
- package/api-reference/markdown/type-aliases/GetAuthorizationArtifactsResponse.md +0 -42
- package/api-reference/markdown/type-aliases/GetAuthorizationArtifactsResult.md +0 -57
- package/api-reference/markdown/type-aliases/GetBooleanRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetBooleanResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetBooleanResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetCoordinateResponse.md +0 -49
- package/api-reference/markdown/type-aliases/GetCoordinateResult.md +0 -29
- package/api-reference/markdown/type-aliases/GetCountryCodeResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetCountryCodeResult.md +0 -25
- package/api-reference/markdown/type-aliases/GetDoubleRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetDoubleResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetDoubleResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetIntRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetIntResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetIntResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetLanguageLocaleIdentifierResponse.md +0 -48
- package/api-reference/markdown/type-aliases/GetLanguageLocaleIdentifierResult.md +0 -31
- package/api-reference/markdown/type-aliases/GetSelectedTravelDestinationResponse.md +0 -48
- package/api-reference/markdown/type-aliases/GetSelectedTravelDestinationResult.md +0 -17
- package/api-reference/markdown/type-aliases/GetSessionParamsResponse.md +0 -40
- package/api-reference/markdown/type-aliases/GetSessionParamsResult.md +0 -27
- package/api-reference/markdown/type-aliases/GetStringRequest.md +0 -21
- package/api-reference/markdown/type-aliases/GetStringResponse.md +0 -57
- package/api-reference/markdown/type-aliases/GetStringResult.md +0 -27
- package/api-reference/markdown/type-aliases/HasAccessToResponse.md +0 -66
- package/api-reference/markdown/type-aliases/HasAccessToResult.md +0 -27
- package/api-reference/markdown/type-aliases/HideBackButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/HideBackButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/HideLoaderResponse.md +0 -37
- package/api-reference/markdown/type-aliases/HideLoaderResult.md +0 -8
- package/api-reference/markdown/type-aliases/HideRefreshButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/HideRefreshButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/IsConnectedResponse.md +0 -31
- package/api-reference/markdown/type-aliases/IsConnectedResult.md +0 -27
- package/api-reference/markdown/type-aliases/IsEsimSupportedResponse.md +0 -48
- package/api-reference/markdown/type-aliases/IsEsimSupportedResult.md +0 -17
- package/api-reference/markdown/type-aliases/ObserveDRMPlaybackResponse.md +0 -15
- package/api-reference/markdown/type-aliases/ObserveLocationChangeResponse.md +0 -15
- package/api-reference/markdown/type-aliases/OnContentLoadedResponse.md +0 -37
- package/api-reference/markdown/type-aliases/OnContentLoadedResult.md +0 -8
- package/api-reference/markdown/type-aliases/OnCtaTapRequest.md +0 -13
- package/api-reference/markdown/type-aliases/OnCtaTapResponse.md +0 -37
- package/api-reference/markdown/type-aliases/OnCtaTapResult.md +0 -8
- package/api-reference/markdown/type-aliases/OpenExternalLinkRequest.md +0 -13
- package/api-reference/markdown/type-aliases/OpenExternalLinkResponse.md +0 -46
- package/api-reference/markdown/type-aliases/OpenExternalLinkResult.md +0 -8
- package/api-reference/markdown/type-aliases/Platform.md +0 -7
- package/api-reference/markdown/type-aliases/PlayDRMContentResponse.md +0 -43
- package/api-reference/markdown/type-aliases/PlayDRMContentResult.md +0 -8
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewRequest.md +0 -23
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewResponse.md +0 -55
- package/api-reference/markdown/type-aliases/RedirectToSystemWebViewResult.md +0 -8
- package/api-reference/markdown/type-aliases/ReloadScopesResponse.md +0 -46
- package/api-reference/markdown/type-aliases/ReloadScopesResult.md +0 -8
- package/api-reference/markdown/type-aliases/RemoveAllResponse.md +0 -37
- package/api-reference/markdown/type-aliases/RemoveAllResult.md +0 -8
- package/api-reference/markdown/type-aliases/RemoveResponse.md +0 -46
- package/api-reference/markdown/type-aliases/RemoveResult.md +0 -8
- package/api-reference/markdown/type-aliases/ResponseStatusCode200.md +0 -34
- package/api-reference/markdown/type-aliases/ResponseStatusCode204.md +0 -20
- package/api-reference/markdown/type-aliases/ResponseStatusCode302.md +0 -20
- package/api-reference/markdown/type-aliases/ResponseStatusCode400.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode401.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode403.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode404.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode424.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode426.md +0 -12
- package/api-reference/markdown/type-aliases/ResponseStatusCode500.md +0 -7
- package/api-reference/markdown/type-aliases/ResponseStatusCode501.md +0 -12
- package/api-reference/markdown/type-aliases/ScanQRCodeRequest.md +0 -27
- package/api-reference/markdown/type-aliases/ScanQRCodeResponse.md +0 -64
- package/api-reference/markdown/type-aliases/ScanQRCodeResult.md +0 -21
- package/api-reference/markdown/type-aliases/SendAnalyticsEventRequest.md +0 -56
- package/api-reference/markdown/type-aliases/SendAnalyticsEventResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SendAnalyticsEventResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetBackgroundColorRequest.md +0 -13
- package/api-reference/markdown/type-aliases/SetBackgroundColorResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetBackgroundColorResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetBooleanResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetBooleanResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetDoubleResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetDoubleResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetIntResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetIntResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetStringResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetStringResult.md +0 -8
- package/api-reference/markdown/type-aliases/SetTitleRequest.md +0 -13
- package/api-reference/markdown/type-aliases/SetTitleResponse.md +0 -46
- package/api-reference/markdown/type-aliases/SetTitleResult.md +0 -8
- package/api-reference/markdown/type-aliases/ShowBackButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/ShowBackButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/ShowLoaderResponse.md +0 -37
- package/api-reference/markdown/type-aliases/ShowLoaderResult.md +0 -8
- package/api-reference/markdown/type-aliases/ShowRefreshButtonResponse.md +0 -37
- package/api-reference/markdown/type-aliases/ShowRefreshButtonResult.md +0 -8
- package/api-reference/markdown/type-aliases/StatusCodeMap.md +0 -80
- package/api-reference/markdown/type-aliases/Subscription.md +0 -12
- package/api-reference/markdown/type-aliases/TriggerCheckoutRequest.md +0 -26
- package/api-reference/markdown/type-aliases/TriggerCheckoutResponse.md +0 -76
- package/api-reference/markdown/type-aliases/TriggerCheckoutResult.md +0 -75
- package/api-reference/markdown/type-aliases/VerifyEmailRequest.md +0 -32
- package/api-reference/markdown/type-aliases/VerifyEmailResponse.md +0 -55
- package/api-reference/markdown/type-aliases/VerifyEmailResult.md +0 -8
- package/api-reference/markdown/variables/ContainerAnalyticsEventData.md +0 -21
- package/api-reference/markdown/variables/ContainerAnalyticsEventName.md +0 -13
- package/api-reference/markdown/variables/ContainerAnalyticsEventState.md +0 -25
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
## Overview
|
|
2
|
-
|
|
3
|
-
The SuperApp SDK enables web developers to build MiniApps that run within the Grab SuperApp WebView. It provides a type-safe bridge for communication between web applications and native Android/iOS capabilities.
|
|
4
|
-
|
|
5
|
-
Each module encapsulates a specific domain of functionality, offering strongly-typed APIs with consistent response patterns.
|
|
6
|
-
|
|
7
|
-
### Key Features
|
|
8
|
-
|
|
9
|
-
- **Type-Safe APIs** — Full TypeScript support with comprehensive type definitions
|
|
10
|
-
- **Modular Architecture** — Import only the modules you need
|
|
11
|
-
- **Consistent Response Pattern** — All methods return standardized bridge responses with HTTP-style status codes
|
|
12
|
-
- **Streaming Support** — Real-time data streams for location updates and media events
|
|
13
|
-
- **Automatic Fallbacks** — Graceful degradation when native features are unavailable
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
### NPM (ES Modules)
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install @grabjs/superapp-sdk
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
import { ContainerModule, LocationModule } from '@grabjs/superapp-sdk';
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### CDN (UMD Bundle)
|
|
28
|
-
|
|
29
|
-
```html
|
|
30
|
-
<script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
31
|
-
<script>
|
|
32
|
-
const { ContainerModule, LocationModule } = window.SuperAppSDK;
|
|
33
|
-
</script>
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Usage
|
|
37
|
-
|
|
38
|
-
### Basic Module Initialization
|
|
39
|
-
|
|
40
|
-
All modules are instantiated with a simple constructor call:
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
import { ContainerModule, LocationModule, IdentityModule } from '@grabjs/superapp-sdk';
|
|
44
|
-
|
|
45
|
-
// Initialize modules
|
|
46
|
-
const container = new ContainerModule();
|
|
47
|
-
const location = new LocationModule();
|
|
48
|
-
const identity = new IdentityModule();
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Handling Responses
|
|
52
|
-
|
|
53
|
-
All SDK methods return a standardized response with HTTP-style status codes:
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
import { CameraModule } from '@grabjs/superapp-sdk';
|
|
57
|
-
|
|
58
|
-
const camera = new CameraModule();
|
|
59
|
-
const response = await camera.scanQRCode({ title: 'Scan Payment QR' });
|
|
60
|
-
|
|
61
|
-
switch (response.status_code) {
|
|
62
|
-
case 200:
|
|
63
|
-
// Successfully scanned - result contains the QR code data
|
|
64
|
-
console.log('QR Code scanned:', response.result.qrCode);
|
|
65
|
-
break;
|
|
66
|
-
case 204:
|
|
67
|
-
// User cancelled the scanning operation
|
|
68
|
-
console.log('Scanning cancelled');
|
|
69
|
-
break;
|
|
70
|
-
case 400:
|
|
71
|
-
// Bad request - invalid request parameters
|
|
72
|
-
console.error('Invalid request:', response.error);
|
|
73
|
-
break;
|
|
74
|
-
case 403:
|
|
75
|
-
// Camera permission not granted to the Grab app
|
|
76
|
-
console.error('Camera permission denied:', response.error);
|
|
77
|
-
break;
|
|
78
|
-
case 501:
|
|
79
|
-
// Not implemented - not running in Grab app
|
|
80
|
-
console.error('Requires Grab SuperApp environment');
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
console.error('Unexpected error:', response);
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Working with Streams
|
|
88
|
-
|
|
89
|
-
Some modules provide streaming methods for real-time data:
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
import { LocationModule } from '@grabjs/superapp-sdk';
|
|
93
|
-
|
|
94
|
-
const location = new LocationModule();
|
|
95
|
-
|
|
96
|
-
// Subscribe to location updates
|
|
97
|
-
const stream = location.observeLocationChange();
|
|
98
|
-
|
|
99
|
-
const subscription = stream.subscribe({
|
|
100
|
-
next: (response) => {
|
|
101
|
-
if (response.status_code === 200) {
|
|
102
|
-
console.log('Location:', response.result);
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
complete: () => {
|
|
106
|
-
console.log('Stream ended');
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// Unsubscribe when done
|
|
111
|
-
subscription.unsubscribe();
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Available Modules
|
|
115
|
-
|
|
116
|
-
- **[ContainerModule](https://grab.github.io/superapp-sdk/classes/ContainerModule.html)** — Control the WebView container UI and lifecycle (header, loading indicators, analytics, connection verification)
|
|
117
|
-
|
|
118
|
-
- **[IdentityModule](https://grab.github.io/superapp-sdk/classes/IdentityModule.html)** — Authenticate users via GrabID OAuth2/OIDC with PKCE support
|
|
119
|
-
|
|
120
|
-
- **[LocationModule](https://grab.github.io/superapp-sdk/classes/LocationModule.html)** — Access device location services and subscribe to location updates
|
|
121
|
-
|
|
122
|
-
- **[StorageModule](https://grab.github.io/superapp-sdk/classes/StorageModule.html)** — Persist key-value data locally with type-safe storage
|
|
123
|
-
|
|
124
|
-
- **[CameraModule](https://grab.github.io/superapp-sdk/classes/CameraModule.html)** — Access device camera capabilities for QR code scanning
|
|
125
|
-
|
|
126
|
-
- **[CheckoutModule](https://grab.github.io/superapp-sdk/classes/CheckoutModule.html)** — Trigger native checkout flows for payment processing
|
|
127
|
-
|
|
128
|
-
- **[DeviceCapabilityModule](https://grab.github.io/superapp-sdk/classes/DeviceCapabilityModule.html)** — Query device hardware capabilities
|
|
129
|
-
|
|
130
|
-
- **[FileModule](https://grab.github.io/superapp-sdk/classes/FileModule.html)** — Handle file operations including downloading from remote URLs
|
|
131
|
-
|
|
132
|
-
- **[LocaleModule](https://grab.github.io/superapp-sdk/classes/LocaleModule.html)** — Access device locale and localization settings
|
|
133
|
-
|
|
134
|
-
- **[MediaModule](https://grab.github.io/superapp-sdk/classes/MediaModule.html)** — Handle media playback including DRM-protected content
|
|
135
|
-
|
|
136
|
-
- **[PlatformModule](https://grab.github.io/superapp-sdk/classes/PlatformModule.html)** — Access platform information and navigation controls
|
|
137
|
-
|
|
138
|
-
- **[ProfileModule](https://grab.github.io/superapp-sdk/classes/ProfileModule.html)** — Access user profile information including email
|
|
139
|
-
|
|
140
|
-
- **[ScopeModule](https://grab.github.io/superapp-sdk/classes/ScopeModule.html)** — Manage permission scopes from GrabID
|
|
141
|
-
|
|
142
|
-
- **[SystemWebViewKitModule](https://grab.github.io/superapp-sdk/classes/SystemWebViewKitModule.html)** — Handle system WebView operations and external browser redirections
|
|
143
|
-
|
|
144
|
-
- **[UserAttributesModule](https://grab.github.io/superapp-sdk/classes/UserAttributesModule.html)** — Access user attribute data
|
|
145
|
-
|
|
146
|
-
> **Important:** Always call `ScopeModule.reloadScopes()` after an OAuth redirect to load the latest permissions from GrabID. Without this, module methods may return 403 errors even when permissions have been granted.
|
|
147
|
-
|
|
148
|
-
## Response Status Codes
|
|
149
|
-
|
|
150
|
-
The SDK uses HTTP-style status codes for all responses:
|
|
151
|
-
|
|
152
|
-
| Code | Type | Description |
|
|
153
|
-
| ----- | ----------------- | --------------------------------------------------- |
|
|
154
|
-
| `200` | OK | Request successful, `result` contains response data |
|
|
155
|
-
| `204` | No Content | Request successful, no data returned |
|
|
156
|
-
| `302` | Redirect | OAuth redirect in progress |
|
|
157
|
-
| `400` | Bad Request | Invalid request parameters |
|
|
158
|
-
| `401` | Unauthorized | Authentication required |
|
|
159
|
-
| `403` | Forbidden | Insufficient permissions for this operation |
|
|
160
|
-
| `404` | Not Found | Resource not found |
|
|
161
|
-
| `424` | Failed Dependency | Underlying native request failed |
|
|
162
|
-
| `426` | Upgrade Required | Requires newer Grab app version |
|
|
163
|
-
| `500` | Internal Error | Unexpected SDK error |
|
|
164
|
-
| `501` | Not Implemented | Method requires Grab SuperApp environment |
|
|
165
|
-
|
|
166
|
-
## Type Guards
|
|
167
|
-
|
|
168
|
-
The SDK provides type guards for response validation:
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
import { isSuccess, isErrorResponse, isClientError, isServerError } from '@grabjs/superapp-sdk';
|
|
172
|
-
|
|
173
|
-
const response = await someModule.someMethod();
|
|
174
|
-
|
|
175
|
-
if (isSuccess(response)) {
|
|
176
|
-
// TypeScript knows response.result is available
|
|
177
|
-
console.log(response.result);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (isErrorResponse(response)) {
|
|
181
|
-
// TypeScript knows response.error is available
|
|
182
|
-
console.error(response.error);
|
|
183
|
-
}
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
## Best Practices
|
|
187
|
-
|
|
188
|
-
2. **Handle all status codes** in your switch statements, including unexpected ones.
|
|
189
|
-
|
|
190
|
-
3. **Use type guards** for cleaner response handling and better type inference.
|
|
191
|
-
|
|
192
|
-
4. **Call `reloadScopes()` when your MiniApp launches and after OAuth** before accessing protected resources.
|
|
193
|
-
|
|
194
|
-
5. **Unsubscribe from streams** when your component unmounts or you no longer need updates.
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
[@grabjs/superapp-sdk](../globals.md) / BaseModule
|
|
2
|
-
|
|
3
|
-
# Class: BaseModule
|
|
4
|
-
|
|
5
|
-
Base class for all JSBridge modules.
|
|
6
|
-
|
|
7
|
-
## Remarks
|
|
8
|
-
|
|
9
|
-
On construction, the class wraps the JSBridge module on `window` (e.g., `WrappedContainerModule`).
|
|
10
|
-
This code must run on the Grab SuperApp's webview to function correctly.
|
|
11
|
-
|
|
12
|
-
## Extended by
|
|
13
|
-
|
|
14
|
-
- [`CameraModule`](CameraModule.md)
|
|
15
|
-
- [`CheckoutModule`](CheckoutModule.md)
|
|
16
|
-
- [`ContainerModule`](ContainerModule.md)
|
|
17
|
-
- [`DeviceCapabilityModule`](DeviceCapabilityModule.md)
|
|
18
|
-
- [`FileModule`](FileModule.md)
|
|
19
|
-
- [`IdentityModule`](IdentityModule.md)
|
|
20
|
-
- [`LocaleModule`](LocaleModule.md)
|
|
21
|
-
- [`LocationModule`](LocationModule.md)
|
|
22
|
-
- [`MediaModule`](MediaModule.md)
|
|
23
|
-
- [`PlatformModule`](PlatformModule.md)
|
|
24
|
-
- [`ProfileModule`](ProfileModule.md)
|
|
25
|
-
- [`ScopeModule`](ScopeModule.md)
|
|
26
|
-
- [`StorageModule`](StorageModule.md)
|
|
27
|
-
- [`SystemWebViewKitModule`](SystemWebViewKitModule.md)
|
|
28
|
-
- [`UserAttributesModule`](UserAttributesModule.md)
|
|
29
|
-
|
|
30
|
-
## Constructors
|
|
31
|
-
|
|
32
|
-
### Constructor
|
|
33
|
-
|
|
34
|
-
> **new BaseModule**(`moduleName`: `string`): `BaseModule`
|
|
35
|
-
|
|
36
|
-
Creates a new module instance and wraps it on the global `window` object.
|
|
37
|
-
|
|
38
|
-
#### Parameters
|
|
39
|
-
|
|
40
|
-
##### moduleName
|
|
41
|
-
|
|
42
|
-
`string`
|
|
43
|
-
|
|
44
|
-
The name of the module (e.g., "ContainerModule", "ProfileModule").
|
|
45
|
-
|
|
46
|
-
#### Returns
|
|
47
|
-
|
|
48
|
-
`BaseModule`
|
|
49
|
-
|
|
50
|
-
#### Throws
|
|
51
|
-
|
|
52
|
-
Error when the bridge SDK fails to wrap the module.
|
|
53
|
-
|
|
54
|
-
## Methods
|
|
55
|
-
|
|
56
|
-
### invoke()
|
|
57
|
-
|
|
58
|
-
> **invoke**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): `Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
59
|
-
|
|
60
|
-
Invokes a JSBridge method with optional app validation and response transformation.
|
|
61
|
-
|
|
62
|
-
#### Type Parameters
|
|
63
|
-
|
|
64
|
-
##### T
|
|
65
|
-
|
|
66
|
-
`T`
|
|
67
|
-
|
|
68
|
-
#### Parameters
|
|
69
|
-
|
|
70
|
-
##### options
|
|
71
|
-
|
|
72
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
73
|
-
|
|
74
|
-
The invoke options including method name, params, validation, and transformation.
|
|
75
|
-
|
|
76
|
-
#### Returns
|
|
77
|
-
|
|
78
|
-
`Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
79
|
-
|
|
80
|
-
A promise resolving to the JSBridge response.
|
|
81
|
-
|
|
82
|
-
#### Remarks
|
|
83
|
-
|
|
84
|
-
- Always checks if running in Grab app (returns 501 if not).
|
|
85
|
-
- When `isSupported` returns false, returns 426 (Upgrade Required).
|
|
86
|
-
- When `transformResponse` is provided, applies it to successful responses.
|
|
87
|
-
- All errors are reported via the `status_code` field; this method never rejects.
|
|
88
|
-
- For streaming methods, use `invokeStream` instead.
|
|
89
|
-
|
|
90
|
-
***
|
|
91
|
-
|
|
92
|
-
### invokeStream()
|
|
93
|
-
|
|
94
|
-
> **invokeStream**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): [`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
95
|
-
|
|
96
|
-
Invokes a JSBridge streaming method that returns a `BridgeStream`.
|
|
97
|
-
|
|
98
|
-
#### Type Parameters
|
|
99
|
-
|
|
100
|
-
##### T
|
|
101
|
-
|
|
102
|
-
`T`
|
|
103
|
-
|
|
104
|
-
#### Parameters
|
|
105
|
-
|
|
106
|
-
##### options
|
|
107
|
-
|
|
108
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
109
|
-
|
|
110
|
-
The invoke options including method name, params, and validation.
|
|
111
|
-
|
|
112
|
-
#### Returns
|
|
113
|
-
|
|
114
|
-
[`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
115
|
-
|
|
116
|
-
A `BridgeStream` for receiving continuous data from the JSBridge.
|
|
117
|
-
|
|
118
|
-
#### Remarks
|
|
119
|
-
|
|
120
|
-
- Always checks if running in Grab app (returns 501 error response if not).
|
|
121
|
-
- When `isSupported` returns false, returns 426 error response.
|
|
122
|
-
- Returns a `BridgeStream` that can be subscribed to or awaited for the first value.
|
|
123
|
-
- All errors are reported via error responses in the stream; this method never rejects.
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
[@grabjs/superapp-sdk](../globals.md) / CameraModule
|
|
2
|
-
|
|
3
|
-
# Class: CameraModule
|
|
4
|
-
|
|
5
|
-
JSBridge module for accessing the device camera.
|
|
6
|
-
|
|
7
|
-
## Remarks
|
|
8
|
-
|
|
9
|
-
Provides access to native camera functionality including QR code scanning.
|
|
10
|
-
This code must run on the Grab SuperApp's webview to function correctly.
|
|
11
|
-
|
|
12
|
-
## Examples
|
|
13
|
-
|
|
14
|
-
**ES Module:**
|
|
15
|
-
```typescript
|
|
16
|
-
import { CameraModule } from '@grabjs/superapp-sdk';
|
|
17
|
-
const cameraModule = new CameraModule();
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
**CDN (UMD):**
|
|
21
|
-
```html
|
|
22
|
-
<script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
23
|
-
<script>
|
|
24
|
-
const cameraModule = new SuperAppSDK.CameraModule();
|
|
25
|
-
</script>
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## No Inherit Doc
|
|
29
|
-
|
|
30
|
-
## Extends
|
|
31
|
-
|
|
32
|
-
- [`BaseModule`](BaseModule.md)
|
|
33
|
-
|
|
34
|
-
## Constructors
|
|
35
|
-
|
|
36
|
-
### Constructor
|
|
37
|
-
|
|
38
|
-
> **new CameraModule**(): `CameraModule`
|
|
39
|
-
|
|
40
|
-
#### Returns
|
|
41
|
-
|
|
42
|
-
`CameraModule`
|
|
43
|
-
|
|
44
|
-
#### Overrides
|
|
45
|
-
|
|
46
|
-
[`BaseModule`](BaseModule.md).[`constructor`](BaseModule.md#constructor)
|
|
47
|
-
|
|
48
|
-
## Methods
|
|
49
|
-
|
|
50
|
-
### invoke()
|
|
51
|
-
|
|
52
|
-
> **invoke**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): `Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
53
|
-
|
|
54
|
-
Invokes a JSBridge method with optional app validation and response transformation.
|
|
55
|
-
|
|
56
|
-
#### Type Parameters
|
|
57
|
-
|
|
58
|
-
##### T
|
|
59
|
-
|
|
60
|
-
`T`
|
|
61
|
-
|
|
62
|
-
#### Parameters
|
|
63
|
-
|
|
64
|
-
##### options
|
|
65
|
-
|
|
66
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
67
|
-
|
|
68
|
-
The invoke options including method name, params, validation, and transformation.
|
|
69
|
-
|
|
70
|
-
#### Returns
|
|
71
|
-
|
|
72
|
-
`Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
73
|
-
|
|
74
|
-
A promise resolving to the JSBridge response.
|
|
75
|
-
|
|
76
|
-
#### Remarks
|
|
77
|
-
|
|
78
|
-
- Always checks if running in Grab app (returns 501 if not).
|
|
79
|
-
- When `isSupported` returns false, returns 426 (Upgrade Required).
|
|
80
|
-
- When `transformResponse` is provided, applies it to successful responses.
|
|
81
|
-
- All errors are reported via the `status_code` field; this method never rejects.
|
|
82
|
-
- For streaming methods, use `invokeStream` instead.
|
|
83
|
-
|
|
84
|
-
#### Inherited from
|
|
85
|
-
|
|
86
|
-
[`BaseModule`](BaseModule.md).[`invoke`](BaseModule.md#invoke)
|
|
87
|
-
|
|
88
|
-
***
|
|
89
|
-
|
|
90
|
-
### invokeStream()
|
|
91
|
-
|
|
92
|
-
> **invokeStream**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): [`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
93
|
-
|
|
94
|
-
Invokes a JSBridge streaming method that returns a `BridgeStream`.
|
|
95
|
-
|
|
96
|
-
#### Type Parameters
|
|
97
|
-
|
|
98
|
-
##### T
|
|
99
|
-
|
|
100
|
-
`T`
|
|
101
|
-
|
|
102
|
-
#### Parameters
|
|
103
|
-
|
|
104
|
-
##### options
|
|
105
|
-
|
|
106
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
107
|
-
|
|
108
|
-
The invoke options including method name, params, and validation.
|
|
109
|
-
|
|
110
|
-
#### Returns
|
|
111
|
-
|
|
112
|
-
[`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
113
|
-
|
|
114
|
-
A `BridgeStream` for receiving continuous data from the JSBridge.
|
|
115
|
-
|
|
116
|
-
#### Remarks
|
|
117
|
-
|
|
118
|
-
- Always checks if running in Grab app (returns 501 error response if not).
|
|
119
|
-
- When `isSupported` returns false, returns 426 error response.
|
|
120
|
-
- Returns a `BridgeStream` that can be subscribed to or awaited for the first value.
|
|
121
|
-
- All errors are reported via error responses in the stream; this method never rejects.
|
|
122
|
-
|
|
123
|
-
#### Inherited from
|
|
124
|
-
|
|
125
|
-
[`BaseModule`](BaseModule.md).[`invokeStream`](BaseModule.md#invokestream)
|
|
126
|
-
|
|
127
|
-
***
|
|
128
|
-
|
|
129
|
-
### scanQRCode()
|
|
130
|
-
|
|
131
|
-
> **scanQRCode**(`request`: [`ScanQRCodeRequest`](../type-aliases/ScanQRCodeRequest.md)): `Promise`\<[`ScanQRCodeResponse`](../type-aliases/ScanQRCodeResponse.md)\>
|
|
132
|
-
|
|
133
|
-
Opens the native camera to scan a QR code.
|
|
134
|
-
|
|
135
|
-
#### Parameters
|
|
136
|
-
|
|
137
|
-
##### request
|
|
138
|
-
|
|
139
|
-
[`ScanQRCodeRequest`](../type-aliases/ScanQRCodeRequest.md)
|
|
140
|
-
|
|
141
|
-
Configuration for the QR code scanning, including the title to display.
|
|
142
|
-
|
|
143
|
-
#### Returns
|
|
144
|
-
|
|
145
|
-
`Promise`\<[`ScanQRCodeResponse`](../type-aliases/ScanQRCodeResponse.md)\>
|
|
146
|
-
|
|
147
|
-
The QR code scanning result, containing the scanned code on success or status information.
|
|
148
|
-
|
|
149
|
-
#### Example
|
|
150
|
-
|
|
151
|
-
**Simple usage**
|
|
152
|
-
```typescript
|
|
153
|
-
// Initialize the camera module
|
|
154
|
-
const cameraModule = new CameraModule();
|
|
155
|
-
|
|
156
|
-
// Scan the QR code
|
|
157
|
-
const response = await cameraModule.scanQRCode({ title: 'Scan Payment QR' });
|
|
158
|
-
switch (response.status_code) {
|
|
159
|
-
case 200:
|
|
160
|
-
console.log('QR Code scanned:', response.result.qrCode);
|
|
161
|
-
break;
|
|
162
|
-
case 204:
|
|
163
|
-
console.log('User cancelled QR code scanning');
|
|
164
|
-
break;
|
|
165
|
-
case 400:
|
|
166
|
-
console.log('Bad request:', response.error);
|
|
167
|
-
break;
|
|
168
|
-
case 403:
|
|
169
|
-
console.log('Camera permission is not enabled for the Grab app');
|
|
170
|
-
break;
|
|
171
|
-
case 501:
|
|
172
|
-
console.log('Not in Grab app:', response.error);
|
|
173
|
-
break;
|
|
174
|
-
default:
|
|
175
|
-
console.log('Unexpected status code:', response);
|
|
176
|
-
}
|
|
177
|
-
```
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
[@grabjs/superapp-sdk](../globals.md) / CheckoutModule
|
|
2
|
-
|
|
3
|
-
# Class: CheckoutModule
|
|
4
|
-
|
|
5
|
-
JSBridge module for triggering native payment flows.
|
|
6
|
-
|
|
7
|
-
## Remarks
|
|
8
|
-
|
|
9
|
-
Invokes the native Grab checkout/pay component to process payments.
|
|
10
|
-
This code must run on the Grab SuperApp's webview to function correctly.
|
|
11
|
-
|
|
12
|
-
## Examples
|
|
13
|
-
|
|
14
|
-
**ES Module:**
|
|
15
|
-
```typescript
|
|
16
|
-
import { CheckoutModule } from '@grabjs/superapp-sdk';
|
|
17
|
-
const checkoutModule = new CheckoutModule();
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
**CDN (UMD):**
|
|
21
|
-
```html
|
|
22
|
-
<script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
23
|
-
<script>
|
|
24
|
-
const checkoutModule = new SuperAppSDK.CheckoutModule();
|
|
25
|
-
</script>
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## No Inherit Doc
|
|
29
|
-
|
|
30
|
-
## Extends
|
|
31
|
-
|
|
32
|
-
- [`BaseModule`](BaseModule.md)
|
|
33
|
-
|
|
34
|
-
## Constructors
|
|
35
|
-
|
|
36
|
-
### Constructor
|
|
37
|
-
|
|
38
|
-
> **new CheckoutModule**(): `CheckoutModule`
|
|
39
|
-
|
|
40
|
-
#### Returns
|
|
41
|
-
|
|
42
|
-
`CheckoutModule`
|
|
43
|
-
|
|
44
|
-
#### Overrides
|
|
45
|
-
|
|
46
|
-
[`BaseModule`](BaseModule.md).[`constructor`](BaseModule.md#constructor)
|
|
47
|
-
|
|
48
|
-
## Methods
|
|
49
|
-
|
|
50
|
-
### invoke()
|
|
51
|
-
|
|
52
|
-
> **invoke**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): `Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
53
|
-
|
|
54
|
-
Invokes a JSBridge method with optional app validation and response transformation.
|
|
55
|
-
|
|
56
|
-
#### Type Parameters
|
|
57
|
-
|
|
58
|
-
##### T
|
|
59
|
-
|
|
60
|
-
`T`
|
|
61
|
-
|
|
62
|
-
#### Parameters
|
|
63
|
-
|
|
64
|
-
##### options
|
|
65
|
-
|
|
66
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
67
|
-
|
|
68
|
-
The invoke options including method name, params, validation, and transformation.
|
|
69
|
-
|
|
70
|
-
#### Returns
|
|
71
|
-
|
|
72
|
-
`Promise`\<[`BridgeResponse`](../type-aliases/BridgeResponse.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>\>
|
|
73
|
-
|
|
74
|
-
A promise resolving to the JSBridge response.
|
|
75
|
-
|
|
76
|
-
#### Remarks
|
|
77
|
-
|
|
78
|
-
- Always checks if running in Grab app (returns 501 if not).
|
|
79
|
-
- When `isSupported` returns false, returns 426 (Upgrade Required).
|
|
80
|
-
- When `transformResponse` is provided, applies it to successful responses.
|
|
81
|
-
- All errors are reported via the `status_code` field; this method never rejects.
|
|
82
|
-
- For streaming methods, use `invokeStream` instead.
|
|
83
|
-
|
|
84
|
-
#### Inherited from
|
|
85
|
-
|
|
86
|
-
[`BaseModule`](BaseModule.md).[`invoke`](BaseModule.md#invoke)
|
|
87
|
-
|
|
88
|
-
***
|
|
89
|
-
|
|
90
|
-
### invokeStream()
|
|
91
|
-
|
|
92
|
-
> **invokeStream**\<`T`\>(`options`: [`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>): [`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
93
|
-
|
|
94
|
-
Invokes a JSBridge streaming method that returns a `BridgeStream`.
|
|
95
|
-
|
|
96
|
-
#### Type Parameters
|
|
97
|
-
|
|
98
|
-
##### T
|
|
99
|
-
|
|
100
|
-
`T`
|
|
101
|
-
|
|
102
|
-
#### Parameters
|
|
103
|
-
|
|
104
|
-
##### options
|
|
105
|
-
|
|
106
|
-
[`InvokeOptions`](../interfaces/InvokeOptions.md)\<`T`\>
|
|
107
|
-
|
|
108
|
-
The invoke options including method name, params, and validation.
|
|
109
|
-
|
|
110
|
-
#### Returns
|
|
111
|
-
|
|
112
|
-
[`BridgeStream`](../type-aliases/BridgeStream.md)\<keyof [`StatusCodeMap`](../type-aliases/StatusCodeMap.md)\<`unknown`\>, `T`\>
|
|
113
|
-
|
|
114
|
-
A `BridgeStream` for receiving continuous data from the JSBridge.
|
|
115
|
-
|
|
116
|
-
#### Remarks
|
|
117
|
-
|
|
118
|
-
- Always checks if running in Grab app (returns 501 error response if not).
|
|
119
|
-
- When `isSupported` returns false, returns 426 error response.
|
|
120
|
-
- Returns a `BridgeStream` that can be subscribed to or awaited for the first value.
|
|
121
|
-
- All errors are reported via error responses in the stream; this method never rejects.
|
|
122
|
-
|
|
123
|
-
#### Inherited from
|
|
124
|
-
|
|
125
|
-
[`BaseModule`](BaseModule.md).[`invokeStream`](BaseModule.md#invokestream)
|
|
126
|
-
|
|
127
|
-
***
|
|
128
|
-
|
|
129
|
-
### triggerCheckout()
|
|
130
|
-
|
|
131
|
-
> **triggerCheckout**(`request`: [`TriggerCheckoutRequest`](../type-aliases/TriggerCheckoutRequest.md)): `Promise`\<[`TriggerCheckoutResponse`](../type-aliases/TriggerCheckoutResponse.md)\>
|
|
132
|
-
|
|
133
|
-
Triggers the native checkout flow for payment processing.
|
|
134
|
-
|
|
135
|
-
#### Parameters
|
|
136
|
-
|
|
137
|
-
##### request
|
|
138
|
-
|
|
139
|
-
[`TriggerCheckoutRequest`](../type-aliases/TriggerCheckoutRequest.md)
|
|
140
|
-
|
|
141
|
-
Payment transaction details, including the transaction ID and amount.
|
|
142
|
-
|
|
143
|
-
#### Returns
|
|
144
|
-
|
|
145
|
-
`Promise`\<[`TriggerCheckoutResponse`](../type-aliases/TriggerCheckoutResponse.md)\>
|
|
146
|
-
|
|
147
|
-
The checkout result, containing transaction status (success, failure, or pending) and transaction details.
|
|
148
|
-
|
|
149
|
-
#### Example
|
|
150
|
-
|
|
151
|
-
**Simple usage**
|
|
152
|
-
```typescript
|
|
153
|
-
// Initialize the checkout module
|
|
154
|
-
const checkoutModule = new CheckoutModule();
|
|
155
|
-
|
|
156
|
-
// Trigger checkout with response params
|
|
157
|
-
const transactionResponse = await createTransaction(); // Call POST /grabpay/partner/v4/charge/init from Grab API to create a transaction
|
|
158
|
-
const response = await checkoutModule.triggerCheckout(transactionResponse);
|
|
159
|
-
|
|
160
|
-
switch (response.status_code) {
|
|
161
|
-
case 200:
|
|
162
|
-
if (response.result.status === 'success') {
|
|
163
|
-
console.log('Transaction successful:', response.result.transactionID);
|
|
164
|
-
} else if (response.result.status === 'failure') {
|
|
165
|
-
console.log('Transaction failed:', response.result.errorMessage, response.result.errorCode);
|
|
166
|
-
} else if (response.result.status === 'pending') {
|
|
167
|
-
console.log('Transaction pending:', response.result.transactionID);
|
|
168
|
-
} else if (response.result.status === 'userInitiatedCancel') {
|
|
169
|
-
console.log('User cancelled the checkout');
|
|
170
|
-
}
|
|
171
|
-
break;
|
|
172
|
-
case 400:
|
|
173
|
-
console.log('Transaction failed:', response.error);
|
|
174
|
-
break;
|
|
175
|
-
case 501:
|
|
176
|
-
console.log('Not in Grab app:', response.error);
|
|
177
|
-
break;
|
|
178
|
-
default:
|
|
179
|
-
console.log('Unexpected status code:', response);
|
|
180
|
-
}
|
|
181
|
-
```
|