Skip to content

Commit 3e5da82

Browse files
committed
Merge branch 'master' into API-13700-counters
2 parents a4c75c8 + 1205691 commit 3e5da82

File tree

26 files changed

+3047
-619
lines changed

26 files changed

+3047
-619
lines changed
158 KB
Loading

public/images/favicon.ico

-19 KB
Binary file not shown.
96.1 KB
Loading
Binary file not shown.

src/configs/redoc/chat-api/spec-rtm.yml

Lines changed: 1647 additions & 104 deletions
Large diffs are not rendered by default.

src/configs/redoc/chat-api/spec.yml

Lines changed: 554 additions & 31 deletions
Large diffs are not rendered by default.

src/configs/redoc/global-accounts-api/spec.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,7 @@ paths:
21002100
An optional token that can be used to obtain a new access
21012101
token once the current one expires. Not available for
21022102
tokens minted with implicit grant flow.
2103-
example: fra-a:0SEkeLZ2Qy2Nm2cg42xIyg
2103+
example: test0SEkeLZ2Qy2Nm2cg42xIyg
21042104
nullable: true
21052105
scope:
21062106
type: string
@@ -2210,7 +2210,7 @@ paths:
22102210
refresh_token:
22112211
description: Refresh token
22122212
type: string
2213-
example: fra-a:apk420S7KM1E4dXwv1DH
2213+
example: testapk420S7KM1E4dXwv1DH
22142214
client_id: *ref_21
22152215
client_secret: *ref_22
22162216
grant_type:

src/pages/authorization/agent-authorization/index.mdx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,14 @@ https://accounts.livechat.com/
310310

311311
#### Request
312312

313-
| Parameter | Required | Required with PKCE | Description |
314-
| ----------------------- | -------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
315-
| `response_type` | yes | yes | Value: `code` |
316-
| `client_id` | yes | yes | **Client Id** from Developer Console (Authorization block) |
313+
| Parameter | Required | Required with PKCE | Description |
314+
| ----------------------- | -------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
315+
| `response_type` | yes | yes | Value: `code` |
316+
| `client_id` | yes | yes | **Client Id** from Developer Console (Authorization block) |
317317
| `redirect_uri` | yes | yes | `redirect_uri` should be the same as `Direct installation URL` defined in the Authorization block during app configuration. The LiveChat OAuth Server will redirect the user back to this URI after successful authorization. |
318-
| `state` | no | no | Any value that might be useful to your application. It's strongly recommended to include an anti-forgery token to mitigate the [cross-site request forgery](https://en.wikipedia.org/wiki/Cross-site_request_forgery). |
319-
| `code_challenge` | no | yes | A string between 43 and 128 characters long. |
320-
| `code_challenge_method` | - | no | Possible values: `s256` or `plain`; default: `plain`. |
318+
| `state` | no | no | Any value that might be useful to your application. It's strongly recommended to include an anti-forgery token to mitigate the [cross-site request forgery](https://en.wikipedia.org/wiki/Cross-site_request_forgery). |
319+
| `code_challenge` | no | yes | A string between 43 and 128 characters long. |
320+
| `code_challenge_method` | - | no | Possible values: `s256` or `plain`; default: `plain`. |
321321

322322
</Text>
323323
<Code>
@@ -477,14 +477,17 @@ curl "https://accounts.livechat.com/v2/token" \
477477
"account_id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
478478
"expires_in": 28800,
479479
"organization_id": "390e44e6-f1e6-0368c-z6ddb-74g14508c2ex",
480-
"refresh_token": "dal:test_gfalskcakg2347o8326",
480+
"refresh_token": "test_gfalskcakg2347o8326",
481481
"scope": "chats--all:ro,chats--all:rw",
482482
"token_type": "Bearer"
483483
}
484484
```
485485

486486
</CodeResponse>
487487
</Code>
488+
489+
💡 **Note**: Refresh tokens no longer include the `dal:` or `fra:` prefixes.
490+
488491
</Section>
489492

490493
## Step 5: Use the token in API calls
@@ -538,7 +541,7 @@ The response is a JSON with the following parameters:
538541
curl "https://accounts.livechat.com/v2/token" \
539542
-X POST \
540543
-d "grant_type=refresh_token&\
541-
refresh_token=dal:test_gfalskcakg2347o8326&\
544+
refresh_token=test_gfalskcakg2347o8326&\
542545
client_id=9cbf3a968289727cb3cdfe83ab1d9836&\
543546
client_secret=test_d7MEp1YYo3"
544547
```
@@ -550,7 +553,7 @@ curl "https://accounts.livechat.com/v2/token" \
550553
curl "https://accounts.livechat.com/v2/token" \
551554
-X POST \
552555
-d "grant_type=refresh_token&\
553-
refresh_token=dal:test_gfalskcakg2347o8326&\
556+
refresh_token=test_gfalskcakg2347o8326&\
554557
client_id=9cbf3a968289727cb3cdfe83ab1d9836&"
555558
```
556559

@@ -565,13 +568,16 @@ curl "https://accounts.livechat.com/v2/token" \
565568
"expires_in": 28800,
566569
"organization_id": "390e44e6-f1e6-0368c-z6ddb-74g14508c2ex",
567570
"scope": "chats--all:ro,chats--all:rw",
568-
"refresh_token": "dal:test_gfalskcakg2347o8326",
571+
"refresh_token": "test_gfalskcakg2347o8326",
569572
"token_type": "Bearer"
570573
}
571574
```
572575

573576
</CodeResponse>
574577
</Code>
578+
579+
💡 **Note**: Refresh tokens no longer include the `dal:` or `fra:` prefixes.
580+
575581
</Section>
576582

577583
<Section>

src/pages/default-credentials.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ code: dal:test_tnlRmy73mg9eaFESA
2323

2424
client_secret: test_d7MEp1YYo3
2525

26-
refresh_token: dal:test_gfalskcakg2347o8326
26+
refresh_token: test_gfalskcakg2347o8326
2727

2828
client_id: 9cbf3a968289727cb3cdfe83ab1d9836 or 0805e283233042b37f460ed8fbf22160
2929

src/pages/extending-agent-app/products-sdk/agent-app-sdk/index.mdx

Lines changed: 142 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ const LiveChat = require("@livechat/agent-app-sdk");
9191
</CodeSample>
9292
</Code>
9393

94-
You can also use the UMD build of the SDK directly in the browser.
95-
96-
You can also use the UMD build:
94+
You can also use the UMD build of the SDK directly in the browser:
9795

9896
<Code>
9997
<CodeSample path={'USE UMD BUILD'}>
@@ -381,13 +379,30 @@ createFullscreenWidget().then(widget => {
381379

382380
### Events
383381

384-
This widget currently does not support any events.
382+
#### `page_data`
383+
384+
Emitted when the widget is initialized. The handler will get the main window page data object as an argument.
385+
386+
Listen for the page data changes:
387+
388+
<Code>
389+
<CodeSample path={'PAGE_DATA'}>
390+
391+
```js
392+
widget.on("page_data", pageData => {
393+
// read the page data
394+
});
395+
```
396+
397+
</CodeSample>
398+
</Code>
385399

386400
### Methods
387401

388402
- [Set notification badge](#set-notification-badge)
389403
- [Navigate to pathname](#navigate-to-pathname)
390404
- [Set Reports filters](#set-reports-filters)
405+
- [Get page data](#get-page-data)
391406

392407
#### Set notification badge
393408

@@ -443,6 +458,18 @@ widget.setReportsFilters({ tag: ['chatbot'] });
443458

444459
</CodeSample>
445460

461+
#### Get page data
462+
463+
Gets the most recently recorded main window page data and returns the `IPageData` object (identical to the one emitted by the `page_data` event). If no data was recorded, it returns `null`.
464+
465+
<CodeSample path={'GET PAGE DATA'}>
466+
467+
```js
468+
widget.getPageData();
469+
```
470+
471+
</CodeSample>
472+
446473
## Settings widgets
447474

448475
If you want to connect a Settings widget to the LiveChat App, you should use the `createSettingsWidget` function. It returns a promise resolving to a Settings widget instance.
@@ -511,6 +538,117 @@ widget.redirect(target);
511538

512539
# Advanced use
513540

541+
## Payments
542+
543+
All widgets allow you to pass a registered charge and display its summary to the customer within the payment modal, directly in the LiveChat App. This flow enables customers to complete or decline the transaction without leaving the LiveChat App context.
544+
545+
<div style={{maxWidth: '535px'}}>
546+
<img src="/images/extending-agent-app/agent-app-sdk-payment-modal.png" alt="Agent App SDK payment modal" width="535px" height="328px"/>
547+
</div>
548+
549+
### Events
550+
551+
#### `transaction_accepted`
552+
553+
Emitted when a payment transaction is approved by the customer and successfully processed by the Billing API.
554+
555+
<CodeSample path={'TRANSACTION_ACCEPTED'}>
556+
557+
```ts
558+
type TransactionEvent {
559+
chargeId: string;
560+
}
561+
```
562+
563+
</CodeSample>
564+
565+
#### `transaction_declined`
566+
567+
Emitted when a payment transaction is declined by the customer (e.g., the user closes the payment modal or clicks the cancel button), and the charge is subsequently marked as declined in the Billing API.
568+
569+
<CodeSample path={'TRANSACTION_DECLINED'}>
570+
571+
```ts
572+
type TransactionEvent {
573+
chargeId: string;
574+
}
575+
```
576+
577+
</CodeSample>
578+
579+
#### `transaction_failed`
580+
581+
Emitted when a payment transaction fails and cannot be processed by the Billing API.
582+
583+
<CodeSample path={'TRANSACTION_FAILED'}>
584+
585+
```ts
586+
type TransactionError {
587+
error: unknown;
588+
}
589+
```
590+
591+
</CodeSample>
592+
593+
#### `update_billing_cycle`
594+
595+
This event is triggered when a customer selects a different billing cycle for a transaction. It only emits if the `showBillingCyclePicker` flag is set to `true` in the `metadata` object at the start of the transaction. The event includes the new billing cycle number and key charge details, allowing you to register the updated charge with the provided information.
596+
597+
<CodeSample path={'UPDATE_BILLING_CYCLE'}>
598+
599+
```ts
600+
type UpdateBillingCycleEvent {
601+
billingCycle: number,
602+
chargeId: string,
603+
paymentIntent: {
604+
name: string,
605+
price: number,
606+
per_account: boolean,
607+
test: boolean,
608+
return_url: string | null,
609+
months?: number,
610+
trial_days?: number,
611+
quantity?: number,
612+
metadata: {
613+
type: string,
614+
isExternalTransaction: boolean,
615+
showBillingCyclePicker: boolean,
616+
icon: string,
617+
description?: string,
618+
}
619+
}
620+
}
621+
```
622+
623+
</CodeSample>
624+
625+
### Methods
626+
627+
#### `startTransaction(charge: Charge, metadata: Metadata): Promise<void>`
628+
629+
This method allows you to pass a registered charge and accompanying metadata to the Agent App. The payment modal will then be displayed to the customer, enabling them to complete the transaction. For more information on registering a charge, refer to the [Billing API](/monetization/billing-api).
630+
631+
<CodeSample>
632+
633+
```ts
634+
const charge = {...} // Billing API charge object
635+
const metadata = {
636+
icon: "https://icon.url";
637+
description: "This is a description of the transaction.";
638+
showBillingCyclePicker: true; // optional, use if you want to display the billing cycle picker to the customer
639+
}
640+
641+
widget.startTransaction(charge, metadata);
642+
```
643+
644+
</CodeSample>
645+
646+
You can follow this flow to create and monitor your in-app transactions:
647+
648+
1. **Create a charge**: use the [Billing API](/monetization/billing-api) to create a new charge object.
649+
2. **Initiate a transaction**: call `startTransaction` with the registered charge and any metadata. This triggers a modal in the LiveChat App (or the parent object).
650+
3. **Monitor events**: Set up listeners for transactions related events. You can listen to available [app webhooks](/getting-started/app-guides/app-webhooks) or built-in [transaction events](/extending-agent-app/products-sdk/agent-app-sdk#events-3) from the Agent App SDK.
651+
514652
## Developing your own widget
515653

516654
If you're building your own widget and you need to interact with the Agent App, be sure to use the [Agent App SDK](#top).

0 commit comments

Comments
 (0)