oneentry 1.0.59 → 1.0.60
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 +714 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/orders/ordersApi.d.ts +54 -0
- package/dist/orders/ordersApi.js +64 -0
- package/dist/orders/ordersInterfaces.d.ts +108 -0
- package/dist/orders/ordersInterfaces.js +2 -0
- package/dist/pages/pagesInterfaces.d.ts +1 -1
- package/dist/payments/paymentsApi.d.ts +80 -0
- package/dist/payments/paymentsApi.js +108 -0
- package/dist/payments/paymentsInterfaces.d.ts +124 -0
- package/dist/payments/paymentsInterfaces.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,7 +84,9 @@ Now you can use the following links to jump to specific entries:
|
|
|
84
84
|
- [Locales](#locales)
|
|
85
85
|
- [Markers](#markers)
|
|
86
86
|
- [Menus](#menus)
|
|
87
|
+
- [Orders](#orders)
|
|
87
88
|
- [Pages](#pages)
|
|
89
|
+
- [Payments](#payments)
|
|
88
90
|
- [Products](#products)
|
|
89
91
|
- [ProductStatuses](#productstatuses)
|
|
90
92
|
- [System](#system)
|
|
@@ -1401,6 +1403,201 @@ example: List [ OrderedMap { "id": 11, "pageUrl": "122", "localizeInfos": Ordere
|
|
|
1401
1403
|
|
|
1402
1404
|
---
|
|
1403
1405
|
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
## <h2 id="orders"> Orders </h2>
|
|
1409
|
+
|
|
1410
|
+
```js
|
|
1411
|
+
const { Orders } = defineOneEntry('your-url')
|
|
1412
|
+
```
|
|
1413
|
+
|
|
1414
|
+
### Orders.getOrderByMarker(marker, langCode)
|
|
1415
|
+
|
|
1416
|
+
```js
|
|
1417
|
+
const value = await Pages.getOrderByMarker('my-order', 'en_US')
|
|
1418
|
+
```
|
|
1419
|
+
|
|
1420
|
+
> This method retrieves one order storage object by marker.
|
|
1421
|
+
|
|
1422
|
+
Example return:
|
|
1423
|
+
```json
|
|
1424
|
+
{
|
|
1425
|
+
"id": 1764,
|
|
1426
|
+
"localizeInfos": {
|
|
1427
|
+
"title": "Order 1"
|
|
1428
|
+
},
|
|
1429
|
+
"identifier": "catalog",
|
|
1430
|
+
"generalTypeId": 4,
|
|
1431
|
+
"formIdentifier": "catalog-form",
|
|
1432
|
+
"paymentAccountIdentifiers": [
|
|
1433
|
+
{
|
|
1434
|
+
"identifier": "p1"
|
|
1435
|
+
}
|
|
1436
|
+
]
|
|
1437
|
+
}
|
|
1438
|
+
```
|
|
1439
|
+
<details>
|
|
1440
|
+
<summary>Schema</summary>
|
|
1441
|
+
|
|
1442
|
+
**id:** number <br>
|
|
1443
|
+
*object identifier* <br>
|
|
1444
|
+
example: 1764 <br>
|
|
1445
|
+
|
|
1446
|
+
**localizeInfos:** Record<string, any> <br>
|
|
1447
|
+
*json description of the main page data object taking into account the language "en_US" (for example)* <br>
|
|
1448
|
+
example: OrderedMap { "en_US": OrderedMap { "title": "Catalog", "plainContent": "Content for catalog", "htmlContent": "<b>Content for catalog</b>", "menuTitle": "Catalog" } } <br>
|
|
1449
|
+
|
|
1450
|
+
**identifier** string <br>
|
|
1451
|
+
*textual identifier for the record field* <br>
|
|
1452
|
+
example: catalog <br>
|
|
1453
|
+
|
|
1454
|
+
**generalTypeId** number <br>
|
|
1455
|
+
*type identifier* <br>
|
|
1456
|
+
example: 4 <br>
|
|
1457
|
+
|
|
1458
|
+
**formIdentifier** string <br>
|
|
1459
|
+
*textual identifier for the form used by the order storage* <br>
|
|
1460
|
+
example: catalog-form <br>
|
|
1461
|
+
|
|
1462
|
+
**paymentAccountIdentifiers** Array<{identifier:string} <br>
|
|
1463
|
+
*array of textual identifiers of payment accounts used by the order storage* <br>
|
|
1464
|
+
example: [{ "identifier": "p1" }] <br>
|
|
1465
|
+
|
|
1466
|
+
</details>
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
### Orders.createOrder(marker, data)
|
|
1470
|
+
|
|
1471
|
+
```js
|
|
1472
|
+
const body = {
|
|
1473
|
+
"formIdentifier": "order_form",
|
|
1474
|
+
"paymentAccountIdentifier": "stripe",
|
|
1475
|
+
"currency": "USD",
|
|
1476
|
+
"formData": {
|
|
1477
|
+
"en_US": [
|
|
1478
|
+
{
|
|
1479
|
+
"marker": "name_order",
|
|
1480
|
+
"value": "Alex"
|
|
1481
|
+
},
|
|
1482
|
+
{
|
|
1483
|
+
"marker": "phone_order",
|
|
1484
|
+
"value": "+19999999999"
|
|
1485
|
+
},
|
|
1486
|
+
{
|
|
1487
|
+
"marker": "email_order",
|
|
1488
|
+
"value": "example@oneentry.cloud"
|
|
1489
|
+
}
|
|
1490
|
+
]
|
|
1491
|
+
},
|
|
1492
|
+
"products": [
|
|
1493
|
+
{
|
|
1494
|
+
"productId": 444,
|
|
1495
|
+
"quantity": 1,
|
|
1496
|
+
"price": "0.1"
|
|
1497
|
+
},
|
|
1498
|
+
{
|
|
1499
|
+
"productId": 446,
|
|
1500
|
+
"quantity": 3,
|
|
1501
|
+
"price": "123"
|
|
1502
|
+
}
|
|
1503
|
+
]
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
const value = await Pages.createOrder('my-order', body)
|
|
1507
|
+
```
|
|
1508
|
+
|
|
1509
|
+
> This method retrieves one order storage object by marker.
|
|
1510
|
+
|
|
1511
|
+
Example return:
|
|
1512
|
+
```json
|
|
1513
|
+
{
|
|
1514
|
+
"statusIdentifier": "inprogress",
|
|
1515
|
+
"formIdentifier": "order-form",
|
|
1516
|
+
"paymentIdentifier": "payment-1",
|
|
1517
|
+
"formData": [
|
|
1518
|
+
{
|
|
1519
|
+
"marker": "name_1",
|
|
1520
|
+
"value": "Name"
|
|
1521
|
+
}
|
|
1522
|
+
],
|
|
1523
|
+
"products": [
|
|
1524
|
+
{
|
|
1525
|
+
"id": 1,
|
|
1526
|
+
"title": "Floorwood Maxima Laminate, 9811 Oak Mistral",
|
|
1527
|
+
"sku": null,
|
|
1528
|
+
"price": "1.00",
|
|
1529
|
+
"quantity": 10,
|
|
1530
|
+
"previewImage": [
|
|
1531
|
+
{
|
|
1532
|
+
"filename": "files/project/page/36/image/20240322_77c83b02-4c82-4bea-80eb-3763c469b00e.jpg",
|
|
1533
|
+
"downloadLink": "http://my-site.com/files/project/page/36/image/20240322_77c83b02-4c82-4bea-80eb-3763c469b00e.jpg",
|
|
1534
|
+
"size": 296391,
|
|
1535
|
+
"previewLink": ""
|
|
1536
|
+
}
|
|
1537
|
+
]
|
|
1538
|
+
}
|
|
1539
|
+
],
|
|
1540
|
+
"totalSum": "12.00",
|
|
1541
|
+
"currency": "USD",
|
|
1542
|
+
"createdDate": "2023-01-01 12:12",
|
|
1543
|
+
"price": 20,
|
|
1544
|
+
"paymentAccountIdentifier": "payment-1",
|
|
1545
|
+
"paymentAccountLocalizeInfos": {
|
|
1546
|
+
"title": "Account 1"
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
```
|
|
1550
|
+
<details>
|
|
1551
|
+
<summary>Schema</summary>
|
|
1552
|
+
|
|
1553
|
+
**statusIdentifier:** string <br>
|
|
1554
|
+
*text identifier of the order status* <br>
|
|
1555
|
+
example: inprogress <br>
|
|
1556
|
+
|
|
1557
|
+
**formIdentifier:** string <br>
|
|
1558
|
+
*text identifier of the form status* <br>
|
|
1559
|
+
example: order-form <br>
|
|
1560
|
+
|
|
1561
|
+
**paymentIdentifier** string <br>
|
|
1562
|
+
*text identifier of the order payment* <br>
|
|
1563
|
+
example: payment-1 <br>
|
|
1564
|
+
|
|
1565
|
+
**formData** FormDataType <br>
|
|
1566
|
+
*data submitted by the form linked to the order store* <br>
|
|
1567
|
+
example: [{ "marker": "name_1", "value": "Name" } ] <br>
|
|
1568
|
+
|
|
1569
|
+
**products** Record<string, string | any>[] <br>
|
|
1570
|
+
*array of products added to order* <br>
|
|
1571
|
+
|
|
1572
|
+
**totalSum** string <br>
|
|
1573
|
+
*total order amount* <br>
|
|
1574
|
+
example: 12.00 <br>
|
|
1575
|
+
|
|
1576
|
+
**currency** string <br>
|
|
1577
|
+
*currency used to pay for the order* <br>
|
|
1578
|
+
example: USD <br>
|
|
1579
|
+
|
|
1580
|
+
**createdDate** string <br>
|
|
1581
|
+
*date when the order was created* <br>
|
|
1582
|
+
example: 2023-01-01 12:12 <br>
|
|
1583
|
+
|
|
1584
|
+
**price** number <br>
|
|
1585
|
+
*price of the product per unit (at the time of ordering)* <br>
|
|
1586
|
+
example: 20.00 <br>
|
|
1587
|
+
|
|
1588
|
+
**paymentAccountIdentifier** string <br>
|
|
1589
|
+
*textual identifier for the order payment* <br>
|
|
1590
|
+
example: payment-1 <br>
|
|
1591
|
+
|
|
1592
|
+
**paymentAccountLocalizeInfos** CommonLocalizeInfos <br>
|
|
1593
|
+
*payment account name considering localization* <br>
|
|
1594
|
+
example: { "title": "Account 1" } <br>
|
|
1595
|
+
</details>
|
|
1596
|
+
|
|
1597
|
+
---
|
|
1598
|
+
|
|
1599
|
+
|
|
1600
|
+
|
|
1404
1601
|
## <h2 id="pages"> Pages </h2>
|
|
1405
1602
|
|
|
1406
1603
|
|
|
@@ -2364,6 +2561,523 @@ Example return:
|
|
|
2364
2561
|
---
|
|
2365
2562
|
|
|
2366
2563
|
|
|
2564
|
+
## <h2 id="payments"> Payments </h2>
|
|
2565
|
+
|
|
2566
|
+
```js
|
|
2567
|
+
const { Payments } = defineOneEntry('your-url')
|
|
2568
|
+
```
|
|
2569
|
+
|
|
2570
|
+
### Payments.getSessions(limit, offset)
|
|
2571
|
+
|
|
2572
|
+
```js
|
|
2573
|
+
const value = await Payments.getSessions(30, 0)
|
|
2574
|
+
```
|
|
2575
|
+
|
|
2576
|
+
> This method get list of a payment session. It returns a Promise that resolves to a payment session object.
|
|
2577
|
+
|
|
2578
|
+
Example return:
|
|
2579
|
+
|
|
2580
|
+
```json
|
|
2581
|
+
[
|
|
2582
|
+
{
|
|
2583
|
+
"id": 1764,
|
|
2584
|
+
"updatedDate": "2024-04-10T16:39:04.297Z",
|
|
2585
|
+
"version": 10,
|
|
2586
|
+
"identifier": "catalog",
|
|
2587
|
+
"type": "session",
|
|
2588
|
+
"lineItems": [
|
|
2589
|
+
{
|
|
2590
|
+
"quantity": 1,
|
|
2591
|
+
"amount": 5,
|
|
2592
|
+
"currency": "USD",
|
|
2593
|
+
"name": "T-shirt",
|
|
2594
|
+
"description": "White T-shirt"
|
|
2595
|
+
}
|
|
2596
|
+
],
|
|
2597
|
+
"orderId": 1,
|
|
2598
|
+
"paymentAccountId": 1,
|
|
2599
|
+
"status": "completed",
|
|
2600
|
+
"sessionId": "9BE88048TU058770M",
|
|
2601
|
+
"paymentUrl": "https://www.sandbox.paypal.com/checkoutnow?token=9BE88048TU058770M",
|
|
2602
|
+
"successUrl": "https://example.com/success",
|
|
2603
|
+
"cancelUrl": "https://example.com/cancel",
|
|
2604
|
+
"intent": {
|
|
2605
|
+
"amount": 1,
|
|
2606
|
+
"currency": "usd"
|
|
2607
|
+
},
|
|
2608
|
+
"intentId": 1,
|
|
2609
|
+
"clientSecret": "pi_3Oyz2kQWzXG1R23w144qG7o4_secret_OeScuCwTpHmyOM1atbm7pWJw2"
|
|
2610
|
+
}
|
|
2611
|
+
]
|
|
2612
|
+
```
|
|
2613
|
+
<details>
|
|
2614
|
+
<summary>Schema</summary>
|
|
2615
|
+
|
|
2616
|
+
**id:** number <br>
|
|
2617
|
+
*object identifier* <br>
|
|
2618
|
+
example: 1764 <br>
|
|
2619
|
+
|
|
2620
|
+
**updatedDate:** string <br>
|
|
2621
|
+
*object modification date* <br>
|
|
2622
|
+
|
|
2623
|
+
**version:** number <br>
|
|
2624
|
+
*object modification version number* <br>
|
|
2625
|
+
example: 10 <br>
|
|
2626
|
+
|
|
2627
|
+
**identifier:** string <br>
|
|
2628
|
+
*text identifier for the record field* <br>
|
|
2629
|
+
example: catalog <br>
|
|
2630
|
+
|
|
2631
|
+
**type:** string <br>
|
|
2632
|
+
*type may be 'session' or 'intent'* <br>
|
|
2633
|
+
example: session <br>
|
|
2634
|
+
|
|
2635
|
+
**lineItems:** array <br>
|
|
2636
|
+
*list of items* <br>
|
|
2637
|
+
|
|
2638
|
+
**orderId:** number <br>
|
|
2639
|
+
*order identifier* <br>
|
|
2640
|
+
example: 1 <br>
|
|
2641
|
+
|
|
2642
|
+
**paymentAccountId:** number <br>
|
|
2643
|
+
*payment account object identifier* <br>
|
|
2644
|
+
example: 1 <br>
|
|
2645
|
+
|
|
2646
|
+
**status:** string <br>
|
|
2647
|
+
*payment status* <br>
|
|
2648
|
+
example: completed <br>
|
|
2649
|
+
|
|
2650
|
+
**sessionId:** string <br>
|
|
2651
|
+
*Payment ID from an external provider* <br>
|
|
2652
|
+
example: 9BE88048TU058770M <br>
|
|
2653
|
+
|
|
2654
|
+
**paymentUrl:** string <br>
|
|
2655
|
+
*payment link* <br>
|
|
2656
|
+
example: https://www.sandbox.paypal.com/checkoutnow?token=9BE88048TU058770M <br>
|
|
2657
|
+
|
|
2658
|
+
**successUrl:** string <br>
|
|
2659
|
+
*redirect link after successful payment* <br>
|
|
2660
|
+
example: https://example.com/success <br>
|
|
2661
|
+
|
|
2662
|
+
**cancelUrl** string <br>
|
|
2663
|
+
*redirect link after payment cancellation* <br>
|
|
2664
|
+
example: https://example.com/cancel <br>
|
|
2665
|
+
|
|
2666
|
+
**intent** string <br>
|
|
2667
|
+
example: { "amount": 1, "currency": "usd" } <br>
|
|
2668
|
+
|
|
2669
|
+
**intentId** number <br>
|
|
2670
|
+
*intent object identifier* <br>
|
|
2671
|
+
example: 1 <br>
|
|
2672
|
+
|
|
2673
|
+
**clientSecret** string <br>
|
|
2674
|
+
*client secret key* <br>
|
|
2675
|
+
example: pi_3Oyz2kQWzXG1R23w144qG7o4_secret_OeScuCwTpHmyOM1atbm7pWJw2 <br>
|
|
2676
|
+
|
|
2677
|
+
</details>
|
|
2678
|
+
|
|
2679
|
+
|
|
2680
|
+
### Payments.getSessionById(id)
|
|
2681
|
+
|
|
2682
|
+
```js
|
|
2683
|
+
const value = await Payments.getSessionById(1764)
|
|
2684
|
+
```
|
|
2685
|
+
|
|
2686
|
+
> This method get a single payment session object by its identifier. It returns a Promise that resolves to a payment session object.
|
|
2687
|
+
|
|
2688
|
+
Example return:
|
|
2689
|
+
|
|
2690
|
+
```json
|
|
2691
|
+
{
|
|
2692
|
+
"id": 1764,
|
|
2693
|
+
"updatedDate": "2024-04-10T16:39:04.297Z",
|
|
2694
|
+
"version": 10,
|
|
2695
|
+
"identifier": "catalog",
|
|
2696
|
+
"type": "session",
|
|
2697
|
+
"lineItems": [
|
|
2698
|
+
{
|
|
2699
|
+
"quantity": 1,
|
|
2700
|
+
"amount": 5,
|
|
2701
|
+
"currency": "USD",
|
|
2702
|
+
"name": "T-shirt",
|
|
2703
|
+
"description": "White T-shirt"
|
|
2704
|
+
}
|
|
2705
|
+
],
|
|
2706
|
+
"orderId": 1,
|
|
2707
|
+
"paymentAccountId": 1,
|
|
2708
|
+
"status": "completed",
|
|
2709
|
+
"sessionId": "9BE88048TU058770M",
|
|
2710
|
+
"paymentUrl": "https://www.sandbox.paypal.com/checkoutnow?token=9BE88048TU058770M",
|
|
2711
|
+
"successUrl": "https://example.com/success",
|
|
2712
|
+
"cancelUrl": "https://example.com/cancel",
|
|
2713
|
+
"intent": {
|
|
2714
|
+
"amount": 1,
|
|
2715
|
+
"currency": "usd"
|
|
2716
|
+
},
|
|
2717
|
+
"intentId": 1,
|
|
2718
|
+
"clientSecret": "pi_3Oyz2kQWzXG1R23w144qG7o4_secret_OeScuCwTpHmyOM1atbm7pWJw2"
|
|
2719
|
+
}
|
|
2720
|
+
```
|
|
2721
|
+
<details>
|
|
2722
|
+
<summary>Schema</summary>
|
|
2723
|
+
|
|
2724
|
+
**id:** number <br>
|
|
2725
|
+
*object identifier* <br>
|
|
2726
|
+
example: 1764 <br>
|
|
2727
|
+
|
|
2728
|
+
**updatedDate:** string <br>
|
|
2729
|
+
*object modification date* <br>
|
|
2730
|
+
|
|
2731
|
+
**version:** number <br>
|
|
2732
|
+
*object modification version number* <br>
|
|
2733
|
+
example: 10 <br>
|
|
2734
|
+
|
|
2735
|
+
**identifier:** string <br>
|
|
2736
|
+
*text identifier for the record field* <br>
|
|
2737
|
+
example: catalog <br>
|
|
2738
|
+
|
|
2739
|
+
**type:** string <br>
|
|
2740
|
+
*type may be 'session' or 'intent'* <br>
|
|
2741
|
+
example: session <br>
|
|
2742
|
+
|
|
2743
|
+
**lineItems:** array <br>
|
|
2744
|
+
*list of items* <br>
|
|
2745
|
+
|
|
2746
|
+
**orderId:** number <br>
|
|
2747
|
+
*order identifier* <br>
|
|
2748
|
+
example: 1 <br>
|
|
2749
|
+
|
|
2750
|
+
**paymentAccountId:** number <br>
|
|
2751
|
+
*payment account object identifier* <br>
|
|
2752
|
+
example: 1 <br>
|
|
2753
|
+
|
|
2754
|
+
**status:** string <br>
|
|
2755
|
+
*payment status* <br>
|
|
2756
|
+
example: completed <br>
|
|
2757
|
+
|
|
2758
|
+
**sessionId:** string <br>
|
|
2759
|
+
*Payment ID from an external provider* <br>
|
|
2760
|
+
example: 9BE88048TU058770M <br>
|
|
2761
|
+
|
|
2762
|
+
**paymentUrl:** string <br>
|
|
2763
|
+
*payment link* <br>
|
|
2764
|
+
example: https://www.sandbox.paypal.com/checkoutnow?token=9BE88048TU058770M <br>
|
|
2765
|
+
|
|
2766
|
+
**successUrl:** string <br>
|
|
2767
|
+
*redirect link after successful payment* <br>
|
|
2768
|
+
example: https://example.com/success <br>
|
|
2769
|
+
|
|
2770
|
+
**cancelUrl** string <br>
|
|
2771
|
+
*redirect link after payment cancellation* <br>
|
|
2772
|
+
example: https://example.com/cancel <br>
|
|
2773
|
+
|
|
2774
|
+
**intent** string <br>
|
|
2775
|
+
example: { "amount": 1, "currency": "usd" } <br>
|
|
2776
|
+
|
|
2777
|
+
**intentId** number <br>
|
|
2778
|
+
*intent object identifier* <br>
|
|
2779
|
+
example: 1 <br>
|
|
2780
|
+
|
|
2781
|
+
**clientSecret** string <br>
|
|
2782
|
+
*client secret key* <br>
|
|
2783
|
+
example: pi_3Oyz2kQWzXG1R23w144qG7o4_secret_OeScuCwTpHmyOM1atbm7pWJw2 <br>
|
|
2784
|
+
|
|
2785
|
+
</details>
|
|
2786
|
+
|
|
2787
|
+
|
|
2788
|
+
### Payments.createSession(body)
|
|
2789
|
+
|
|
2790
|
+
```js
|
|
2791
|
+
const body = {
|
|
2792
|
+
"lineItems": [
|
|
2793
|
+
{
|
|
2794
|
+
"quantity": 1,
|
|
2795
|
+
"amount": 5,
|
|
2796
|
+
"currency": "USD",
|
|
2797
|
+
"name": "T-Shirt",
|
|
2798
|
+
"description": "White T-Shirt"
|
|
2799
|
+
}
|
|
2800
|
+
],
|
|
2801
|
+
"orderId": 22
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
const value = await Payments.createSession(body)
|
|
2805
|
+
```
|
|
2806
|
+
|
|
2807
|
+
> This method creation of a payment session. It returns a Promise that resolves to a payment session object.
|
|
2808
|
+
|
|
2809
|
+
Example return:
|
|
2810
|
+
|
|
2811
|
+
```json
|
|
2812
|
+
{
|
|
2813
|
+
"id": 1764,
|
|
2814
|
+
"updatedDate": "2024-04-10T16:39:04.297Z",
|
|
2815
|
+
"version": 10,
|
|
2816
|
+
"identifier": "catalog",
|
|
2817
|
+
"type": "session",
|
|
2818
|
+
"lineItems": [
|
|
2819
|
+
{
|
|
2820
|
+
"quantity": 1,
|
|
2821
|
+
"amount": 5,
|
|
2822
|
+
"currency": "USD",
|
|
2823
|
+
"name": "T-shirt",
|
|
2824
|
+
"description": "White T-shirt"
|
|
2825
|
+
}
|
|
2826
|
+
],
|
|
2827
|
+
"orderId": 1,
|
|
2828
|
+
"paymentAccountId": 1,
|
|
2829
|
+
"status": "completed",
|
|
2830
|
+
"sessionId": "9BE88048TU058770M",
|
|
2831
|
+
"paymentUrl": "https://www.sandbox.paypal.com/checkoutnow?token=9BE88048TU058770M",
|
|
2832
|
+
"successUrl": "https://example.com/success",
|
|
2833
|
+
"cancelUrl": "https://example.com/cancel",
|
|
2834
|
+
"intent": {
|
|
2835
|
+
"amount": 1,
|
|
2836
|
+
"currency": "usd"
|
|
2837
|
+
},
|
|
2838
|
+
"intentId": 1,
|
|
2839
|
+
"clientSecret": "pi_3Oyz2kQWzXG1R23w144qG7o4_secret_OeScuCwTpHmyOM1atbm7pWJw2"
|
|
2840
|
+
}
|
|
2841
|
+
```
|
|
2842
|
+
<details>
|
|
2843
|
+
<summary>Schema</summary>
|
|
2844
|
+
|
|
2845
|
+
**id:** number <br>
|
|
2846
|
+
*object identifier* <br>
|
|
2847
|
+
example: 1764 <br>
|
|
2848
|
+
|
|
2849
|
+
**updatedDate:** string <br>
|
|
2850
|
+
*object modification date* <br>
|
|
2851
|
+
|
|
2852
|
+
**version:** number <br>
|
|
2853
|
+
*object modification version number* <br>
|
|
2854
|
+
example: 10 <br>
|
|
2855
|
+
|
|
2856
|
+
**identifier:** string <br>
|
|
2857
|
+
*text identifier for the record field* <br>
|
|
2858
|
+
example: catalog <br>
|
|
2859
|
+
|
|
2860
|
+
**type:** string <br>
|
|
2861
|
+
*type may be 'session' or 'intent'* <br>
|
|
2862
|
+
example: session <br>
|
|
2863
|
+
|
|
2864
|
+
**lineItems:** array <br>
|
|
2865
|
+
*list of items* <br>
|
|
2866
|
+
|
|
2867
|
+
**orderId:** number <br>
|
|
2868
|
+
*order identifier* <br>
|
|
2869
|
+
example: 1 <br>
|
|
2870
|
+
|
|
2871
|
+
**paymentAccountId:** number <br>
|
|
2872
|
+
*payment account object identifier* <br>
|
|
2873
|
+
example: 1 <br>
|
|
2874
|
+
|
|
2875
|
+
**status:** string <br>
|
|
2876
|
+
*payment status* <br>
|
|
2877
|
+
example: completed <br>
|
|
2878
|
+
|
|
2879
|
+
**sessionId:** string <br>
|
|
2880
|
+
*Payment ID from an external provider* <br>
|
|
2881
|
+
example: 9BE88048TU058770M <br>
|
|
2882
|
+
|
|
2883
|
+
**paymentUrl:** string <br>
|
|
2884
|
+
*payment link* <br>
|
|
2885
|
+
example: https://www.sandbox.paypal.com/checkoutnow?token=9BE88048TU058770M <br>
|
|
2886
|
+
|
|
2887
|
+
**successUrl:** string <br>
|
|
2888
|
+
*redirect link after successful payment* <br>
|
|
2889
|
+
example: https://example.com/success <br>
|
|
2890
|
+
|
|
2891
|
+
**cancelUrl** string <br>
|
|
2892
|
+
*redirect link after payment cancellation* <br>
|
|
2893
|
+
example: https://example.com/cancel <br>
|
|
2894
|
+
|
|
2895
|
+
**intent** string <br>
|
|
2896
|
+
example: { "amount": 1, "currency": "usd" } <br>
|
|
2897
|
+
|
|
2898
|
+
**intentId** number <br>
|
|
2899
|
+
*intent object identifier* <br>
|
|
2900
|
+
example: 1 <br>
|
|
2901
|
+
|
|
2902
|
+
**clientSecret** string <br>
|
|
2903
|
+
*client secret key* <br>
|
|
2904
|
+
example: pi_3Oyz2kQWzXG1R23w144qG7o4_secret_OeScuCwTpHmyOM1atbm7pWJw2 <br>
|
|
2905
|
+
|
|
2906
|
+
</details>
|
|
2907
|
+
|
|
2908
|
+
|
|
2909
|
+
### Payments.getConnected()
|
|
2910
|
+
|
|
2911
|
+
```js
|
|
2912
|
+
const value = await Payments.getConnected()
|
|
2913
|
+
```
|
|
2914
|
+
|
|
2915
|
+
> This method get payment settings. It returns a Promise that resolves to a payment connection object.
|
|
2916
|
+
|
|
2917
|
+
Example return:
|
|
2918
|
+
|
|
2919
|
+
```json
|
|
2920
|
+
{
|
|
2921
|
+
"stripeAccountId": "acct_1OtRiIHTHOaLRCAa",
|
|
2922
|
+
"stripePublishableKey": "pk_51OOvk2HPDnVW5KWJwZfiYAlTLAytYqYYKYjGkxm6PqDD4BATCwuRDGgVYXNCqnvwrewgtDVaGyju5VfClW3GrxxT005KnY7MS3",
|
|
2923
|
+
"paypalAccountId": "4Q0BANTF5BE7N"
|
|
2924
|
+
}
|
|
2925
|
+
```
|
|
2926
|
+
<details>
|
|
2927
|
+
<summary>Schema</summary>
|
|
2928
|
+
|
|
2929
|
+
**stripeAccountId:** string <br>
|
|
2930
|
+
*Identifier of connected Stripe account* <br>
|
|
2931
|
+
example: acct_1OtRiIHTHOaLRCAa <br>
|
|
2932
|
+
|
|
2933
|
+
**stripePublishableKey:** string <br>
|
|
2934
|
+
*Stripe Connect public key* <br>
|
|
2935
|
+
example: pk_51OOvk2HPDnVW5KWJwZfiYAlTLAytYqYYKYjGkxm6PqDD4BATCwuRDGgVYXNCqnvwrewgtDVaGyju5VfClW3GrxxT005KnY7MS3 <br>
|
|
2936
|
+
|
|
2937
|
+
**paypalAccountId:** string <br>
|
|
2938
|
+
*Identifier of connected Paypal account* <br>
|
|
2939
|
+
example: 4Q0BANTF5BE7N <br>
|
|
2940
|
+
|
|
2941
|
+
</details>
|
|
2942
|
+
|
|
2943
|
+
|
|
2944
|
+
### Payments.getAccounts()
|
|
2945
|
+
|
|
2946
|
+
```js
|
|
2947
|
+
const value = await Payments.getAccounts()
|
|
2948
|
+
```
|
|
2949
|
+
|
|
2950
|
+
> This method get payment account as an array. It returns a Promise that resolves to a payment account object.
|
|
2951
|
+
|
|
2952
|
+
Example return:
|
|
2953
|
+
|
|
2954
|
+
```json
|
|
2955
|
+
[
|
|
2956
|
+
{
|
|
2957
|
+
"id": 1764,
|
|
2958
|
+
"updatedDate": "2024-04-10T17:02:20.707Z",
|
|
2959
|
+
"version": 10,
|
|
2960
|
+
"identifier": "catalog",
|
|
2961
|
+
"localizeInfos": {
|
|
2962
|
+
"title": "Stripe"
|
|
2963
|
+
},
|
|
2964
|
+
"type": "stripe",
|
|
2965
|
+
"isVisible": true
|
|
2966
|
+
}
|
|
2967
|
+
]
|
|
2968
|
+
```
|
|
2969
|
+
<details>
|
|
2970
|
+
<summary>Schema</summary>
|
|
2971
|
+
|
|
2972
|
+
**id:** number <br>
|
|
2973
|
+
*object identifier* <br>
|
|
2974
|
+
example: 1764 <br>
|
|
2975
|
+
|
|
2976
|
+
**updatedDate:** string <br>
|
|
2977
|
+
*object modification date* <br>
|
|
2978
|
+
|
|
2979
|
+
**version:** number <br>
|
|
2980
|
+
*object modification version number* <br>
|
|
2981
|
+
example: 10 <br>
|
|
2982
|
+
|
|
2983
|
+
**identifier:** string <br>
|
|
2984
|
+
*text identifier for the recording field* <br>
|
|
2985
|
+
example: catalog <br>
|
|
2986
|
+
|
|
2987
|
+
**localizeInfos:** Record<string, any> <br>
|
|
2988
|
+
*json description of the main page data object taking into account the language "en_US" (for example)* <br>
|
|
2989
|
+
example: OrderedMap { "title": "Catalog", "plainContent": "Content for catalog", "htmlContent": "<b>Content for catalog</b>", "menuTitle": "Catalog" } <br>
|
|
2990
|
+
|
|
2991
|
+
**type:** string <br>
|
|
2992
|
+
*type may be 'stripe', 'paypal' or 'custom'* <br>
|
|
2993
|
+
example: stripe <br>
|
|
2994
|
+
|
|
2995
|
+
**isVisible:** boolean <br>
|
|
2996
|
+
*visibility indicator of the payment account* <br>
|
|
2997
|
+
example: true <br>
|
|
2998
|
+
|
|
2999
|
+
</details>
|
|
3000
|
+
|
|
3001
|
+
|
|
3002
|
+
### Payments.getAccountById()
|
|
3003
|
+
|
|
3004
|
+
```js
|
|
3005
|
+
const value = await Payments.getAccountById(1764)
|
|
3006
|
+
```
|
|
3007
|
+
|
|
3008
|
+
> This method get a single payment account object by its identifier. It returns a Promise that resolves to a payment account object.
|
|
3009
|
+
|
|
3010
|
+
Example return:
|
|
3011
|
+
|
|
3012
|
+
```json
|
|
3013
|
+
{
|
|
3014
|
+
"id": 1764,
|
|
3015
|
+
"updatedDate": "2024-04-10T17:12:20.233Z",
|
|
3016
|
+
"version": 10,
|
|
3017
|
+
"identifier": "catalog",
|
|
3018
|
+
"localizeInfos": {
|
|
3019
|
+
"en_US": {
|
|
3020
|
+
"title": "Stripe"
|
|
3021
|
+
}
|
|
3022
|
+
},
|
|
3023
|
+
"type": "stripe",
|
|
3024
|
+
"isVisible": true
|
|
3025
|
+
}
|
|
3026
|
+
```
|
|
3027
|
+
<details>
|
|
3028
|
+
<summary>Schema</summary>
|
|
3029
|
+
|
|
3030
|
+
**id:** number <br>
|
|
3031
|
+
*object identifier* <br>
|
|
3032
|
+
example: 1764 <br>
|
|
3033
|
+
|
|
3034
|
+
**updatedDate:** string <br>
|
|
3035
|
+
*object modification date* <br>
|
|
3036
|
+
|
|
3037
|
+
**version:** number <br>
|
|
3038
|
+
*object modification version number* <br>
|
|
3039
|
+
example: 10 <br>
|
|
3040
|
+
|
|
3041
|
+
**identifier:** string <br>
|
|
3042
|
+
*text identifier for the recording field* <br>
|
|
3043
|
+
example: catalog <br>
|
|
3044
|
+
|
|
3045
|
+
**localizeInfos:** Record<string, any> <br>
|
|
3046
|
+
*json description of the main page data object taking into account the language "en_US" (for example)* <br>
|
|
3047
|
+
example: OrderedMap { "title": "Catalog", "plainContent": "Content for catalog", "htmlContent": "<b>Content for catalog</b>", "menuTitle": "Catalog" } <br>
|
|
3048
|
+
|
|
3049
|
+
**type:** string <br>
|
|
3050
|
+
*type may be 'stripe', 'paypal' or 'custom'* <br>
|
|
3051
|
+
example: stripe <br>
|
|
3052
|
+
|
|
3053
|
+
**isVisible:** boolean <br>
|
|
3054
|
+
*visibility indicator of the payment account* <br>
|
|
3055
|
+
example: true <br>
|
|
3056
|
+
|
|
3057
|
+
</details>
|
|
3058
|
+
|
|
3059
|
+
|
|
3060
|
+
### Payments.webhookStripe()
|
|
3061
|
+
|
|
3062
|
+
```js
|
|
3063
|
+
const value = await Payments.webhookStripe()
|
|
3064
|
+
```
|
|
3065
|
+
|
|
3066
|
+
> This method use webhook for Stripe. Returns true (in case of successful execution) or false (in case of unsuccessful execution).
|
|
3067
|
+
|
|
3068
|
+
|
|
3069
|
+
|
|
3070
|
+
### Payments.webhookStripe()
|
|
3071
|
+
|
|
3072
|
+
```js
|
|
3073
|
+
const value = await Payments.webhookPaypal()
|
|
3074
|
+
```
|
|
3075
|
+
|
|
3076
|
+
> This method use webhook for Paypal. Returns true (in case of successful execution) or false (in case of unsuccessful execution).
|
|
3077
|
+
|
|
3078
|
+
---
|
|
3079
|
+
|
|
3080
|
+
|
|
2367
3081
|
## <h2 id="products"> Products </h2>
|
|
2368
3082
|
|
|
2369
3083
|
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ import BlocksApi from "./blocks/blocksApi";
|
|
|
15
15
|
import AttributesSetsApi from "./attribute-sets/attributeSetsApi";
|
|
16
16
|
import MarkersApi from "./markers/markersApi";
|
|
17
17
|
import { IConfig } from "./base/utils";
|
|
18
|
+
import OrdersApi from "./orders/ordersApi";
|
|
19
|
+
import PaymentsApi from "./payments/paymentsApi";
|
|
18
20
|
interface IDefineApi {
|
|
19
21
|
Admins: AdminsApi;
|
|
20
22
|
AttributesSets: AttributesSetsApi;
|
|
@@ -26,7 +28,9 @@ interface IDefineApi {
|
|
|
26
28
|
Locales: LocalesApi;
|
|
27
29
|
Markers: MarkersApi;
|
|
28
30
|
Menus: MenusApi;
|
|
31
|
+
Orders: OrdersApi;
|
|
29
32
|
Pages: PageApi;
|
|
33
|
+
Payments: PaymentsApi;
|
|
30
34
|
Products: ProductApi;
|
|
31
35
|
ProductStatuses: ProductStatusesApi;
|
|
32
36
|
System: SystemApi;
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,8 @@ const systemApi_1 = require("./system/systemApi");
|
|
|
17
17
|
const blocksApi_1 = require("./blocks/blocksApi");
|
|
18
18
|
const attributeSetsApi_1 = require("./attribute-sets/attributeSetsApi");
|
|
19
19
|
const markersApi_1 = require("./markers/markersApi");
|
|
20
|
+
const ordersApi_1 = require("./orders/ordersApi");
|
|
21
|
+
const paymentsApi_1 = require("./payments/paymentsApi");
|
|
20
22
|
/**
|
|
21
23
|
* Define API.
|
|
22
24
|
* @param {string} url - URl of your project.
|
|
@@ -36,7 +38,9 @@ function defineOneEntry(url, config) {
|
|
|
36
38
|
const Locales = new localesApi_1.default(url, config);
|
|
37
39
|
const Markers = new markersApi_1.default(url, config);
|
|
38
40
|
const Menus = new menusApi_1.default(url, config);
|
|
41
|
+
const Orders = new ordersApi_1.default(url, config);
|
|
39
42
|
const Pages = new pagesApi_1.default(url, config);
|
|
43
|
+
const Payments = new paymentsApi_1.default(url, config);
|
|
40
44
|
const Products = new productsApi_1.default(url, config);
|
|
41
45
|
const ProductStatuses = new productStatusesApi_1.default(url, config);
|
|
42
46
|
const System = new systemApi_1.default(url, config);
|
|
@@ -53,7 +57,9 @@ function defineOneEntry(url, config) {
|
|
|
53
57
|
Locales,
|
|
54
58
|
Markers,
|
|
55
59
|
Menus,
|
|
60
|
+
Orders,
|
|
56
61
|
Pages,
|
|
62
|
+
Payments,
|
|
57
63
|
Products,
|
|
58
64
|
ProductStatuses,
|
|
59
65
|
System,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import OneEntry from "../base/oneEntry";
|
|
2
|
+
import { IConfig } from "../base/utils";
|
|
3
|
+
import { IOrdersApi, IOrdersEntity, IBaseOrdersEntity, IOrderData } from "./ordersInterfaces";
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with orders
|
|
6
|
+
*/
|
|
7
|
+
export default class OrdersApi extends OneEntry implements IOrdersApi {
|
|
8
|
+
constructor(url: string, config: IConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Retrieve one order storage object by marker.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} marker - Marker of the order object
|
|
13
|
+
* @param {string} [langCode] - Language code
|
|
14
|
+
*
|
|
15
|
+
* @returns Return object of order information.
|
|
16
|
+
*/
|
|
17
|
+
getOrderByMarker(marker: string, langCode?: string): Promise<IOrdersEntity>;
|
|
18
|
+
/**
|
|
19
|
+
* Creation of an order in the order storage.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} marker - Textual identifier of the order storage object
|
|
22
|
+
* @param {IOrderData} data - Object for creating an order
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* {
|
|
26
|
+
* "formIdentifier": "bar-orders-form",
|
|
27
|
+
* "paymentIdentifier": "usd-payment",
|
|
28
|
+
* "formData": {
|
|
29
|
+
* "en_US": [
|
|
30
|
+
* {
|
|
31
|
+
* "marker": "name_1",
|
|
32
|
+
* "value": "Name"
|
|
33
|
+
* }
|
|
34
|
+
* ]
|
|
35
|
+
* },
|
|
36
|
+
* "products": [
|
|
37
|
+
* {
|
|
38
|
+
* "productId": 1,
|
|
39
|
+
* "quantity": 2,
|
|
40
|
+
* "price": "23.02"
|
|
41
|
+
* },
|
|
42
|
+
* {
|
|
43
|
+
* "productId": 2,
|
|
44
|
+
* "quantity": 3,
|
|
45
|
+
* "price": "3.02"
|
|
46
|
+
* }
|
|
47
|
+
* ],
|
|
48
|
+
* "currency": "USD"
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* @returns Returns object for creating an order.
|
|
52
|
+
*/
|
|
53
|
+
createOrder(marker: string, data: IOrderData): Promise<IBaseOrdersEntity>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const oneEntry_1 = require("../base/oneEntry");
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with orders
|
|
6
|
+
*/
|
|
7
|
+
class OrdersApi extends oneEntry_1.default {
|
|
8
|
+
constructor(url, config) {
|
|
9
|
+
super(url, config);
|
|
10
|
+
this._url += '/api/content/orders-storage';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Retrieve one order storage object by marker.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} marker - Marker of the order object
|
|
16
|
+
* @param {string} [langCode] - Language code
|
|
17
|
+
*
|
|
18
|
+
* @returns Return object of order information.
|
|
19
|
+
*/
|
|
20
|
+
async getOrderByMarker(marker, langCode = this._defaultLangCode) {
|
|
21
|
+
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
22
|
+
return this._normalizeData(result);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creation of an order in the order storage.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} marker - Textual identifier of the order storage object
|
|
28
|
+
* @param {IOrderData} data - Object for creating an order
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* {
|
|
32
|
+
* "formIdentifier": "bar-orders-form",
|
|
33
|
+
* "paymentIdentifier": "usd-payment",
|
|
34
|
+
* "formData": {
|
|
35
|
+
* "en_US": [
|
|
36
|
+
* {
|
|
37
|
+
* "marker": "name_1",
|
|
38
|
+
* "value": "Name"
|
|
39
|
+
* }
|
|
40
|
+
* ]
|
|
41
|
+
* },
|
|
42
|
+
* "products": [
|
|
43
|
+
* {
|
|
44
|
+
* "productId": 1,
|
|
45
|
+
* "quantity": 2,
|
|
46
|
+
* "price": "23.02"
|
|
47
|
+
* },
|
|
48
|
+
* {
|
|
49
|
+
* "productId": 2,
|
|
50
|
+
* "quantity": 3,
|
|
51
|
+
* "price": "3.02"
|
|
52
|
+
* }
|
|
53
|
+
* ],
|
|
54
|
+
* "currency": "USD"
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* @returns Returns object for creating an order.
|
|
58
|
+
*/
|
|
59
|
+
async createOrder(marker, data) {
|
|
60
|
+
const result = await this._fetchPost(`/marker/${marker}/order`, data);
|
|
61
|
+
return this._normalizeData(result);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.default = OrdersApi;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an interface object of Orders Api.
|
|
3
|
+
*
|
|
4
|
+
* @property {function} getOrderByMarker - Retrieve one order storage object by marker.
|
|
5
|
+
* @property {function} createOrder - Creation of an order in the order storage.
|
|
6
|
+
|
|
7
|
+
*/
|
|
8
|
+
interface IOrdersApi {
|
|
9
|
+
getOrderByMarker(marker: string, langCode?: string): Promise<IOrdersEntity>;
|
|
10
|
+
createOrder(marker: string, data: IOrderData): Promise<IBaseOrdersEntity>;
|
|
11
|
+
}
|
|
12
|
+
interface IPicture {
|
|
13
|
+
filename: string;
|
|
14
|
+
downloadLink: string;
|
|
15
|
+
size: number;
|
|
16
|
+
previewLink: string;
|
|
17
|
+
}
|
|
18
|
+
interface IOrderProducts {
|
|
19
|
+
id: number;
|
|
20
|
+
title: string;
|
|
21
|
+
sku: string | null;
|
|
22
|
+
price: string | null;
|
|
23
|
+
quantity: number | null;
|
|
24
|
+
previewImage: Array<IPicture>;
|
|
25
|
+
}
|
|
26
|
+
interface IOrdersFormData {
|
|
27
|
+
marker: string;
|
|
28
|
+
value: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @interface
|
|
32
|
+
* @property {string} statusIdentifier - Text identifier of the order status.
|
|
33
|
+
* @property {string} formIdentifier - Text identifier of the form status.
|
|
34
|
+
* @property {string} paymentIdentifier - Text identifier of the order payment.
|
|
35
|
+
* @property {Array<IOrdersFormData>} formData - Data submitted by the form linked to the order store.
|
|
36
|
+
* @property {Array<IOrderProducts>} products - Array of products added to order.
|
|
37
|
+
* @property {string} totalSum - Total order amount.
|
|
38
|
+
* @property {string} currency - Currency used to pay for the order.
|
|
39
|
+
* @property {string} createdDate - Date when the order was created.
|
|
40
|
+
* @property {number} price - Price of the product per unit (at the time of ordering).
|
|
41
|
+
* @property {string} paymentAccountIdentifier - Textual identifier for the order payment.
|
|
42
|
+
* @property {Record<string, any>} paymentAccountLocalizeInfos - Payment account name considering localization.
|
|
43
|
+
*/
|
|
44
|
+
interface IBaseOrdersEntity {
|
|
45
|
+
statusIdentifier: string;
|
|
46
|
+
formIdentifier: string;
|
|
47
|
+
paymentIdentifier: string;
|
|
48
|
+
formData: Array<IOrdersFormData>;
|
|
49
|
+
products: Array<IOrderProducts>;
|
|
50
|
+
totalSum: string;
|
|
51
|
+
currency: string;
|
|
52
|
+
createdDate: string;
|
|
53
|
+
price: number;
|
|
54
|
+
paymentAccountIdentifier: string;
|
|
55
|
+
paymentAccountLocalizeInfos: Record<string, any>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @interface
|
|
59
|
+
* @property {number} id - Object identifier.
|
|
60
|
+
* @property {Record<string, any>} localizeInfos - Name considering localization.
|
|
61
|
+
* @property {string} identifier - Textual identifier for the record field.
|
|
62
|
+
* @property {number} generalTypeId - Type identifier.
|
|
63
|
+
* @property {string} formIdentifier - Textual identifier for the form used by the order storage.
|
|
64
|
+
* @property {Array<{identifier:string}>} paymentAccountIdentifiers - Array of textual identifiers of payment accounts used by the order storage.
|
|
65
|
+
*/
|
|
66
|
+
interface IOrdersEntity {
|
|
67
|
+
id: number;
|
|
68
|
+
localizeInfos: Record<string, any>;
|
|
69
|
+
identifier: string | null;
|
|
70
|
+
generalTypeId: number | null;
|
|
71
|
+
formIdentifier: string | null;
|
|
72
|
+
paymentAccountIdentifiers: Array<{
|
|
73
|
+
identifier: string;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
interface IOrderMarkerData {
|
|
77
|
+
marker: string;
|
|
78
|
+
value: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @interface
|
|
82
|
+
* @property {number} productId - Product identifier.
|
|
83
|
+
* @property {number} quantity - Quantity of the product.
|
|
84
|
+
* @property {string} price - Price per unit of the product.
|
|
85
|
+
*/
|
|
86
|
+
interface IOrderProductData {
|
|
87
|
+
productId: number;
|
|
88
|
+
quantity: number;
|
|
89
|
+
price: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @interface
|
|
93
|
+
* @property {string} formIdentifier - Text identifier of the form object linked to the order repository.
|
|
94
|
+
* @property {string} paymentIdentifier - Text identifier of the payment object linked to the order repository.
|
|
95
|
+
* @property {string} [statusIdentifier] - Text identifier of the order status object (if not specified, the default status will be assigned).
|
|
96
|
+
* @property {Record<string, Array<IOrderMarkerData>>} formData - Form data linked to the order repositor.
|
|
97
|
+
* @property {Array<IOrderProductData>} products - An array of ordered products.
|
|
98
|
+
* @property {string} currency - Currency used for order paymen.
|
|
99
|
+
*/
|
|
100
|
+
interface IOrderData {
|
|
101
|
+
formIdentifier: string;
|
|
102
|
+
paymentIdentifier: string;
|
|
103
|
+
statusIdentifier?: string;
|
|
104
|
+
formData: Record<string, Array<IOrderMarkerData>>;
|
|
105
|
+
products: Array<IOrderProductData>;
|
|
106
|
+
currency: string;
|
|
107
|
+
}
|
|
108
|
+
export { IOrdersEntity, IBaseOrdersEntity, IOrderProducts, IPicture, IOrdersApi, IOrderData, IOrderProductData, IOrderMarkerData, IOrdersFormData };
|
|
@@ -147,7 +147,7 @@ interface IPagesEntity {
|
|
|
147
147
|
parentId: number | null;
|
|
148
148
|
position?: number;
|
|
149
149
|
products?: number;
|
|
150
|
-
templateIdentifier: string;
|
|
150
|
+
templateIdentifier: string | null;
|
|
151
151
|
type: Types;
|
|
152
152
|
}
|
|
153
153
|
export { IPageApi, IPageConfig, IPagesEntity, IPositionForm, IPositionBlock };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import OneEntry from "../base/oneEntry";
|
|
2
|
+
import { IConfig } from "../base/utils";
|
|
3
|
+
import { IPaymentsApi, ISessionEntity, IConnectedEntity, IAccountsEntity, ISessionBody } from "./paymentsInterfaces";
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with payments
|
|
6
|
+
*/
|
|
7
|
+
export default class PaymentsApi extends OneEntry implements IPaymentsApi {
|
|
8
|
+
constructor(url: string, config: IConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Get list of payment sessions.
|
|
11
|
+
*
|
|
12
|
+
* @param {number} [limit] - Optional parameter for pagination, default is 0
|
|
13
|
+
* @param {number} [offset] - Optional parameter for pagination, default is 30
|
|
14
|
+
*
|
|
15
|
+
* @returns Returns an array of SessionEntity objects.
|
|
16
|
+
*/
|
|
17
|
+
getSessions(limit?: number, offset?: number): Promise<Array<ISessionEntity>>;
|
|
18
|
+
/**
|
|
19
|
+
* Get a single payment session object by its identifier.
|
|
20
|
+
*
|
|
21
|
+
* @param {number} id - Identifier of the retrieved payment session object
|
|
22
|
+
*
|
|
23
|
+
* @returns Returns a single payment session object.
|
|
24
|
+
*/
|
|
25
|
+
getSessionById(id: number): Promise<ISessionEntity>;
|
|
26
|
+
/**
|
|
27
|
+
* Creation of payment session.
|
|
28
|
+
*
|
|
29
|
+
* @param {ISessionBody} body - Object for creating a payment
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* {
|
|
33
|
+
* "lineItems": [
|
|
34
|
+
* {
|
|
35
|
+
* "quantity": 1,
|
|
36
|
+
* "amount": 5,
|
|
37
|
+
* "currency": "USD",
|
|
38
|
+
* "name": "T-Shirt",
|
|
39
|
+
* "description": "White T-Shirt"
|
|
40
|
+
* }
|
|
41
|
+
* ],
|
|
42
|
+
* "orderId": 22
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* @returns Returns a single payment session object.
|
|
46
|
+
*/
|
|
47
|
+
createSession(body: ISessionBody): Promise<ISessionEntity>;
|
|
48
|
+
/**
|
|
49
|
+
* Get payment settings.
|
|
50
|
+
*
|
|
51
|
+
* @returns Returns object PaymentsConnected or null.
|
|
52
|
+
*/
|
|
53
|
+
getConnected(): Promise<IConnectedEntity | null>;
|
|
54
|
+
/**
|
|
55
|
+
* Get all payment accounts as an array.
|
|
56
|
+
*
|
|
57
|
+
* @returns Returns all created payment accounts as an array of PaymentAccountEntity objects.
|
|
58
|
+
*/
|
|
59
|
+
getAccounts(): Promise<Array<IAccountsEntity>>;
|
|
60
|
+
/**
|
|
61
|
+
* Get a single payment account object by its identifier.
|
|
62
|
+
*
|
|
63
|
+
* @param {number} id - Identifier of the retrieved payment account object
|
|
64
|
+
*
|
|
65
|
+
* @returns Returns a single payment account object.
|
|
66
|
+
*/
|
|
67
|
+
getAccountById(id: number): Promise<IAccountsEntity>;
|
|
68
|
+
/**
|
|
69
|
+
* Webhook for Stripe.
|
|
70
|
+
*
|
|
71
|
+
* @returns Returns true (in case of successful execution) or false (in case of unsuccessful execution)
|
|
72
|
+
*/
|
|
73
|
+
webhookStripe(): Promise<boolean>;
|
|
74
|
+
/**
|
|
75
|
+
* Webhook for Paypal.
|
|
76
|
+
*
|
|
77
|
+
* @returns Returns true (in case of successful execution) or false (in case of unsuccessful execution)
|
|
78
|
+
*/
|
|
79
|
+
webhookPaypal(): Promise<boolean>;
|
|
80
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const oneEntry_1 = require("../base/oneEntry");
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with payments
|
|
6
|
+
*/
|
|
7
|
+
class PaymentsApi extends oneEntry_1.default {
|
|
8
|
+
constructor(url, config) {
|
|
9
|
+
super(url, config);
|
|
10
|
+
this._url += '/api/content/payments';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get list of payment sessions.
|
|
14
|
+
*
|
|
15
|
+
* @param {number} [limit] - Optional parameter for pagination, default is 0
|
|
16
|
+
* @param {number} [offset] - Optional parameter for pagination, default is 30
|
|
17
|
+
*
|
|
18
|
+
* @returns Returns an array of SessionEntity objects.
|
|
19
|
+
*/
|
|
20
|
+
async getSessions(limit = 30, offset = 0) {
|
|
21
|
+
const result = await this._fetchGet('/sessions');
|
|
22
|
+
return result.items;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get a single payment session object by its identifier.
|
|
26
|
+
*
|
|
27
|
+
* @param {number} id - Identifier of the retrieved payment session object
|
|
28
|
+
*
|
|
29
|
+
* @returns Returns a single payment session object.
|
|
30
|
+
*/
|
|
31
|
+
async getSessionById(id) {
|
|
32
|
+
const result = await this._fetchGet(`/sessions/${id}`);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creation of payment session.
|
|
37
|
+
*
|
|
38
|
+
* @param {ISessionBody} body - Object for creating a payment
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* {
|
|
42
|
+
* "lineItems": [
|
|
43
|
+
* {
|
|
44
|
+
* "quantity": 1,
|
|
45
|
+
* "amount": 5,
|
|
46
|
+
* "currency": "USD",
|
|
47
|
+
* "name": "T-Shirt",
|
|
48
|
+
* "description": "White T-Shirt"
|
|
49
|
+
* }
|
|
50
|
+
* ],
|
|
51
|
+
* "orderId": 22
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* @returns Returns a single payment session object.
|
|
55
|
+
*/
|
|
56
|
+
async createSession(body) {
|
|
57
|
+
const result = await this._fetchPost('/sessions', body);
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get payment settings.
|
|
62
|
+
*
|
|
63
|
+
* @returns Returns object PaymentsConnected or null.
|
|
64
|
+
*/
|
|
65
|
+
async getConnected() {
|
|
66
|
+
const result = await this._fetchGet('/connected');
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get all payment accounts as an array.
|
|
71
|
+
*
|
|
72
|
+
* @returns Returns all created payment accounts as an array of PaymentAccountEntity objects.
|
|
73
|
+
*/
|
|
74
|
+
async getAccounts() {
|
|
75
|
+
const result = await this._fetchGet('/accounts');
|
|
76
|
+
return this._normalizeData(result);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get a single payment account object by its identifier.
|
|
80
|
+
*
|
|
81
|
+
* @param {number} id - Identifier of the retrieved payment account object
|
|
82
|
+
*
|
|
83
|
+
* @returns Returns a single payment account object.
|
|
84
|
+
*/
|
|
85
|
+
async getAccountById(id) {
|
|
86
|
+
const result = await this._fetchGet(`/accounts/${id}`);
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Webhook for Stripe.
|
|
91
|
+
*
|
|
92
|
+
* @returns Returns true (in case of successful execution) or false (in case of unsuccessful execution)
|
|
93
|
+
*/
|
|
94
|
+
async webhookStripe() {
|
|
95
|
+
const result = await this._fetchPost('/webhook/stripe', null);
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Webhook for Paypal.
|
|
100
|
+
*
|
|
101
|
+
* @returns Returns true (in case of successful execution) or false (in case of unsuccessful execution)
|
|
102
|
+
*/
|
|
103
|
+
async webhookPaypal() {
|
|
104
|
+
const result = await this._fetchPost('/webhook/paypal', null);
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.default = PaymentsApi;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an interface object of Orders Api.
|
|
3
|
+
*
|
|
4
|
+
* @property {function} getSessions - Get list of payment sessions.
|
|
5
|
+
* @property {function} getSessionById - Get a single payment session object by its identifier.
|
|
6
|
+
* @property {function} createSession - Creation of payment session.
|
|
7
|
+
* @property {function} getConnected - Get payment settings.
|
|
8
|
+
* @property {function} getAccounts - Get all payment accounts as an array.
|
|
9
|
+
* @property {function} getAccountById - Get a single payment account object by its identifier.
|
|
10
|
+
* @property {function} webhookStripe - Webhook for Stripe.
|
|
11
|
+
* @property {function} webhookPaypal - Webhook for Paypal.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
interface IPaymentsApi {
|
|
15
|
+
getSessions(limit: number, offset: number): Promise<Array<ISessionEntity>>;
|
|
16
|
+
getSessionById(id: number): Promise<ISessionEntity>;
|
|
17
|
+
createSession(body: ISessionBody): Promise<ISessionEntity>;
|
|
18
|
+
getConnected(): Promise<IConnectedEntity | null>;
|
|
19
|
+
getAccounts(): Promise<Array<IAccountsEntity>>;
|
|
20
|
+
getAccountById(id: number): Promise<IAccountsEntity>;
|
|
21
|
+
webhookStripe(): Promise<boolean>;
|
|
22
|
+
webhookPaypal(): Promise<boolean>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @interface
|
|
27
|
+
* @property {number} quantity - Quantity information.
|
|
28
|
+
* @property {number} amount - Amount information.
|
|
29
|
+
* @property {string} currency - Currency information.
|
|
30
|
+
* @property {string} name - Name.
|
|
31
|
+
* @property {string} description - Description.
|
|
32
|
+
*/
|
|
33
|
+
interface ILineItems {
|
|
34
|
+
quantity: number;
|
|
35
|
+
amount: number;
|
|
36
|
+
currency: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @interface
|
|
42
|
+
* @property {Array<ILineItems>} lineItems - List of items.
|
|
43
|
+
* @property {number} orderId - Order identifier.
|
|
44
|
+
*/
|
|
45
|
+
interface ISessionBody {
|
|
46
|
+
lineItems: Array<ILineItems>;
|
|
47
|
+
orderId: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @interface
|
|
51
|
+
* @property {number} amount
|
|
52
|
+
* @property {string} currency
|
|
53
|
+
*/
|
|
54
|
+
interface IIntent {
|
|
55
|
+
amount: number;
|
|
56
|
+
currency: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @interface
|
|
60
|
+
* @property {number} id - Object identifier.
|
|
61
|
+
* @property {string} updatedDate - Object modification date.
|
|
62
|
+
* @property {number} version - Object modification version number.
|
|
63
|
+
* @property {string} identifier - Text identifier for the record field.
|
|
64
|
+
* @property {string} type - Type may be 'session' or 'intent'.
|
|
65
|
+
* @property {number} orderId - Order identifier.
|
|
66
|
+
* @property {number} paymentAccountId - Payment account object identifier.
|
|
67
|
+
* @property {string} status - Payment status.
|
|
68
|
+
* @property {string} sessionId - Payment ID from an external provider.
|
|
69
|
+
* @property {string} paymentUrl - Payment link.
|
|
70
|
+
* @property {string} successUrl - Redirect link after successful payment.
|
|
71
|
+
* @property {string} cancelUrl - Redirect link after payment cancellation.
|
|
72
|
+
* @property {IIntent} intent - Payment intent.
|
|
73
|
+
* @property {number} intentId - Intent object identifier.
|
|
74
|
+
* @property {string} clientSecret - Client secret key.
|
|
75
|
+
*/
|
|
76
|
+
interface ISessionEntity {
|
|
77
|
+
id: number;
|
|
78
|
+
updatedDate: string;
|
|
79
|
+
version: number;
|
|
80
|
+
identifier: string;
|
|
81
|
+
type: 'session' | 'intent';
|
|
82
|
+
lineItems: Array<ILineItems>;
|
|
83
|
+
orderId: number;
|
|
84
|
+
paymentAccountId: number;
|
|
85
|
+
status: string;
|
|
86
|
+
sessionId: string;
|
|
87
|
+
paymentUrl: string;
|
|
88
|
+
successUrl: string;
|
|
89
|
+
cancelUrl: string;
|
|
90
|
+
intent: IIntent;
|
|
91
|
+
intentId: number;
|
|
92
|
+
clientSecret: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @interface
|
|
96
|
+
* @property {string} [stripeAccountId] - Identifier of connected Stripe account.
|
|
97
|
+
* @property {string} [stripePublishableKey] - Stripe Connect public key.
|
|
98
|
+
* @property {string} [paypalAccountId] - Identifier of connected Paypal account.
|
|
99
|
+
*/
|
|
100
|
+
interface IConnectedEntity {
|
|
101
|
+
stripeAccountId?: string;
|
|
102
|
+
stripePublishableKey?: string;
|
|
103
|
+
paypalAccountId?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @interface
|
|
107
|
+
* @property {number} id - Object identifier.
|
|
108
|
+
* @property {string} updatedDate - Object modification date.
|
|
109
|
+
* @property {number} version - Object modification version number.
|
|
110
|
+
* @property {string} identifier - Text identifier for the recording field.
|
|
111
|
+
* @property {Record<string, any>} localizeInfos - Json description of the payment account object.
|
|
112
|
+
* @property {string} type - Type may be 'stripe', 'paypal' or 'custom'.
|
|
113
|
+
* @property {boolean} isVisible - Visibility indicator of the payment account.
|
|
114
|
+
*/
|
|
115
|
+
interface IAccountsEntity {
|
|
116
|
+
id: number;
|
|
117
|
+
updatedDate: string;
|
|
118
|
+
version: number;
|
|
119
|
+
identifier: string;
|
|
120
|
+
localizeInfos: Record<string, any>;
|
|
121
|
+
type: 'stripe' | 'paypal' | 'custom';
|
|
122
|
+
isVisible: boolean;
|
|
123
|
+
}
|
|
124
|
+
export { IAccountsEntity, IConnectedEntity, ISessionEntity, ILineItems, ISessionBody, IPaymentsApi, IIntent };
|