forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration-examples.ts
More file actions
60 lines (55 loc) · 1.54 KB
/
Copy pathintegration-examples.ts
File metadata and controls
60 lines (55 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Integration Examples for Activity Tracking
*
* This file demonstrates how to integrate activity tracking
* into various services within the StellarSplit application.
*/
import { Injectable } from "@nestjs/common";
import { ActivitiesService } from "../activities/activities.service";
/**
* Example 1: Payment Service Integration
* Track payment-related activities
*/
@Injectable()
export class PaymentServiceExample {
constructor(private readonly activitiesService: ActivitiesService) {}
async processPayment(
userId: string,
splitId: string,
amount: number,
txHash: string,
asset: string
) {
try {
// Process payment logic here...
// const result = await this.stellarService.submitPayment(...);
// Track the payment made activity
await this.activitiesService.trackPaymentMade(
userId,
splitId,
amount,
txHash,
{
asset,
timestamp: new Date().toISOString(),
status: "confirmed",
}
);
// Notify recipient(s) - they'll get payment_received activities
// const recipients = await this.getRecipients(splitId);
// for (const recipient of recipients) {
// await this.activitiesService.trackPaymentReceived(
// recipient.userId,
// splitId,
// amount,
// txHash,
// userId, // from address
// { asset }
// );
// }
} catch (error) {
console.error("Payment processing failed:", error);
throw error;
}
}
}