@qredex/angular 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/angular
|
|
|
34
34
|
|
|
35
35
|
## Attribution Flow
|
|
36
36
|
|
|
37
|
-

|
|
37
|
+

|
|
38
38
|
|
|
39
39
|
Call `provideQredexAgent()` once at bootstrap, get the runtime with `injectQredexAgent()`, 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
|
Register `provideQredexAgent()` once, then call `injectQredexAgent()` inside the existing cart surface you already control.
|
|
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
|
```ts
|
|
46
50
|
import { bootstrapApplication } from '@angular/platform-browser';
|
|
@@ -71,25 +75,32 @@ export class QredexCartBridgeComponent implements OnChanges {
|
|
|
71
75
|
readonly agent = injectQredexAgent();
|
|
72
76
|
|
|
73
77
|
ngOnChanges(): void {
|
|
78
|
+
// [Qredex] Report the cart transition after your merchant cart changes.
|
|
74
79
|
this.agent.handleCartChange({
|
|
75
80
|
itemCount: this.itemCount,
|
|
76
81
|
previousCount: this.previousCount,
|
|
77
82
|
});
|
|
78
83
|
|
|
84
|
+
// [Merchant] Keep your local snapshot ready for the next transition.
|
|
79
85
|
this.previousCount = this.itemCount;
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
async clearCart(): Promise<void> {
|
|
89
|
+
// [Merchant] Clear the real cart in your own backend/storefront first.
|
|
83
90
|
await fetch('/api/cart/clear', {
|
|
84
91
|
method: 'POST',
|
|
85
92
|
});
|
|
86
93
|
|
|
94
|
+
// [Qredex] Clear attribution because the merchant cart is now empty.
|
|
87
95
|
this.agent.handleCartEmpty();
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
async submitOrder(): Promise<void> {
|
|
99
|
+
// [Qredex] Read PIT from the core runtime before checkout.
|
|
91
100
|
const pit = this.agent.getPurchaseIntentToken();
|
|
92
101
|
|
|
102
|
+
// [Merchant] Send the PIT as part of your normal order payload so the
|
|
103
|
+
// backend can carry order + PIT into attribution ingestion.
|
|
93
104
|
await fetch('/api/orders', {
|
|
94
105
|
method: 'POST',
|
|
95
106
|
headers: {
|
|
@@ -101,6 +112,7 @@ export class QredexCartBridgeComponent implements OnChanges {
|
|
|
101
112
|
}),
|
|
102
113
|
});
|
|
103
114
|
|
|
115
|
+
// [Merchant + Qredex] Reuse the same clear path after checkout succeeds.
|
|
104
116
|
await this.clearCart();
|
|
105
117
|
}
|
|
106
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qredex/angular",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Angular 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:../.."
|