• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-mirakl-connector / 5798341140

pending completion
5798341140

push

github

web-flow
Merge pull request #129 from anuj-mirakl/php-symfony-upgradation

Php symfony upgradation

169 of 169 new or added lines in 28 files covered. (100.0%)

1767 of 1845 relevant lines covered (95.77%)

7.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.74
/src/Service/PaymentSplitService.php
1
<?php
2

3
namespace App\Service;
4

5
use App\Factory\StripeTransferFactory;
6
use App\Repository\StripeTransferRepository;
7

8
class PaymentSplitService
9
{
10
    /**
11
     * @var StripeTransferFactory
12
     */
13
    private $stripeTransferFactory;
14

15
    /**
16
     * @var StripeTransferRepository
17
     */
18
    private $stripeTransferRepository;
19

20
    private $enablePaymentTaxSplit;
21
    private $taxOrderPostfix;
22

23
    public function __construct(
24
        StripeTransferFactory $stripeTransferFactory,
25
        StripeTransferRepository $stripeTransferRepository,
26
        bool $enablePaymentTaxSplit,
27
        string $taxOrderPostfix
28
    ) {
29
        $this->stripeTransferFactory = $stripeTransferFactory;
12✔
30
        $this->stripeTransferRepository = $stripeTransferRepository;
12✔
31
        $this->enablePaymentTaxSplit = $enablePaymentTaxSplit;
12✔
32
        $this->taxOrderPostfix = $taxOrderPostfix;
12✔
33
    }
34

35
    /**
36
     * @return array App\Entity\StripeTransfer[]
37
     */
38
    public function getRetriableProductTransfers(): array
39
    {
40
        return $this->stripeTransferRepository->findRetriableProductOrderTransfers();
11✔
41
    }
42

43
    /**
44
     * @return array App\Entity\StripeTransfer[]
45
     */
46
    public function getRetriableServiceTransfers(): array
47
    {
48
        return $this->stripeTransferRepository->findRetriableServiceOrderTransfers();
9✔
49
    }
50

51
    /**
52
     * @return array App\Entity\StripeTransfer[]
53
     */
54
    public function getTransfersFromOrders(array $orders, array $pendingDebits): array
55
    {
56
        // Retrieve existing StripeTransfers with provided order IDs
57
        $existingTransfers = $this->stripeTransferRepository
9✔
58
            ->findTransfersByOrderIds(array_keys($orders));
9✔
59

60
        $transfers = [];
9✔
61
        foreach ($orders as $orderId => $order) {
9✔
62
            $pendingDebit = $pendingDebits[$orderId] ?? null;
9✔
63
            if (is_array($existingTransfers) && isset($existingTransfers[$orderId])) {
9✔
64
                $transfer = $existingTransfers[$orderId];
1✔
65
                if (!$transfer->isRetriable()) {
1✔
66
                    continue;
1✔
67
                }
68

69
                // Use existing transfer
70
                $transfer = $this->stripeTransferFactory->updateFromOrder($transfer, $order, $pendingDebit);
×
71
            } else {
72
                // Create new transfer
73
                $transfer = $this->stripeTransferFactory->createFromOrder($order, $pendingDebit);
9✔
74
                $this->stripeTransferRepository->persist($transfer);
9✔
75
                if ($this->enablePaymentTaxSplit) {
9✔
76
                    $tax_transfer = $this->stripeTransferFactory->createFromOrderForTax($order, $pendingDebit);
×
77
                    $this->stripeTransferRepository->persist($tax_transfer);
×
78
                }
79
            }
80

81
            $transfers[] = $transfer;
9✔
82
            if (isset($tax_transfer)) {
9✔
83
                $transfers[] = $tax_transfer;
×
84
            }
85
        }
86

87
        // Save
88
        $this->stripeTransferRepository->flush();
9✔
89

90
        return $transfers;
9✔
91
    }
92

93
    /**
94
     * @return array App\Entity\StripeTransfer[]
95
     */
96
    public function updateTransfersFromOrders(array $existingTransfers, array $orders, array $pendingDebits)
97
    {
98
        $updated = [];
5✔
99
        foreach ($existingTransfers as $orderId => $transfer) {
5✔
100
            $pendingDebit = $pendingDebits[$orderId] ?? null;
5✔
101
            if ($this->enablePaymentTaxSplit && false !== strpos($orderId, $this->taxOrderPostfix)) {
5✔
102
                $tax_suffixed_orderId = $orderId;
×
103
                $orderId = str_replace($this->taxOrderPostfix, '', $orderId);
×
104
                $pendingDebit = $pendingDebits[$orderId] ?? null;
×
105
                $updated[$tax_suffixed_orderId] = $this->stripeTransferFactory->updateFromOrder(
×
106
                    $transfer,
×
107
                    $orders[$orderId],
×
108
                    $pendingDebit,
×
109
                    true
×
110
                );
×
111
            } else {
112
                $updated[$orderId] = $this->stripeTransferFactory->updateFromOrder(
5✔
113
                    $transfer,
5✔
114
                    $orders[$orderId],
5✔
115
                    $pendingDebit
5✔
116
                );
5✔
117
            }
118
        }
119

120
        // Save
121
        $this->stripeTransferRepository->flush();
5✔
122

123
        return $updated;
5✔
124
    }
125
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc