MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / pay

Function pay

apps/testbed/src/App.tsx:109–125  ·  view source on GitHub ↗
(succeed: boolean)

Source from the content-addressed store, hash-verified

107 }
108
109 function pay(succeed: boolean) {
110 const total = cart.reduce((sum, i) => sum + i.price * i.qty, 0);
111 op.track('payment_attempted', { total, success: succeed });
112
113 if (succeed) {
114 op.revenue(total, {
115 items: cart.map((i) => i.id),
116 item_count: cart.reduce((sum, i) => sum + i.qty, 0),
117 });
118 op.track('purchase_completed', { total });
119 setCart([]);
120 navigate('/success');
121 } else {
122 op.track('purchase_failed', { total, reason: 'declined' });
123 navigate('/error');
124 }
125 }
126
127 const cartCount = cart.reduce((sum, i) => sum + i.qty, 0);
128

Callers

nothing calls this directly

Calls 3

trackMethod · 0.45
revenueMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected