Completed
Branch apply-extra-txn-fees-to-regs (69a605)
by
unknown
03:37 queued 13s
created
extra_txn_fees/line_items/ApplyExtraFeesToPrimaryRegistrantOnly.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -16,59 +16,59 @@
 block discarded – undo
16 16
 class ApplyExtraFeesToPrimaryRegistrantOnly implements ExtraTxnFeesDistributionStrategyInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @param EEI_Line_Item $line_item
21
-     * @param EEI_Line_Item $child_line_item
22
-     * @param float         $original_li_total
23
-     * @param float         $running_total_for_all_tickets
24
-     * @param float         $running_total_for_specific_ticket
25
-     * @param bool          $is_primary_registrant
26
-     * @param int           $total_reg_count
27
-     * @param string        $context
28
-     * @throws EE_Error
29
-     */
30
-    public function adjustUnitPriceForNonTicketLineItem(
31
-        EEI_Line_Item $line_item,
32
-        EEI_Line_Item $child_line_item,
33
-        $original_li_total,
34
-        $running_total_for_all_tickets,
35
-        $running_total_for_specific_ticket,
36
-        $is_primary_registrant,
37
-        $total_reg_count,
38
-        $context
39
-    ) {
40
-        $percent_of_running_total = $running_total_for_all_tickets
41
-            ? $original_li_total / $running_total_for_all_tickets
42
-            : 0;
43
-        $line_item->set_total($running_total_for_specific_ticket * $percent_of_running_total);
19
+	/**
20
+	 * @param EEI_Line_Item $line_item
21
+	 * @param EEI_Line_Item $child_line_item
22
+	 * @param float         $original_li_total
23
+	 * @param float         $running_total_for_all_tickets
24
+	 * @param float         $running_total_for_specific_ticket
25
+	 * @param bool          $is_primary_registrant
26
+	 * @param int           $total_reg_count
27
+	 * @param string        $context
28
+	 * @throws EE_Error
29
+	 */
30
+	public function adjustUnitPriceForNonTicketLineItem(
31
+		EEI_Line_Item $line_item,
32
+		EEI_Line_Item $child_line_item,
33
+		$original_li_total,
34
+		$running_total_for_all_tickets,
35
+		$running_total_for_specific_ticket,
36
+		$is_primary_registrant,
37
+		$total_reg_count,
38
+		$context
39
+	) {
40
+		$percent_of_running_total = $running_total_for_all_tickets
41
+			? $original_li_total / $running_total_for_all_tickets
42
+			: 0;
43
+		$line_item->set_total($running_total_for_specific_ticket * $percent_of_running_total);
44 44
 
45
-        if ($context === ExtraTxnFeesHandler::CONTEXT_ONE_REGISTRATION && ! $is_primary_registrant) {
46
-            $child_line_item->set_unit_price(0);
47
-            $child_line_item->set_quantity(0);
48
-            $child_line_item->set_total(0);
49
-        }
45
+		if ($context === ExtraTxnFeesHandler::CONTEXT_ONE_REGISTRATION && ! $is_primary_registrant) {
46
+			$child_line_item->set_unit_price(0);
47
+			$child_line_item->set_quantity(0);
48
+			$child_line_item->set_total(0);
49
+		}
50 50
 
51
-        if (! $line_item->is_percent()) {
52
-            $line_item->set_unit_price($line_item->total() / $line_item->quantity());
53
-        }
54
-    }
51
+		if (! $line_item->is_percent()) {
52
+			$line_item->set_unit_price($line_item->total() / $line_item->quantity());
53
+		}
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * @param EEI_Line_Item $line_item
59
-     * @param EEI_Line_Item $child_line_item
60
-     * @param bool          $is_primary_registrant
61
-     * @param int           $total_reg_count
62
-     * @param string        $context
63
-     */
64
-    public function adjustUnitPriceAndQtyForTicketLineItem(
65
-        EEI_Line_Item $line_item,
66
-        EEI_Line_Item $child_line_item,
67
-        $is_primary_registrant,
68
-        $total_reg_count,
69
-        $context
70
-    ) {
71
-        $child_line_item->set_quantity($line_item->quantity());
72
-        $child_line_item->set_total($child_line_item->unit_price() * $child_line_item->quantity());
73
-    }
57
+	/**
58
+	 * @param EEI_Line_Item $line_item
59
+	 * @param EEI_Line_Item $child_line_item
60
+	 * @param bool          $is_primary_registrant
61
+	 * @param int           $total_reg_count
62
+	 * @param string        $context
63
+	 */
64
+	public function adjustUnitPriceAndQtyForTicketLineItem(
65
+		EEI_Line_Item $line_item,
66
+		EEI_Line_Item $child_line_item,
67
+		$is_primary_registrant,
68
+		$total_reg_count,
69
+		$context
70
+	) {
71
+		$child_line_item->set_quantity($line_item->quantity());
72
+		$child_line_item->set_total($child_line_item->unit_price() * $child_line_item->quantity());
73
+	}
74 74
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
             $child_line_item->set_total(0);
49 49
         }
50 50
 
51
-        if (! $line_item->is_percent()) {
51
+        if ( ! $line_item->is_percent()) {
52 52
             $line_item->set_unit_price($line_item->total() / $line_item->quantity());
53 53
         }
54 54
     }
Please login to merge, or discard this patch.
checkout/extra_txn_fees/spco/ExtraTxnFeesDistributionStrategyInterface.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@
 block discarded – undo
6 6
 
7 7
 interface ExtraTxnFeesDistributionStrategyInterface
8 8
 {
9
-    /**
10
-     * @param float $extra_fees
11
-     * @param EE_Registration[] $registrations
12
-     */
13
-    public function applyExtraFeesToRegistrants($extra_fees, array $registrations);
9
+	/**
10
+	 * @param float $extra_fees
11
+	 * @param EE_Registration[] $registrations
12
+	 */
13
+	public function applyExtraFeesToRegistrants($extra_fees, array $registrations);
14 14
 }
Please login to merge, or discard this patch.
checkout/extra_txn_fees/spco/ApplyExtraFeesToAllRegistrationsEvenly.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@
 block discarded – undo
15 15
  */
16 16
 class ApplyExtraFeesToAllRegistrationsEvenly implements ExtraTxnFeesDistributionStrategyInterface
17 17
 {
18
-    /**
19
-     * @param float             $extra_fees
20
-     * @param EE_Registration[] $registrations
21
-     * @throws EE_Error
22
-     * @throws ReflectionException
23
-     */
24
-    public function applyExtraFeesToRegistrants($extra_fees, array $registrations)
25
-    {
26
-        // divide remaining fees by number of registrations and apply to each
27
-        $extra_payment = $extra_fees / count($registrations);
28
-        foreach ($registrations as $registration) {
29
-            if ($registration instanceof EE_Registration) {
30
-                $new_registration_total = $registration->final_price() + $extra_payment;
31
-                $registration->set_final_price($new_registration_total);
32
-                $registration->save();
33
-            }
34
-        }
35
-    }
18
+	/**
19
+	 * @param float             $extra_fees
20
+	 * @param EE_Registration[] $registrations
21
+	 * @throws EE_Error
22
+	 * @throws ReflectionException
23
+	 */
24
+	public function applyExtraFeesToRegistrants($extra_fees, array $registrations)
25
+	{
26
+		// divide remaining fees by number of registrations and apply to each
27
+		$extra_payment = $extra_fees / count($registrations);
28
+		foreach ($registrations as $registration) {
29
+			if ($registration instanceof EE_Registration) {
30
+				$new_registration_total = $registration->final_price() + $extra_payment;
31
+				$registration->set_final_price($new_registration_total);
32
+				$registration->save();
33
+			}
34
+		}
35
+	}
36 36
 }
Please login to merge, or discard this patch.
services/checkout/extra_txn_fees/spco/ExtraTxnFeesForRegistrantsHandler.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -17,51 +17,51 @@
 block discarded – undo
17 17
 class ExtraTxnFeesForRegistrantsHandler extends ExtraTxnFeesHandler
18 18
 {
19 19
 
20
-    /**
21
-     * @var ExtraTxnFeesDistributionStrategyInterface
22
-     */
23
-    protected $extra_fees_strategy;
20
+	/**
21
+	 * @var ExtraTxnFeesDistributionStrategyInterface
22
+	 */
23
+	protected $extra_fees_strategy;
24 24
 
25 25
 
26
-    /**
27
-     * @return void
28
-     * @throws DomainException
29
-     * @throws EE_Error
30
-     * @throws ReflectionException
31
-     */
32
-    public function applyExtraFeesToRegistrants()
33
-    {
34
-        $this->calculateExtraFeesForRegistrations($this->registrations);
35
-        // if there's money owing after all the individual registration fees have been subtracted
36
-        if ($this->extra_fees > 0) {
37
-            // then first decide whether to spread extra fees across all registrations,
38
-            // or assign everything to the primary registrant
39
-            $extra_fees_strategy = $this->getExtraTxnFeesDistributionStrategy();
40
-            $extra_fees_strategy->applyExtraFeesToRegistrants($this->extra_fees, $this->registrations);
41
-        }
42
-    }
26
+	/**
27
+	 * @return void
28
+	 * @throws DomainException
29
+	 * @throws EE_Error
30
+	 * @throws ReflectionException
31
+	 */
32
+	public function applyExtraFeesToRegistrants()
33
+	{
34
+		$this->calculateExtraFeesForRegistrations($this->registrations);
35
+		// if there's money owing after all the individual registration fees have been subtracted
36
+		if ($this->extra_fees > 0) {
37
+			// then first decide whether to spread extra fees across all registrations,
38
+			// or assign everything to the primary registrant
39
+			$extra_fees_strategy = $this->getExtraTxnFeesDistributionStrategy();
40
+			$extra_fees_strategy->applyExtraFeesToRegistrants($this->extra_fees, $this->registrations);
41
+		}
42
+	}
43 43
 
44
-    /**
45
-     * @return ExtraTxnFeesDistributionStrategyInterface
46
-     * @throws DomainException
47
-     */
48
-    private function getExtraTxnFeesDistributionStrategy()
49
-    {
50
-        if (! $this->extra_fees_strategy instanceof ExtraTxnFeesDistributionStrategyInterface) {
51
-            switch ($this->getDistributionStrategy()) {
52
-                case ExtraTxnFeesHandler::STRATEGY_PRIMARY_REGISTRANT_ONLY:
53
-                    $extra_fees_strategy = new ApplyExtraFeesToPrimaryRegistrantOnly();
54
-                    break;
55
-                case ExtraTxnFeesHandler::STRATEGY_DISTRIBUTE_EVENLY:
56
-                default:
57
-                    $extra_fees_strategy = new ApplyExtraFeesToAllRegistrationsEvenly();
58
-            }
59
-            $this->validateExtraTxnFeesDistributionStrategy(
60
-                $extra_fees_strategy,
61
-                ExtraTxnFeesDistributionStrategyInterface::class
62
-            );
63
-            $this->extra_fees_strategy = $extra_fees_strategy;
64
-        }
65
-        return $this->extra_fees_strategy;
66
-    }
44
+	/**
45
+	 * @return ExtraTxnFeesDistributionStrategyInterface
46
+	 * @throws DomainException
47
+	 */
48
+	private function getExtraTxnFeesDistributionStrategy()
49
+	{
50
+		if (! $this->extra_fees_strategy instanceof ExtraTxnFeesDistributionStrategyInterface) {
51
+			switch ($this->getDistributionStrategy()) {
52
+				case ExtraTxnFeesHandler::STRATEGY_PRIMARY_REGISTRANT_ONLY:
53
+					$extra_fees_strategy = new ApplyExtraFeesToPrimaryRegistrantOnly();
54
+					break;
55
+				case ExtraTxnFeesHandler::STRATEGY_DISTRIBUTE_EVENLY:
56
+				default:
57
+					$extra_fees_strategy = new ApplyExtraFeesToAllRegistrationsEvenly();
58
+			}
59
+			$this->validateExtraTxnFeesDistributionStrategy(
60
+				$extra_fees_strategy,
61
+				ExtraTxnFeesDistributionStrategyInterface::class
62
+			);
63
+			$this->extra_fees_strategy = $extra_fees_strategy;
64
+		}
65
+		return $this->extra_fees_strategy;
66
+	}
67 67
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
      */
31 31
     private function getExtraTxnFeesDistributionStrategy()
32 32
     {
33
-        if (! $this->extra_fees_strategy instanceof ExtraTxnFeesDistributionStrategyInterface) {
33
+        if ( ! $this->extra_fees_strategy instanceof ExtraTxnFeesDistributionStrategyInterface) {
34 34
             switch ($this->getDistributionStrategy()) {
35 35
                 case ExtraTxnFeesHandler::STRATEGY_PRIMARY_REGISTRANT_ONLY:
36 36
                     $extra_fees_strategy = new ApplyExtraFeesToPrimaryRegistrantOnly();
Please login to merge, or discard this patch.
checkout/extra_txn_fees/spco/ApplyExtraFeesToPrimaryRegistrantOnly.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@
 block discarded – undo
15 15
  */
16 16
 class ApplyExtraFeesToPrimaryRegistrantOnly implements ExtraTxnFeesDistributionStrategyInterface
17 17
 {
18
-    /**
19
-     * @param float             $extra_fees
20
-     * @param EE_Registration[] $registrations
21
-     * @throws EE_Error
22
-     * @throws ReflectionException
23
-     */
24
-    public function applyExtraFeesToRegistrants($extra_fees, array $registrations)
25
-    {
26
-        foreach ($registrations as $registration) {
27
-            if ($registration instanceof EE_Registration && $registration->is_primary_registrant()) {
28
-                $primary_registrant_total = $registration->final_price() + $extra_fees;
29
-                $registration->set_final_price($primary_registrant_total);
30
-                $registration->save();
31
-            }
32
-        }
33
-    }
18
+	/**
19
+	 * @param float             $extra_fees
20
+	 * @param EE_Registration[] $registrations
21
+	 * @throws EE_Error
22
+	 * @throws ReflectionException
23
+	 */
24
+	public function applyExtraFeesToRegistrants($extra_fees, array $registrations)
25
+	{
26
+		foreach ($registrations as $registration) {
27
+			if ($registration instanceof EE_Registration && $registration->is_primary_registrant()) {
28
+				$primary_registrant_total = $registration->final_price() + $extra_fees;
29
+				$registration->set_final_price($primary_registrant_total);
30
+				$registration->save();
31
+			}
32
+		}
33
+	}
34 34
 }
Please login to merge, or discard this patch.
core/domain/services/checkout/extra_txn_fees/ExtraTxnFeesHandler.php 2 patches
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -19,191 +19,191 @@
 block discarded – undo
19 19
 abstract class ExtraTxnFeesHandler
20 20
 {
21 21
 
22
-    const CONTEXT_ALL_REGISTRATIONS = 'all-registrations';
22
+	const CONTEXT_ALL_REGISTRATIONS = 'all-registrations';
23 23
 
24
-    const CONTEXT_ONE_REGISTRATION  = 'one-registration';
24
+	const CONTEXT_ONE_REGISTRATION  = 'one-registration';
25 25
 
26
-    const STRATEGY_DISTRIBUTE_EVENLY       = 'distribute-evenly';
26
+	const STRATEGY_DISTRIBUTE_EVENLY       = 'distribute-evenly';
27 27
 
28
-    const STRATEGY_PRIMARY_REGISTRANT_ONLY = 'primary-registrant-only';
28
+	const STRATEGY_PRIMARY_REGISTRANT_ONLY = 'primary-registrant-only';
29 29
 
30 30
 
31
-    /**
32
-     * @var string
33
-     */
34
-    protected $context = '';
31
+	/**
32
+	 * @var string
33
+	 */
34
+	protected $context = '';
35 35
 
36
-    /**
37
-     * one of the STRATEGY_* constants above
38
-     *
39
-     * @var string
40
-     */
41
-    protected $distribution_strategy;
36
+	/**
37
+	 * one of the STRATEGY_* constants above
38
+	 *
39
+	 * @var string
40
+	 */
41
+	protected $distribution_strategy;
42 42
 
43
-    /**
44
-     * @var float
45
-     */
46
-    protected $extra_fees = 0.00;
43
+	/**
44
+	 * @var float
45
+	 */
46
+	protected $extra_fees = 0.00;
47 47
 
48
-    /**
49
-     * @var int
50
-     */
51
-    protected $reg_count = 0;
48
+	/**
49
+	 * @var int
50
+	 */
51
+	protected $reg_count = 0;
52 52
 
53
-    /**
54
-     * @var int
55
-     */
56
-    protected $total_reg_count = 0;
53
+	/**
54
+	 * @var int
55
+	 */
56
+	protected $total_reg_count = 0;
57 57
 
58
-    /*
58
+	/*
59 59
      * ALL of the registrations for the transaction
60 60
      *
61 61
      * @var EE_Registration[]
62 62
      */
63
-    protected $all_registrations;
63
+	protected $all_registrations;
64 64
 
65
-    /*
65
+	/*
66 66
      * just the registration being currently processed
67 67
      *
68 68
      * @var EE_Registration[]
69 69
      */
70
-    protected $registrations;
70
+	protected $registrations;
71 71
 
72
-    /*
72
+	/*
73 73
      * @var EE_Transaction
74 74
      */
75
-    protected $transaction;
76
-
77
-
78
-    /**
79
-     * ExtraTxnFeesHandler constructor.
80
-     *
81
-     * @param EE_Registration[] $registrations
82
-     * @throws EE_Error
83
-     * @throws ReflectionException
84
-     */
85
-    public function __construct(array $registrations)
86
-    {
87
-        $this->setDistributionStrategy(
88
-            apply_filters(
89
-                'FHEE__EventEspresso_core_domain_services_checkout__ExtraTxnFeesHandler__distribution_strategy',
90
-                // STRATEGY_DISTRIBUTE_EVENLY or STRATEGY_PRIMARY_REGISTRANT_ONLY
91
-                ExtraTxnFeesHandler::STRATEGY_DISTRIBUTE_EVENLY
92
-            )
93
-        );
94
-        $this->setRegistrationsAndTransactions($registrations);
95
-        $this->setContext();
96
-    }
97
-
98
-
99
-    /**
100
-     * @param EE_Transaction    $transaction
101
-     * @param EE_Registration[] $registrations
102
-     * @throws EE_Error
103
-     * @throws ReflectionException
104
-     */
105
-    private function calculateExtraFees(EE_Transaction $transaction, array $registrations)
106
-    {
107
-        // we're going to calculate if there are any extra fees on the TXN, so start with the full amount
108
-        $extra_fees = $transaction->total();
109
-        // then subtract the total for each registration from what's owing for the entire txn
110
-        foreach ($registrations as $registration) {
111
-            if ($registration instanceof EE_Registration) {
112
-                $extra_fees -= $registration->final_price();
113
-            }
114
-        }
115
-        $this->extra_fees = $extra_fees;
116
-    }
117
-
118
-
119
-    /**
120
-     * @param EE_Registration[] $registrations
121
-     * @throws EE_Error
122
-     * @throws ReflectionException
123
-     */
124
-    protected function calculateExtraFeesForRegistrations(array $registrations)
125
-    {
126
-        $this->setRegistrationsAndTransactions($registrations);
127
-        $this->calculateExtraFees($this->transaction, $this->registrations);
128
-    }
129
-
130
-
131
-    /**
132
-     * @return void
133
-     */
134
-    public function setContext()
135
-    {
136
-        $reg_count             = count($this->registrations);
137
-        $this->total_reg_count = count($this->all_registrations);
138
-        $this->context         = $reg_count === 1 && $reg_count !== $this->total_reg_count
139
-            ? ExtraTxnFeesHandler::CONTEXT_ONE_REGISTRATION
140
-            : ExtraTxnFeesHandler::CONTEXT_ALL_REGISTRATIONS;
141
-    }
142
-
143
-
144
-    /**
145
-     * @param EE_Registration[] $registrations
146
-     * @throws EE_Error
147
-     * @throws ReflectionException
148
-     */
149
-    protected function setRegistrationsAndTransactions(array $registrations)
150
-    {
151
-        $registration = reset($registrations);
152
-        if (! $registration instanceof EE_Registration) {
153
-            throw new DomainException(
154
-                esc_html__(
155
-                    'Invalid Registrations supplied to ExtraTxnFeesForLineItemsHandler::applyExtraFeesToLineItems()',
156
-                    'event_espresso'
157
-                )
158
-            );
159
-        }
160
-        $this->registrations = $registrations;
161
-        $this->transaction   = $registration->transaction();
162
-        $this->all_registrations   = $this->transaction->registrations();
163
-    }
164
-
165
-
166
-    /**
167
-     * @param string $distribution_strategy
168
-     */
169
-    private function setDistributionStrategy($distribution_strategy)
170
-    {
171
-        $valid_distribution_strategies = [
172
-            ExtraTxnFeesHandler::STRATEGY_DISTRIBUTE_EVENLY,
173
-            ExtraTxnFeesHandler::STRATEGY_PRIMARY_REGISTRANT_ONLY,
174
-        ];
175
-        $this->distribution_strategy   = in_array($distribution_strategy, $valid_distribution_strategies)
176
-            ? $distribution_strategy
177
-            : ExtraTxnFeesHandler::STRATEGY_DISTRIBUTE_EVENLY;
178
-    }
179
-
180
-
181
-    /**
182
-     * @param object $extra_fees_strategy
183
-     * @param string $required_interface
184
-     */
185
-    protected function validateExtraTxnFeesDistributionStrategy($extra_fees_strategy, $required_interface)
186
-    {
187
-        if (! is_subclass_of($extra_fees_strategy, $required_interface)) {
188
-            throw new DomainException(
189
-                sprintf(
190
-                    esc_html__(
191
-                        'Invalid Extra Txn Fees Distribution Strategy. Expected: [%1$s] Received: [%2$s]',
192
-                        'event_espresso'
193
-                    ),
194
-                    $required_interface,
195
-                    is_object($extra_fees_strategy) ? get_class($extra_fees_strategy) : 'Unknown'
196
-                )
197
-            );
198
-        }
199
-    }
200
-
201
-
202
-    /**
203
-     * @return string
204
-     */
205
-    public function getDistributionStrategy()
206
-    {
207
-        return $this->distribution_strategy;
208
-    }
75
+	protected $transaction;
76
+
77
+
78
+	/**
79
+	 * ExtraTxnFeesHandler constructor.
80
+	 *
81
+	 * @param EE_Registration[] $registrations
82
+	 * @throws EE_Error
83
+	 * @throws ReflectionException
84
+	 */
85
+	public function __construct(array $registrations)
86
+	{
87
+		$this->setDistributionStrategy(
88
+			apply_filters(
89
+				'FHEE__EventEspresso_core_domain_services_checkout__ExtraTxnFeesHandler__distribution_strategy',
90
+				// STRATEGY_DISTRIBUTE_EVENLY or STRATEGY_PRIMARY_REGISTRANT_ONLY
91
+				ExtraTxnFeesHandler::STRATEGY_DISTRIBUTE_EVENLY
92
+			)
93
+		);
94
+		$this->setRegistrationsAndTransactions($registrations);
95
+		$this->setContext();
96
+	}
97
+
98
+
99
+	/**
100
+	 * @param EE_Transaction    $transaction
101
+	 * @param EE_Registration[] $registrations
102
+	 * @throws EE_Error
103
+	 * @throws ReflectionException
104
+	 */
105
+	private function calculateExtraFees(EE_Transaction $transaction, array $registrations)
106
+	{
107
+		// we're going to calculate if there are any extra fees on the TXN, so start with the full amount
108
+		$extra_fees = $transaction->total();
109
+		// then subtract the total for each registration from what's owing for the entire txn
110
+		foreach ($registrations as $registration) {
111
+			if ($registration instanceof EE_Registration) {
112
+				$extra_fees -= $registration->final_price();
113
+			}
114
+		}
115
+		$this->extra_fees = $extra_fees;
116
+	}
117
+
118
+
119
+	/**
120
+	 * @param EE_Registration[] $registrations
121
+	 * @throws EE_Error
122
+	 * @throws ReflectionException
123
+	 */
124
+	protected function calculateExtraFeesForRegistrations(array $registrations)
125
+	{
126
+		$this->setRegistrationsAndTransactions($registrations);
127
+		$this->calculateExtraFees($this->transaction, $this->registrations);
128
+	}
129
+
130
+
131
+	/**
132
+	 * @return void
133
+	 */
134
+	public function setContext()
135
+	{
136
+		$reg_count             = count($this->registrations);
137
+		$this->total_reg_count = count($this->all_registrations);
138
+		$this->context         = $reg_count === 1 && $reg_count !== $this->total_reg_count
139
+			? ExtraTxnFeesHandler::CONTEXT_ONE_REGISTRATION
140
+			: ExtraTxnFeesHandler::CONTEXT_ALL_REGISTRATIONS;
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param EE_Registration[] $registrations
146
+	 * @throws EE_Error
147
+	 * @throws ReflectionException
148
+	 */
149
+	protected function setRegistrationsAndTransactions(array $registrations)
150
+	{
151
+		$registration = reset($registrations);
152
+		if (! $registration instanceof EE_Registration) {
153
+			throw new DomainException(
154
+				esc_html__(
155
+					'Invalid Registrations supplied to ExtraTxnFeesForLineItemsHandler::applyExtraFeesToLineItems()',
156
+					'event_espresso'
157
+				)
158
+			);
159
+		}
160
+		$this->registrations = $registrations;
161
+		$this->transaction   = $registration->transaction();
162
+		$this->all_registrations   = $this->transaction->registrations();
163
+	}
164
+
165
+
166
+	/**
167
+	 * @param string $distribution_strategy
168
+	 */
169
+	private function setDistributionStrategy($distribution_strategy)
170
+	{
171
+		$valid_distribution_strategies = [
172
+			ExtraTxnFeesHandler::STRATEGY_DISTRIBUTE_EVENLY,
173
+			ExtraTxnFeesHandler::STRATEGY_PRIMARY_REGISTRANT_ONLY,
174
+		];
175
+		$this->distribution_strategy   = in_array($distribution_strategy, $valid_distribution_strategies)
176
+			? $distribution_strategy
177
+			: ExtraTxnFeesHandler::STRATEGY_DISTRIBUTE_EVENLY;
178
+	}
179
+
180
+
181
+	/**
182
+	 * @param object $extra_fees_strategy
183
+	 * @param string $required_interface
184
+	 */
185
+	protected function validateExtraTxnFeesDistributionStrategy($extra_fees_strategy, $required_interface)
186
+	{
187
+		if (! is_subclass_of($extra_fees_strategy, $required_interface)) {
188
+			throw new DomainException(
189
+				sprintf(
190
+					esc_html__(
191
+						'Invalid Extra Txn Fees Distribution Strategy. Expected: [%1$s] Received: [%2$s]',
192
+						'event_espresso'
193
+					),
194
+					$required_interface,
195
+					is_object($extra_fees_strategy) ? get_class($extra_fees_strategy) : 'Unknown'
196
+				)
197
+			);
198
+		}
199
+	}
200
+
201
+
202
+	/**
203
+	 * @return string
204
+	 */
205
+	public function getDistributionStrategy()
206
+	{
207
+		return $this->distribution_strategy;
208
+	}
209 209
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     protected function setRegistrationsAndTransactions(array $registrations)
150 150
     {
151 151
         $registration = reset($registrations);
152
-        if (! $registration instanceof EE_Registration) {
152
+        if ( ! $registration instanceof EE_Registration) {
153 153
             throw new DomainException(
154 154
                 esc_html__(
155 155
                     'Invalid Registrations supplied to ExtraTxnFeesForLineItemsHandler::applyExtraFeesToLineItems()',
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         }
160 160
         $this->registrations = $registrations;
161 161
         $this->transaction   = $registration->transaction();
162
-        $this->all_registrations   = $this->transaction->registrations();
162
+        $this->all_registrations = $this->transaction->registrations();
163 163
     }
164 164
 
165 165
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
             ExtraTxnFeesHandler::STRATEGY_DISTRIBUTE_EVENLY,
173 173
             ExtraTxnFeesHandler::STRATEGY_PRIMARY_REGISTRANT_ONLY,
174 174
         ];
175
-        $this->distribution_strategy   = in_array($distribution_strategy, $valid_distribution_strategies)
175
+        $this->distribution_strategy = in_array($distribution_strategy, $valid_distribution_strategies)
176 176
             ? $distribution_strategy
177 177
             : ExtraTxnFeesHandler::STRATEGY_DISTRIBUTE_EVENLY;
178 178
     }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     protected function validateExtraTxnFeesDistributionStrategy($extra_fees_strategy, $required_interface)
186 186
     {
187
-        if (! is_subclass_of($extra_fees_strategy, $required_interface)) {
187
+        if ( ! is_subclass_of($extra_fees_strategy, $required_interface)) {
188 188
             throw new DomainException(
189 189
                 sprintf(
190 190
                     esc_html__(
Please login to merge, or discard this patch.
payment_methods/Bank/templates/bank_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 esc_html_e(
4
-    'Bank is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a bank transfer.',
5
-    'event_espresso'
4
+	'Bank is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a bank transfer.',
5
+	'event_espresso'
6 6
 );
Please login to merge, or discard this patch.
payment_methods/Check/templates/check_intro.template.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 esc_html_e(
4
-    'Check is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a check.',
5
-    'event_espresso'
4
+	'Check is an offline payment method for accepting payments. Payments are processed manually by providing your registrants/attendees with information on how to pay with a check.',
5
+	'event_espresso'
6 6
 );
Please login to merge, or discard this patch.
payment_methods/Invoice/EE_PMT_Invoice.pm.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             '<br />'
41 41
         );
42 42
         parent::__construct($pm_instance);
43
-        $this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
43
+        $this->_default_button_url = $this->file_url().'lib/invoice-logo.png';
44 44
     }
45 45
 
46 46
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     {
66 66
         $pdf_payee_input_name = 'pdf_payee_name';
67 67
         $confirmation_text_input_name = 'page_confirmation_text';
68
-        $form =  new EE_Payment_Method_Form(array(
68
+        $form = new EE_Payment_Method_Form(array(
69 69
 //              'payment_method_type' => $this,
70 70
                 'extra_meta_inputs' => array(
71 71
                     $pdf_payee_input_name => new EE_Text_Input(array(
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
                         )),
80 80
                     'pdf_payee_address' => new EE_Text_Area_Input(array(
81 81
                         'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
82
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
82
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
83 83
                     )),
84 84
                     'pdf_instructions' => new EE_Text_Area_Input(array(
85 85
                         'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
86 86
                         'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
87
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
87
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
88 88
                     )),
89 89
                     'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
90 90
                         'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
                     $confirmation_text_input_name => new EE_Text_Area_Input(array(
95 95
                         'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
96 96
                         'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
97
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
97
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
98 98
                     )),
99 99
                     'page_extra_info' => new EE_Text_Area_Input(array(
100 100
                         'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
101
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
101
+                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
102 102
                     )),
103 103
                 ),
104 104
                 'include' => array(
105
-                    'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
106
-                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
105
+                    'PMD_ID', 'PMD_name', 'PMD_desc', 'PMD_admin_name', 'PMD_admin_desc', 'PMD_type', 'PMD_slug', 'PMD_open_by_default', 'PMD_button_url', 'PMD_scope', 'Currency', 'PMD_order',
106
+                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions', 'pdf_logo_image',
107 107
                     $confirmation_text_input_name, 'page_extra_info'),
108 108
             ));
109 109
         $form->add_subsections(
110
-            array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
110
+            array('header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
111 111
             $pdf_payee_input_name
112 112
         );
113 113
         $form->add_subsections(
114
-            array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
114
+            array('header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
115 115
             $confirmation_text_input_name
116 116
         );
117 117
         return $form;
Please login to merge, or discard this patch.
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -24,136 +24,136 @@
 block discarded – undo
24 24
  */
25 25
 class EE_PMT_Invoice extends EE_PMT_Base
26 26
 {
27
-    /**
28
-     *
29
-     * @param EE_Payment_Method $pm_instance
30
-     * @return EE_PMT_Invoice
31
-     */
32
-    public function __construct($pm_instance = null)
33
-    {
34
-        $this->_pretty_name = esc_html__("Invoice", 'event_espresso');
35
-        $this->_default_description = sprintf(
36
-            esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
37
-            '<br />'
38
-        );
39
-        parent::__construct($pm_instance);
40
-        $this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
41
-    }
27
+	/**
28
+	 *
29
+	 * @param EE_Payment_Method $pm_instance
30
+	 * @return EE_PMT_Invoice
31
+	 */
32
+	public function __construct($pm_instance = null)
33
+	{
34
+		$this->_pretty_name = esc_html__("Invoice", 'event_espresso');
35
+		$this->_default_description = sprintf(
36
+			esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
37
+			'<br />'
38
+		);
39
+		parent::__construct($pm_instance);
40
+		$this->_default_button_url = $this->file_url() . 'lib/invoice-logo.png';
41
+	}
42 42
 
43 43
 
44 44
 
45
-    /**
46
-     * Creates the billing form for this payment method type
47
-     * @param \EE_Transaction $transaction
48
-     * @return NULL
49
-     */
50
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
51
-    {
52
-        return null;
53
-    }
45
+	/**
46
+	 * Creates the billing form for this payment method type
47
+	 * @param \EE_Transaction $transaction
48
+	 * @return NULL
49
+	 */
50
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
51
+	{
52
+		return null;
53
+	}
54 54
 
55 55
 
56 56
 
57
-    /**
58
-     * Gets the form for all the settings related to this payment method type
59
-     * @return EE_Payment_Method_Form
60
-     */
61
-    public function generate_new_settings_form()
62
-    {
63
-        $pdf_payee_input_name = 'pdf_payee_name';
64
-        $confirmation_text_input_name = 'page_confirmation_text';
65
-        $form =  new EE_Payment_Method_Form(array(
57
+	/**
58
+	 * Gets the form for all the settings related to this payment method type
59
+	 * @return EE_Payment_Method_Form
60
+	 */
61
+	public function generate_new_settings_form()
62
+	{
63
+		$pdf_payee_input_name = 'pdf_payee_name';
64
+		$confirmation_text_input_name = 'page_confirmation_text';
65
+		$form =  new EE_Payment_Method_Form(array(
66 66
 //              'payment_method_type' => $this,
67
-                'extra_meta_inputs' => array(
68
-                    $pdf_payee_input_name => new EE_Text_Input(array(
69
-                        'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
70
-                    )),
71
-                    'pdf_payee_email' => new EE_Email_Input(array(
72
-                        'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
73
-                    )),
74
-                    'pdf_payee_tax_number' => new EE_Text_Input(array(
75
-                        'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
76
-                        )),
77
-                    'pdf_payee_address' => new EE_Text_Area_Input(array(
78
-                        'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
79
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
80
-                    )),
81
-                    'pdf_instructions' => new EE_Text_Area_Input(array(
82
-                        'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
83
-                        'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
84
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
85
-                    )),
86
-                    'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
87
-                        'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
88
-                        'default' =>  EE_Config::instance()->organization->logo_url,
89
-                        'html_help_text' =>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
90
-                    )),
91
-                    $confirmation_text_input_name => new EE_Text_Area_Input(array(
92
-                        'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
93
-                        'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
94
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
95
-                    )),
96
-                    'page_extra_info' => new EE_Text_Area_Input(array(
97
-                        'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
98
-                        'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
99
-                    )),
100
-                ),
101
-                'include' => array(
102
-                    'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
103
-                    $pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
104
-                    $confirmation_text_input_name, 'page_extra_info'),
105
-            ));
106
-        $form->add_subsections(
107
-            array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
108
-            $pdf_payee_input_name
109
-        );
110
-        $form->add_subsections(
111
-            array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
112
-            $confirmation_text_input_name
113
-        );
114
-        return $form;
115
-    }
67
+				'extra_meta_inputs' => array(
68
+					$pdf_payee_input_name => new EE_Text_Input(array(
69
+						'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
70
+					)),
71
+					'pdf_payee_email' => new EE_Email_Input(array(
72
+						'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
73
+					)),
74
+					'pdf_payee_tax_number' => new EE_Text_Input(array(
75
+						'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
76
+						)),
77
+					'pdf_payee_address' => new EE_Text_Area_Input(array(
78
+						'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
79
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
80
+					)),
81
+					'pdf_instructions' => new EE_Text_Area_Input(array(
82
+						'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
83
+						'default' =>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
84
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
85
+					)),
86
+					'pdf_logo_image' => new EE_Admin_File_Uploader_Input(array(
87
+						'html_label_text' =>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
88
+						'default' =>  EE_Config::instance()->organization->logo_url,
89
+						'html_help_text' =>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
90
+					)),
91
+					$confirmation_text_input_name => new EE_Text_Area_Input(array(
92
+						'html_label_text' =>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
93
+						'default' =>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'),
94
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
95
+					)),
96
+					'page_extra_info' => new EE_Text_Area_Input(array(
97
+						'html_label_text' =>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
98
+						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
99
+					)),
100
+				),
101
+				'include' => array(
102
+					'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
103
+					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
104
+					$confirmation_text_input_name, 'page_extra_info'),
105
+			));
106
+		$form->add_subsections(
107
+			array( 'header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
108
+			$pdf_payee_input_name
109
+		);
110
+		$form->add_subsections(
111
+			array( 'header2' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
112
+			$confirmation_text_input_name
113
+		);
114
+		return $form;
115
+	}
116 116
 
117 117
 
118 118
 
119
-    /**
120
-     * Adds the help tab
121
-     * @see EE_PMT_Base::help_tabs_config()
122
-     * @return array
123
-     */
124
-    public function help_tabs_config()
125
-    {
126
-        return array(
127
-            $this->get_help_tab_name() => array(
128
-                'title' => esc_html__('Invoice Settings', 'event_espresso'),
129
-                'filename' => 'payment_methods_overview_invoice'
130
-            ),
131
-        );
132
-    }
119
+	/**
120
+	 * Adds the help tab
121
+	 * @see EE_PMT_Base::help_tabs_config()
122
+	 * @return array
123
+	 */
124
+	public function help_tabs_config()
125
+	{
126
+		return array(
127
+			$this->get_help_tab_name() => array(
128
+				'title' => esc_html__('Invoice Settings', 'event_espresso'),
129
+				'filename' => 'payment_methods_overview_invoice'
130
+			),
131
+		);
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * For adding any html output above the payment overview.
137
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
138
-     * Other gateways may want to override this, such as offline gateways.
139
-     *
140
-     * @param \EE_Payment $payment
141
-     * @return string
142
-     */
143
-    public function payment_overview_content(EE_Payment $payment)
144
-    {
145
-        return EEH_Template::locate_template(
146
-            'payment_methods/Invoice/templates/invoice_payment_details_content.template.php',
147
-            array_merge(
148
-                array(
149
-                    'payment_method'            => $this->_pm_instance,
150
-                    'payment'                       => $payment,
151
-                    'page_confirmation_text'                    => '',
152
-                    'page_extra_info'   => '',
153
-                    'invoice_url'                   => $payment->transaction()->primary_registration()->invoice_url('html')
154
-                ),
155
-                $this->_pm_instance->all_extra_meta_array()
156
-            )
157
-        );
158
-    }
135
+	/**
136
+	 * For adding any html output above the payment overview.
137
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
138
+	 * Other gateways may want to override this, such as offline gateways.
139
+	 *
140
+	 * @param \EE_Payment $payment
141
+	 * @return string
142
+	 */
143
+	public function payment_overview_content(EE_Payment $payment)
144
+	{
145
+		return EEH_Template::locate_template(
146
+			'payment_methods/Invoice/templates/invoice_payment_details_content.template.php',
147
+			array_merge(
148
+				array(
149
+					'payment_method'            => $this->_pm_instance,
150
+					'payment'                       => $payment,
151
+					'page_confirmation_text'                    => '',
152
+					'page_extra_info'   => '',
153
+					'invoice_url'                   => $payment->transaction()->primary_registration()->invoice_url('html')
154
+				),
155
+				$this->_pm_instance->all_extra_meta_array()
156
+			)
157
+		);
158
+	}
159 159
 }
Please login to merge, or discard this patch.