@geophrase/core 1.4.1 → 1.5.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/index.d.ts +22 -3
- package/package.json +1 -1
- package/src/index.js +6 -4
package/index.d.ts
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
|
+
export interface GeophraseAddressDetails {
|
|
2
|
+
city: string;
|
|
3
|
+
state: string;
|
|
4
|
+
digi_pin: string;
|
|
5
|
+
landmark: string;
|
|
6
|
+
latitude: number;
|
|
7
|
+
longitude: number;
|
|
8
|
+
postal_code: number;
|
|
9
|
+
address_type: string;
|
|
10
|
+
address_line_one: string;
|
|
11
|
+
address_line_two: string;
|
|
12
|
+
contact_full_name: string;
|
|
13
|
+
verified_mobile_num: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
1
16
|
export interface GeophraseAddress {
|
|
2
|
-
|
|
3
|
-
|
|
17
|
+
short_code: string;
|
|
18
|
+
short_link: string;
|
|
19
|
+
qr_code: string;
|
|
20
|
+
captured_at: number;
|
|
21
|
+
order_id: string;
|
|
22
|
+
address: GeophraseAddressDetails;
|
|
4
23
|
}
|
|
5
24
|
|
|
6
25
|
export interface GeophraseToken {
|
|
7
|
-
|
|
26
|
+
requestId: string;
|
|
8
27
|
}
|
|
9
28
|
|
|
10
29
|
export interface GeophraseError {
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -59,7 +59,6 @@ class Geophrase {
|
|
|
59
59
|
|
|
60
60
|
// 6. Pre-compute the secure widget URL
|
|
61
61
|
const url = new URL(this.widgetOrigin);
|
|
62
|
-
if (this.orderId) url.searchParams.append('order-id', this.orderId);
|
|
63
62
|
if (this.phone) url.searchParams.append('phone', this.phone);
|
|
64
63
|
if (this.theme) url.searchParams.append('theme', this.theme);
|
|
65
64
|
this.widgetUrl = url.toString();
|
|
@@ -309,13 +308,13 @@ class Geophrase {
|
|
|
309
308
|
// the raw token to the merchant for backend exchange.
|
|
310
309
|
if (this.mode === 'server') {
|
|
311
310
|
this.close();
|
|
312
|
-
this._safeCall(this.onSuccess, {
|
|
311
|
+
this._safeCall(this.onSuccess, { requestId: data.requestId });
|
|
313
312
|
return;
|
|
314
313
|
}
|
|
315
314
|
|
|
316
315
|
// Client mode: keep the overlay + spinner visible while we exchange
|
|
317
316
|
// the token for the resolved address. Closing now would leave the
|
|
318
|
-
// merchant's page blank for the duration of the API round-trip
|
|
317
|
+
// merchant's page blank for the duration of the API round-trip
|
|
319
318
|
iframe.style.opacity = '0';
|
|
320
319
|
|
|
321
320
|
const controller = new AbortController();
|
|
@@ -325,6 +324,9 @@ class Geophrase {
|
|
|
325
324
|
// merchant sees the modal disappear before their handler runs.
|
|
326
325
|
let callback = null;
|
|
327
326
|
|
|
327
|
+
const payload = { request_id: data.requestId };
|
|
328
|
+
if (this.orderId) payload.order_id = this.orderId;
|
|
329
|
+
|
|
328
330
|
try {
|
|
329
331
|
const response = await fetch(`${this.apiBase}/business/resolve/`, {
|
|
330
332
|
method: 'POST',
|
|
@@ -332,7 +334,7 @@ class Geophrase {
|
|
|
332
334
|
'X-API-Key': this.apiKey,
|
|
333
335
|
'Content-Type': 'application/json'
|
|
334
336
|
},
|
|
335
|
-
body: JSON.stringify(
|
|
337
|
+
body: JSON.stringify(payload),
|
|
336
338
|
signal: controller.signal
|
|
337
339
|
});
|
|
338
340
|
|