@qredex/react 1.0.3 → 1.0.5

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.
Files changed (2) hide show
  1. package/README.md +31 -2
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,4 +1,21 @@
1
- span
1
+ <!--
2
+ ▄▄▄▄
3
+ ▄█▀▀███▄▄ █▄
4
+ ██ ██ ▄ ██
5
+ ██ ██ ████▄▄█▀█▄ ▄████ ▄█▀█▄▀██ ██▀
6
+ ██ ▄ ██ ██ ██▄█▀ ██ ██ ██▄█▀ ███
7
+ ▀█████▄▄█▀ ▄▀█▄▄▄▄█▀███▄▀█▄▄▄▄██ ██▄
8
+ ▀█
9
+
10
+ Copyright (C) 2026 — 2026, Qredex, LTD. All Rights Reserved.
11
+
12
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
13
+
14
+ This file is part of the Qredex Agent SDK and is licensed under the MIT License. See LICENSE.
15
+ Redistribution and use are permitted under that license.
16
+
17
+ If you need additional information or have any questions, please email: copyright@qredex.com
18
+ -->
2
19
 
3
20
  # @qredex/react
4
21
 
@@ -17,13 +34,17 @@ npm install @qredex/react
17
34
 
18
35
  ## Attribution Flow
19
36
 
20
- ![React wrapper attribution flow](https://raw.githubusercontent.com/Qredex/qredex-agent/main/docs/diagrams/wrapper-attribution-sequence.svg?v=20260313-2)
37
+ ![React wrapper attribution flow](https://raw.githubusercontent.com/Qredex/qredex-agent/main/docs/diagrams/wrapper-attribution-sequence.svg?v=20260313-3)
21
38
 
22
39
  Call `useQredexAgent()`, then forward merchant cart state with `agent.handleCartChange(...)`, read the PIT with `agent.getPurchaseIntentToken()`, and clear attribution with `agent.handleCartEmpty()`. Only call `agent.handlePaymentSuccess()` if your platform has no cart-empty step after checkout.
23
40
 
24
41
  ## Recommended Integration
25
42
 
26
43
  Use `useQredexAgent()` inside the cart surface you already own. The wrapper stays headless.
44
+ The merchant still owns cart APIs, totals, checkout, and order submission.
45
+ Qredex only needs the cart transition so the core runtime can lock IIT to PIT.
46
+ After lock, the merchant reads that PIT and carries it with the normal order
47
+ payload to the merchant backend or direct Qredex ingestion path.
27
48
 
28
49
  ```tsx
29
50
  import { useEffect, useRef } from 'react';
@@ -38,25 +59,32 @@ export function QredexCartBridge({ itemCount }: QredexCartBridgeProps) {
38
59
  const previousCountRef = useRef(itemCount);
39
60
 
40
61
  useEffect(() => {
62
+ // [Qredex] Report the cart transition after your merchant cart changes.
41
63
  agent.handleCartChange({
42
64
  itemCount,
43
65
  previousCount: previousCountRef.current,
44
66
  });
45
67
 
68
+ // [Merchant] Keep your local snapshot ready for the next transition.
46
69
  previousCountRef.current = itemCount;
47
70
  }, [agent, itemCount]);
48
71
 
49
72
  async function clearCart() {
73
+ // [Merchant] Clear the real cart in your own backend/storefront first.
50
74
  await fetch('/api/cart/clear', {
51
75
  method: 'POST',
52
76
  });
53
77
 
78
+ // [Qredex] Clear attribution because the merchant cart is now empty.
54
79
  agent.handleCartEmpty();
55
80
  }
56
81
 
57
82
  async function submitOrder() {
83
+ // [Qredex] Read PIT from wrapper state, with the core runtime as fallback.
58
84
  const pit = state.pit ?? agent.getPurchaseIntentToken();
59
85
 
86
+ // [Merchant] Send the PIT as part of your normal order payload so the
87
+ // backend can carry order + PIT into attribution ingestion.
60
88
  await fetch('/api/orders', {
61
89
  method: 'POST',
62
90
  headers: {
@@ -68,6 +96,7 @@ export function QredexCartBridge({ itemCount }: QredexCartBridgeProps) {
68
96
  }),
69
97
  });
70
98
 
99
+ // [Merchant + Qredex] Reuse the same clear path after checkout succeeds.
71
100
  await clearCart();
72
101
  }
73
102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qredex/react",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "React wrapper for Qredex Agent",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -22,7 +22,7 @@
22
22
  "build": "tsc -p tsconfig.json"
23
23
  },
24
24
  "dependencies": {
25
- "@qredex/agent": "^1.0.3"
25
+ "@qredex/agent": "^1.0.5"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@qredex/agent": "file:../.."