This repository was archived by the owner on Aug 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Abonnements récurrents avec paypal #103
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
885f66d
Abonnements récurrents avec paypal
FunixG d705219
Fix copilot
FunixG 09589a3
Wip dtos paypal service
FunixG 7e79912
Done dtos for paypal interfacing
FunixG 301a8c4
Fix interfaces for external
FunixG 98bcf03
lang
FunixG 2771e03
V1 impl service
FunixG 1c001d2
Add webhook and fix build and tests, also connected subs to the billi…
FunixG ac5989c
Security
FunixG ad493a8
Done V1 of paypal subs
FunixG a31ff2f
Add migration file
FunixG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
...rc/main/java/com/funixproductions/api/payment/paypal/client/clients/PaypalPlanClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package com.funixproductions.api.payment.paypal.client.clients; | ||
|
|
||
| import com.funixproductions.api.payment.paypal.client.dtos.responses.PaypalPlanDTO; | ||
| import com.funixproductions.core.crud.dtos.PageDTO; | ||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.Min; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| /** | ||
| * Client pour gérer les plans d'abonnements Paypal. | ||
| */ | ||
| public interface PaypalPlanClient { | ||
|
|
||
| /** | ||
| * Crée un abonnement mensuel sur Paypal. | ||
| * @param paypalPlanDTO Dto pour créer un abonnement mensuel sur Paypal | ||
| * @return le plan créé (201 Http) | ||
| */ | ||
| @PostMapping | ||
| PaypalPlanDTO create(@RequestBody @Valid PaypalPlanDTO paypalPlanDTO); | ||
|
|
||
| /** | ||
| * Récupère un plan par son id. | ||
| * @param id id du plan (id de paypal) | ||
| * @return le plan (200 Http) | ||
| */ | ||
| @GetMapping("{id}") | ||
| PaypalPlanDTO getPlanById(@PathVariable @Valid @NotBlank String id); | ||
|
|
||
| /** | ||
| * Met à jour un plan. | ||
| * @param id id du plan (id de paypal) | ||
| * @param paypalPlanDTO Dto pour mettre à jour un plan | ||
| */ | ||
| @PatchMapping("{id}") | ||
| PaypalPlanDTO updatePlan(@PathVariable String id, @RequestBody @Valid PaypalPlanDTO paypalPlanDTO); | ||
|
|
||
| /** | ||
| * Active un plan, par ID. | ||
| * @param id id du plan (id de paypal) | ||
| */ | ||
| @PostMapping("{id}/activate") | ||
| PaypalPlanDTO activatePlan(@PathVariable @Valid @NotBlank String id); | ||
|
|
||
| /** | ||
| * Deactivates a plan, by ID. | ||
| * @param id the plan ID (PayPal ID) | ||
| */ | ||
| @PostMapping("{id}/deactivate") | ||
| PaypalPlanDTO deactivatePlan(@PathVariable @Valid @NotBlank String id); | ||
|
|
||
| @PostMapping("{id}/update-price") | ||
| PaypalPlanDTO updatePricePlan( | ||
| @PathVariable String id, | ||
| @RequestBody @Valid @NotNull(message = "Le prix du produit est obligatoire") @Min(value = 1, message = "Le prix du produit doit être supérieur à 1") Double newPrice | ||
| ); | ||
|
|
||
| @GetMapping | ||
| PageDTO<PaypalPlanDTO> getAll( | ||
| @RequestParam(value = "page",defaultValue = "0") String page, | ||
| @RequestParam(value = "elemsPerPage",defaultValue = "300") String elemsPerPage, | ||
| @RequestParam(value = "search",defaultValue = "") String search, | ||
| @RequestParam(value = "sort",defaultValue = "") String sort | ||
| ); | ||
|
|
||
| } |
11 changes: 11 additions & 0 deletions
11
...in/java/com/funixproductions/api/payment/paypal/client/clients/PaypalPlanFeignClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.funixproductions.api.payment.paypal.client.clients; | ||
|
|
||
| import org.springframework.cloud.openfeign.FeignClient; | ||
|
|
||
| @FeignClient( | ||
| name = "FunixProductionsPaypalPlanFeignClient", | ||
| url = "http://payment-paypal", | ||
| path = "/paypal/plans" | ||
| ) | ||
| public interface PaypalPlanFeignClient extends PaypalPlanClient { | ||
| } |
42 changes: 42 additions & 0 deletions
42
...java/com/funixproductions/api/payment/paypal/client/clients/PaypalSubscriptionClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.funixproductions.api.payment.paypal.client.clients; | ||
|
|
||
| import com.funixproductions.api.payment.paypal.client.dtos.requests.paypal.PaypalCreateSubscriptionDTO; | ||
| import com.funixproductions.api.payment.paypal.client.dtos.responses.PaypalSubscriptionDTO; | ||
| import com.funixproductions.core.crud.dtos.PageDTO; | ||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
|
|
||
| /** | ||
| * Client pour gérer les abonnements des utilisateurs sur Paypal. | ||
| */ | ||
| public interface PaypalSubscriptionClient { | ||
|
|
||
| @PostMapping | ||
| PaypalSubscriptionDTO subscribe(@NotNull @Valid PaypalCreateSubscriptionDTO request); | ||
|
|
||
| @GetMapping("{id}") | ||
| PaypalSubscriptionDTO getSubscriptionById(@PathVariable @Valid @NotBlank String id); | ||
|
|
||
| @PostMapping("{id}/pause") | ||
| PaypalSubscriptionDTO pauseSubscription(@PathVariable @Valid @NotBlank String id); | ||
|
|
||
| @PostMapping("{id}/activate") | ||
| PaypalSubscriptionDTO activateSubscription(@PathVariable @Valid @NotBlank String id); | ||
|
|
||
| @PostMapping("{id}/cancel") | ||
| void cancelSubscription(@PathVariable @Valid @NotBlank String id); | ||
|
|
||
| @GetMapping | ||
| PageDTO<PaypalSubscriptionDTO> getAll( | ||
| @RequestParam(value = "page",defaultValue = "0") String page, | ||
| @RequestParam(value = "elemsPerPage",defaultValue = "300") String elemsPerPage, | ||
| @RequestParam(value = "search",defaultValue = "") String search, | ||
| @RequestParam(value = "sort",defaultValue = "") String sort | ||
| ); | ||
|
|
||
| } |
11 changes: 11 additions & 0 deletions
11
...com/funixproductions/api/payment/paypal/client/clients/PaypalSubscriptionFeignClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.funixproductions.api.payment.paypal.client.clients; | ||
|
|
||
| import org.springframework.cloud.openfeign.FeignClient; | ||
|
|
||
| @FeignClient( | ||
| name = "FunixProductionsPaypalSubscriptionFeignClient", | ||
| url = "http://payment-paypal", | ||
| path = "/paypal/subscriptions" | ||
| ) | ||
| public interface PaypalSubscriptionFeignClient extends PaypalSubscriptionClient { | ||
| } |
42 changes: 42 additions & 0 deletions
42
...oductions/api/payment/paypal/client/dtos/requests/paypal/PaypalCreateSubscriptionDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.funixproductions.api.payment.paypal.client.dtos.requests.paypal; | ||
|
|
||
| import com.funixproductions.api.payment.paypal.client.dtos.responses.PaypalPlanDTO; | ||
| import com.funixproductions.core.tools.pdf.tools.VATInformation; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class PaypalCreateSubscriptionDTO { | ||
|
|
||
| @NotNull(message = "Le plan est obligatoire") | ||
| private PaypalPlanDTO plan; | ||
|
|
||
| @NotNull(message = "L'utilisateur id est obligatoire") | ||
| private UUID funixProdUserId; | ||
|
|
||
| /** | ||
| * LA TVA, null si pas de TVA | ||
| */ | ||
| @Nullable | ||
| private VATInformation vatInformation; | ||
|
|
||
| @NotBlank(message = "L'URL d'annulation est obligatoire") | ||
| private String cancelUrl; | ||
|
|
||
| @NotBlank(message = "L'URL de retour valide est obligatoire") | ||
| private String returnUrl; | ||
|
|
||
| @NotBlank(message = "La marque est obligatoire") | ||
| private String brandName; | ||
|
|
||
| } |
84 changes: 84 additions & 0 deletions
84
...ain/java/com/funixproductions/api/payment/paypal/client/dtos/responses/PaypalPlanDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package com.funixproductions.api.payment.paypal.client.dtos.responses; | ||
|
|
||
| import com.funixproductions.core.crud.dtos.ApiDTO; | ||
| import jakarta.validation.constraints.Max; | ||
| import jakarta.validation.constraints.Min; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
|
|
||
| /** | ||
| * Dto pour créer un abonnement mensuel sur Paypal. | ||
| * <a href="https://developer.paypal.com/docs/api/catalog-products/v1/#products_create">Create Product</a> | ||
| * <a href="https://developer.paypal.com/docs/api/subscriptions/v1/#plans_create">Create plan</a> | ||
| */ | ||
| @Getter | ||
| @Setter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class PaypalPlanDTO extends ApiDTO { | ||
|
|
||
| /** | ||
| * The plan id de paypal | ||
| */ | ||
| private String planId; | ||
|
|
||
| /** | ||
| * The subscription name. | ||
| */ | ||
| @NotBlank(message = "Le nom du produit est obligatoire") | ||
| @Min(value = 1, message = "Le nom du produit doit contenir au moins 1 caractère") | ||
| @Max(value = 127, message = "Le nom du produit doit contenir au maximum 127 caractères") | ||
| private String name; | ||
|
|
||
| /** | ||
| * The subscription description | ||
| */ | ||
| @NotBlank(message = "La description du produit est obligatoire") | ||
| @Min(value = 1, message = "La description du produit doit contenir au moins 1 caractère") | ||
| @Max(value = 256, message = "La description du produit doit contenir au maximum 256 caractères") | ||
FunixG marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private String description; | ||
|
|
||
| /** | ||
| * The image URL for the product. | ||
| */ | ||
| @NotBlank(message = "L'URL de l'image du produit est obligatoire") | ||
| @Min(value = 1, message = "L'URL de l'image du produit doit contenir au moins 1 caractère") | ||
| @Max(value = 2000, message = "L'URL de l'image du produit doit contenir au maximum 2000 caractères") | ||
FunixG marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private String imageUrl; | ||
|
|
||
| /** | ||
| * The home page URL for the product. | ||
| */ | ||
| @NotBlank(message = "L'URL de la page d'accueil du produit est obligatoire") | ||
| @Min(value = 1, message = "L'URL de la page d'accueil du produit doit contenir au moins 1 caractère") | ||
FunixG marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @Max(value = 2000, message = "L'URL de la page d'accueil du produit doit contenir au maximum 2000 caractères") | ||
| private String homeUrl; | ||
|
|
||
| /** | ||
| * The subscription price. HT Hors taxes | ||
| */ | ||
| @NotNull(message = "Le prix du produit est obligatoire") | ||
| @Min(value = 1, message = "Le prix du produit doit être supérieur à 1") | ||
| private Double price; | ||
|
|
||
| /** | ||
| * Le nom du projet auquel est associé le plan, exemple pacifista pour un pacifista+ | ||
| */ | ||
| @NotNull(message = "Le nom du projet est obligatoire") | ||
| @Min(value = 1, message = "Le nom du projet doit contenir au moins 1 caractère") | ||
| @Max(value = 50, message = "Le nom du projet doit contenir au maximum 50 caractères") | ||
FunixG marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private String projectName; | ||
|
|
||
| public PaypalPlanDTO(String name, String description, String imageUrl, String homeUrl, Double price) { | ||
| this.name = name; | ||
| this.description = description; | ||
| this.imageUrl = imageUrl; | ||
| this.homeUrl = homeUrl; | ||
| this.price = price; | ||
| } | ||
|
|
||
| } | ||
46 changes: 46 additions & 0 deletions
46
.../com/funixproductions/api/payment/paypal/client/dtos/responses/PaypalSubscriptionDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.funixproductions.api.payment.paypal.client.dtos.responses; | ||
|
|
||
| import com.funixproductions.core.crud.dtos.ApiDTO; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
|
|
||
| import java.util.Date; | ||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * <a href="https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create">Création d'un sub</a> | ||
| */ | ||
| @Getter | ||
| @Setter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class PaypalSubscriptionDTO extends ApiDTO { | ||
|
|
||
| /** | ||
| * Le plan, pour lequel l'abonnement est créé. Doit au moins contenir l'id et le planId du plan pour la création. | ||
| */ | ||
| private PaypalPlanDTO plan; | ||
|
|
||
| /** | ||
| * L'id utilisateur de la funixproductions | ||
| */ | ||
| private UUID funixProdUserId; | ||
|
|
||
| /** | ||
| * Si l'abonnement est actif ou non. (pause ou pas) | ||
| */ | ||
| private Boolean active; | ||
|
|
||
| /** | ||
| * La date du dernier paiement | ||
| */ | ||
| private Date lastPaymentDate; | ||
|
|
||
| /** | ||
| * La date du prochain paiement | ||
| */ | ||
| private Date nextPaymentDate; | ||
|
|
||
| } |
47 changes: 47 additions & 0 deletions
47
...funixproductions/api/payment/paypal/service/subscriptions/services/PaypalPlanService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package com.funixproductions.api.payment.paypal.service.subscriptions.services; | ||
|
|
||
| import com.funixproductions.api.payment.paypal.client.clients.PaypalPlanClient; | ||
| import com.funixproductions.api.payment.paypal.client.dtos.responses.PaypalPlanDTO; | ||
| import com.funixproductions.core.crud.dtos.PageDTO; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @Slf4j(topic = "PaypalPlanService") | ||
| public class PaypalPlanService implements PaypalPlanClient { | ||
|
|
||
| @Override | ||
| public PaypalPlanDTO create(PaypalPlanDTO paypalPlanDTO) { | ||
| return null; | ||
FunixG marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Override | ||
| public PaypalPlanDTO getPlanById(String id) { | ||
| return null; | ||
FunixG marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Override | ||
| public PaypalPlanDTO updatePlan(String id, PaypalPlanDTO paypalPlanDTO) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public PaypalPlanDTO activatePlan(String id) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public PaypalPlanDTO deactivatePlan(String id) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public PaypalPlanDTO updatePricePlan(String id, Double newPrice) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public PageDTO<PaypalPlanDTO> getAll(String page, String elemsPerPage, String search, String sort) { | ||
| return null; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.