Coverage for payment\services\payment_service.py: 50%

10 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-10-13 15:18 +0200

1from payment.infrastructure.payement_gateway import PaymentGatewayMock 

2 

3 

4class PaymentService: 

5 def create_payment_intent(self, amount, force_failed=False): 

6 """ 

7 Simule la création d'un Payment 

8 Le paiement n'est pas encore confirmé (capturé). 

9 """ 

10 if force_failed: 

11 return { 

12 "status": "failed", 

13 "transaction_id": None, 

14 "error": "Paiement refusé" 

15 } 

16 return { 

17 "status": "requires_confirmation", 

18 "transaction_id": "pi_mock_12345", 

19 "amount": amount 

20 } 

21 

22 def confirm_payment(self, transaction_id): 

23 """ 

24 Simule la confirmation du paiement. 

25 """ 

26 return { 

27 "status": "succeeded", 

28 "transaction_id": transaction_id 

29 } 

30 

31 def refund(self, transaction_id): 

32 """ 

33 Simule un remboursement 

34 """ 

35 return { 

36 "status": "refunded", 

37 "transaction_id": transaction_id 

38 }