Completed
Branch FET/add-loco-translate-support (7d9689)
by
unknown
26:14 queued 18:13
created
payment_methods/Paypal_Standard/EE_Paypal_Standard_Form.form.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -16,77 +16,77 @@
 block discarded – undo
16 16
 
17 17
 
18 18
 
19
-    /**
20
-     * @param EE_PMT_Paypal_Standard $payment_method_type
21
-     */
22
-    public function __construct($payment_method_type)
23
-    {
24
-        parent::__construct(
25
-            array(
26
-                'payment_method_type'          => $payment_method_type,
27
-                'extra_meta_inputs'            => array(
28
-                    'paypal_id'        => new EE_Text_Input(array(
29
-                        'html_label_text' => sprintf(__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()),
30
-                        'html_help_text'  => __("Typically [email protected]", 'event_espresso'),
31
-                        'required'        => true
32
-                    )),
33
-                    'image_url'        => new EE_Admin_File_Uploader_Input(array(
34
-                        'html_help_text'  => __("Used for your business/personal logo on the PayPal page", 'event_espresso'),
35
-                        'html_label_text' => __('Image URL', 'event_espresso')
36
-                    )),
37
-                    'paypal_taxes'     => new EE_Yes_No_Input(array(
38
-                        'html_label_text' => sprintf(__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
39
-                        'html_help_text'  => __('Whether Paypal should add taxes to the order', 'event_espresso'),
40
-                        'default'         => false
41
-                    )),
42
-                    'paypal_shipping'  => new EE_Yes_No_Input(array(
43
-                        'html_label_text' => sprintf(__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
44
-                        'html_help_text'  => __('Whether Paypal should add shipping surcharges', 'event_espresso'),
45
-                        'default'         => false
46
-                    )),
47
-                    'shipping_details' => new EE_Select_Input(array(
48
-                        EE_PMT_Paypal_Standard::shipping_info_none     => __("Do not prompt for an address", 'event_espresso'),
49
-                        EE_PMT_Paypal_Standard::shipping_info_optional => __("Prompt for an address, but do not require it", 'event_espresso'),
50
-                        EE_PMT_Paypal_Standard::shipping_info_required => __("Prompt for an address, and require it", 'event_espresso')
51
-                    ))
52
-                )
53
-            )
54
-        );
55
-    }
19
+	/**
20
+	 * @param EE_PMT_Paypal_Standard $payment_method_type
21
+	 */
22
+	public function __construct($payment_method_type)
23
+	{
24
+		parent::__construct(
25
+			array(
26
+				'payment_method_type'          => $payment_method_type,
27
+				'extra_meta_inputs'            => array(
28
+					'paypal_id'        => new EE_Text_Input(array(
29
+						'html_label_text' => sprintf(__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()),
30
+						'html_help_text'  => __("Typically [email protected]", 'event_espresso'),
31
+						'required'        => true
32
+					)),
33
+					'image_url'        => new EE_Admin_File_Uploader_Input(array(
34
+						'html_help_text'  => __("Used for your business/personal logo on the PayPal page", 'event_espresso'),
35
+						'html_label_text' => __('Image URL', 'event_espresso')
36
+					)),
37
+					'paypal_taxes'     => new EE_Yes_No_Input(array(
38
+						'html_label_text' => sprintf(__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
39
+						'html_help_text'  => __('Whether Paypal should add taxes to the order', 'event_espresso'),
40
+						'default'         => false
41
+					)),
42
+					'paypal_shipping'  => new EE_Yes_No_Input(array(
43
+						'html_label_text' => sprintf(__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
44
+						'html_help_text'  => __('Whether Paypal should add shipping surcharges', 'event_espresso'),
45
+						'default'         => false
46
+					)),
47
+					'shipping_details' => new EE_Select_Input(array(
48
+						EE_PMT_Paypal_Standard::shipping_info_none     => __("Do not prompt for an address", 'event_espresso'),
49
+						EE_PMT_Paypal_Standard::shipping_info_optional => __("Prompt for an address, but do not require it", 'event_espresso'),
50
+						EE_PMT_Paypal_Standard::shipping_info_required => __("Prompt for an address, and require it", 'event_espresso')
51
+					))
52
+				)
53
+			)
54
+		);
55
+	}
56 56
 
57 57
 
58 58
 
59
-    /**
60
-     * @param array $req_data
61
-     * @throws EE_Error
62
-     */
63
-    public function _normalize($req_data)
64
-    {
65
-        parent::_normalize($req_data);
66
-        $paypal_calculates_shipping = $this->get_input_value('paypal_shipping');
67
-        $paypal_calculates_taxes = $this->get_input_value('paypal_taxes');
68
-        $paypal_requests_address_info = $this->get_input_value('shipping_details');
69
-        if (( $paypal_calculates_shipping || $paypal_calculates_taxes ) &&
70
-            $paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none
71
-        ) {
72
-            // they want paypal to calculate taxes or shipping. They need to ask for
73
-            // address info, otherwise paypal can't calculate taxes or shipping
74
-            /** @type EE_Select_Input $shipping_details_input */
75
-            $shipping_details_input = $this->get_input('shipping_details');
76
-            $shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional);
77
-            $shipping_details_input_options = $shipping_details_input->options();
78
-            EE_Error::add_attention(
79
-                sprintf(
80
-                    __('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'),
81
-                    strip_tags($shipping_details_input->html_label_text()),
82
-                    isset($shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ])
83
-                        ? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ]
84
-                        : __('Unknown', 'event_espresso')
85
-                ),
86
-                __FILE__,
87
-                __FUNCTION__,
88
-                __LINE__
89
-            );
90
-        }
91
-    }
59
+	/**
60
+	 * @param array $req_data
61
+	 * @throws EE_Error
62
+	 */
63
+	public function _normalize($req_data)
64
+	{
65
+		parent::_normalize($req_data);
66
+		$paypal_calculates_shipping = $this->get_input_value('paypal_shipping');
67
+		$paypal_calculates_taxes = $this->get_input_value('paypal_taxes');
68
+		$paypal_requests_address_info = $this->get_input_value('shipping_details');
69
+		if (( $paypal_calculates_shipping || $paypal_calculates_taxes ) &&
70
+			$paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none
71
+		) {
72
+			// they want paypal to calculate taxes or shipping. They need to ask for
73
+			// address info, otherwise paypal can't calculate taxes or shipping
74
+			/** @type EE_Select_Input $shipping_details_input */
75
+			$shipping_details_input = $this->get_input('shipping_details');
76
+			$shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional);
77
+			$shipping_details_input_options = $shipping_details_input->options();
78
+			EE_Error::add_attention(
79
+				sprintf(
80
+					__('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'),
81
+					strip_tags($shipping_details_input->html_label_text()),
82
+					isset($shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ])
83
+						? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ]
84
+						: __('Unknown', 'event_espresso')
85
+				),
86
+				__FILE__,
87
+				__FUNCTION__,
88
+				__LINE__
89
+			);
90
+		}
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $paypal_calculates_shipping = $this->get_input_value('paypal_shipping');
67 67
         $paypal_calculates_taxes = $this->get_input_value('paypal_taxes');
68 68
         $paypal_requests_address_info = $this->get_input_value('shipping_details');
69
-        if (( $paypal_calculates_shipping || $paypal_calculates_taxes ) &&
69
+        if (($paypal_calculates_shipping || $paypal_calculates_taxes) &&
70 70
             $paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none
71 71
         ) {
72 72
             // they want paypal to calculate taxes or shipping. They need to ask for
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
                 sprintf(
80 80
                     __('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'),
81 81
                     strip_tags($shipping_details_input->html_label_text()),
82
-                    isset($shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ])
83
-                        ? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ]
82
+                    isset($shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional])
83
+                        ? $shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional]
84 84
                         : __('Unknown', 'event_espresso')
85 85
                 ),
86 86
                 __FILE__,
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EE_PMT_Paypal_Standard.pm.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -13,105 +13,105 @@
 block discarded – undo
13 13
 class EE_PMT_Paypal_Standard extends EE_PMT_Base
14 14
 {
15 15
 
16
-    const shipping_info_none = 1;
17
-    const shipping_info_optional = 0;
18
-    const shipping_info_required = 2;
19
-
20
-
21
-
22
-    /**
23
-     * @param null $pm_instance
24
-     * @return \EE_PMT_Paypal_Standard
25
-     * @throws \EE_Error
26
-     */
27
-    public function __construct($pm_instance = null)
28
-    {
29
-        require_once($this->file_folder().'EEG_Paypal_Standard.gateway.php');
30
-        $this->_gateway = new EEG_Paypal_Standard();
31
-        $this->_pretty_name = __("PayPal Standard", 'event_espresso');
32
-        $this->_default_description = sprintf(
33
-            __(
34
-                'Upon submitting this form, you will be forwarded to PayPal to make your payment. %1$sMake sure you return to this site in order to properly finalize your registration.%2$s',
35
-                'event_espresso'
36
-            ),
37
-            '<strong>',
38
-            '</strong>'
39
-        );
40
-        parent::__construct($pm_instance);
41
-        $this->_default_button_url = $this->file_url().'lib'.DS.'paypal-logo.png';
42
-    }
43
-
44
-
45
-
46
-    /**
47
-     * Creates the billing form for this payment method type
48
-     * @param \EE_Transaction $transaction
49
-     * @return NULL
50
-     */
51
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
52
-    {
53
-        return null;
54
-    }
55
-
56
-
57
-
58
-    /**
59
-     * Gets the form for all the settings related to this payment method type
60
-     *
61
-     * @return EE_Payment_Method_Form
62
-     * @throws \EE_Error
63
-     */
64
-    public function generate_new_settings_form()
65
-    {
66
-        require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php');
67
-        $form =  new EE_Paypal_Standard_Form($this);
68
-        $form->get_input('PMD_debug_mode')->set_html_label_text(
69
-            sprintf(__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link())
70
-        );
71
-        $form->get_input('shipping_details')->set_html_label_text(
72
-            sprintf(__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link())
73
-        );
74
-        return $form;
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * Adds the help tab
81
-     * @see EE_PMT_Base::help_tabs_config()
82
-     * @return array
83
-     */
84
-    public function help_tabs_config()
85
-    {
86
-        return array(
87
-            $this->get_help_tab_name() => array(
88
-                'title'=>  __("PayPal Standard Settings", 'event_espresso'),
89
-                'filename'=>'payment_methods_overview_paypalstandard'
90
-            )
91
-        );
92
-    }
93
-
94
-
95
-
96
-    /**
97
-     * Logic to be accomplished when the payment attempt is complete.
98
-     * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
99
-     * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
100
-     * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
101
-     * of the payment). Fed a transaction because it's always assumed to be the last payment that
102
-     *
103
-     * @param EE_Transaction $transaction
104
-     * @return EE_Payment
105
-     * @throws \EE_Error
106
-     */
107
-    public function finalize_payment_for($transaction)
108
-    {
109
-        // PayPal standard actually sends the IPN info along with the user when they return to our site
110
-        // so in case the IPN is arriving later, let's try to process an IPN!
111
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
112
-            return $this->handle_ipn($_POST, $transaction);
113
-        } else {
114
-            return parent::finalize_payment_for($transaction);
115
-        }
116
-    }
16
+	const shipping_info_none = 1;
17
+	const shipping_info_optional = 0;
18
+	const shipping_info_required = 2;
19
+
20
+
21
+
22
+	/**
23
+	 * @param null $pm_instance
24
+	 * @return \EE_PMT_Paypal_Standard
25
+	 * @throws \EE_Error
26
+	 */
27
+	public function __construct($pm_instance = null)
28
+	{
29
+		require_once($this->file_folder().'EEG_Paypal_Standard.gateway.php');
30
+		$this->_gateway = new EEG_Paypal_Standard();
31
+		$this->_pretty_name = __("PayPal Standard", 'event_espresso');
32
+		$this->_default_description = sprintf(
33
+			__(
34
+				'Upon submitting this form, you will be forwarded to PayPal to make your payment. %1$sMake sure you return to this site in order to properly finalize your registration.%2$s',
35
+				'event_espresso'
36
+			),
37
+			'<strong>',
38
+			'</strong>'
39
+		);
40
+		parent::__construct($pm_instance);
41
+		$this->_default_button_url = $this->file_url().'lib'.DS.'paypal-logo.png';
42
+	}
43
+
44
+
45
+
46
+	/**
47
+	 * Creates the billing form for this payment method type
48
+	 * @param \EE_Transaction $transaction
49
+	 * @return NULL
50
+	 */
51
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
52
+	{
53
+		return null;
54
+	}
55
+
56
+
57
+
58
+	/**
59
+	 * Gets the form for all the settings related to this payment method type
60
+	 *
61
+	 * @return EE_Payment_Method_Form
62
+	 * @throws \EE_Error
63
+	 */
64
+	public function generate_new_settings_form()
65
+	{
66
+		require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php');
67
+		$form =  new EE_Paypal_Standard_Form($this);
68
+		$form->get_input('PMD_debug_mode')->set_html_label_text(
69
+			sprintf(__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link())
70
+		);
71
+		$form->get_input('shipping_details')->set_html_label_text(
72
+			sprintf(__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link())
73
+		);
74
+		return $form;
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * Adds the help tab
81
+	 * @see EE_PMT_Base::help_tabs_config()
82
+	 * @return array
83
+	 */
84
+	public function help_tabs_config()
85
+	{
86
+		return array(
87
+			$this->get_help_tab_name() => array(
88
+				'title'=>  __("PayPal Standard Settings", 'event_espresso'),
89
+				'filename'=>'payment_methods_overview_paypalstandard'
90
+			)
91
+		);
92
+	}
93
+
94
+
95
+
96
+	/**
97
+	 * Logic to be accomplished when the payment attempt is complete.
98
+	 * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
99
+	 * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
100
+	 * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
101
+	 * of the payment). Fed a transaction because it's always assumed to be the last payment that
102
+	 *
103
+	 * @param EE_Transaction $transaction
104
+	 * @return EE_Payment
105
+	 * @throws \EE_Error
106
+	 */
107
+	public function finalize_payment_for($transaction)
108
+	{
109
+		// PayPal standard actually sends the IPN info along with the user when they return to our site
110
+		// so in case the IPN is arriving later, let's try to process an IPN!
111
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
112
+			return $this->handle_ipn($_POST, $transaction);
113
+		} else {
114
+			return parent::finalize_payment_for($transaction);
115
+		}
116
+	}
117 117
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,8 +63,8 @@
 block discarded – undo
63 63
      */
64 64
     public function generate_new_settings_form()
65 65
     {
66
-        require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php');
67
-        $form =  new EE_Paypal_Standard_Form($this);
66
+        require_once($this->file_folder().'EE_Paypal_Standard_Form.form.php');
67
+        $form = new EE_Paypal_Standard_Form($this);
68 68
         $form->get_input('PMD_debug_mode')->set_html_label_text(
69 69
             sprintf(__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link())
70 70
         );
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EEG_Paypal_Standard.gateway.php 2 patches
Indentation   +600 added lines, -600 removed lines patch added patch discarded remove patch
@@ -19,605 +19,605 @@
 block discarded – undo
19 19
 class EEG_Paypal_Standard extends EE_Offsite_Gateway
20 20
 {
21 21
 
22
-    /**
23
-     * Name for the wp option used to save the itemized payment
24
-     */
25
-    const itemized_payment_option_name = '_itemized_payment';
26
-
27
-    protected $_paypal_id;
28
-
29
-    protected $_image_url;
30
-
31
-    protected $_shipping_details;
32
-
33
-    protected $_paypal_shipping;
34
-
35
-    protected $_paypal_taxes;
36
-
37
-    protected $_gateway_url;
38
-
39
-    protected $_currencies_supported = array(
40
-        'USD',
41
-        'GBP',
42
-        'CAD',
43
-        'AUD',
44
-        'BRL',
45
-        'CHF',
46
-        'CZK',
47
-        'DKK',
48
-        'EUR',
49
-        'HKD',
50
-        'HUF',
51
-        'ILS',
52
-        'JPY',
53
-        'MXN',
54
-        'MYR',
55
-        'NOK',
56
-        'NZD',
57
-        'PHP',
58
-        'PLN',
59
-        'SEK',
60
-        'SGD',
61
-        'THB',
62
-        'TRY',
63
-        'TWD',
64
-        'RUB'
65
-    );
66
-
67
-
68
-    /**
69
-     * EEG_Paypal_Standard constructor.
70
-     *
71
-     * @return EEG_Paypal_Standard
72
-     */
73
-    public function __construct()
74
-    {
75
-        $this->set_uses_separate_IPN_request(true);
76
-        parent::__construct();
77
-    }
78
-
79
-
80
-    /**
81
-     * Also sets the gateway url class variable based on whether debug mode is enabled or not.
82
-     *
83
-     * @param array $settings_array
84
-     */
85
-    public function set_settings($settings_array)
86
-    {
87
-        parent::set_settings($settings_array);
88
-        $this->_gateway_url = $this->_debug_mode
89
-            ? 'https://www.sandbox.paypal.com/cgi-bin/webscr'
90
-            : 'https://www.paypal.com/cgi-bin/webscr';
91
-    }
92
-
93
-
94
-    /**
95
-     * @param EEI_Payment $payment      the payment to process
96
-     * @param array       $billing_info but should be empty for this gateway
97
-     * @param string      $return_url   URL to send the user to after payment on the payment provider's website
98
-     * @param string      $notify_url   URL to send the instant payment notification
99
-     * @param string      $cancel_url   URL to send the user to after a cancelled payment attempt
100
-     *                                  on the payment provider's website
101
-     * @return EEI_Payment
102
-     * @throws \EE_Error
103
-     */
104
-    public function set_redirection_info(
105
-        $payment,
106
-        $billing_info = array(),
107
-        $return_url = null,
108
-        $notify_url = null,
109
-        $cancel_url = null
110
-    ) {
111
-        $redirect_args = array();
112
-        $transaction = $payment->transaction();
113
-        $gateway_formatter = $this->_get_gateway_formatter();
114
-        $item_num = 1;
115
-        /** @type EE_Line_Item $total_line_item */
116
-        $total_line_item = $transaction->total_line_item();
117
-
118
-        $total_discounts_to_cart_total = $transaction->paid();
119
-        // only itemize the order if we're paying for the rest of the order's amount
120
-        if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) {
121
-            $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true);
122
-            // this payment is for the remaining transaction amount,
123
-            // keep track of exactly how much the itemized order amount equals
124
-            $itemized_sum = 0;
125
-            $shipping_previously_added = 0;
126
-            // so let's show all the line items
127
-            foreach ($total_line_item->get_items() as $line_item) {
128
-                if ($line_item instanceof EE_Line_Item) {
129
-                    // it's some kind of discount
130
-                    if ($line_item->total() < 0) {
131
-                        $total_discounts_to_cart_total += abs($line_item->total());
132
-                        $itemized_sum += $line_item->total();
133
-                        continue;
134
-                    }
135
-                    // dont include shipping again.
136
-                    if (strpos($line_item->code(), 'paypal_shipping_') === 0) {
137
-                        $shipping_previously_added = $line_item->total();
138
-                        continue;
139
-                    }
140
-                    $redirect_args[ 'item_name_' . $item_num ] = substr(
141
-                        $gateway_formatter->formatLineItemName($line_item, $payment),
142
-                        0,
143
-                        127
144
-                    );
145
-                    $redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price();
146
-                    $redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity();
147
-                    // if we're not letting PayPal calculate shipping, tell them its 0
148
-                    if (! $this->_paypal_shipping) {
149
-                        $redirect_args[ 'shipping_' . $item_num ] = '0';
150
-                        $redirect_args[ 'shipping2_' . $item_num ] = '0';
151
-                    }
152
-                    $item_num++;
153
-                    $itemized_sum += $line_item->total();
154
-                }
155
-            }
156
-            $taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item);
157
-            // ideally itemized sum equals the transaction total. but if not (which is weird)
158
-            // and the itemized sum is LESS than the transaction total
159
-            // add another line item
160
-            // if the itemized sum is MORE than the transaction total,
161
-            // add the difference it to the discounts
162
-            $itemized_sum_diff_from_txn_total = round(
163
-                $transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added,
164
-                2
165
-            );
166
-            if ($itemized_sum_diff_from_txn_total < 0) {
167
-                // itemized sum is too big
168
-                $total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total);
169
-            } elseif ($itemized_sum_diff_from_txn_total > 0) {
170
-                $redirect_args[ 'item_name_' . $item_num ] = substr(
171
-                    __('Other charges', 'event_espresso'),
172
-                    0,
173
-                    127
174
-                );
175
-                $redirect_args[ 'amount_' . $item_num ] = $gateway_formatter->formatCurrency(
176
-                    $itemized_sum_diff_from_txn_total
177
-                );
178
-                $redirect_args[ 'quantity_' . $item_num ] = 1;
179
-                $item_num++;
180
-            }
181
-            if ($total_discounts_to_cart_total > 0) {
182
-                $redirect_args['discount_amount_cart'] = $gateway_formatter->formatCurrency(
183
-                    $total_discounts_to_cart_total
184
-                );
185
-            }
186
-            // add our taxes to the order if we're NOT using PayPal's
187
-            if (! $this->_paypal_taxes) {
188
-                $redirect_args['tax_cart'] = $total_line_item->get_total_tax();
189
-            }
190
-        } else {
191
-            $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false);
192
-            // partial payment that's not for the remaining amount, so we can't send an itemized list
193
-            $redirect_args[ 'item_name_' . $item_num ] = substr(
194
-                $gateway_formatter->formatPartialPaymentLineItemName($payment),
195
-                0,
196
-                127
197
-            );
198
-            $redirect_args[ 'amount_' . $item_num ] = $payment->amount();
199
-            $redirect_args[ 'shipping_' . $item_num ] = '0';
200
-            $redirect_args[ 'shipping2_' . $item_num ] = '0';
201
-            $redirect_args['tax_cart'] = '0';
202
-            $item_num++;
203
-        }
204
-
205
-        if ($this->_debug_mode) {
206
-            $redirect_args[ 'item_name_' . $item_num ] = 'DEBUG INFO (this item only added in sandbox mode';
207
-            $redirect_args[ 'amount_' . $item_num ] = 0;
208
-            $redirect_args[ 'on0_'.$item_num ] = 'NOTIFY URL';
209
-            $redirect_args[ 'os0_' . $item_num ] = $notify_url;
210
-            $redirect_args[ 'on1_'.$item_num ] = 'RETURN URL';
211
-            $redirect_args[ 'os1_' . $item_num ] = $return_url;
22
+	/**
23
+	 * Name for the wp option used to save the itemized payment
24
+	 */
25
+	const itemized_payment_option_name = '_itemized_payment';
26
+
27
+	protected $_paypal_id;
28
+
29
+	protected $_image_url;
30
+
31
+	protected $_shipping_details;
32
+
33
+	protected $_paypal_shipping;
34
+
35
+	protected $_paypal_taxes;
36
+
37
+	protected $_gateway_url;
38
+
39
+	protected $_currencies_supported = array(
40
+		'USD',
41
+		'GBP',
42
+		'CAD',
43
+		'AUD',
44
+		'BRL',
45
+		'CHF',
46
+		'CZK',
47
+		'DKK',
48
+		'EUR',
49
+		'HKD',
50
+		'HUF',
51
+		'ILS',
52
+		'JPY',
53
+		'MXN',
54
+		'MYR',
55
+		'NOK',
56
+		'NZD',
57
+		'PHP',
58
+		'PLN',
59
+		'SEK',
60
+		'SGD',
61
+		'THB',
62
+		'TRY',
63
+		'TWD',
64
+		'RUB'
65
+	);
66
+
67
+
68
+	/**
69
+	 * EEG_Paypal_Standard constructor.
70
+	 *
71
+	 * @return EEG_Paypal_Standard
72
+	 */
73
+	public function __construct()
74
+	{
75
+		$this->set_uses_separate_IPN_request(true);
76
+		parent::__construct();
77
+	}
78
+
79
+
80
+	/**
81
+	 * Also sets the gateway url class variable based on whether debug mode is enabled or not.
82
+	 *
83
+	 * @param array $settings_array
84
+	 */
85
+	public function set_settings($settings_array)
86
+	{
87
+		parent::set_settings($settings_array);
88
+		$this->_gateway_url = $this->_debug_mode
89
+			? 'https://www.sandbox.paypal.com/cgi-bin/webscr'
90
+			: 'https://www.paypal.com/cgi-bin/webscr';
91
+	}
92
+
93
+
94
+	/**
95
+	 * @param EEI_Payment $payment      the payment to process
96
+	 * @param array       $billing_info but should be empty for this gateway
97
+	 * @param string      $return_url   URL to send the user to after payment on the payment provider's website
98
+	 * @param string      $notify_url   URL to send the instant payment notification
99
+	 * @param string      $cancel_url   URL to send the user to after a cancelled payment attempt
100
+	 *                                  on the payment provider's website
101
+	 * @return EEI_Payment
102
+	 * @throws \EE_Error
103
+	 */
104
+	public function set_redirection_info(
105
+		$payment,
106
+		$billing_info = array(),
107
+		$return_url = null,
108
+		$notify_url = null,
109
+		$cancel_url = null
110
+	) {
111
+		$redirect_args = array();
112
+		$transaction = $payment->transaction();
113
+		$gateway_formatter = $this->_get_gateway_formatter();
114
+		$item_num = 1;
115
+		/** @type EE_Line_Item $total_line_item */
116
+		$total_line_item = $transaction->total_line_item();
117
+
118
+		$total_discounts_to_cart_total = $transaction->paid();
119
+		// only itemize the order if we're paying for the rest of the order's amount
120
+		if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) {
121
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true);
122
+			// this payment is for the remaining transaction amount,
123
+			// keep track of exactly how much the itemized order amount equals
124
+			$itemized_sum = 0;
125
+			$shipping_previously_added = 0;
126
+			// so let's show all the line items
127
+			foreach ($total_line_item->get_items() as $line_item) {
128
+				if ($line_item instanceof EE_Line_Item) {
129
+					// it's some kind of discount
130
+					if ($line_item->total() < 0) {
131
+						$total_discounts_to_cart_total += abs($line_item->total());
132
+						$itemized_sum += $line_item->total();
133
+						continue;
134
+					}
135
+					// dont include shipping again.
136
+					if (strpos($line_item->code(), 'paypal_shipping_') === 0) {
137
+						$shipping_previously_added = $line_item->total();
138
+						continue;
139
+					}
140
+					$redirect_args[ 'item_name_' . $item_num ] = substr(
141
+						$gateway_formatter->formatLineItemName($line_item, $payment),
142
+						0,
143
+						127
144
+					);
145
+					$redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price();
146
+					$redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity();
147
+					// if we're not letting PayPal calculate shipping, tell them its 0
148
+					if (! $this->_paypal_shipping) {
149
+						$redirect_args[ 'shipping_' . $item_num ] = '0';
150
+						$redirect_args[ 'shipping2_' . $item_num ] = '0';
151
+					}
152
+					$item_num++;
153
+					$itemized_sum += $line_item->total();
154
+				}
155
+			}
156
+			$taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item);
157
+			// ideally itemized sum equals the transaction total. but if not (which is weird)
158
+			// and the itemized sum is LESS than the transaction total
159
+			// add another line item
160
+			// if the itemized sum is MORE than the transaction total,
161
+			// add the difference it to the discounts
162
+			$itemized_sum_diff_from_txn_total = round(
163
+				$transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added,
164
+				2
165
+			);
166
+			if ($itemized_sum_diff_from_txn_total < 0) {
167
+				// itemized sum is too big
168
+				$total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total);
169
+			} elseif ($itemized_sum_diff_from_txn_total > 0) {
170
+				$redirect_args[ 'item_name_' . $item_num ] = substr(
171
+					__('Other charges', 'event_espresso'),
172
+					0,
173
+					127
174
+				);
175
+				$redirect_args[ 'amount_' . $item_num ] = $gateway_formatter->formatCurrency(
176
+					$itemized_sum_diff_from_txn_total
177
+				);
178
+				$redirect_args[ 'quantity_' . $item_num ] = 1;
179
+				$item_num++;
180
+			}
181
+			if ($total_discounts_to_cart_total > 0) {
182
+				$redirect_args['discount_amount_cart'] = $gateway_formatter->formatCurrency(
183
+					$total_discounts_to_cart_total
184
+				);
185
+			}
186
+			// add our taxes to the order if we're NOT using PayPal's
187
+			if (! $this->_paypal_taxes) {
188
+				$redirect_args['tax_cart'] = $total_line_item->get_total_tax();
189
+			}
190
+		} else {
191
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false);
192
+			// partial payment that's not for the remaining amount, so we can't send an itemized list
193
+			$redirect_args[ 'item_name_' . $item_num ] = substr(
194
+				$gateway_formatter->formatPartialPaymentLineItemName($payment),
195
+				0,
196
+				127
197
+			);
198
+			$redirect_args[ 'amount_' . $item_num ] = $payment->amount();
199
+			$redirect_args[ 'shipping_' . $item_num ] = '0';
200
+			$redirect_args[ 'shipping2_' . $item_num ] = '0';
201
+			$redirect_args['tax_cart'] = '0';
202
+			$item_num++;
203
+		}
204
+
205
+		if ($this->_debug_mode) {
206
+			$redirect_args[ 'item_name_' . $item_num ] = 'DEBUG INFO (this item only added in sandbox mode';
207
+			$redirect_args[ 'amount_' . $item_num ] = 0;
208
+			$redirect_args[ 'on0_'.$item_num ] = 'NOTIFY URL';
209
+			$redirect_args[ 'os0_' . $item_num ] = $notify_url;
210
+			$redirect_args[ 'on1_'.$item_num ] = 'RETURN URL';
211
+			$redirect_args[ 'os1_' . $item_num ] = $return_url;
212 212
 //          $redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ?
213
-            $redirect_args[ 'shipping_' . $item_num ] = '0';
214
-            $redirect_args[ 'shipping2_' . $item_num ] = '0';
215
-        }
216
-
217
-        $redirect_args['business'] = $this->_paypal_id;
218
-        $redirect_args['return'] = $return_url;
219
-        $redirect_args['cancel_return'] = $cancel_url;
220
-        $redirect_args['notify_url'] = $notify_url;
221
-        $redirect_args['cmd'] = '_cart';
222
-        $redirect_args['upload'] = 1;
223
-        $redirect_args['currency_code'] = $payment->currency_code();
224
-        $redirect_args['rm'] = 2;// makes the user return with method=POST
225
-        if ($this->_image_url) {
226
-            $redirect_args['image_url'] = $this->_image_url;
227
-        }
228
-        $redirect_args['no_shipping'] = $this->_shipping_details;
229
-        $redirect_args['bn'] = 'EventEspresso_SP';// EE will blow up if you change this
230
-
231
-        $redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this);
232
-
233
-        $payment->set_redirect_url($this->_gateway_url);
234
-        $payment->set_redirect_args($redirect_args);
235
-        // log the results
236
-        $this->log(
237
-            array(
238
-                'message'     => sprintf(
239
-                    __('PayPal payment request initiated.', 'event_espresso')
240
-                ),
241
-                'transaction' => $transaction->model_field_array(),
242
-            ),
243
-            $payment
244
-        );
245
-        return $payment;
246
-    }
247
-
248
-
249
-    /**
250
-     * Often used for IPNs. But applies the info in $update_info to the payment.
251
-     * What is $update_info? Often the contents of $_REQUEST, but not necessarily. Whatever
252
-     * the payment method passes in.
253
-     *
254
-     * @param array $update_info like $_POST
255
-     * @param EEI_Transaction $transaction
256
-     * @return \EEI_Payment updated
257
-     * @throws \EE_Error, IpnException
258
-     */
259
-    public function handle_payment_update($update_info, $transaction)
260
-    {
261
-        // verify there's payment data that's been sent
262
-        if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) {
263
-            // log the results
264
-            $this->log(
265
-                array(
266
-                    'message'     => sprintf(
267
-                        // @codingStandardsIgnoreStart
268
-                        __('PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso')
269
-                        // @codingStandardsIgnoreEnd
270
-                    ),
271
-                    'update_info' => $update_info,
272
-                ),
273
-                $transaction
274
-            );
275
-            // waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/)
276
-            // indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes
277
-            if (isset($update_info['tx'])) {
278
-                return $transaction->last_payment();
279
-            } else {
280
-                return null;
281
-            }
282
-        }
283
-        $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']);
284
-        if (! $payment instanceof EEI_Payment) {
285
-            $payment = $transaction->last_payment();
286
-        }
287
-        // ok, then validate the IPN. Even if we've already processed this payment,
288
-        // let PayPal know we don't want to hear from them anymore!
289
-        if (! $this->validate_ipn($update_info, $payment)) {
290
-            return $payment;
291
-        }
292
-        // kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction,
293
-        // registrations, ticket counts, etc)
294
-        if ((
295
-                $update_info['payment_status'] === 'Refunded'
296
-                || $update_info['payment_status'] === 'Partially_Refunded'
297
-            )
298
-            && apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)
299
-        ) {
300
-            throw new EventEspresso\core\exceptions\IpnException(
301
-                sprintf(
302
-                    esc_html__('Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'),
303
-                    $update_info['payment_status']
304
-                ),
305
-                EventEspresso\core\exceptions\IpnException::UNSUPPORTED,
306
-                null,
307
-                $payment,
308
-                $update_info
309
-            );
310
-        }
311
-        // ok, well let's process this payment then!
312
-        switch ($update_info['payment_status']) {
313
-            case 'Completed':
314
-                $status = $this->_pay_model->approved_status();
315
-                $gateway_response = esc_html__('The payment is approved.', 'event_espresso');
316
-                break;
317
-
318
-            case 'Pending':
319
-                $status = $this->_pay_model->pending_status();
320
-                $gateway_response = esc_html__(
321
-                    'The payment is in progress. Another message will be sent when payment is approved.',
322
-                    'event_espresso'
323
-                );
324
-                break;
325
-
326
-            case 'Denied':
327
-                $status = $this->_pay_model->declined_status();
328
-                $gateway_response = esc_html__('The payment has been declined.', 'event_espresso');
329
-                break;
330
-
331
-            case 'Expired':
332
-            case 'Failed':
333
-                $status = $this->_pay_model->failed_status();
334
-                $gateway_response = esc_html__('The payment failed for technical reasons or expired.', 'event_espresso');
335
-                break;
336
-
337
-            case 'Refunded':
338
-            case 'Partially_Refunded':
339
-                // even though it's a refund, we consider the payment as approved, it just has a negative value
340
-                $status = $this->_pay_model->approved_status();
341
-                $gateway_response = esc_html__(
342
-                    'The payment has been refunded. Please update registrations accordingly.',
343
-                    'event_espresso'
344
-                );
345
-                break;
346
-
347
-            case 'Voided':
348
-            case 'Reversed':
349
-            case 'Canceled_Reversal':
350
-            default:
351
-                $status = $this->_pay_model->cancelled_status();
352
-                $gateway_response = esc_html__(
353
-                    'The payment was cancelled, reversed, or voided. Please update registrations accordingly.',
354
-                    'event_espresso'
355
-                );
356
-                break;
357
-        }
358
-
359
-        // check if we've already processed this payment
360
-        if ($payment instanceof EEI_Payment) {
361
-            // payment exists. if this has the exact same status and amount, don't bother updating. just return
362
-            if ($payment->status() === $status && (float) $payment->amount() === (float) $update_info['mc_gross']) {
363
-                // DUPLICATED IPN! don't bother updating transaction
364
-                throw new IpnException(
365
-                    sprintf(
366
-                        esc_html__(
367
-                            'It appears we have received a duplicate IPN from PayPal for payment %d',
368
-                            'event_espresso'
369
-                        ),
370
-                        $payment->ID()
371
-                    ),
372
-                    IpnException::DUPLICATE,
373
-                    null,
374
-                    $payment,
375
-                    $update_info
376
-                );
377
-            } else {
378
-                // new payment yippee !!!
379
-                $payment->set_status($status);
380
-                $payment->set_amount((float) $update_info['mc_gross']);
381
-                $payment->set_gateway_response($gateway_response);
382
-                $payment->set_details($update_info);
383
-                $payment->set_txn_id_chq_nmbr($update_info['txn_id']);
384
-                $this->log(
385
-                    array(
386
-                        'message'  => esc_html__(
387
-                            'Updated payment either from IPN or as part of POST from PayPal',
388
-                            'event_espresso'
389
-                        ),
390
-                        'url'      => $this->_process_response_url(),
391
-                        'payment'  => $payment->model_field_array(),
392
-                        'IPN_data' => $update_info
393
-                    ),
394
-                    $payment
395
-                );
396
-            }
397
-        }
398
-        do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this);
399
-        return $payment;
400
-    }
401
-
402
-
403
-    /**
404
-     * Validate the IPN notification.
405
-     *
406
-     * @param array                  $update_info like $_REQUEST
407
-     * @param EE_Payment|EEI_Payment $payment
408
-     * @return boolean
409
-     * @throws \EE_Error
410
-     */
411
-    public function validate_ipn($update_info, $payment)
412
-    {
413
-        // allow us to skip validating IPNs with PayPal (useful for testing)
414
-        if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) {
415
-            return true;
416
-        }
417
-        // ...otherwise, we actually don't care what the $update_info is, we need to look
418
-        // at the request directly because we can't use $update_info because it has issues with quotes
419
-        // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
420
-        // Instead, read raw POST data from the input stream.
421
-        // @see https://gist.github.com/xcommerce-gists/3440401
422
-        $raw_post_data = file_get_contents('php://input');
423
-        $raw_post_array = explode('&', $raw_post_data);
424
-        $update_info = array();
425
-        foreach ($raw_post_array as $keyval) {
426
-            $keyval = explode('=', $keyval);
427
-            if (count($keyval) === 2) {
428
-                $update_info[ $keyval[0] ] = urldecode($keyval[1]);
429
-            }
430
-        }
431
-        // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
432
-        $req = 'cmd=_notify-validate';
433
-        $uses_get_magic_quotes = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() === 1
434
-            ? true
435
-            : false;
436
-        foreach ($update_info as $key => $value) {
437
-            $value = $uses_get_magic_quotes ? urlencode(stripslashes($value)) : urlencode($value);
438
-            $req .= "&$key=$value";
439
-        }
440
-        // HTTP POST the complete, unaltered IPN back to PayPal
441
-        $response = wp_remote_post(
442
-            $this->_gateway_url,
443
-            array(
444
-                'body'              => $req,
445
-                'sslverify'         => false,
446
-                'timeout'           => 60,
447
-                // make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal
448
-                // plz see: https://github.com/websharks/s2member/issues/610
449
-                'user-agent'        => 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(),
450
-                'httpversion'       => '1.1'
451
-            )
452
-        );
453
-        // then check the response
454
-        if (array_key_exists('body', $response)
455
-            && ! is_wp_error($response)
456
-            && strcmp($response['body'], "VERIFIED") === 0
457
-        ) {
458
-            return true;
459
-        }
460
-        // huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly,
461
-        // or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html
462
-        if ($response instanceof WP_Error) {
463
-            $error_msg = sprintf(
464
-                esc_html__('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'),
465
-                $response->get_error_code(),
466
-                $response->get_error_message(),
467
-                print_r($response->get_error_data(), true)
468
-            );
469
-        } elseif (is_array($response) && isset($response['body'])) {
470
-            $error_msg = $response['body'];
471
-        } else {
472
-            $error_msg = print_r($response, true);
473
-        }
474
-        $payment->set_gateway_response(
475
-            sprintf(
476
-                esc_html__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"),
477
-                $error_msg
478
-            )
479
-        );
480
-        $payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response));
481
-        $payment->set_status(EEM_Payment::status_id_failed);
482
-        // log the results
483
-        $this->log(
484
-            array(
485
-                'url'     => $this->_process_response_url(),
486
-                'message' => $payment->gateway_response(),
487
-                'details' => $payment->details(),
488
-            ),
489
-            $payment
490
-        );
491
-        return false;
492
-    }
493
-
494
-
495
-    /**
496
-     * _process_response_url
497
-     * @return string
498
-     */
499
-    protected function _process_response_url()
500
-    {
501
-        if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
502
-            $url = is_ssl() ? 'https://' : 'http://';
503
-            $url .= EEH_URL::filter_input_server_url('HTTP_HOST');
504
-            $url .= EEH_URL::filter_input_server_url();
505
-        } else {
506
-            $url = 'unknown';
507
-        }
508
-        return $url;
509
-    }
510
-
511
-
512
-    /**
513
-     * Updates the transaction and line items based on the payment IPN data from PayPal,
514
-     * like the taxes or shipping
515
-     *
516
-     * @param EEI_Payment $payment
517
-     * @throws \EE_Error
518
-     */
519
-    public function update_txn_based_on_payment($payment)
520
-    {
521
-        $update_info = $payment->details();
522
-        /** @var EE_Transaction $transaction */
523
-        $transaction = $payment->transaction();
524
-        $payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false);
525
-        if (! $transaction) {
526
-            $this->log(
527
-                esc_html__(
528
-                    // @codingStandardsIgnoreStart
529
-                    'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly',
530
-                    // @codingStandardsIgnoreEnd
531
-                    'event_espresso'
532
-                ),
533
-                $payment
534
-            );
535
-            return;
536
-        }
537
-        if (! is_array($update_info)
538
-            || ! isset($update_info['mc_shipping'])
539
-            || ! isset($update_info['tax'])
540
-        ) {
541
-            $this->log(
542
-                array(
543
-                    'message' => esc_html__(
544
-                        // @codingStandardsIgnoreStart
545
-                        'Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal',
546
-                        // @codingStandardsIgnoreEnd
547
-                        'event_espresso'
548
-                    ),
549
-                    'url'     => $this->_process_response_url(),
550
-                    'payment' => $payment->model_field_array()
551
-                ),
552
-                $payment
553
-            );
554
-            return;
555
-        }
556
-        if ($payment->status() !== $this->_pay_model->approved_status()) {
557
-            $this->log(
558
-                array(
559
-                    'message' => esc_html__(
560
-                        'We shouldn\'t update transactions taxes or shipping data from non-approved payments',
561
-                        'event_espresso'
562
-                    ),
563
-                    'url'     => $this->_process_response_url(),
564
-                    'payment' => $payment->model_field_array()
565
-                ),
566
-                $payment
567
-            );
568
-            return;
569
-        }
570
-        $grand_total_needs_resaving = false;
571
-        /** @var EE_Line_Item $transaction_total_line_item */
572
-        $transaction_total_line_item = $transaction->total_line_item();
573
-
574
-        // might paypal have changed the taxes?
575
-        if ($this->_paypal_taxes && $payment_was_itemized) {
576
-            // note that we're doing this BEFORE adding shipping;
577
-            // we actually want PayPal's shipping to remain non-taxable
578
-            $this->_line_item->set_line_items_taxable($transaction_total_line_item, true, 'paypal_shipping');
579
-            $this->_line_item->set_total_tax_to(
580
-                $transaction_total_line_item,
581
-                (float) $update_info['tax'],
582
-                esc_html__('Taxes', 'event_espresso'),
583
-                esc_html__('Calculated by Paypal', 'event_espresso'),
584
-                'paypal_tax'
585
-            );
586
-            $grand_total_needs_resaving = true;
587
-        }
588
-
589
-        $shipping_amount = (float) $update_info['mc_shipping'];
590
-        // might paypal have added shipping?
591
-        if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) {
592
-            $this->_line_item->add_unrelated_item(
593
-                $transaction_total_line_item,
594
-                sprintf(esc_html__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()),
595
-                $shipping_amount,
596
-                esc_html__('Shipping charges calculated by Paypal', 'event_espresso'),
597
-                1,
598
-                false,
599
-                'paypal_shipping_' . $transaction->ID()
600
-            );
601
-            $grand_total_needs_resaving = true;
602
-        }
603
-
604
-        if ($grand_total_needs_resaving) {
605
-            $transaction_total_line_item->save_this_and_descendants_to_txn($transaction->ID());
606
-            /** @var EE_Registration_Processor $registration_processor */
607
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
608
-            $registration_processor->update_registration_final_prices($transaction);
609
-        }
610
-        $this->log(
611
-            array(
612
-                'message'                     => esc_html__('Updated transaction related to payment', 'event_espresso'),
613
-                'url'                         => $this->_process_response_url(),
614
-                'transaction (updated)'       => $transaction->model_field_array(),
615
-                'payment (updated)'           => $payment->model_field_array(),
616
-                'use_paypal_shipping'         => $this->_paypal_shipping,
617
-                'use_paypal_tax'              => $this->_paypal_taxes,
618
-                'grand_total_needed_resaving' => $grand_total_needs_resaving,
619
-            ),
620
-            $payment
621
-        );
622
-    }
213
+			$redirect_args[ 'shipping_' . $item_num ] = '0';
214
+			$redirect_args[ 'shipping2_' . $item_num ] = '0';
215
+		}
216
+
217
+		$redirect_args['business'] = $this->_paypal_id;
218
+		$redirect_args['return'] = $return_url;
219
+		$redirect_args['cancel_return'] = $cancel_url;
220
+		$redirect_args['notify_url'] = $notify_url;
221
+		$redirect_args['cmd'] = '_cart';
222
+		$redirect_args['upload'] = 1;
223
+		$redirect_args['currency_code'] = $payment->currency_code();
224
+		$redirect_args['rm'] = 2;// makes the user return with method=POST
225
+		if ($this->_image_url) {
226
+			$redirect_args['image_url'] = $this->_image_url;
227
+		}
228
+		$redirect_args['no_shipping'] = $this->_shipping_details;
229
+		$redirect_args['bn'] = 'EventEspresso_SP';// EE will blow up if you change this
230
+
231
+		$redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this);
232
+
233
+		$payment->set_redirect_url($this->_gateway_url);
234
+		$payment->set_redirect_args($redirect_args);
235
+		// log the results
236
+		$this->log(
237
+			array(
238
+				'message'     => sprintf(
239
+					__('PayPal payment request initiated.', 'event_espresso')
240
+				),
241
+				'transaction' => $transaction->model_field_array(),
242
+			),
243
+			$payment
244
+		);
245
+		return $payment;
246
+	}
247
+
248
+
249
+	/**
250
+	 * Often used for IPNs. But applies the info in $update_info to the payment.
251
+	 * What is $update_info? Often the contents of $_REQUEST, but not necessarily. Whatever
252
+	 * the payment method passes in.
253
+	 *
254
+	 * @param array $update_info like $_POST
255
+	 * @param EEI_Transaction $transaction
256
+	 * @return \EEI_Payment updated
257
+	 * @throws \EE_Error, IpnException
258
+	 */
259
+	public function handle_payment_update($update_info, $transaction)
260
+	{
261
+		// verify there's payment data that's been sent
262
+		if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) {
263
+			// log the results
264
+			$this->log(
265
+				array(
266
+					'message'     => sprintf(
267
+						// @codingStandardsIgnoreStart
268
+						__('PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso')
269
+						// @codingStandardsIgnoreEnd
270
+					),
271
+					'update_info' => $update_info,
272
+				),
273
+				$transaction
274
+			);
275
+			// waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/)
276
+			// indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes
277
+			if (isset($update_info['tx'])) {
278
+				return $transaction->last_payment();
279
+			} else {
280
+				return null;
281
+			}
282
+		}
283
+		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']);
284
+		if (! $payment instanceof EEI_Payment) {
285
+			$payment = $transaction->last_payment();
286
+		}
287
+		// ok, then validate the IPN. Even if we've already processed this payment,
288
+		// let PayPal know we don't want to hear from them anymore!
289
+		if (! $this->validate_ipn($update_info, $payment)) {
290
+			return $payment;
291
+		}
292
+		// kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction,
293
+		// registrations, ticket counts, etc)
294
+		if ((
295
+				$update_info['payment_status'] === 'Refunded'
296
+				|| $update_info['payment_status'] === 'Partially_Refunded'
297
+			)
298
+			&& apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)
299
+		) {
300
+			throw new EventEspresso\core\exceptions\IpnException(
301
+				sprintf(
302
+					esc_html__('Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'),
303
+					$update_info['payment_status']
304
+				),
305
+				EventEspresso\core\exceptions\IpnException::UNSUPPORTED,
306
+				null,
307
+				$payment,
308
+				$update_info
309
+			);
310
+		}
311
+		// ok, well let's process this payment then!
312
+		switch ($update_info['payment_status']) {
313
+			case 'Completed':
314
+				$status = $this->_pay_model->approved_status();
315
+				$gateway_response = esc_html__('The payment is approved.', 'event_espresso');
316
+				break;
317
+
318
+			case 'Pending':
319
+				$status = $this->_pay_model->pending_status();
320
+				$gateway_response = esc_html__(
321
+					'The payment is in progress. Another message will be sent when payment is approved.',
322
+					'event_espresso'
323
+				);
324
+				break;
325
+
326
+			case 'Denied':
327
+				$status = $this->_pay_model->declined_status();
328
+				$gateway_response = esc_html__('The payment has been declined.', 'event_espresso');
329
+				break;
330
+
331
+			case 'Expired':
332
+			case 'Failed':
333
+				$status = $this->_pay_model->failed_status();
334
+				$gateway_response = esc_html__('The payment failed for technical reasons or expired.', 'event_espresso');
335
+				break;
336
+
337
+			case 'Refunded':
338
+			case 'Partially_Refunded':
339
+				// even though it's a refund, we consider the payment as approved, it just has a negative value
340
+				$status = $this->_pay_model->approved_status();
341
+				$gateway_response = esc_html__(
342
+					'The payment has been refunded. Please update registrations accordingly.',
343
+					'event_espresso'
344
+				);
345
+				break;
346
+
347
+			case 'Voided':
348
+			case 'Reversed':
349
+			case 'Canceled_Reversal':
350
+			default:
351
+				$status = $this->_pay_model->cancelled_status();
352
+				$gateway_response = esc_html__(
353
+					'The payment was cancelled, reversed, or voided. Please update registrations accordingly.',
354
+					'event_espresso'
355
+				);
356
+				break;
357
+		}
358
+
359
+		// check if we've already processed this payment
360
+		if ($payment instanceof EEI_Payment) {
361
+			// payment exists. if this has the exact same status and amount, don't bother updating. just return
362
+			if ($payment->status() === $status && (float) $payment->amount() === (float) $update_info['mc_gross']) {
363
+				// DUPLICATED IPN! don't bother updating transaction
364
+				throw new IpnException(
365
+					sprintf(
366
+						esc_html__(
367
+							'It appears we have received a duplicate IPN from PayPal for payment %d',
368
+							'event_espresso'
369
+						),
370
+						$payment->ID()
371
+					),
372
+					IpnException::DUPLICATE,
373
+					null,
374
+					$payment,
375
+					$update_info
376
+				);
377
+			} else {
378
+				// new payment yippee !!!
379
+				$payment->set_status($status);
380
+				$payment->set_amount((float) $update_info['mc_gross']);
381
+				$payment->set_gateway_response($gateway_response);
382
+				$payment->set_details($update_info);
383
+				$payment->set_txn_id_chq_nmbr($update_info['txn_id']);
384
+				$this->log(
385
+					array(
386
+						'message'  => esc_html__(
387
+							'Updated payment either from IPN or as part of POST from PayPal',
388
+							'event_espresso'
389
+						),
390
+						'url'      => $this->_process_response_url(),
391
+						'payment'  => $payment->model_field_array(),
392
+						'IPN_data' => $update_info
393
+					),
394
+					$payment
395
+				);
396
+			}
397
+		}
398
+		do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this);
399
+		return $payment;
400
+	}
401
+
402
+
403
+	/**
404
+	 * Validate the IPN notification.
405
+	 *
406
+	 * @param array                  $update_info like $_REQUEST
407
+	 * @param EE_Payment|EEI_Payment $payment
408
+	 * @return boolean
409
+	 * @throws \EE_Error
410
+	 */
411
+	public function validate_ipn($update_info, $payment)
412
+	{
413
+		// allow us to skip validating IPNs with PayPal (useful for testing)
414
+		if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) {
415
+			return true;
416
+		}
417
+		// ...otherwise, we actually don't care what the $update_info is, we need to look
418
+		// at the request directly because we can't use $update_info because it has issues with quotes
419
+		// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
420
+		// Instead, read raw POST data from the input stream.
421
+		// @see https://gist.github.com/xcommerce-gists/3440401
422
+		$raw_post_data = file_get_contents('php://input');
423
+		$raw_post_array = explode('&', $raw_post_data);
424
+		$update_info = array();
425
+		foreach ($raw_post_array as $keyval) {
426
+			$keyval = explode('=', $keyval);
427
+			if (count($keyval) === 2) {
428
+				$update_info[ $keyval[0] ] = urldecode($keyval[1]);
429
+			}
430
+		}
431
+		// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
432
+		$req = 'cmd=_notify-validate';
433
+		$uses_get_magic_quotes = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() === 1
434
+			? true
435
+			: false;
436
+		foreach ($update_info as $key => $value) {
437
+			$value = $uses_get_magic_quotes ? urlencode(stripslashes($value)) : urlencode($value);
438
+			$req .= "&$key=$value";
439
+		}
440
+		// HTTP POST the complete, unaltered IPN back to PayPal
441
+		$response = wp_remote_post(
442
+			$this->_gateway_url,
443
+			array(
444
+				'body'              => $req,
445
+				'sslverify'         => false,
446
+				'timeout'           => 60,
447
+				// make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal
448
+				// plz see: https://github.com/websharks/s2member/issues/610
449
+				'user-agent'        => 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(),
450
+				'httpversion'       => '1.1'
451
+			)
452
+		);
453
+		// then check the response
454
+		if (array_key_exists('body', $response)
455
+			&& ! is_wp_error($response)
456
+			&& strcmp($response['body'], "VERIFIED") === 0
457
+		) {
458
+			return true;
459
+		}
460
+		// huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly,
461
+		// or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html
462
+		if ($response instanceof WP_Error) {
463
+			$error_msg = sprintf(
464
+				esc_html__('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'),
465
+				$response->get_error_code(),
466
+				$response->get_error_message(),
467
+				print_r($response->get_error_data(), true)
468
+			);
469
+		} elseif (is_array($response) && isset($response['body'])) {
470
+			$error_msg = $response['body'];
471
+		} else {
472
+			$error_msg = print_r($response, true);
473
+		}
474
+		$payment->set_gateway_response(
475
+			sprintf(
476
+				esc_html__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"),
477
+				$error_msg
478
+			)
479
+		);
480
+		$payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response));
481
+		$payment->set_status(EEM_Payment::status_id_failed);
482
+		// log the results
483
+		$this->log(
484
+			array(
485
+				'url'     => $this->_process_response_url(),
486
+				'message' => $payment->gateway_response(),
487
+				'details' => $payment->details(),
488
+			),
489
+			$payment
490
+		);
491
+		return false;
492
+	}
493
+
494
+
495
+	/**
496
+	 * _process_response_url
497
+	 * @return string
498
+	 */
499
+	protected function _process_response_url()
500
+	{
501
+		if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
502
+			$url = is_ssl() ? 'https://' : 'http://';
503
+			$url .= EEH_URL::filter_input_server_url('HTTP_HOST');
504
+			$url .= EEH_URL::filter_input_server_url();
505
+		} else {
506
+			$url = 'unknown';
507
+		}
508
+		return $url;
509
+	}
510
+
511
+
512
+	/**
513
+	 * Updates the transaction and line items based on the payment IPN data from PayPal,
514
+	 * like the taxes or shipping
515
+	 *
516
+	 * @param EEI_Payment $payment
517
+	 * @throws \EE_Error
518
+	 */
519
+	public function update_txn_based_on_payment($payment)
520
+	{
521
+		$update_info = $payment->details();
522
+		/** @var EE_Transaction $transaction */
523
+		$transaction = $payment->transaction();
524
+		$payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false);
525
+		if (! $transaction) {
526
+			$this->log(
527
+				esc_html__(
528
+					// @codingStandardsIgnoreStart
529
+					'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly',
530
+					// @codingStandardsIgnoreEnd
531
+					'event_espresso'
532
+				),
533
+				$payment
534
+			);
535
+			return;
536
+		}
537
+		if (! is_array($update_info)
538
+			|| ! isset($update_info['mc_shipping'])
539
+			|| ! isset($update_info['tax'])
540
+		) {
541
+			$this->log(
542
+				array(
543
+					'message' => esc_html__(
544
+						// @codingStandardsIgnoreStart
545
+						'Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal',
546
+						// @codingStandardsIgnoreEnd
547
+						'event_espresso'
548
+					),
549
+					'url'     => $this->_process_response_url(),
550
+					'payment' => $payment->model_field_array()
551
+				),
552
+				$payment
553
+			);
554
+			return;
555
+		}
556
+		if ($payment->status() !== $this->_pay_model->approved_status()) {
557
+			$this->log(
558
+				array(
559
+					'message' => esc_html__(
560
+						'We shouldn\'t update transactions taxes or shipping data from non-approved payments',
561
+						'event_espresso'
562
+					),
563
+					'url'     => $this->_process_response_url(),
564
+					'payment' => $payment->model_field_array()
565
+				),
566
+				$payment
567
+			);
568
+			return;
569
+		}
570
+		$grand_total_needs_resaving = false;
571
+		/** @var EE_Line_Item $transaction_total_line_item */
572
+		$transaction_total_line_item = $transaction->total_line_item();
573
+
574
+		// might paypal have changed the taxes?
575
+		if ($this->_paypal_taxes && $payment_was_itemized) {
576
+			// note that we're doing this BEFORE adding shipping;
577
+			// we actually want PayPal's shipping to remain non-taxable
578
+			$this->_line_item->set_line_items_taxable($transaction_total_line_item, true, 'paypal_shipping');
579
+			$this->_line_item->set_total_tax_to(
580
+				$transaction_total_line_item,
581
+				(float) $update_info['tax'],
582
+				esc_html__('Taxes', 'event_espresso'),
583
+				esc_html__('Calculated by Paypal', 'event_espresso'),
584
+				'paypal_tax'
585
+			);
586
+			$grand_total_needs_resaving = true;
587
+		}
588
+
589
+		$shipping_amount = (float) $update_info['mc_shipping'];
590
+		// might paypal have added shipping?
591
+		if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) {
592
+			$this->_line_item->add_unrelated_item(
593
+				$transaction_total_line_item,
594
+				sprintf(esc_html__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()),
595
+				$shipping_amount,
596
+				esc_html__('Shipping charges calculated by Paypal', 'event_espresso'),
597
+				1,
598
+				false,
599
+				'paypal_shipping_' . $transaction->ID()
600
+			);
601
+			$grand_total_needs_resaving = true;
602
+		}
603
+
604
+		if ($grand_total_needs_resaving) {
605
+			$transaction_total_line_item->save_this_and_descendants_to_txn($transaction->ID());
606
+			/** @var EE_Registration_Processor $registration_processor */
607
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
608
+			$registration_processor->update_registration_final_prices($transaction);
609
+		}
610
+		$this->log(
611
+			array(
612
+				'message'                     => esc_html__('Updated transaction related to payment', 'event_espresso'),
613
+				'url'                         => $this->_process_response_url(),
614
+				'transaction (updated)'       => $transaction->model_field_array(),
615
+				'payment (updated)'           => $payment->model_field_array(),
616
+				'use_paypal_shipping'         => $this->_paypal_shipping,
617
+				'use_paypal_tax'              => $this->_paypal_taxes,
618
+				'grand_total_needed_resaving' => $grand_total_needs_resaving,
619
+			),
620
+			$payment
621
+		);
622
+	}
623 623
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -137,17 +137,17 @@  discard block
 block discarded – undo
137 137
                         $shipping_previously_added = $line_item->total();
138 138
                         continue;
139 139
                     }
140
-                    $redirect_args[ 'item_name_' . $item_num ] = substr(
140
+                    $redirect_args['item_name_'.$item_num] = substr(
141 141
                         $gateway_formatter->formatLineItemName($line_item, $payment),
142 142
                         0,
143 143
                         127
144 144
                     );
145
-                    $redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price();
146
-                    $redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity();
145
+                    $redirect_args['amount_'.$item_num] = $line_item->unit_price();
146
+                    $redirect_args['quantity_'.$item_num] = $line_item->quantity();
147 147
                     // if we're not letting PayPal calculate shipping, tell them its 0
148
-                    if (! $this->_paypal_shipping) {
149
-                        $redirect_args[ 'shipping_' . $item_num ] = '0';
150
-                        $redirect_args[ 'shipping2_' . $item_num ] = '0';
148
+                    if ( ! $this->_paypal_shipping) {
149
+                        $redirect_args['shipping_'.$item_num] = '0';
150
+                        $redirect_args['shipping2_'.$item_num] = '0';
151 151
                     }
152 152
                     $item_num++;
153 153
                     $itemized_sum += $line_item->total();
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
                 // itemized sum is too big
168 168
                 $total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total);
169 169
             } elseif ($itemized_sum_diff_from_txn_total > 0) {
170
-                $redirect_args[ 'item_name_' . $item_num ] = substr(
170
+                $redirect_args['item_name_'.$item_num] = substr(
171 171
                     __('Other charges', 'event_espresso'),
172 172
                     0,
173 173
                     127
174 174
                 );
175
-                $redirect_args[ 'amount_' . $item_num ] = $gateway_formatter->formatCurrency(
175
+                $redirect_args['amount_'.$item_num] = $gateway_formatter->formatCurrency(
176 176
                     $itemized_sum_diff_from_txn_total
177 177
                 );
178
-                $redirect_args[ 'quantity_' . $item_num ] = 1;
178
+                $redirect_args['quantity_'.$item_num] = 1;
179 179
                 $item_num++;
180 180
             }
181 181
             if ($total_discounts_to_cart_total > 0) {
@@ -184,34 +184,34 @@  discard block
 block discarded – undo
184 184
                 );
185 185
             }
186 186
             // add our taxes to the order if we're NOT using PayPal's
187
-            if (! $this->_paypal_taxes) {
187
+            if ( ! $this->_paypal_taxes) {
188 188
                 $redirect_args['tax_cart'] = $total_line_item->get_total_tax();
189 189
             }
190 190
         } else {
191 191
             $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false);
192 192
             // partial payment that's not for the remaining amount, so we can't send an itemized list
193
-            $redirect_args[ 'item_name_' . $item_num ] = substr(
193
+            $redirect_args['item_name_'.$item_num] = substr(
194 194
                 $gateway_formatter->formatPartialPaymentLineItemName($payment),
195 195
                 0,
196 196
                 127
197 197
             );
198
-            $redirect_args[ 'amount_' . $item_num ] = $payment->amount();
199
-            $redirect_args[ 'shipping_' . $item_num ] = '0';
200
-            $redirect_args[ 'shipping2_' . $item_num ] = '0';
198
+            $redirect_args['amount_'.$item_num] = $payment->amount();
199
+            $redirect_args['shipping_'.$item_num] = '0';
200
+            $redirect_args['shipping2_'.$item_num] = '0';
201 201
             $redirect_args['tax_cart'] = '0';
202 202
             $item_num++;
203 203
         }
204 204
 
205 205
         if ($this->_debug_mode) {
206
-            $redirect_args[ 'item_name_' . $item_num ] = 'DEBUG INFO (this item only added in sandbox mode';
207
-            $redirect_args[ 'amount_' . $item_num ] = 0;
208
-            $redirect_args[ 'on0_'.$item_num ] = 'NOTIFY URL';
209
-            $redirect_args[ 'os0_' . $item_num ] = $notify_url;
210
-            $redirect_args[ 'on1_'.$item_num ] = 'RETURN URL';
211
-            $redirect_args[ 'os1_' . $item_num ] = $return_url;
206
+            $redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode';
207
+            $redirect_args['amount_'.$item_num] = 0;
208
+            $redirect_args['on0_'.$item_num] = 'NOTIFY URL';
209
+            $redirect_args['os0_'.$item_num] = $notify_url;
210
+            $redirect_args['on1_'.$item_num] = 'RETURN URL';
211
+            $redirect_args['os1_'.$item_num] = $return_url;
212 212
 //          $redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ?
213
-            $redirect_args[ 'shipping_' . $item_num ] = '0';
214
-            $redirect_args[ 'shipping2_' . $item_num ] = '0';
213
+            $redirect_args['shipping_'.$item_num] = '0';
214
+            $redirect_args['shipping2_'.$item_num] = '0';
215 215
         }
216 216
 
217 217
         $redirect_args['business'] = $this->_paypal_id;
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
         $redirect_args['cmd'] = '_cart';
222 222
         $redirect_args['upload'] = 1;
223 223
         $redirect_args['currency_code'] = $payment->currency_code();
224
-        $redirect_args['rm'] = 2;// makes the user return with method=POST
224
+        $redirect_args['rm'] = 2; // makes the user return with method=POST
225 225
         if ($this->_image_url) {
226 226
             $redirect_args['image_url'] = $this->_image_url;
227 227
         }
228 228
         $redirect_args['no_shipping'] = $this->_shipping_details;
229
-        $redirect_args['bn'] = 'EventEspresso_SP';// EE will blow up if you change this
229
+        $redirect_args['bn'] = 'EventEspresso_SP'; // EE will blow up if you change this
230 230
 
231 231
         $redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this);
232 232
 
@@ -281,12 +281,12 @@  discard block
 block discarded – undo
281 281
             }
282 282
         }
283 283
         $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']);
284
-        if (! $payment instanceof EEI_Payment) {
284
+        if ( ! $payment instanceof EEI_Payment) {
285 285
             $payment = $transaction->last_payment();
286 286
         }
287 287
         // ok, then validate the IPN. Even if we've already processed this payment,
288 288
         // let PayPal know we don't want to hear from them anymore!
289
-        if (! $this->validate_ipn($update_info, $payment)) {
289
+        if ( ! $this->validate_ipn($update_info, $payment)) {
290 290
             return $payment;
291 291
         }
292 292
         // kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction,
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
         foreach ($raw_post_array as $keyval) {
426 426
             $keyval = explode('=', $keyval);
427 427
             if (count($keyval) === 2) {
428
-                $update_info[ $keyval[0] ] = urldecode($keyval[1]);
428
+                $update_info[$keyval[0]] = urldecode($keyval[1]);
429 429
             }
430 430
         }
431 431
         // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
                 'timeout'           => 60,
447 447
                 // make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal
448 448
                 // plz see: https://github.com/websharks/s2member/issues/610
449
-                'user-agent'        => 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(),
449
+                'user-agent'        => 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(),
450 450
                 'httpversion'       => '1.1'
451 451
             )
452 452
         );
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         /** @var EE_Transaction $transaction */
523 523
         $transaction = $payment->transaction();
524 524
         $payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false);
525
-        if (! $transaction) {
525
+        if ( ! $transaction) {
526 526
             $this->log(
527 527
                 esc_html__(
528 528
                     // @codingStandardsIgnoreStart
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
             );
535 535
             return;
536 536
         }
537
-        if (! is_array($update_info)
537
+        if ( ! is_array($update_info)
538 538
             || ! isset($update_info['mc_shipping'])
539 539
             || ! isset($update_info['tax'])
540 540
         ) {
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
                 esc_html__('Shipping charges calculated by Paypal', 'event_espresso'),
597 597
                 1,
598 598
                 false,
599
-                'paypal_shipping_' . $transaction->ID()
599
+                'paypal_shipping_'.$transaction->ID()
600 600
             );
601 601
             $grand_total_needs_resaving = true;
602 602
         }
Please login to merge, or discard this patch.
Paypal_Standard/templates/paypal_standard_intro.template.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@
 block discarded – undo
3 3
 // if this is decaf, which is put on WordPress.org, we need to inform users that
4 4
 // we just put an affiliate link there. See https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/ section 12
5 5
 if (apply_filters('FHEE__ee_show_affiliate_links', true)) {
6
-    $closing_tag .= esc_html__(' (affiliate link)', 'event_espresso');
6
+	$closing_tag .= esc_html__(' (affiliate link)', 'event_espresso');
7 7
 }
8 8
 printf(
9
-    esc_html__(
10
-        'PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.',
11
-        'event_espresso'
12
-    ),
13
-    '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">',
14
-    $closing_tag
9
+	esc_html__(
10
+		'PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.',
11
+		'event_espresso'
12
+	),
13
+	'<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">',
14
+	$closing_tag
15 15
 );
Please login to merge, or discard this patch.
payment_methods/Check/EE_PMT_Check.pm.php 2 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -13,121 +13,121 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * @param null $pm_instance
18
-     * @return EE_PMT_Check
19
-     */
20
-    public function __construct($pm_instance = null)
21
-    {
22
-        $this->_pretty_name = __("Check", 'event_espresso');
23
-        $this->_default_description = __('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso');
24
-        parent::__construct($pm_instance);
25
-        $this->_default_button_url = $this->file_url().'lib'.DS.'check-logo.png';
26
-    }
16
+	/**
17
+	 * @param null $pm_instance
18
+	 * @return EE_PMT_Check
19
+	 */
20
+	public function __construct($pm_instance = null)
21
+	{
22
+		$this->_pretty_name = __("Check", 'event_espresso');
23
+		$this->_default_description = __('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso');
24
+		parent::__construct($pm_instance);
25
+		$this->_default_button_url = $this->file_url().'lib'.DS.'check-logo.png';
26
+	}
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * Creates the billing form for this payment method type
32
-     * @param \EE_Transaction $transaction
33
-     * @return NULL
34
-     */
35
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
36
-    {
37
-        return null;
38
-    }
30
+	/**
31
+	 * Creates the billing form for this payment method type
32
+	 * @param \EE_Transaction $transaction
33
+	 * @return NULL
34
+	 */
35
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
36
+	{
37
+		return null;
38
+	}
39 39
 
40 40
 
41 41
 
42
-    /**
43
-     * Overrides parent to dynamically set some defaults, but only when the form is requested
44
-     * @return EE_Form_Section_Proper
45
-     */
46
-    public function generate_new_settings_form()
47
-    {
48
-        if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
49
-            $organization = EE_Registry::instance()->CFG->organization;
50
-            $organization_name = $organization->get_pretty('name');
51
-            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
52
-            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
53
-            $default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
54
-            $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
55
-            $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
56
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
57
-            $default_address .=  $state ? $state->name() . '<br />' : '';
58
-            $default_address .= $country ? $country->name(). '<br />' : '';
59
-            $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
60
-        } else {
61
-            $default_address = 'unknown';
62
-            $organization_name = 'unknown';
63
-        }
64
-            return new EE_Payment_Method_Form(array(
65
-            'extra_meta_inputs'=>array(
66
-                'check_title'=> new EE_Text_Input(array(
67
-                    'html_label_text'=>  sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()),
68
-                    'default'=>  __("Check/Money Order Payments", 'event_espresso'),
69
-                )),
70
-                'payment_instructions'=>new EE_Text_Area_Input(array(
71
-                    'html_label_text'=>  sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
72
-                    'default'=> __("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
73
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
74
-                )),
75
-                'payable_to'=>new EE_Text_Input(array(
76
-                    'html_label_text'=>  sprintf(__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
77
-                    'default'=>$organization_name
78
-                )),
79
-                'address_to_send_payment'=>new EE_Text_Area_Input(array(
80
-                    'html_label_text'=>  sprintf(__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
81
-                    'default'=>$default_address,
82
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
83
-                )),
84
-            ),
85
-            'exclude'=>array('PMD_debug_mode')
86
-            ));
87
-    }
42
+	/**
43
+	 * Overrides parent to dynamically set some defaults, but only when the form is requested
44
+	 * @return EE_Form_Section_Proper
45
+	 */
46
+	public function generate_new_settings_form()
47
+	{
48
+		if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
49
+			$organization = EE_Registry::instance()->CFG->organization;
50
+			$organization_name = $organization->get_pretty('name');
51
+			$default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
52
+			$default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
53
+			$default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
54
+			$default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
55
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
56
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
57
+			$default_address .=  $state ? $state->name() . '<br />' : '';
58
+			$default_address .= $country ? $country->name(). '<br />' : '';
59
+			$default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
60
+		} else {
61
+			$default_address = 'unknown';
62
+			$organization_name = 'unknown';
63
+		}
64
+			return new EE_Payment_Method_Form(array(
65
+			'extra_meta_inputs'=>array(
66
+				'check_title'=> new EE_Text_Input(array(
67
+					'html_label_text'=>  sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()),
68
+					'default'=>  __("Check/Money Order Payments", 'event_espresso'),
69
+				)),
70
+				'payment_instructions'=>new EE_Text_Area_Input(array(
71
+					'html_label_text'=>  sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
72
+					'default'=> __("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
73
+					'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
74
+				)),
75
+				'payable_to'=>new EE_Text_Input(array(
76
+					'html_label_text'=>  sprintf(__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
77
+					'default'=>$organization_name
78
+				)),
79
+				'address_to_send_payment'=>new EE_Text_Area_Input(array(
80
+					'html_label_text'=>  sprintf(__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
81
+					'default'=>$default_address,
82
+					'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
83
+				)),
84
+			),
85
+			'exclude'=>array('PMD_debug_mode')
86
+			));
87
+	}
88 88
 
89 89
 
90 90
 
91
-    /**
92
-     * Adds the help tab
93
-     * @see EE_PMT_Base::help_tabs_config()
94
-     * @return array
95
-     */
96
-    public function help_tabs_config()
97
-    {
98
-        return array(
99
-            $this->get_help_tab_name() => array(
100
-                        'title' => __('Check Settings', 'event_espresso'),
101
-                        'filename' => 'payment_methods_overview_check'
102
-                        ),
103
-        );
104
-    }
91
+	/**
92
+	 * Adds the help tab
93
+	 * @see EE_PMT_Base::help_tabs_config()
94
+	 * @return array
95
+	 */
96
+	public function help_tabs_config()
97
+	{
98
+		return array(
99
+			$this->get_help_tab_name() => array(
100
+						'title' => __('Check Settings', 'event_espresso'),
101
+						'filename' => 'payment_methods_overview_check'
102
+						),
103
+		);
104
+	}
105 105
 
106 106
 
107 107
 
108
-    /**
109
-     * For adding any html output ab ove the payment overview.
110
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
111
-     * Other gateways may want to override this, such as offline gateways.
112
-     * @return string
113
-     */
114
-    public function payment_overview_content(EE_Payment $payment)
115
-    {
116
-        $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
117
-        $template_vars = array_merge(
118
-            array(
119
-                            'payment_method'=>$this->_pm_instance,
120
-                            'payment'=>$payment,
121
-                            'check_title'=>'',
122
-                            'payment_instructions'=>'',
123
-                            'payable_to'=>'',
124
-                            'address_to_send_payment'=>'',
125
-                            ),
126
-            $extra_meta_for_payment_method
127
-        );
128
-        return EEH_Template::locate_template(
129
-            'payment_methods' . DS . 'Check'. DS . 'templates'.DS.'check_payment_details_content.template.php',
130
-            $template_vars
131
-        );
132
-    }
108
+	/**
109
+	 * For adding any html output ab ove the payment overview.
110
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
111
+	 * Other gateways may want to override this, such as offline gateways.
112
+	 * @return string
113
+	 */
114
+	public function payment_overview_content(EE_Payment $payment)
115
+	{
116
+		$extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
117
+		$template_vars = array_merge(
118
+			array(
119
+							'payment_method'=>$this->_pm_instance,
120
+							'payment'=>$payment,
121
+							'check_title'=>'',
122
+							'payment_instructions'=>'',
123
+							'payable_to'=>'',
124
+							'address_to_send_payment'=>'',
125
+							),
126
+			$extra_meta_for_payment_method
127
+		);
128
+		return EEH_Template::locate_template(
129
+			'payment_methods' . DS . 'Check'. DS . 'templates'.DS.'check_payment_details_content.template.php',
130
+			$template_vars
131
+		);
132
+	}
133 133
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
         if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
49 49
             $organization = EE_Registry::instance()->CFG->organization;
50 50
             $organization_name = $organization->get_pretty('name');
51
-            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
52
-            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
51
+            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1').'<br />' : '';
52
+            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2').'<br />' : '';
53 53
             $default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
54
-            $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
54
+            $default_address .= ($organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
55 55
             $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
56
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
57
-            $default_address .=  $state ? $state->name() . '<br />' : '';
58
-            $default_address .= $country ? $country->name(). '<br />' : '';
56
+            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO);
57
+            $default_address .= $state ? $state->name().'<br />' : '';
58
+            $default_address .= $country ? $country->name().'<br />' : '';
59 59
             $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
60 60
         } else {
61 61
             $default_address = 'unknown';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                 'payment_instructions'=>new EE_Text_Area_Input(array(
71 71
                     'html_label_text'=>  sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
72 72
                     'default'=> __("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
73
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
73
+                    'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
74 74
                 )),
75 75
                 'payable_to'=>new EE_Text_Input(array(
76 76
                     'html_label_text'=>  sprintf(__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 'address_to_send_payment'=>new EE_Text_Area_Input(array(
80 80
                     'html_label_text'=>  sprintf(__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
81 81
                     'default'=>$default_address,
82
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
82
+                    'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
83 83
                 )),
84 84
             ),
85 85
             'exclude'=>array('PMD_debug_mode')
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             $extra_meta_for_payment_method
127 127
         );
128 128
         return EEH_Template::locate_template(
129
-            'payment_methods' . DS . 'Check'. DS . 'templates'.DS.'check_payment_details_content.template.php',
129
+            'payment_methods'.DS.'Check'.DS.'templates'.DS.'check_payment_details_content.template.php',
130 130
             $template_vars
131 131
         );
132 132
     }
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,4 +1,4 @@
 block discarded – undo
1 1
 <?php esc_html_e(
2
-    '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.',
3
-    'event_espresso'
2
+	'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.',
3
+	'event_espresso'
4 4
 );
Please login to merge, or discard this patch.
payment_methods/Admin_Only/EE_PMT_Admin_Only.pm.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -16,38 +16,38 @@
 block discarded – undo
16 16
 
17 17
 
18 18
 
19
-    /**
20
-     *
21
-     * @param EE_Payment_Method $pm_instance
22
-     * @return EE_PMT_Admin_Only
23
-     */
24
-    public function __construct($pm_instance = null)
25
-    {
26
-        $this->_pretty_name = __("Admin Only", 'event_espresso');
27
-        $this->_default_button_url = '';
28
-        parent::__construct($pm_instance);
29
-    }
30
-
31
-
32
-
33
-    /**
34
-     * Creates the billing form for this payment method type
35
-     * @param \EE_Transaction $transaction
36
-     * @return NULL
37
-     */
38
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
39
-    {
40
-        return null;
41
-    }
42
-
43
-
44
-
45
-    /**
46
-     * Gets the form for all the settings related to this payment method type
47
-     * @return EE_Payment_Method_Form
48
-     */
49
-    public function generate_new_settings_form()
50
-    {
51
-        return new EE_Payment_Method_Form();
52
-    }
19
+	/**
20
+	 *
21
+	 * @param EE_Payment_Method $pm_instance
22
+	 * @return EE_PMT_Admin_Only
23
+	 */
24
+	public function __construct($pm_instance = null)
25
+	{
26
+		$this->_pretty_name = __("Admin Only", 'event_espresso');
27
+		$this->_default_button_url = '';
28
+		parent::__construct($pm_instance);
29
+	}
30
+
31
+
32
+
33
+	/**
34
+	 * Creates the billing form for this payment method type
35
+	 * @param \EE_Transaction $transaction
36
+	 * @return NULL
37
+	 */
38
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
39
+	{
40
+		return null;
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 * Gets the form for all the settings related to this payment method type
47
+	 * @return EE_Payment_Method_Form
48
+	 */
49
+	public function generate_new_settings_form()
50
+	{
51
+		return new EE_Payment_Method_Form();
52
+	}
53 53
 }
Please login to merge, or discard this patch.
payment_methods/Bank/EE_PMT_Bank.pm.php 2 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -14,99 +14,99 @@
 block discarded – undo
14 14
 
15 15
 
16 16
 
17
-    /**
18
-     *
19
-     * @param EE_Payment_Method $pm_instance
20
-     * @return EE_PMT_Bank
21
-     */
22
-    public function __construct($pm_instance = null)
23
-    {
24
-        $this->_pretty_name = __("Bank", 'event_espresso');
25
-        parent::__construct($pm_instance);
26
-        $this->_default_button_url = $this->file_url().'lib'.DS.'bank-logo.png';
27
-        $this->_default_description = __('Make payment using an electronic funds transfer from your bank.', 'event_espresso');
28
-    }
29
-
30
-
31
-
32
-    /**
33
-     * Creates the billing form for this payment method type
34
-     * @param \EE_Transaction $transaction
35
-     * @return NULL
36
-     */
37
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
38
-    {
39
-        return null;
40
-    }
41
-
42
-
43
-
44
-    /**
45
-     * Gets the form for all the settings related to this payment method type
46
-     * @return EE_Payment_Method_Form
47
-     */
48
-    public function generate_new_settings_form()
49
-    {
50
-        return new EE_Payment_Method_Form(array(
51
-            'extra_meta_inputs'=>array(
52
-                'page_title'=>new EE_Text_Input(array(
53
-                    'html_label_text'=>  sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()),
54
-                    'default'=>  __("Electronic Funds Transfers", 'event_espresso')
55
-                )),
56
-                'payment_instructions'=>new EE_Text_Area_Input(array(
57
-                    'html_label_text'=>  sprintf(__("Payment Instructions %s", "event_espresso"), $this->get_help_tab_link()),
58
-                    'html_help_text' => __('Provide instructions on how registrants can send the bank draft payment. Eg, mention your account name, bank account number, bank name, bank routing code, and bank address, etc.', 'event_espresso'),
59
-                    'default'=> sprintf(
60
-                        __('Please initiate an electronic payment using the following bank information: %1$sAccount Owner: Luke Skywalker%1$sBank Account # 1234567890%1$sBank Name: Rebellion Bank%1$sRouting Number: 12345%1$sBank Address: 12345 Wookie Rd., Planet Corellian.%1$sPayment must be received within 48 hours of event date.', 'event_espresso'),
61
-                        "\n"
62
-                    ),
63
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
64
-                )),
65
-            ),
66
-            'exclude'=>array('PMD_debug_mode')
67
-        ));
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * Adds the help tab
74
-     * @see EE_PMT_Base::help_tabs_config()
75
-     * @return array
76
-     */
77
-    public function help_tabs_config()
78
-    {
79
-        return array(
80
-            $this->get_help_tab_name() => array(
81
-                        'title' => __('Bank Draft Settings', 'event_espresso'),
82
-                        'filename' => 'payment_methods_overview_bank_draft'
83
-                        ),
84
-        );
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * For adding any html output ab ove the payment overview.
91
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
92
-     * Other gateways may want to override this, such as offline gateways.
93
-     * @return string
94
-     */
95
-    public function payment_overview_content(EE_Payment $payment)
96
-    {
97
-        $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
98
-        $template_vars = array_merge(
99
-            array(
100
-                            'payment_method'=>$this->_pm_instance,
101
-                            'payment'=>$payment,
102
-                            'page_title'=>'',
103
-                            'payment_instructions'=>'',
104
-                            ),
105
-            $extra_meta_for_payment_method
106
-        );
107
-        return EEH_Template::locate_template(
108
-            'payment_methods' . DS . 'Bank'. DS . 'templates' . DS . 'bank_payment_details_content.template.php',
109
-            $template_vars
110
-        );
111
-    }
17
+	/**
18
+	 *
19
+	 * @param EE_Payment_Method $pm_instance
20
+	 * @return EE_PMT_Bank
21
+	 */
22
+	public function __construct($pm_instance = null)
23
+	{
24
+		$this->_pretty_name = __("Bank", 'event_espresso');
25
+		parent::__construct($pm_instance);
26
+		$this->_default_button_url = $this->file_url().'lib'.DS.'bank-logo.png';
27
+		$this->_default_description = __('Make payment using an electronic funds transfer from your bank.', 'event_espresso');
28
+	}
29
+
30
+
31
+
32
+	/**
33
+	 * Creates the billing form for this payment method type
34
+	 * @param \EE_Transaction $transaction
35
+	 * @return NULL
36
+	 */
37
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
38
+	{
39
+		return null;
40
+	}
41
+
42
+
43
+
44
+	/**
45
+	 * Gets the form for all the settings related to this payment method type
46
+	 * @return EE_Payment_Method_Form
47
+	 */
48
+	public function generate_new_settings_form()
49
+	{
50
+		return new EE_Payment_Method_Form(array(
51
+			'extra_meta_inputs'=>array(
52
+				'page_title'=>new EE_Text_Input(array(
53
+					'html_label_text'=>  sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()),
54
+					'default'=>  __("Electronic Funds Transfers", 'event_espresso')
55
+				)),
56
+				'payment_instructions'=>new EE_Text_Area_Input(array(
57
+					'html_label_text'=>  sprintf(__("Payment Instructions %s", "event_espresso"), $this->get_help_tab_link()),
58
+					'html_help_text' => __('Provide instructions on how registrants can send the bank draft payment. Eg, mention your account name, bank account number, bank name, bank routing code, and bank address, etc.', 'event_espresso'),
59
+					'default'=> sprintf(
60
+						__('Please initiate an electronic payment using the following bank information: %1$sAccount Owner: Luke Skywalker%1$sBank Account # 1234567890%1$sBank Name: Rebellion Bank%1$sRouting Number: 12345%1$sBank Address: 12345 Wookie Rd., Planet Corellian.%1$sPayment must be received within 48 hours of event date.', 'event_espresso'),
61
+						"\n"
62
+					),
63
+					'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
64
+				)),
65
+			),
66
+			'exclude'=>array('PMD_debug_mode')
67
+		));
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * Adds the help tab
74
+	 * @see EE_PMT_Base::help_tabs_config()
75
+	 * @return array
76
+	 */
77
+	public function help_tabs_config()
78
+	{
79
+		return array(
80
+			$this->get_help_tab_name() => array(
81
+						'title' => __('Bank Draft Settings', 'event_espresso'),
82
+						'filename' => 'payment_methods_overview_bank_draft'
83
+						),
84
+		);
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * For adding any html output ab ove the payment overview.
91
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
92
+	 * Other gateways may want to override this, such as offline gateways.
93
+	 * @return string
94
+	 */
95
+	public function payment_overview_content(EE_Payment $payment)
96
+	{
97
+		$extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
98
+		$template_vars = array_merge(
99
+			array(
100
+							'payment_method'=>$this->_pm_instance,
101
+							'payment'=>$payment,
102
+							'page_title'=>'',
103
+							'payment_instructions'=>'',
104
+							),
105
+			$extra_meta_for_payment_method
106
+		);
107
+		return EEH_Template::locate_template(
108
+			'payment_methods' . DS . 'Bank'. DS . 'templates' . DS . 'bank_payment_details_content.template.php',
109
+			$template_vars
110
+		);
111
+	}
112 112
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                         __('Please initiate an electronic payment using the following bank information: %1$sAccount Owner: Luke Skywalker%1$sBank Account # 1234567890%1$sBank Name: Rebellion Bank%1$sRouting Number: 12345%1$sBank Address: 12345 Wookie Rd., Planet Corellian.%1$sPayment must be received within 48 hours of event date.', 'event_espresso'),
61 61
                         "\n"
62 62
                     ),
63
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
63
+                    'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
64 64
                 )),
65 65
             ),
66 66
             'exclude'=>array('PMD_debug_mode')
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             $extra_meta_for_payment_method
106 106
         );
107 107
         return EEH_Template::locate_template(
108
-            'payment_methods' . DS . 'Bank'. DS . 'templates' . DS . 'bank_payment_details_content.template.php',
108
+            'payment_methods'.DS.'Bank'.DS.'templates'.DS.'bank_payment_details_content.template.php',
109 109
             $template_vars
110 110
         );
111 111
     }
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,4 +1,4 @@
 block discarded – undo
1 1
 <?php esc_html_e(
2
-    '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.',
3
-    'event_espresso'
2
+	'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.',
3
+	'event_espresso'
4 4
 );
Please login to merge, or discard this patch.