@qredex/svelte 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.
- package/README.md +13 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,13 +34,17 @@ npm install @qredex/svelte
|
|
|
34
34
|
|
|
35
35
|
## Attribution Flow
|
|
36
36
|
|
|
37
|
-

|
|
38
38
|
|
|
39
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.
|
|
40
40
|
|
|
41
41
|
## Recommended Integration
|
|
42
42
|
|
|
43
43
|
Use `useQredexAgent()` inside the existing 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.
|
|
44
48
|
|
|
45
49
|
```svelte
|
|
46
50
|
<script lang="ts">
|
|
@@ -52,25 +56,32 @@ Use `useQredexAgent()` inside the existing cart surface you already own. The wra
|
|
|
52
56
|
let previousCount = itemCount;
|
|
53
57
|
|
|
54
58
|
$: if (itemCount !== previousCount) {
|
|
59
|
+
// [Qredex] Report the cart transition after your merchant cart changes.
|
|
55
60
|
agent.handleCartChange({
|
|
56
61
|
itemCount,
|
|
57
62
|
previousCount,
|
|
58
63
|
});
|
|
59
64
|
|
|
65
|
+
// [Merchant] Keep your local snapshot ready for the next transition.
|
|
60
66
|
previousCount = itemCount;
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
async function clearCart() {
|
|
70
|
+
// [Merchant] Clear the real cart in your own backend/storefront first.
|
|
64
71
|
await fetch('/api/cart/clear', {
|
|
65
72
|
method: 'POST',
|
|
66
73
|
});
|
|
67
74
|
|
|
75
|
+
// [Qredex] Clear attribution because the merchant cart is now empty.
|
|
68
76
|
agent.handleCartEmpty();
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
async function submitOrder() {
|
|
80
|
+
// [Qredex] Read PIT from wrapper state, with the core runtime as fallback.
|
|
72
81
|
const pit = $state.pit ?? agent.getPurchaseIntentToken();
|
|
73
82
|
|
|
83
|
+
// [Merchant] Send the PIT as part of your normal order payload so the
|
|
84
|
+
// backend can carry order + PIT into attribution ingestion.
|
|
74
85
|
await fetch('/api/orders', {
|
|
75
86
|
method: 'POST',
|
|
76
87
|
headers: {
|
|
@@ -82,6 +93,7 @@ Use `useQredexAgent()` inside the existing cart surface you already own. The wra
|
|
|
82
93
|
}),
|
|
83
94
|
});
|
|
84
95
|
|
|
96
|
+
// [Merchant + Qredex] Reuse the same clear path after checkout succeeds.
|
|
85
97
|
await clearCart();
|
|
86
98
|
}
|
|
87
99
|
</script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qredex/svelte",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Svelte 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.
|
|
25
|
+
"@qredex/agent": "^1.0.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@qredex/agent": "file:../.."
|