@salesforce/afv-skills 1.12.0 → 1.14.0
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/package.json +3 -3
- package/skills/building-mobile-apps/SKILL.md +70 -0
- package/skills/building-ui-bundle-app/SKILL.md +33 -8
- package/skills/generating-custom-application/SKILL.md +1 -1
- package/skills/generating-ui-bundle-custom-app/SKILL.md +93 -0
- package/skills/generating-ui-bundle-custom-app/docs/configure-metadata-custom-application.md +70 -0
- package/skills/generating-ui-bundle-metadata/SKILL.md +39 -1
- package/skills/reviewing-lwc-mobile-offline/SKILL.md +168 -0
- package/skills/reviewing-lwc-mobile-offline/references/grounding.md +7 -0
- package/skills/reviewing-lwc-mobile-offline/references/inline-graphql.md +43 -0
- package/skills/reviewing-lwc-mobile-offline/references/komaci-eslint.md +125 -0
- package/skills/reviewing-lwc-mobile-offline/references/lwc-if.md +78 -0
- package/skills/reviewing-lwc-mobile-offline/scripts/komaci.config.mjs +18 -0
- package/skills/reviewing-lwc-mobile-offline/scripts/package.json +10 -0
- package/skills/reviewing-lwc-mobile-offline/scripts/run-komaci.sh +69 -0
- package/skills/using-mobile-native-capabilities/SKILL.md +182 -0
- package/skills/using-mobile-native-capabilities/references/app-review.md +68 -0
- package/skills/using-mobile-native-capabilities/references/ar-space-capture.md +125 -0
- package/skills/using-mobile-native-capabilities/references/barcode-scanner.md +219 -0
- package/skills/using-mobile-native-capabilities/references/base-capability.md +22 -0
- package/skills/using-mobile-native-capabilities/references/biometrics.md +90 -0
- package/skills/using-mobile-native-capabilities/references/calendar.md +213 -0
- package/skills/using-mobile-native-capabilities/references/contacts.md +232 -0
- package/skills/using-mobile-native-capabilities/references/document-scanner.md +342 -0
- package/skills/using-mobile-native-capabilities/references/geofencing.md +123 -0
- package/skills/using-mobile-native-capabilities/references/location.md +158 -0
- package/skills/using-mobile-native-capabilities/references/mobile-capabilities.md +30 -0
- package/skills/using-mobile-native-capabilities/references/nfc.md +181 -0
- package/skills/using-mobile-native-capabilities/references/payments.md +95 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Location Service Grounding Context
|
|
2
|
+
|
|
3
|
+
The following content provides grounding information for generating a Salesforce LWC that leverages location facilities on mobile devices. Specifically, this context will cover the API types and methods available to leverage the location API of the mobile device, within the LWC.
|
|
4
|
+
|
|
5
|
+
## Location Service API
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
* For full license text, see the LICENSE.txt file
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { BaseCapability } from '../BaseCapability.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Use this factory function to get an instance of {@linkcode LocationService}.
|
|
18
|
+
* @returns An instance of {@linkcode LocationService}.
|
|
19
|
+
*/
|
|
20
|
+
export function getLocationService(): LocationService;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Access and track location in a Lightning web component.
|
|
24
|
+
* @see {@link https://developer.salesforce.com/docs/platform/lwc/guide/reference-lightning-locationservice.html|LocationService API}
|
|
25
|
+
*/
|
|
26
|
+
export interface LocationService extends BaseCapability {
|
|
27
|
+
/**
|
|
28
|
+
* Gets the device’s current geolocation.
|
|
29
|
+
* @param options A {@linkcode LocationServiceOptions} object to configure the location request.
|
|
30
|
+
* @returns A Promise object that resolves as a {@linkcode LocationResult} object with the device location details.
|
|
31
|
+
*/
|
|
32
|
+
getCurrentPosition(options?: LocationServiceOptions): Promise<LocationResult>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Subscribes to asynchronous location updates for the mobile device.
|
|
36
|
+
* @param options A {@linkcode LocationServiceOptions} object to configure the location request.
|
|
37
|
+
* @param callback A function to handle location update responses.
|
|
38
|
+
* @returns An integer identifier for the location subscription, which you can use to end the subscription when you want to stop receiving location updates.
|
|
39
|
+
*/
|
|
40
|
+
startWatchingPosition(
|
|
41
|
+
options: LocationServiceOptions | null,
|
|
42
|
+
callback: (result?: LocationResult, failure?: LocationServiceFailure) => void,
|
|
43
|
+
): number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Unsubscribes from location updates for the mobile device.
|
|
47
|
+
* @param watchId An integer identifier for an active location subscription, returned by a call to startWatchingPosition().
|
|
48
|
+
*/
|
|
49
|
+
stopWatchingPosition(watchId: number): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* LocationResult interface.
|
|
54
|
+
*/
|
|
55
|
+
export interface LocationResult {
|
|
56
|
+
/**
|
|
57
|
+
* The physical location.
|
|
58
|
+
*/
|
|
59
|
+
coords: Coordinates;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The time of the location reading, measured in milliseconds since January 1, 1970.
|
|
63
|
+
*/
|
|
64
|
+
timestamp: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* An object representing a specific point located on the planet Earth. Includes velocity details, if available.
|
|
69
|
+
* Includes accuracy information, to the best of the device’s ability to evaluate. Similar to a GeolocationCoordinates in the Geolocation Web API.
|
|
70
|
+
*/
|
|
71
|
+
export interface Coordinates {
|
|
72
|
+
/**
|
|
73
|
+
* The latitude, in degrees. Ranges from -90 to 90.
|
|
74
|
+
*/
|
|
75
|
+
latitude: number;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The longitude, in degrees. Ranges from -180 to 180.
|
|
79
|
+
*/
|
|
80
|
+
longitude: number;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Optional. Accuracy of the location measurement, in meters, as a radius around the measurement.
|
|
84
|
+
*/
|
|
85
|
+
accuracy?: number;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Optional. Meters above sea level.
|
|
89
|
+
*/
|
|
90
|
+
altitude?: number;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Optional. Accuracy of the altitude measurement, in meters.
|
|
94
|
+
*/
|
|
95
|
+
altitudeAccuracy?: number;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Optional. Velocity of motion, if any, in meters per second.
|
|
99
|
+
*/
|
|
100
|
+
speed?: number;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Optional. Accuracy of the speed measurement, in meters.
|
|
104
|
+
*/
|
|
105
|
+
speedAccuracy?: number;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Optional. Direction of motion, in degrees from true north. Ranges from 0 to 360.
|
|
109
|
+
*/
|
|
110
|
+
heading?: number;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Optional. Accuracy of the heading measurement, in degrees.
|
|
114
|
+
*/
|
|
115
|
+
headingAccuracy?: number; // accuracy for the heading in degree
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* An object representing an error that occurred when accessing LocationService features.
|
|
120
|
+
*/
|
|
121
|
+
export interface LocationServiceFailure {
|
|
122
|
+
/**
|
|
123
|
+
* A value representing the reason for a location error.
|
|
124
|
+
*/
|
|
125
|
+
code: LocationServiceFailureCode;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* A string value explaining the reason for the failure. This value is suitable for use in user interface messages. The message is provided in English, and isn’t localized.
|
|
129
|
+
*/
|
|
130
|
+
message: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Possible failure codes.
|
|
135
|
+
*/
|
|
136
|
+
export type LocationServiceFailureCode =
|
|
137
|
+
| 'LOCATION_SERVICE_DISABLED' // Android only - The code when the location service is disabled on the device, not just for this app.
|
|
138
|
+
| 'USER_DENIED_PERMISSION' // Permission was denied by user when prompt, could ask again
|
|
139
|
+
| 'USER_DISABLED_PERMISSION' // Android: permission was denied along "don't ask again" when prompt, will need to go app setting to turn on. iOS: permission was disabled by the user and will need to be turned on in settings
|
|
140
|
+
| 'SERVICE_NOT_ENABLED' // The service is not enabled and therefore cannot be used.
|
|
141
|
+
| 'UNKNOWN_REASON'; // An error happened in the Native Code that is not permission based. Will give more information in the LocationServiceFailure message.
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* An object representing configuration details for a location service session.
|
|
145
|
+
*/
|
|
146
|
+
export interface LocationServiceOptions {
|
|
147
|
+
/**
|
|
148
|
+
* Whether to use high accuracy mode when determining location. Set to true to prioritize location accuracy.
|
|
149
|
+
* Set to false to prioritize battery life and response time.
|
|
150
|
+
*/
|
|
151
|
+
enableHighAccuracy: boolean;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Optional, and only for Android implementations. The text shown in the UI when the device prompts the user to grant permission for your app to use the Android's location service.
|
|
155
|
+
*/
|
|
156
|
+
permissionRationaleText?: string;
|
|
157
|
+
}
|
|
158
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# lightning/mobileCapabilities
|
|
2
|
+
|
|
3
|
+
Module declaration that re-exports every native capability service. Import the factory functions from `lightning/mobileCapabilities` (or the per-service path) when authoring an LWC.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
/*
|
|
7
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
8
|
+
* All rights reserved.
|
|
9
|
+
* For full license text, see the LICENSE.txt file
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Mobile capabilities are JavaScript APIs that make mobile hardware and platform (operating system) features available in JavaScript. They require access to device hardware, platform APIs, or both.
|
|
14
|
+
* Mobile capability APIs are available only when a Lightning web component runs in a supported mobile app on a mobile device.
|
|
15
|
+
* @see {@link https://developer.salesforce.com/docs/platform/lwc/guide/reference-lightning-mobilecapabilities.html|lightning/mobileCapabilities Module}
|
|
16
|
+
*/
|
|
17
|
+
declare module 'lightning/mobileCapabilities' {
|
|
18
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/AppReviewService/appReviewService.js';
|
|
19
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/ARSpaceCapture/arSpaceCapture.js';
|
|
20
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/BarcodeScanner/barcodeScanner.js';
|
|
21
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/BiometricsService/biometricsService.js';
|
|
22
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/CalendarService/calendarService.js';
|
|
23
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/ContactsService/contactsService.js';
|
|
24
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/DocumentScanner/documentScanner.js';
|
|
25
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/GeofencingService/geofencingService.js';
|
|
26
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/LocationService/locationService.js';
|
|
27
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/NfcService/nfcService.js';
|
|
28
|
+
export * from '@salesforce/lightning-types/dist/lightning/mobileCapabilities/PaymentsService/paymentsService.js';
|
|
29
|
+
}
|
|
30
|
+
```
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# NFC Service Grounding Context
|
|
2
|
+
|
|
3
|
+
The following content provides grounding information for generating a Salesforce LWC that leverages NFC facilities on mobile devices. Specifically, this context will cover the API types and methods available to leverage the NFC API of the mobile device, within the LWC.
|
|
4
|
+
|
|
5
|
+
## NFC Service API
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
* For full license text, see the LICENSE.txt file
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { BaseCapability } from '../BaseCapability.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Use this factory function to get an instance of {@linkcode NfcService}.
|
|
18
|
+
* @returns An instance of {@linkcode NfcService}.
|
|
19
|
+
*/
|
|
20
|
+
export function getNfcService(): NfcService;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Interact with NFC tags from a Lightning web component.
|
|
24
|
+
* @see {@link https://developer.salesforce.com/docs/platform/lwc/guide/reference-lightning-nfcservice.html|NFCService API}
|
|
25
|
+
*/
|
|
26
|
+
export interface NfcService extends BaseCapability {
|
|
27
|
+
/**
|
|
28
|
+
* Reads an NFC tag and returns the data read from it.
|
|
29
|
+
* @param options An {@linkcode NFCServiceOptions} object to configure the {@linkcode NfcService} request.
|
|
30
|
+
* @returns A Promise object that resolves to an array containing a single {@linkcode NFCMessage} object.
|
|
31
|
+
*/
|
|
32
|
+
read(options?: NFCServiceOptions): Promise<NFCMessage[]>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Erase the contents of an NFC tag.
|
|
36
|
+
* @param options An {@linkcode NFCServiceOptions} object to configure the {@linkcode NfcService} request.
|
|
37
|
+
* @returns If successful, the OS returns a Promise object that resolves to null.
|
|
38
|
+
*/
|
|
39
|
+
erase(options?: NFCServiceOptions): Promise<null>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Write text to an NFC tag.
|
|
43
|
+
* @param payloads An array of {@linkcode NFCRecord} objects containing the raw bytes to be written.
|
|
44
|
+
* @param options An {@linkcode NFCServiceOptions} object to configure the {@linkcode NfcService} request.
|
|
45
|
+
* @returns If successful, the OS returns a Promise object that resolves to null.
|
|
46
|
+
*/
|
|
47
|
+
write(payloads: NFCRecord[], options?: NFCServiceOptions): Promise<null>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Given a text payload, this function creates a properly formatted {@linkcode NFCRecord} to be written to an NFC tag.
|
|
51
|
+
* @param payload A {@link TextPayload} object, which contains the text to be converted to an NFC record.
|
|
52
|
+
* @returns A Promise object that resolves to an {@linkcode NFCRecord} object.
|
|
53
|
+
*/
|
|
54
|
+
createTextRecord(payload: TextPayload): Promise<NFCRecord>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Given a URI string payload, this function creates a properly formatted {@linkcode NFCRecord} to be written to an NFC tag.
|
|
58
|
+
* @param payload The URI to be converted to an NFC record.
|
|
59
|
+
* @returns A Promise object that resolves to an {@linkcode NFCRecord} object.
|
|
60
|
+
*/
|
|
61
|
+
createUriRecord(payload: string): Promise<NFCRecord>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* An object returned by an NFC read() operation.
|
|
66
|
+
*/
|
|
67
|
+
export interface NFCMessage {
|
|
68
|
+
/**
|
|
69
|
+
* The size, in number of bytes, of the data received by the read() operation.
|
|
70
|
+
*/
|
|
71
|
+
totalByteLength: number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* An array containing a single {@linkcode NFCMessageRecord} object, which in turn contains the payload from the NFC tag.
|
|
75
|
+
*/
|
|
76
|
+
records: NFCMessageRecord[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* An object within an {@linkcode NFCMessage} object, containing the payload read from an NFC tag.
|
|
81
|
+
*/
|
|
82
|
+
export interface NFCMessageRecord {
|
|
83
|
+
/**
|
|
84
|
+
* Contains the parsed values of the raw data read from the NFC tag. The parsing operation
|
|
85
|
+
* only occurs if the value of the typeNameFormat property on the {@linkcode NFCRecord} object is "WELLKNOWN".
|
|
86
|
+
* Otherwise, this property’s value is null.
|
|
87
|
+
*/
|
|
88
|
+
parsed: NFCRecord;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Contains the raw base64 data string read from the NFC tag.
|
|
92
|
+
*/
|
|
93
|
+
raw: NFCRecord;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* An object containing one record of data from an NFC tag scan.
|
|
98
|
+
*/
|
|
99
|
+
export interface NFCRecord {
|
|
100
|
+
/**
|
|
101
|
+
* The Type Name Format field of the payload, as defined by the NDEF specification.
|
|
102
|
+
*/
|
|
103
|
+
typeNameFormat: TypeNameFormat;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The type of the payload, as defined by the NDEF specification.
|
|
107
|
+
*/
|
|
108
|
+
type: string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The identifier of the payload, as defined by the NDEF specification, or an empty string if no identifier data was present in the tag.
|
|
112
|
+
*/
|
|
113
|
+
identifier: string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The content of the record, encoded in base64 format.
|
|
117
|
+
*/
|
|
118
|
+
payload: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* An object containing raw text input, to be converted into an {@linkcode NFCRecord}.
|
|
123
|
+
*/
|
|
124
|
+
export interface TextPayload {
|
|
125
|
+
/**
|
|
126
|
+
* The raw text payload to be converted.
|
|
127
|
+
*/
|
|
128
|
+
text: string;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The ISO 639-1 language ID of the text.
|
|
132
|
+
*/
|
|
133
|
+
langId: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The following constants are available as properties on an instance of {@linkcode NfcService}. The constants enumerate the accepted values for the associated properties.
|
|
138
|
+
*/
|
|
139
|
+
export type TypeNameFormat = 'ABSOLUTE_URI' | 'EMPTY' | 'EXTERNAL' | 'MEDIA' | 'WELLKNOWN' | 'UNCHANGED' | 'UNKNOWN';
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* An object containing configuration details for an NFC interaction.
|
|
143
|
+
*/
|
|
144
|
+
export interface NFCServiceOptions {
|
|
145
|
+
/**
|
|
146
|
+
* Optional. Provides instructions to display in the user interface. Defaults to no text.
|
|
147
|
+
*/
|
|
148
|
+
instructionText?: string;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Optional. Provides a message to display in the user interface when an NFC operation is successfully completed. Defaults to no text.
|
|
152
|
+
*/
|
|
153
|
+
successText?: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* An object representing an error that occurred when accessing {@linkcode NfcService} features.
|
|
158
|
+
*/
|
|
159
|
+
export interface NFCServiceFailure {
|
|
160
|
+
/**
|
|
161
|
+
* A value representing the reason for an error. See {@linkcode NFCServiceFailureCode} for the list of possible values.
|
|
162
|
+
*/
|
|
163
|
+
code: NFCServiceFailureCode;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A string value describing the reason for the failure. This value is suitable for use in user interface messages. The message is provided in English and isn’t localized.
|
|
167
|
+
*/
|
|
168
|
+
message: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Correlates with the code property on the {@linkcode NFCServiceFailure} object.
|
|
173
|
+
*/
|
|
174
|
+
export type NFCServiceFailureCode =
|
|
175
|
+
| 'USER_DISMISSED' // The user dismissed the scanner.
|
|
176
|
+
| 'NFC_NOT_SUPPORTED' // The device doesn’t support NFC capabilities.
|
|
177
|
+
| 'NFC_NOT_ENABLED' // The device NFC feature is turned off.
|
|
178
|
+
| 'TAG_EMPTY' // The NFC tag contains no data to be read.
|
|
179
|
+
| 'SERVICE_NOT_ENABLED' // NFCService is not enabled and cannot be used.
|
|
180
|
+
| 'UNKNOWN_REASON'; // An error occurred in the native code that isn’t related to permissions or hardware issues. More information is provided in the NFCServiceFailure message.
|
|
181
|
+
```
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Payments Service Grounding Context
|
|
2
|
+
|
|
3
|
+
The following content provides grounding information for generating a Salesforce LWC that leverages payments facilities on mobile devices. Specifically, this context will cover the API types and methods available to leverage the payments API of the mobile device, within the LWC.
|
|
4
|
+
|
|
5
|
+
## Payments Service API
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
* For full license text, see the LICENSE.txt file
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { BaseCapability } from '../BaseCapability.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Use this factory function to get an instance of {@linkcode PaymentsService}.
|
|
18
|
+
* @returns An instance of {@linkcode PaymentsService}.
|
|
19
|
+
*/
|
|
20
|
+
export function getPaymentsService(): PaymentsService;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* PaymentsService is a Nimbus plugin that allows JavaScript code in a Lightning web component to call functions that launches Stripe's Tap to Pay capabilities.
|
|
24
|
+
*/
|
|
25
|
+
export interface PaymentsService extends BaseCapability {
|
|
26
|
+
/**
|
|
27
|
+
* Process payment.
|
|
28
|
+
* @param options The customization options.
|
|
29
|
+
* @returns A Promise object that resolves to {@linkcode CollectPaymentResult} object.
|
|
30
|
+
*/
|
|
31
|
+
collectPayment(options: CollectPaymentOptions): Promise<CollectPaymentResult>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get the supported payment methods on this device
|
|
35
|
+
* @param options The customization options.
|
|
36
|
+
* @returns A Promise object that resolves to an array containing {@linkcode PaymentMethod} objects.
|
|
37
|
+
*/
|
|
38
|
+
getSupportedPaymentMethods(options: GetSupportedPaymentMethodsOptions): Promise<PaymentMethod[]>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* PaymentMethod values.
|
|
43
|
+
*/
|
|
44
|
+
export type PaymentMethod = 'TAP_TO_PAY' | 'CREDIT_CARD_DETAILS' | 'PAY_VIA_LINK';
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* GetSupportedPaymentMethodsOptions interface.
|
|
48
|
+
*/
|
|
49
|
+
export interface GetSupportedPaymentMethodsOptions {
|
|
50
|
+
countryIsoCode?: string;
|
|
51
|
+
merchantAccountId?: string;
|
|
52
|
+
permissionRationaleText?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* CollectPaymentOptions interface.
|
|
57
|
+
*/
|
|
58
|
+
export interface CollectPaymentOptions {
|
|
59
|
+
amount: number;
|
|
60
|
+
paymentMethod: PaymentMethod;
|
|
61
|
+
currencyIsoCode: string;
|
|
62
|
+
merchantAccountId: string;
|
|
63
|
+
merchantName: string;
|
|
64
|
+
payerAccountId?: string;
|
|
65
|
+
sourceObjectIds?: string[];
|
|
66
|
+
permissionRationaleText?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* CollectPaymentResult interface.
|
|
71
|
+
*/
|
|
72
|
+
export interface CollectPaymentResult {
|
|
73
|
+
gatewayRefId?: string;
|
|
74
|
+
guid?: string;
|
|
75
|
+
paymentGatewayId?: string;
|
|
76
|
+
status?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* PaymentsServiceFailure interface.
|
|
81
|
+
*/
|
|
82
|
+
export interface PaymentsServiceFailure {
|
|
83
|
+
code: PaymentsServiceFailureCode;
|
|
84
|
+
message: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Possible failure codes.
|
|
89
|
+
*/
|
|
90
|
+
export type PaymentsServiceFailureCode =
|
|
91
|
+
| 'USER_DISMISSED' // User cancelled the operation.
|
|
92
|
+
| 'USER_DENIED_PERMISSION' // Permission to access device location is denied.
|
|
93
|
+
| 'SERVICE_NOT_ENABLED' // The service is not enabled and therefore cannot be used.
|
|
94
|
+
| 'UNKNOWN_REASON'; // An error happened in the native code that is not permission based. Will give more information in the PaymentsServiceFailure message.
|
|
95
|
+
```
|