Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit 52cb18b

Browse files
authored
Feature/pacifista plus (#27)
* wip p+ * p+
1 parent a50983b commit 52cb18b

File tree

10 files changed

+415
-127
lines changed

10 files changed

+415
-127
lines changed

package-lock.json

Lines changed: 168 additions & 107 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@funixproductions/angular-core",
3-
"version": "0.4.5",
3+
"version": "0.4.6",
44
"description": "Package used in all FunixProductions Angular projects",
55
"scripts": {
66
"ng": "ng",

projects/funixproductions-requests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@funixproductions/funixproductions-requests",
3-
"version": "0.4.5",
3+
"version": "0.4.6",
44
"description": "Package used in all FunixProductions Angular projects",
55
"peerDependencies": {
66
"@angular/common": "^19.1.7",
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import {ApiDTO} from "../../../core/dtos/api-dto";
2+
3+
export class PaypalPlanDTO extends ApiDTO {
4+
/**
5+
* The plan id de paypal
6+
*/
7+
planId?: string;
8+
9+
/**
10+
* The subscription name.
11+
*/
12+
name: string;
13+
14+
/**
15+
* The subscription description
16+
*/
17+
description: string;
18+
19+
/**
20+
* The image URL for the product.
21+
*/
22+
imageUrl: string;
23+
24+
/**
25+
* The home page URL for the product.
26+
*/
27+
homeUrl: string;
28+
29+
/**
30+
* The subscription price. HT Hors taxes
31+
*/
32+
price: number;
33+
34+
/**
35+
* Le nom du projet auquel est associé le plan, exemple pacifista pour un pacifista+
36+
*/
37+
projectName: string;
38+
39+
constructor(
40+
name: string,
41+
description: string,
42+
imageUrl: string,
43+
homeUrl: string,
44+
price: number,
45+
projectName: string,
46+
planId?: string
47+
) {
48+
super();
49+
this.name = name;
50+
this.description = description;
51+
this.imageUrl = imageUrl;
52+
this.homeUrl = homeUrl;
53+
this.price = price;
54+
this.projectName = projectName;
55+
this.planId = planId;
56+
}
57+
58+
equals(other: PaypalPlanDTO): boolean {
59+
return (
60+
this.name === other.name &&
61+
this.description === other.description &&
62+
this.imageUrl === other.imageUrl &&
63+
this.homeUrl === other.homeUrl &&
64+
this.price === other.price &&
65+
this.projectName === other.projectName &&
66+
(this.planId ? this.planId === other.planId : true)
67+
);
68+
}
69+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {PaypalPlanDTO} from "./PaypalPlanDTO";
2+
import {ApiDTO} from "../../../core/dtos/api-dto";
3+
4+
export class PaypalSubscriptionDTO extends ApiDTO {
5+
/**
6+
* Le plan, pour lequel l'abonnement est créé. Doit au moins contenir l'id et le planId du plan pour la création.
7+
*/
8+
plan!: PaypalPlanDTO;
9+
10+
/**
11+
* L'id de l'abonnement par PayPal
12+
*/
13+
subscriptionId?: string;
14+
15+
/**
16+
* L'id utilisateur de la funixproductions
17+
*/
18+
funixProdUserId!: string;
19+
20+
/**
21+
* Si l'abonnement est actif ou non. (pause ou pas)
22+
*/
23+
active!: boolean;
24+
25+
/**
26+
* Le nombre de cycles d'abonnement terminés
27+
*/
28+
cyclesCompleted!: number;
29+
30+
/**
31+
* La date du dernier paiement
32+
*/
33+
lastPaymentDate?: Date;
34+
35+
/**
36+
* La date du prochain paiement
37+
*/
38+
nextPaymentDate?: Date;
39+
40+
/**
41+
* Le lien pour approuver l'abonnement
42+
*/
43+
approveLink?: string;
44+
}

projects/funixproductions-requests/src/lib/services/pacifista-api/web/shop/articles/dtos/PacifistaShopArticleDTO.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,33 @@ import {PacifistaShopCategoryDTO} from "../../categories/dtos/PacifistaShopCateg
33
import {PacifistaServerType} from "../../../../core/enums/PacifistaServerType";
44

55
export class PacifistaShopArticleDTO extends ApiDTO {
6-
category?: PacifistaShopCategoryDTO;
7-
name?: string;
8-
description?: string;
9-
htmlDescription?: string;
10-
price?: number;
6+
category: PacifistaShopCategoryDTO;
7+
name: string;
8+
description: string;
9+
htmlDescription: string;
10+
markDownDescription: string;
11+
price: number;
1112
tax?: number;
1213
priceWithTax?: number;
13-
commandExecuted?: string;
14+
commandExecuted: string;
1415
serverType?: PacifistaServerType;
16+
17+
constructor(category: PacifistaShopCategoryDTO,
18+
name: string,
19+
description: string,
20+
htmlDescription: string,
21+
markDownDescription: string,
22+
price: number,
23+
commandExecuted: string,
24+
serverType?: PacifistaServerType) {
25+
super();
26+
this.category = category;
27+
this.name = name;
28+
this.description = description;
29+
this.htmlDescription = htmlDescription;
30+
this.markDownDescription = markDownDescription;
31+
this.price = price;
32+
this.commandExecuted = commandExecuted;
33+
this.serverType = serverType;
34+
}
1535
}
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import {ApiDTO} from "../../../../../core/dtos/api-dto";
22

33
export class PacifistaShopCategoryDTO extends ApiDTO {
4-
name?: string;
5-
description?: string;
6-
multiPurchaseAllowed?: boolean;
4+
name: string;
5+
description: string;
6+
multiPurchaseAllowed: boolean;
7+
8+
constructor(name: string, description: string, multiPurchaseAllowed: boolean) {
9+
super();
10+
this.name = name;
11+
this.description = description;
12+
this.multiPurchaseAllowed = multiPurchaseAllowed;
13+
}
714
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
1-
21
export class PacifistaPaymentRequestDTO {
3-
articles?: PacifistaShopArtcileRequestDTO[];
2+
articles: PacifistaShopArtcileRequestDTO[];
43
creditCard?: PacifistaShopCreditCardDTO;
4+
5+
constructor(articles: PacifistaShopArtcileRequestDTO[],
6+
creditCard?: PacifistaShopCreditCardDTO) {
7+
this.articles = articles;
8+
this.creditCard = creditCard;
9+
}
510
}
611

712
export class PacifistaShopArtcileRequestDTO {
8-
articleId?: string;
9-
quantity?: number;
13+
articleId: string;
14+
quantity: number;
15+
16+
constructor(articleId: string, quantity: number) {
17+
this.articleId = articleId;
18+
this.quantity = quantity;
19+
}
1020
}
1121

1222
export class PacifistaShopCreditCardDTO {
13-
cardHolderName?: string;
14-
cardNumber?: string;
15-
securityCode?: string;
16-
expirationMonth?: number;
17-
expirationYear?: number;
23+
cardHolderName: string;
24+
cardNumber: string;
25+
securityCode: string;
26+
expirationMonth: number;
27+
expirationYear: number;
28+
29+
constructor(cardHolderName: string,
30+
cardNumber: string,
31+
securityCode: string,
32+
expirationMonth: number,
33+
expirationYear: number) {
34+
this.cardHolderName = cardHolderName;
35+
this.cardNumber = cardNumber;
36+
this.securityCode = securityCode;
37+
this.expirationMonth = expirationMonth;
38+
this.expirationYear = expirationYear;
39+
}
1840
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import {FunixprodHttpClient} from "../../../../../core/components/requests/funixprod-http-client";
2+
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
3+
import {environment} from "../../../../../../../environments/environment";
4+
import {environmentDev} from "../../../../../../../environments/environment-dev";
5+
import {catchError, Observable, throwError} from "rxjs";
6+
import {PaypalSubscriptionDTO} from "../../../../../funixproductions-api/billing/dtos/PaypalSubscriptionDTO";
7+
8+
export class PacifistaPlusPaymentService extends FunixprodHttpClient {
9+
10+
url: string;
11+
12+
constructor(protected httpClient: HttpClient, production: boolean) {
13+
super();
14+
this.url = production ? environment.pacifistaApiUrl : environmentDev.pacifistaApiUrl + 'web/shop/pacifistaplus';
15+
}
16+
17+
createSubscription(): Observable<PaypalSubscriptionDTO> {
18+
return this.httpClient.post<PaypalSubscriptionDTO>(this.url, null, {headers: super.getHeaders()})
19+
.pipe(
20+
catchError((error: HttpErrorResponse) => {
21+
return throwError(() => this.buildErrorDto(error));
22+
})
23+
);
24+
}
25+
26+
getSubscriptionStatus(): Observable<PaypalSubscriptionDTO> {
27+
return this.httpClient.get<PaypalSubscriptionDTO>(this.url, {headers: super.getHeaders()})
28+
.pipe(
29+
catchError((error: HttpErrorResponse) => {
30+
return throwError(() => this.buildErrorDto(error));
31+
})
32+
);
33+
}
34+
35+
pauseSubscription(): Observable<PaypalSubscriptionDTO> {
36+
return this.httpClient.post<PaypalSubscriptionDTO>(this.url + '/pause', null, {headers: super.getHeaders()})
37+
.pipe(
38+
catchError((error: HttpErrorResponse) => {
39+
return throwError(() => this.buildErrorDto(error));
40+
})
41+
);
42+
}
43+
44+
resumeSubscription(): Observable<PaypalSubscriptionDTO> {
45+
return this.httpClient.post<PaypalSubscriptionDTO>(this.url + '/resume', null, {headers: super.getHeaders()})
46+
.pipe(
47+
catchError((error: HttpErrorResponse) => {
48+
return throwError(() => this.buildErrorDto(error));
49+
})
50+
);
51+
}
52+
53+
cancelSubscription(): Observable<PaypalSubscriptionDTO> {
54+
return this.httpClient.post<PaypalSubscriptionDTO>(this.url + '/cancel', null, {headers: super.getHeaders()})
55+
.pipe(
56+
catchError((error: HttpErrorResponse) => {
57+
return throwError(() => this.buildErrorDto(error));
58+
})
59+
);
60+
}
61+
62+
}

projects/funixproductions-requests/src/public-api.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export * from './lib/services/funixproductions-api/accounting/dtos/income-dto';
3535
export * from './lib/services/funixproductions-api/accounting/dtos/product-dto';
3636
export * from './lib/services/funixproductions-api/billing/dtos/funixprod-billing-dto';
3737
export * from './lib/services/funixproductions-api/billing/services/funixprod-billing-service';
38+
export * from './lib/services/funixproductions-api/billing/dtos/PaypalPlanDTO';
39+
export * from './lib/services/funixproductions-api/billing/dtos/PaypalSubscriptionDTO';
3840
export * from './lib/services/funixproductions-api/user/services/user-jwt-checker-service';
3941
export * from './lib/services/funixproductions-api/user/dtos/user-session-jwt';
4042
export * from './lib/services/funixproductions-api/user/services/user-auth-service';
@@ -83,6 +85,7 @@ export * from './lib/services/pacifista-api/web/shop/categories/dtos/PacifistaSh
8385
export * from './lib/services/pacifista-api/web/shop/payment/dtos/responses/PacifistaPaymentResponseDTO';
8486
export * from './lib/services/pacifista-api/web/shop/payment/dtos/requests/PacifistaPaymentRequestDTO';
8587
export * from './lib/services/pacifista-api/web/shop/payment/services/PacifistaPaymentService';
88+
export * from './lib/services/pacifista-api/web/shop/payment/services/PacifistaPlusPaymentService';
8689

8790
export * from './lib/services/pacifista-api/server/players/data/dtos/PacifistaPlayerDataDTO';
8891
export * from './lib/services/pacifista-api/server/players/data/dtos/PacifistaPlayerChatMessageDTO';

0 commit comments

Comments
 (0)