@@ -7,44 +7,44 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Make sure that the form is active. |
13 | -if ( ! $form->is_active() ) { |
|
13 | +if (!$form->is_active()) { |
|
14 | 14 | echo aui()->alert( |
15 | 15 | array( |
16 | 16 | 'type' => 'warning', |
17 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
17 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
18 | 18 | ) |
19 | 19 | ); |
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | 23 | // Fires before displaying a payment form. |
24 | -do_action( 'getpaid_before_payment_form', $form ); |
|
24 | +do_action('getpaid_before_payment_form', $form); |
|
25 | 25 | ?> |
26 | 26 | |
27 | -<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui position-relative' method='POST' data-key='<?php echo uniqid('gpf'); ?>' data-currency='<?php echo esc_attr( empty( $form->invoice ) ? wpinv_get_currency() : $form->invoice->get_currency() ); ?>'> |
|
27 | +<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui position-relative' method='POST' data-key='<?php echo uniqid('gpf'); ?>' data-currency='<?php echo esc_attr(empty($form->invoice) ? wpinv_get_currency() : $form->invoice->get_currency()); ?>'> |
|
28 | 28 | |
29 | 29 | |
30 | 30 | <?php |
31 | 31 | |
32 | 32 | // Fires when printing the top of a payment form. |
33 | - do_action( 'getpaid_payment_form_top', $form ); |
|
33 | + do_action('getpaid_payment_form_top', $form); |
|
34 | 34 | |
35 | 35 | // And the optional invoice id. |
36 | - if ( ! empty( $form->invoice ) ) { |
|
37 | - echo getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() ); |
|
36 | + if (!empty($form->invoice)) { |
|
37 | + echo getpaid_hidden_field('invoice_id', $form->invoice->get_id()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // We also want to include the form id. |
41 | - echo getpaid_hidden_field( 'form_id', $form->get_id() ); |
|
41 | + echo getpaid_hidden_field('form_id', $form->get_id()); |
|
42 | 42 | |
43 | 43 | // And an indication that this is a payment form submission. |
44 | - echo getpaid_hidden_field( 'getpaid_payment_form_submission', '1' ); |
|
44 | + echo getpaid_hidden_field('getpaid_payment_form_submission', '1'); |
|
45 | 45 | |
46 | 46 | // Fires before displaying payment form elements. |
47 | - do_action( 'getpaid_payment_form_before_elements', $form ); |
|
47 | + do_action('getpaid_payment_form_before_elements', $form); |
|
48 | 48 | |
49 | 49 | // Display the elements. |
50 | 50 | ?> |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | <div class="row"> |
53 | 53 | <?php |
54 | 54 | |
55 | - foreach ( $form->get_elements() as $element ) { |
|
55 | + foreach ($form->get_elements() as $element) { |
|
56 | 56 | |
57 | - if ( isset( $element['type'] ) ) { |
|
58 | - $grid_class = esc_attr( getpaid_get_form_element_grid_class( $element ) ); |
|
57 | + if (isset($element['type'])) { |
|
58 | + $grid_class = esc_attr(getpaid_get_form_element_grid_class($element)); |
|
59 | 59 | echo "<div class='$grid_class'>"; |
60 | - do_action( 'getpaid_payment_form_element', $element, $form ); |
|
61 | - do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form ); |
|
60 | + do_action('getpaid_payment_form_element', $element, $form); |
|
61 | + do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form); |
|
62 | 62 | echo "</div>"; |
63 | 63 | } |
64 | 64 | |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | |
71 | 71 | <?php |
72 | 72 | // Fires after displaying payment form elements. |
73 | - do_action( 'getpaid_payment_form_after_elements', $form ); |
|
73 | + do_action('getpaid_payment_form_after_elements', $form); |
|
74 | 74 | |
75 | 75 | echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>"; |
76 | 76 | |
77 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
77 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
78 | 78 | |
79 | 79 | edit_post_link( |
80 | - __( 'Edit this form.', 'invoicing' ), |
|
80 | + __('Edit this form.', 'invoicing'), |
|
81 | 81 | '<small class="form-text text-muted">', |
82 | - ' ' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>', |
|
82 | + ' ' . __('This is only visible to website administators.', 'invoicing') . '</small>', |
|
83 | 83 | $form->get_id(), |
84 | 84 | 'text-danger' |
85 | 85 | ); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | <div class="loading_div overlay overlay-black position-absolute row m-0 rounded overflow-hidden" style="height: 100%;width: 100%;top: 0px;z-index: 2;display:none;"> |
93 | 93 | <div class="spinner-border mx-auto align-self-center text-white" role="status"> |
94 | - <span class="sr-only"><?php _e( 'Loading...', 'invoicing' );?></span> |
|
94 | + <span class="sr-only"><?php _e('Loading...', 'invoicing'); ?></span> |
|
95 | 95 | </div> |
96 | 96 | </div> |
97 | 97 | |
@@ -100,4 +100,4 @@ discard block |
||
100 | 100 | <?php |
101 | 101 | |
102 | 102 | // Fires after displaying a payment form. |
103 | -do_action( 'getpaid_after_payment_form', $form ); |
|
103 | +do_action('getpaid_after_payment_form', $form); |
@@ -13,462 +13,462 @@ discard block |
||
13 | 13 | */ |
14 | 14 | abstract class GetPaid_Payment_Gateway { |
15 | 15 | |
16 | - /** |
|
17 | - * Set if the place checkout button should be renamed on selection. |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $checkout_button_text; |
|
22 | - |
|
23 | - /** |
|
24 | - * Boolean whether the method is enabled. |
|
25 | - * |
|
26 | - * @var bool |
|
27 | - */ |
|
28 | - public $enabled = true; |
|
29 | - |
|
30 | - /** |
|
31 | - * Payment method id. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $id; |
|
36 | - |
|
37 | - /** |
|
38 | - * Payment method order. |
|
39 | - * |
|
40 | - * @var int |
|
41 | - */ |
|
42 | - public $order = 10; |
|
43 | - |
|
44 | - /** |
|
45 | - * Payment method title for the frontend. |
|
46 | - * |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - public $title; |
|
50 | - |
|
51 | - /** |
|
52 | - * Payment method description for the frontend. |
|
53 | - * |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $description; |
|
57 | - |
|
58 | - /** |
|
59 | - * Gateway title. |
|
60 | - * |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - public $method_title = ''; |
|
64 | - |
|
65 | - /** |
|
66 | - * Gateway description. |
|
67 | - * |
|
68 | - * @var string |
|
69 | - */ |
|
70 | - public $method_description = ''; |
|
71 | - |
|
72 | - /** |
|
73 | - * Countries this gateway is allowed for. |
|
74 | - * |
|
75 | - * @var array |
|
76 | - */ |
|
77 | - public $countries; |
|
78 | - |
|
79 | - /** |
|
80 | - * Currencies this gateway is allowed for. |
|
81 | - * |
|
82 | - * @var array |
|
83 | - */ |
|
84 | - public $currencies; |
|
85 | - |
|
86 | - /** |
|
87 | - * Currencies this gateway is not allowed for. |
|
88 | - * |
|
89 | - * @var array |
|
90 | - */ |
|
91 | - public $exclude_currencies; |
|
92 | - |
|
93 | - /** |
|
94 | - * Maximum transaction amount, zero does not define a maximum. |
|
95 | - * |
|
96 | - * @var int |
|
97 | - */ |
|
98 | - public $max_amount = 0; |
|
99 | - |
|
100 | - /** |
|
101 | - * Optional URL to view a transaction. |
|
102 | - * |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - public $view_transaction_url = ''; |
|
106 | - |
|
107 | - /** |
|
108 | - * Optional URL to view a subscription. |
|
109 | - * |
|
110 | - * @var string |
|
111 | - */ |
|
112 | - public $view_subscription_url = ''; |
|
113 | - |
|
114 | - /** |
|
115 | - * Optional label to show for "new payment method" in the payment |
|
116 | - * method/token selection radio selection. |
|
117 | - * |
|
118 | - * @var string |
|
119 | - */ |
|
120 | - public $new_method_label = ''; |
|
121 | - |
|
122 | - /** |
|
123 | - * Contains a user's saved tokens for this gateway. |
|
124 | - * |
|
125 | - * @var array |
|
126 | - */ |
|
127 | - protected $tokens = array(); |
|
128 | - |
|
129 | - /** |
|
130 | - * An array of features that this gateway supports. |
|
131 | - * |
|
132 | - * @var array |
|
133 | - */ |
|
134 | - protected $supports = array(); |
|
135 | - |
|
136 | - /** |
|
137 | - * Class constructor. |
|
138 | - */ |
|
139 | - public function __construct() { |
|
140 | - |
|
141 | - // Register gateway. |
|
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | - |
|
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | - |
|
146 | - // Add support for various features. |
|
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
149 | - } |
|
150 | - |
|
151 | - // Invoice addons. |
|
152 | - if ( $this->supports( 'addons' ) ) { |
|
153 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
154 | - } |
|
155 | - |
|
156 | - // Gateway settings. |
|
157 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
16 | + /** |
|
17 | + * Set if the place checkout button should be renamed on selection. |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $checkout_button_text; |
|
22 | + |
|
23 | + /** |
|
24 | + * Boolean whether the method is enabled. |
|
25 | + * |
|
26 | + * @var bool |
|
27 | + */ |
|
28 | + public $enabled = true; |
|
29 | + |
|
30 | + /** |
|
31 | + * Payment method id. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $id; |
|
36 | + |
|
37 | + /** |
|
38 | + * Payment method order. |
|
39 | + * |
|
40 | + * @var int |
|
41 | + */ |
|
42 | + public $order = 10; |
|
43 | + |
|
44 | + /** |
|
45 | + * Payment method title for the frontend. |
|
46 | + * |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + public $title; |
|
50 | + |
|
51 | + /** |
|
52 | + * Payment method description for the frontend. |
|
53 | + * |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $description; |
|
57 | + |
|
58 | + /** |
|
59 | + * Gateway title. |
|
60 | + * |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + public $method_title = ''; |
|
64 | + |
|
65 | + /** |
|
66 | + * Gateway description. |
|
67 | + * |
|
68 | + * @var string |
|
69 | + */ |
|
70 | + public $method_description = ''; |
|
71 | + |
|
72 | + /** |
|
73 | + * Countries this gateway is allowed for. |
|
74 | + * |
|
75 | + * @var array |
|
76 | + */ |
|
77 | + public $countries; |
|
78 | + |
|
79 | + /** |
|
80 | + * Currencies this gateway is allowed for. |
|
81 | + * |
|
82 | + * @var array |
|
83 | + */ |
|
84 | + public $currencies; |
|
85 | + |
|
86 | + /** |
|
87 | + * Currencies this gateway is not allowed for. |
|
88 | + * |
|
89 | + * @var array |
|
90 | + */ |
|
91 | + public $exclude_currencies; |
|
92 | + |
|
93 | + /** |
|
94 | + * Maximum transaction amount, zero does not define a maximum. |
|
95 | + * |
|
96 | + * @var int |
|
97 | + */ |
|
98 | + public $max_amount = 0; |
|
99 | + |
|
100 | + /** |
|
101 | + * Optional URL to view a transaction. |
|
102 | + * |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + public $view_transaction_url = ''; |
|
106 | + |
|
107 | + /** |
|
108 | + * Optional URL to view a subscription. |
|
109 | + * |
|
110 | + * @var string |
|
111 | + */ |
|
112 | + public $view_subscription_url = ''; |
|
113 | + |
|
114 | + /** |
|
115 | + * Optional label to show for "new payment method" in the payment |
|
116 | + * method/token selection radio selection. |
|
117 | + * |
|
118 | + * @var string |
|
119 | + */ |
|
120 | + public $new_method_label = ''; |
|
121 | + |
|
122 | + /** |
|
123 | + * Contains a user's saved tokens for this gateway. |
|
124 | + * |
|
125 | + * @var array |
|
126 | + */ |
|
127 | + protected $tokens = array(); |
|
128 | + |
|
129 | + /** |
|
130 | + * An array of features that this gateway supports. |
|
131 | + * |
|
132 | + * @var array |
|
133 | + */ |
|
134 | + protected $supports = array(); |
|
135 | + |
|
136 | + /** |
|
137 | + * Class constructor. |
|
138 | + */ |
|
139 | + public function __construct() { |
|
140 | + |
|
141 | + // Register gateway. |
|
142 | + add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | + |
|
144 | + $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | + |
|
146 | + // Add support for various features. |
|
147 | + foreach ( $this->supports as $feature ) { |
|
148 | + add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
149 | + } |
|
150 | + |
|
151 | + // Invoice addons. |
|
152 | + if ( $this->supports( 'addons' ) ) { |
|
153 | + add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
154 | + } |
|
155 | + |
|
156 | + // Gateway settings. |
|
157 | + add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
158 | 158 | |
159 | 159 | |
160 | - // Gateway checkout fiellds. |
|
161 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
162 | - |
|
163 | - // Process payment. |
|
164 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
165 | - |
|
166 | - // Change the checkout button text. |
|
167 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
168 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
169 | - } |
|
170 | - |
|
171 | - // Check if a gateway is valid for a given currency. |
|
172 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
173 | - |
|
174 | - // Generate the transaction url. |
|
175 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
176 | - |
|
177 | - // Generate the subscription url. |
|
178 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
179 | - |
|
180 | - // Confirm payments. |
|
181 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
182 | - |
|
183 | - // Verify IPNs. |
|
184 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
185 | - |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Checks if this gateway is a given gateway. |
|
190 | - * |
|
191 | - * @since 1.0.19 |
|
192 | - * @return bool |
|
193 | - */ |
|
194 | - public function is( $gateway ) { |
|
195 | - return $gateway == $this->id; |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * Returns a users saved tokens for this gateway. |
|
200 | - * |
|
201 | - * @since 1.0.19 |
|
202 | - * @return array |
|
203 | - */ |
|
204 | - public function get_tokens( $sandbox = null ) { |
|
205 | - |
|
206 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
207 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
208 | - |
|
209 | - if ( is_array( $tokens ) ) { |
|
210 | - $this->tokens = $tokens; |
|
211 | - } |
|
212 | - |
|
213 | - } |
|
214 | - |
|
215 | - if ( ! is_bool( $sandbox ) ) { |
|
216 | - return $this->tokens; |
|
217 | - } |
|
218 | - |
|
219 | - // Filter tokens. |
|
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
222 | - |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * Saves a token for this gateway. |
|
227 | - * |
|
228 | - * @since 1.0.19 |
|
229 | - */ |
|
230 | - public function save_token( $token ) { |
|
231 | - |
|
232 | - $tokens = $this->get_tokens(); |
|
233 | - $tokens[] = $token; |
|
234 | - |
|
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
236 | - |
|
237 | - $this->tokens = $tokens; |
|
238 | - |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Return the title for admin screens. |
|
243 | - * |
|
244 | - * @return string |
|
245 | - */ |
|
246 | - public function get_method_title() { |
|
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Return the description for admin screens. |
|
252 | - * |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public function get_method_description() { |
|
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Get the success url. |
|
261 | - * |
|
262 | - * @param WPInv_Invoice $invoice Invoice object. |
|
263 | - * @return string |
|
264 | - */ |
|
265 | - public function get_return_url( $invoice ) { |
|
266 | - |
|
267 | - // Payment success url |
|
268 | - $return_url = add_query_arg( |
|
269 | - array( |
|
270 | - 'payment-confirm' => $this->id, |
|
271 | - 'invoice_key' => $invoice->get_key(), |
|
272 | - 'utm_nooverride' => 1 |
|
273 | - ), |
|
274 | - wpinv_get_success_page_uri() |
|
275 | - ); |
|
276 | - |
|
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
278 | - } |
|
279 | - |
|
280 | - /** |
|
281 | - * Confirms payments when rendering the success page. |
|
282 | - * |
|
283 | - * @param string $content Success page content. |
|
284 | - * @return string |
|
285 | - */ |
|
286 | - public function confirm_payment( $content ) { |
|
287 | - |
|
288 | - // Retrieve the invoice. |
|
289 | - $invoice_id = getpaid_get_current_invoice_id(); |
|
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
291 | - |
|
292 | - // Ensure that it exists and that it is pending payment. |
|
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
294 | - return $content; |
|
295 | - } |
|
296 | - |
|
297 | - // Can the user view this invoice?? |
|
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
299 | - return $content; |
|
300 | - } |
|
301 | - |
|
302 | - // Show payment processing indicator. |
|
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Processes ipns and marks payments as complete. |
|
308 | - * |
|
309 | - * @return void |
|
310 | - */ |
|
311 | - public function verify_ipn() {} |
|
312 | - |
|
313 | - /** |
|
314 | - * Processes invoice addons. |
|
315 | - * |
|
316 | - * @param WPInv_Invoice $invoice |
|
317 | - * @param GetPaid_Form_Item[] $items |
|
318 | - * @return WPInv_Invoice |
|
319 | - */ |
|
320 | - public function process_addons( $invoice, $items ) { |
|
321 | - |
|
322 | - } |
|
323 | - |
|
324 | - /** |
|
325 | - * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
326 | - * |
|
327 | - * @param string $transaction_url transaction url. |
|
328 | - * @param WPInv_Invoice $invoice Invoice object. |
|
329 | - * @return string transaction URL, or empty string. |
|
330 | - */ |
|
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
332 | - |
|
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
334 | - |
|
335 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
339 | - } |
|
340 | - |
|
341 | - return $transaction_url; |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
346 | - * |
|
347 | - * @param string $subscription_url transaction url. |
|
348 | - * @param WPInv_Subscription $subscription Subscription objectt. |
|
349 | - * @return string subscription URL, or empty string. |
|
350 | - */ |
|
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
352 | - |
|
353 | - $profile_id = $subscription->get_profile_id(); |
|
354 | - |
|
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
356 | - |
|
357 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
360 | - |
|
361 | - } |
|
362 | - |
|
363 | - return $subscription_url; |
|
364 | - } |
|
365 | - |
|
366 | - /** |
|
367 | - * Check if the gateway is available for use. |
|
368 | - * |
|
369 | - * @return bool |
|
370 | - */ |
|
371 | - public function is_available() { |
|
372 | - return ! empty( $this->enabled ); |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * Return the gateway's title. |
|
377 | - * |
|
378 | - * @return string |
|
379 | - */ |
|
380 | - public function get_title() { |
|
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Return the gateway's description. |
|
386 | - * |
|
387 | - * @return string |
|
388 | - */ |
|
389 | - public function get_description() { |
|
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Process Payment. |
|
395 | - * |
|
396 | - * |
|
397 | - * @param WPInv_Invoice $invoice Invoice. |
|
398 | - * @param array $submission_data Posted checkout fields. |
|
399 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
400 | - * @return void |
|
401 | - */ |
|
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
403 | - // Process the payment then either redirect to the success page or the gateway. |
|
404 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
405 | - } |
|
406 | - |
|
407 | - /** |
|
408 | - * Process refund. |
|
409 | - * |
|
410 | - * If the gateway declares 'refunds' support, this will allow it to refund. |
|
411 | - * a passed in amount. |
|
412 | - * |
|
413 | - * @param WPInv_Invoice $invoice Invoice. |
|
414 | - * @param float $amount Refund amount. |
|
415 | - * @param string $reason Refund reason. |
|
416 | - * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
417 | - */ |
|
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | - } |
|
421 | - |
|
422 | - /** |
|
423 | - * Displays the payment fields, credit cards etc. |
|
424 | - * |
|
425 | - * @param int $invoice_id 0 or invoice id. |
|
426 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
427 | - */ |
|
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | - } |
|
431 | - |
|
432 | - /** |
|
433 | - * Filters the gateway settings. |
|
434 | - * |
|
435 | - * @param array $admin_settings |
|
436 | - */ |
|
437 | - public function admin_settings( $admin_settings ) { |
|
438 | - return $admin_settings; |
|
439 | - } |
|
440 | - |
|
441 | - /** |
|
442 | - * Retrieves the value of a gateway setting. |
|
443 | - * |
|
444 | - * @param string $option |
|
445 | - */ |
|
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | - } |
|
449 | - |
|
450 | - /** |
|
451 | - * Check if a gateway supports a given feature. |
|
452 | - * |
|
453 | - * Gateways should override this to declare support (or lack of support) for a feature. |
|
454 | - * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
455 | - * |
|
456 | - * @param string $feature string The name of a feature to test support for. |
|
457 | - * @return bool True if the gateway supports the feature, false otherwise. |
|
458 | - * @since 1.0.19 |
|
459 | - */ |
|
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | - } |
|
463 | - |
|
464 | - /** |
|
465 | - * Returns the credit card form html. |
|
466 | - * |
|
467 | - * @param bool $save whether or not to display the save button. |
|
468 | - */ |
|
160 | + // Gateway checkout fiellds. |
|
161 | + add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
162 | + |
|
163 | + // Process payment. |
|
164 | + add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
165 | + |
|
166 | + // Change the checkout button text. |
|
167 | + if ( ! empty( $this->checkout_button_text ) ) { |
|
168 | + add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
169 | + } |
|
170 | + |
|
171 | + // Check if a gateway is valid for a given currency. |
|
172 | + add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
173 | + |
|
174 | + // Generate the transaction url. |
|
175 | + add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
176 | + |
|
177 | + // Generate the subscription url. |
|
178 | + add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
179 | + |
|
180 | + // Confirm payments. |
|
181 | + add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
182 | + |
|
183 | + // Verify IPNs. |
|
184 | + add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
185 | + |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Checks if this gateway is a given gateway. |
|
190 | + * |
|
191 | + * @since 1.0.19 |
|
192 | + * @return bool |
|
193 | + */ |
|
194 | + public function is( $gateway ) { |
|
195 | + return $gateway == $this->id; |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * Returns a users saved tokens for this gateway. |
|
200 | + * |
|
201 | + * @since 1.0.19 |
|
202 | + * @return array |
|
203 | + */ |
|
204 | + public function get_tokens( $sandbox = null ) { |
|
205 | + |
|
206 | + if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
207 | + $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
208 | + |
|
209 | + if ( is_array( $tokens ) ) { |
|
210 | + $this->tokens = $tokens; |
|
211 | + } |
|
212 | + |
|
213 | + } |
|
214 | + |
|
215 | + if ( ! is_bool( $sandbox ) ) { |
|
216 | + return $this->tokens; |
|
217 | + } |
|
218 | + |
|
219 | + // Filter tokens. |
|
220 | + $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | + return wp_list_filter( $this->tokens, $args ); |
|
222 | + |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * Saves a token for this gateway. |
|
227 | + * |
|
228 | + * @since 1.0.19 |
|
229 | + */ |
|
230 | + public function save_token( $token ) { |
|
231 | + |
|
232 | + $tokens = $this->get_tokens(); |
|
233 | + $tokens[] = $token; |
|
234 | + |
|
235 | + update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
236 | + |
|
237 | + $this->tokens = $tokens; |
|
238 | + |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Return the title for admin screens. |
|
243 | + * |
|
244 | + * @return string |
|
245 | + */ |
|
246 | + public function get_method_title() { |
|
247 | + return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Return the description for admin screens. |
|
252 | + * |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public function get_method_description() { |
|
256 | + return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Get the success url. |
|
261 | + * |
|
262 | + * @param WPInv_Invoice $invoice Invoice object. |
|
263 | + * @return string |
|
264 | + */ |
|
265 | + public function get_return_url( $invoice ) { |
|
266 | + |
|
267 | + // Payment success url |
|
268 | + $return_url = add_query_arg( |
|
269 | + array( |
|
270 | + 'payment-confirm' => $this->id, |
|
271 | + 'invoice_key' => $invoice->get_key(), |
|
272 | + 'utm_nooverride' => 1 |
|
273 | + ), |
|
274 | + wpinv_get_success_page_uri() |
|
275 | + ); |
|
276 | + |
|
277 | + return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
278 | + } |
|
279 | + |
|
280 | + /** |
|
281 | + * Confirms payments when rendering the success page. |
|
282 | + * |
|
283 | + * @param string $content Success page content. |
|
284 | + * @return string |
|
285 | + */ |
|
286 | + public function confirm_payment( $content ) { |
|
287 | + |
|
288 | + // Retrieve the invoice. |
|
289 | + $invoice_id = getpaid_get_current_invoice_id(); |
|
290 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
291 | + |
|
292 | + // Ensure that it exists and that it is pending payment. |
|
293 | + if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
294 | + return $content; |
|
295 | + } |
|
296 | + |
|
297 | + // Can the user view this invoice?? |
|
298 | + if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
299 | + return $content; |
|
300 | + } |
|
301 | + |
|
302 | + // Show payment processing indicator. |
|
303 | + return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Processes ipns and marks payments as complete. |
|
308 | + * |
|
309 | + * @return void |
|
310 | + */ |
|
311 | + public function verify_ipn() {} |
|
312 | + |
|
313 | + /** |
|
314 | + * Processes invoice addons. |
|
315 | + * |
|
316 | + * @param WPInv_Invoice $invoice |
|
317 | + * @param GetPaid_Form_Item[] $items |
|
318 | + * @return WPInv_Invoice |
|
319 | + */ |
|
320 | + public function process_addons( $invoice, $items ) { |
|
321 | + |
|
322 | + } |
|
323 | + |
|
324 | + /** |
|
325 | + * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
326 | + * |
|
327 | + * @param string $transaction_url transaction url. |
|
328 | + * @param WPInv_Invoice $invoice Invoice object. |
|
329 | + * @return string transaction URL, or empty string. |
|
330 | + */ |
|
331 | + public function filter_transaction_url( $transaction_url, $invoice ) { |
|
332 | + |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
334 | + |
|
335 | + if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | + $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | + $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
339 | + } |
|
340 | + |
|
341 | + return $transaction_url; |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
346 | + * |
|
347 | + * @param string $subscription_url transaction url. |
|
348 | + * @param WPInv_Subscription $subscription Subscription objectt. |
|
349 | + * @return string subscription URL, or empty string. |
|
350 | + */ |
|
351 | + public function generate_subscription_url( $subscription_url, $subscription ) { |
|
352 | + |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | + |
|
355 | + if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
356 | + |
|
357 | + $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | + $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | + $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
360 | + |
|
361 | + } |
|
362 | + |
|
363 | + return $subscription_url; |
|
364 | + } |
|
365 | + |
|
366 | + /** |
|
367 | + * Check if the gateway is available for use. |
|
368 | + * |
|
369 | + * @return bool |
|
370 | + */ |
|
371 | + public function is_available() { |
|
372 | + return ! empty( $this->enabled ); |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * Return the gateway's title. |
|
377 | + * |
|
378 | + * @return string |
|
379 | + */ |
|
380 | + public function get_title() { |
|
381 | + return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Return the gateway's description. |
|
386 | + * |
|
387 | + * @return string |
|
388 | + */ |
|
389 | + public function get_description() { |
|
390 | + return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Process Payment. |
|
395 | + * |
|
396 | + * |
|
397 | + * @param WPInv_Invoice $invoice Invoice. |
|
398 | + * @param array $submission_data Posted checkout fields. |
|
399 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
400 | + * @return void |
|
401 | + */ |
|
402 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
403 | + // Process the payment then either redirect to the success page or the gateway. |
|
404 | + do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
405 | + } |
|
406 | + |
|
407 | + /** |
|
408 | + * Process refund. |
|
409 | + * |
|
410 | + * If the gateway declares 'refunds' support, this will allow it to refund. |
|
411 | + * a passed in amount. |
|
412 | + * |
|
413 | + * @param WPInv_Invoice $invoice Invoice. |
|
414 | + * @param float $amount Refund amount. |
|
415 | + * @param string $reason Refund reason. |
|
416 | + * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
417 | + */ |
|
418 | + public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | + return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * Displays the payment fields, credit cards etc. |
|
424 | + * |
|
425 | + * @param int $invoice_id 0 or invoice id. |
|
426 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
427 | + */ |
|
428 | + public function payment_fields( $invoice_id, $form ) { |
|
429 | + do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | + } |
|
431 | + |
|
432 | + /** |
|
433 | + * Filters the gateway settings. |
|
434 | + * |
|
435 | + * @param array $admin_settings |
|
436 | + */ |
|
437 | + public function admin_settings( $admin_settings ) { |
|
438 | + return $admin_settings; |
|
439 | + } |
|
440 | + |
|
441 | + /** |
|
442 | + * Retrieves the value of a gateway setting. |
|
443 | + * |
|
444 | + * @param string $option |
|
445 | + */ |
|
446 | + public function get_option( $option, $default = false ) { |
|
447 | + return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | + } |
|
449 | + |
|
450 | + /** |
|
451 | + * Check if a gateway supports a given feature. |
|
452 | + * |
|
453 | + * Gateways should override this to declare support (or lack of support) for a feature. |
|
454 | + * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
455 | + * |
|
456 | + * @param string $feature string The name of a feature to test support for. |
|
457 | + * @return bool True if the gateway supports the feature, false otherwise. |
|
458 | + * @since 1.0.19 |
|
459 | + */ |
|
460 | + public function supports( $feature ) { |
|
461 | + return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | + } |
|
463 | + |
|
464 | + /** |
|
465 | + * Returns the credit card form html. |
|
466 | + * |
|
467 | + * @param bool $save whether or not to display the save button. |
|
468 | + */ |
|
469 | 469 | public function get_cc_form( $save = false ) { |
470 | 470 | |
471 | - ob_start(); |
|
471 | + ob_start(); |
|
472 | 472 | |
473 | 473 | $id_prefix = esc_attr( uniqid( $this->id ) ); |
474 | 474 | |
@@ -563,11 +563,11 @@ discard block |
||
563 | 563 | 'name' => $this->id . '[cc_cvv2]', |
564 | 564 | 'id' => "$id_prefix-cc-cvv2", |
565 | 565 | 'label' => __( 'CCV', 'invoicing' ), |
566 | - 'label_type' => 'vertical', |
|
567 | - 'class' => 'form-control-sm', |
|
568 | - 'extra_attributes' => array( |
|
569 | - 'autocomplete' => "cc-csc", |
|
570 | - ), |
|
566 | + 'label_type' => 'vertical', |
|
567 | + 'class' => 'form-control-sm', |
|
568 | + 'extra_attributes' => array( |
|
569 | + 'autocomplete' => "cc-csc", |
|
570 | + ), |
|
571 | 571 | ) |
572 | 572 | ); |
573 | 573 | ?> |
@@ -577,192 +577,192 @@ discard block |
||
577 | 577 | |
578 | 578 | <?php |
579 | 579 | |
580 | - if ( $save ) { |
|
581 | - echo $this->save_payment_method_checkbox(); |
|
582 | - } |
|
580 | + if ( $save ) { |
|
581 | + echo $this->save_payment_method_checkbox(); |
|
582 | + } |
|
583 | 583 | |
584 | - ?> |
|
584 | + ?> |
|
585 | 585 | </div> |
586 | 586 | |
587 | 587 | </div> |
588 | 588 | <?php |
589 | 589 | |
590 | - return ob_get_clean(); |
|
590 | + return ob_get_clean(); |
|
591 | + |
|
592 | + } |
|
591 | 593 | |
594 | + /** |
|
595 | + * Displays a new payment method entry form. |
|
596 | + * |
|
597 | + * @since 1.0.19 |
|
598 | + */ |
|
599 | + public function new_payment_method_entry( $form ) { |
|
600 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
592 | 601 | } |
593 | 602 | |
594 | - /** |
|
595 | - * Displays a new payment method entry form. |
|
596 | - * |
|
597 | - * @since 1.0.19 |
|
598 | - */ |
|
599 | - public function new_payment_method_entry( $form ) { |
|
600 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
601 | - } |
|
602 | - |
|
603 | - /** |
|
604 | - * Grab and display our saved payment methods. |
|
605 | - * |
|
606 | - * @since 1.0.19 |
|
607 | - */ |
|
608 | - public function saved_payment_methods() { |
|
609 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
610 | - |
|
611 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
613 | - } |
|
614 | - |
|
615 | - $html .= $this->get_new_payment_method_option_html(); |
|
616 | - $html .= '</ul>'; |
|
617 | - |
|
618 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
619 | - } |
|
620 | - |
|
621 | - /** |
|
622 | - * Gets saved payment method HTML from a token. |
|
623 | - * |
|
624 | - * @since 1.0.19 |
|
625 | - * @param array $token Payment Token. |
|
626 | - * @return string Generated payment method HTML |
|
627 | - */ |
|
628 | - public function get_saved_payment_method_option_html( $token ) { |
|
629 | - |
|
630 | - return sprintf( |
|
631 | - '<li class="getpaid-payment-method form-group"> |
|
603 | + /** |
|
604 | + * Grab and display our saved payment methods. |
|
605 | + * |
|
606 | + * @since 1.0.19 |
|
607 | + */ |
|
608 | + public function saved_payment_methods() { |
|
609 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
610 | + |
|
611 | + foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | + $html .= $this->get_saved_payment_method_option_html( $token ); |
|
613 | + } |
|
614 | + |
|
615 | + $html .= $this->get_new_payment_method_option_html(); |
|
616 | + $html .= '</ul>'; |
|
617 | + |
|
618 | + echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
619 | + } |
|
620 | + |
|
621 | + /** |
|
622 | + * Gets saved payment method HTML from a token. |
|
623 | + * |
|
624 | + * @since 1.0.19 |
|
625 | + * @param array $token Payment Token. |
|
626 | + * @return string Generated payment method HTML |
|
627 | + */ |
|
628 | + public function get_saved_payment_method_option_html( $token ) { |
|
629 | + |
|
630 | + return sprintf( |
|
631 | + '<li class="getpaid-payment-method form-group"> |
|
632 | 632 | <label> |
633 | 633 | <input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" data-currency="%5$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s /> |
634 | 634 | <span>%3$s</span> |
635 | 635 | </label> |
636 | 636 | </li>', |
637 | - esc_attr( $this->id ), |
|
638 | - esc_attr( $token['id'] ), |
|
639 | - esc_html( $token['name'] ), |
|
640 | - checked( empty( $token['default'] ), false, false ), |
|
641 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
642 | - ); |
|
643 | - |
|
644 | - } |
|
645 | - |
|
646 | - /** |
|
647 | - * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
648 | - * |
|
649 | - * @since 1.0.19 |
|
650 | - */ |
|
651 | - public function get_new_payment_method_option_html() { |
|
652 | - |
|
653 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
654 | - |
|
655 | - return sprintf( |
|
656 | - '<li class="getpaid-new-payment-method"> |
|
637 | + esc_attr( $this->id ), |
|
638 | + esc_attr( $token['id'] ), |
|
639 | + esc_html( $token['name'] ), |
|
640 | + checked( empty( $token['default'] ), false, false ), |
|
641 | + empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
642 | + ); |
|
643 | + |
|
644 | + } |
|
645 | + |
|
646 | + /** |
|
647 | + * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
648 | + * |
|
649 | + * @since 1.0.19 |
|
650 | + */ |
|
651 | + public function get_new_payment_method_option_html() { |
|
652 | + |
|
653 | + $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
654 | + |
|
655 | + return sprintf( |
|
656 | + '<li class="getpaid-new-payment-method"> |
|
657 | 657 | <label> |
658 | 658 | <input name="getpaid-%1$s-payment-method" type="radio" data-currency="none" value="new" style="width:auto;" /> |
659 | 659 | <span>%2$s</span> |
660 | 660 | </label> |
661 | 661 | </li>', |
662 | - esc_attr( $this->id ), |
|
663 | - esc_html( $label ) |
|
664 | - ); |
|
665 | - |
|
666 | - } |
|
667 | - |
|
668 | - /** |
|
669 | - * Outputs a checkbox for saving a new payment method to the database. |
|
670 | - * |
|
671 | - * @since 1.0.19 |
|
672 | - */ |
|
673 | - public function save_payment_method_checkbox() { |
|
674 | - |
|
675 | - return aui()->input( |
|
676 | - array( |
|
677 | - 'type' => 'checkbox', |
|
678 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
679 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
680 | - 'required' => false, |
|
681 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
682 | - 'value' => 'true', |
|
683 | - 'checked' => true, |
|
684 | - 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
685 | - ) |
|
686 | - ); |
|
687 | - |
|
688 | - } |
|
689 | - |
|
690 | - /** |
|
691 | - * Registers the gateway. |
|
692 | - * |
|
693 | - * @return array |
|
694 | - */ |
|
695 | - public function register_gateway( $gateways ) { |
|
696 | - |
|
697 | - $gateways[ $this->id ] = array( |
|
698 | - |
|
699 | - 'admin_label' => $this->method_title, |
|
662 | + esc_attr( $this->id ), |
|
663 | + esc_html( $label ) |
|
664 | + ); |
|
665 | + |
|
666 | + } |
|
667 | + |
|
668 | + /** |
|
669 | + * Outputs a checkbox for saving a new payment method to the database. |
|
670 | + * |
|
671 | + * @since 1.0.19 |
|
672 | + */ |
|
673 | + public function save_payment_method_checkbox() { |
|
674 | + |
|
675 | + return aui()->input( |
|
676 | + array( |
|
677 | + 'type' => 'checkbox', |
|
678 | + 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
679 | + 'id' => esc_attr( uniqid( $this->id ) ), |
|
680 | + 'required' => false, |
|
681 | + 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
682 | + 'value' => 'true', |
|
683 | + 'checked' => true, |
|
684 | + 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
685 | + ) |
|
686 | + ); |
|
687 | + |
|
688 | + } |
|
689 | + |
|
690 | + /** |
|
691 | + * Registers the gateway. |
|
692 | + * |
|
693 | + * @return array |
|
694 | + */ |
|
695 | + public function register_gateway( $gateways ) { |
|
696 | + |
|
697 | + $gateways[ $this->id ] = array( |
|
698 | + |
|
699 | + 'admin_label' => $this->method_title, |
|
700 | 700 | 'checkout_label' => $this->title, |
701 | - 'ordering' => $this->order, |
|
701 | + 'ordering' => $this->order, |
|
702 | 702 | |
703 | - ); |
|
703 | + ); |
|
704 | 704 | |
705 | - return $gateways; |
|
705 | + return $gateways; |
|
706 | 706 | |
707 | - } |
|
707 | + } |
|
708 | 708 | |
709 | - /** |
|
710 | - * Checks whether or not this is a sandbox request. |
|
711 | - * |
|
712 | - * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
713 | - * @return bool |
|
714 | - */ |
|
715 | - public function is_sandbox( $invoice = null ) { |
|
709 | + /** |
|
710 | + * Checks whether or not this is a sandbox request. |
|
711 | + * |
|
712 | + * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
713 | + * @return bool |
|
714 | + */ |
|
715 | + public function is_sandbox( $invoice = null ) { |
|
716 | 716 | |
717 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
718 | - return $invoice->get_mode() == 'test'; |
|
719 | - } |
|
717 | + if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
718 | + return $invoice->get_mode() == 'test'; |
|
719 | + } |
|
720 | 720 | |
721 | - return wpinv_is_test_mode( $this->id ); |
|
721 | + return wpinv_is_test_mode( $this->id ); |
|
722 | 722 | |
723 | - } |
|
723 | + } |
|
724 | 724 | |
725 | - /** |
|
726 | - * Renames the checkout button |
|
727 | - * |
|
728 | - * @return string |
|
729 | - */ |
|
730 | - public function rename_checkout_button() { |
|
731 | - return $this->checkout_button_text; |
|
732 | - } |
|
725 | + /** |
|
726 | + * Renames the checkout button |
|
727 | + * |
|
728 | + * @return string |
|
729 | + */ |
|
730 | + public function rename_checkout_button() { |
|
731 | + return $this->checkout_button_text; |
|
732 | + } |
|
733 | 733 | |
734 | - /** |
|
735 | - * Validate gateway currency |
|
736 | - * |
|
737 | - * @return bool |
|
738 | - */ |
|
739 | - public function validate_currency( $validation, $currency ) { |
|
734 | + /** |
|
735 | + * Validate gateway currency |
|
736 | + * |
|
737 | + * @return bool |
|
738 | + */ |
|
739 | + public function validate_currency( $validation, $currency ) { |
|
740 | 740 | |
741 | - // Required currencies. |
|
742 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
743 | - return false; |
|
744 | - } |
|
741 | + // Required currencies. |
|
742 | + if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
743 | + return false; |
|
744 | + } |
|
745 | 745 | |
746 | - // Excluded currencies. |
|
747 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
748 | - return false; |
|
749 | - } |
|
746 | + // Excluded currencies. |
|
747 | + if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
748 | + return false; |
|
749 | + } |
|
750 | 750 | |
751 | - return $validation; |
|
752 | - } |
|
751 | + return $validation; |
|
752 | + } |
|
753 | 753 | |
754 | - /** |
|
755 | - * Displays an error |
|
756 | - * |
|
757 | - */ |
|
758 | - public function show_error( $code, $message, $type ) { |
|
754 | + /** |
|
755 | + * Displays an error |
|
756 | + * |
|
757 | + */ |
|
758 | + public function show_error( $code, $message, $type ) { |
|
759 | 759 | |
760 | - if ( is_admin() ) { |
|
761 | - getpaid_admin()->{"show_$type"}( $message ); |
|
762 | - } |
|
760 | + if ( is_admin() ) { |
|
761 | + getpaid_admin()->{"show_$type"}( $message ); |
|
762 | + } |
|
763 | 763 | |
764 | - wpinv_set_error( $code, $message, $type ); |
|
764 | + wpinv_set_error( $code, $message, $type ); |
|
765 | 765 | |
766 | - } |
|
766 | + } |
|
767 | 767 | |
768 | 768 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Abstaract Payment Gateway class. |
@@ -139,49 +139,49 @@ discard block |
||
139 | 139 | public function __construct() { |
140 | 140 | |
141 | 141 | // Register gateway. |
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
143 | 143 | |
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
145 | 145 | |
146 | 146 | // Add support for various features. |
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
147 | + foreach ($this->supports as $feature) { |
|
148 | + add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Invoice addons. |
152 | - if ( $this->supports( 'addons' ) ) { |
|
153 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
152 | + if ($this->supports('addons')) { |
|
153 | + add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | // Gateway settings. |
157 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
157 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
158 | 158 | |
159 | 159 | |
160 | 160 | // Gateway checkout fiellds. |
161 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
161 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
162 | 162 | |
163 | 163 | // Process payment. |
164 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
164 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
165 | 165 | |
166 | 166 | // Change the checkout button text. |
167 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
168 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
167 | + if (!empty($this->checkout_button_text)) { |
|
168 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // Check if a gateway is valid for a given currency. |
172 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
172 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
173 | 173 | |
174 | 174 | // Generate the transaction url. |
175 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
175 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
176 | 176 | |
177 | 177 | // Generate the subscription url. |
178 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
178 | + add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2); |
|
179 | 179 | |
180 | 180 | // Confirm payments. |
181 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
181 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
182 | 182 | |
183 | 183 | // Verify IPNs. |
184 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
184 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @since 1.0.19 |
192 | 192 | * @return bool |
193 | 193 | */ |
194 | - public function is( $gateway ) { |
|
194 | + public function is($gateway) { |
|
195 | 195 | return $gateway == $this->id; |
196 | 196 | } |
197 | 197 | |
@@ -201,24 +201,24 @@ discard block |
||
201 | 201 | * @since 1.0.19 |
202 | 202 | * @return array |
203 | 203 | */ |
204 | - public function get_tokens( $sandbox = null ) { |
|
204 | + public function get_tokens($sandbox = null) { |
|
205 | 205 | |
206 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
207 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
206 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
207 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
208 | 208 | |
209 | - if ( is_array( $tokens ) ) { |
|
209 | + if (is_array($tokens)) { |
|
210 | 210 | $this->tokens = $tokens; |
211 | 211 | } |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_bool( $sandbox ) ) { |
|
215 | + if (!is_bool($sandbox)) { |
|
216 | 216 | return $this->tokens; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Filter tokens. |
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
220 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
221 | + return wp_list_filter($this->tokens, $args); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0.19 |
229 | 229 | */ |
230 | - public function save_token( $token ) { |
|
230 | + public function save_token($token) { |
|
231 | 231 | |
232 | 232 | $tokens = $this->get_tokens(); |
233 | 233 | $tokens[] = $token; |
234 | 234 | |
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
235 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
236 | 236 | |
237 | 237 | $this->tokens = $tokens; |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @return string |
245 | 245 | */ |
246 | 246 | public function get_method_title() { |
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
247 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return string |
254 | 254 | */ |
255 | 255 | public function get_method_description() { |
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
256 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param WPInv_Invoice $invoice Invoice object. |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function get_return_url( $invoice ) { |
|
265 | + public function get_return_url($invoice) { |
|
266 | 266 | |
267 | 267 | // Payment success url |
268 | 268 | $return_url = add_query_arg( |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | wpinv_get_success_page_uri() |
275 | 275 | ); |
276 | 276 | |
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
277 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -283,24 +283,24 @@ discard block |
||
283 | 283 | * @param string $content Success page content. |
284 | 284 | * @return string |
285 | 285 | */ |
286 | - public function confirm_payment( $content ) { |
|
286 | + public function confirm_payment($content) { |
|
287 | 287 | |
288 | 288 | // Retrieve the invoice. |
289 | 289 | $invoice_id = getpaid_get_current_invoice_id(); |
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
290 | + $invoice = wpinv_get_invoice($invoice_id); |
|
291 | 291 | |
292 | 292 | // Ensure that it exists and that it is pending payment. |
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
293 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
294 | 294 | return $content; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Can the user view this invoice?? |
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
298 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
299 | 299 | return $content; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Show payment processing indicator. |
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
303 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param GetPaid_Form_Item[] $items |
318 | 318 | * @return WPInv_Invoice |
319 | 319 | */ |
320 | - public function process_addons( $invoice, $items ) { |
|
320 | + public function process_addons($invoice, $items) { |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | * @param WPInv_Invoice $invoice Invoice object. |
329 | 329 | * @return string transaction URL, or empty string. |
330 | 330 | */ |
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
331 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
332 | 332 | |
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
334 | 334 | |
335 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
335 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
336 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
337 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
338 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $transaction_url; |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | * @param WPInv_Subscription $subscription Subscription objectt. |
349 | 349 | * @return string subscription URL, or empty string. |
350 | 350 | */ |
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
351 | + public function generate_subscription_url($subscription_url, $subscription) { |
|
352 | 352 | |
353 | - $profile_id = $subscription->get_profile_id(); |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | 354 | |
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
355 | + if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) { |
|
356 | 356 | |
357 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
357 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
358 | + $replace = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : ''; |
|
359 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
360 | 360 | |
361 | 361 | } |
362 | 362 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @return bool |
370 | 370 | */ |
371 | 371 | public function is_available() { |
372 | - return ! empty( $this->enabled ); |
|
372 | + return !empty($this->enabled); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @return string |
379 | 379 | */ |
380 | 380 | public function get_title() { |
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
381 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @return string |
388 | 388 | */ |
389 | 389 | public function get_description() { |
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
390 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
400 | 400 | * @return void |
401 | 401 | */ |
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
402 | + public function process_payment($invoice, $submission_data, $submission) { |
|
403 | 403 | // Process the payment then either redirect to the success page or the gateway. |
404 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
404 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $reason Refund reason. |
416 | 416 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
417 | 417 | */ |
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
418 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
419 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param int $invoice_id 0 or invoice id. |
426 | 426 | * @param GetPaid_Payment_Form $form Current payment form. |
427 | 427 | */ |
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
428 | + public function payment_fields($invoice_id, $form) { |
|
429 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @param array $admin_settings |
436 | 436 | */ |
437 | - public function admin_settings( $admin_settings ) { |
|
437 | + public function admin_settings($admin_settings) { |
|
438 | 438 | return $admin_settings; |
439 | 439 | } |
440 | 440 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @param string $option |
445 | 445 | */ |
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
446 | + public function get_option($option, $default = false) { |
|
447 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | * @return bool True if the gateway supports the feature, false otherwise. |
458 | 458 | * @since 1.0.19 |
459 | 459 | */ |
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
460 | + public function supports($feature) { |
|
461 | + return getpaid_payment_gateway_supports($this->id, $feature); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -466,36 +466,36 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @param bool $save whether or not to display the save button. |
468 | 468 | */ |
469 | - public function get_cc_form( $save = false ) { |
|
469 | + public function get_cc_form($save = false) { |
|
470 | 470 | |
471 | 471 | ob_start(); |
472 | 472 | |
473 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
473 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
474 | 474 | |
475 | 475 | $months = array( |
476 | - '01' => __( 'January', 'invoicing' ), |
|
477 | - '02' => __( 'February', 'invoicing' ), |
|
478 | - '03' => __( 'March', 'invoicing' ), |
|
479 | - '04' => __( 'April', 'invoicing' ), |
|
480 | - '05' => __( 'May', 'invoicing' ), |
|
481 | - '06' => __( 'June', 'invoicing' ), |
|
482 | - '07' => __( 'July', 'invoicing' ), |
|
483 | - '08' => __( 'August', 'invoicing' ), |
|
484 | - '09' => __( 'September', 'invoicing' ), |
|
485 | - '10' => __( 'October', 'invoicing' ), |
|
486 | - '11' => __( 'November', 'invoicing' ), |
|
487 | - '12' => __( 'December', 'invoicing' ), |
|
476 | + '01' => __('January', 'invoicing'), |
|
477 | + '02' => __('February', 'invoicing'), |
|
478 | + '03' => __('March', 'invoicing'), |
|
479 | + '04' => __('April', 'invoicing'), |
|
480 | + '05' => __('May', 'invoicing'), |
|
481 | + '06' => __('June', 'invoicing'), |
|
482 | + '07' => __('July', 'invoicing'), |
|
483 | + '08' => __('August', 'invoicing'), |
|
484 | + '09' => __('September', 'invoicing'), |
|
485 | + '10' => __('October', 'invoicing'), |
|
486 | + '11' => __('November', 'invoicing'), |
|
487 | + '12' => __('December', 'invoicing'), |
|
488 | 488 | ); |
489 | 489 | |
490 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
490 | + $year = (int) date('Y', current_time('timestamp')); |
|
491 | 491 | $years = array(); |
492 | 492 | |
493 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
494 | - $years[ $year + $i ] = $year + $i; |
|
493 | + for ($i = 0; $i <= 10; $i++) { |
|
494 | + $years[$year + $i] = $year + $i; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | ?> |
498 | - <div class="<?php echo esc_attr( $this->id );?>-cc-form getpaid-cc-form mt-1"> |
|
498 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
499 | 499 | |
500 | 500 | |
501 | 501 | <div class="getpaid-cc-card-inner"> |
@@ -504,14 +504,14 @@ discard block |
||
504 | 504 | <div class="col-12"> |
505 | 505 | |
506 | 506 | <div class="form-group"> |
507 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>"><?php _e( 'Card number', 'invoicing' ); ?></label> |
|
507 | + <label for="<?php echo esc_attr("$id_prefix-cc-number") ?>"><?php _e('Card number', 'invoicing'); ?></label> |
|
508 | 508 | <div class="input-group input-group-sm"> |
509 | 509 | <div class="input-group-prepend "> |
510 | 510 | <span class="input-group-text"> |
511 | 511 | <i class="fa fa-credit-card"></i> |
512 | 512 | </span> |
513 | 513 | </div> |
514 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ) ?>authorizenet[cc_number]" id="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
514 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]') ?>authorizenet[cc_number]" id="<?php echo esc_attr("$id_prefix-cc-number") ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
515 | 515 | </div> |
516 | 516 | </div> |
517 | 517 | |
@@ -519,17 +519,17 @@ discard block |
||
519 | 519 | |
520 | 520 | <div class="col-12"> |
521 | 521 | <div class="form-group"> |
522 | - <label><?php _e( 'Expiration', 'invoicing' ); ?></label> |
|
522 | + <label><?php _e('Expiration', 'invoicing'); ?></label> |
|
523 | 523 | <div class="form-row"> |
524 | 524 | |
525 | 525 | <div class="col"> |
526 | - <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id );?>[cc_expire_month]"> |
|
527 | - <option disabled selected="selected"><?php _e( 'MM', 'invoicing' ); ?></option> |
|
526 | + <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
527 | + <option disabled selected="selected"><?php _e('MM', 'invoicing'); ?></option> |
|
528 | 528 | |
529 | 529 | <?php |
530 | - foreach ( $months as $key => $month ) { |
|
531 | - $key = esc_attr( $key ); |
|
532 | - $month = wpinv_clean( $month ); |
|
530 | + foreach ($months as $key => $month) { |
|
531 | + $key = esc_attr($key); |
|
532 | + $month = wpinv_clean($month); |
|
533 | 533 | echo "<option value='$key'>$month</option>" . PHP_EOL; |
534 | 534 | } |
535 | 535 | ?> |
@@ -538,13 +538,13 @@ discard block |
||
538 | 538 | </div> |
539 | 539 | |
540 | 540 | <div class="col"> |
541 | - <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id );?>[cc_expire_year]"> |
|
542 | - <option disabled selected="selected"><?php _e( 'YY', 'invoicing' ); ?></option> |
|
541 | + <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
542 | + <option disabled selected="selected"><?php _e('YY', 'invoicing'); ?></option> |
|
543 | 543 | |
544 | 544 | <?php |
545 | - foreach ( $years as $key => $year ) { |
|
546 | - $key = esc_attr( $key ); |
|
547 | - $year = wpinv_clean( $year ); |
|
545 | + foreach ($years as $key => $year) { |
|
546 | + $key = esc_attr($key); |
|
547 | + $year = wpinv_clean($year); |
|
548 | 548 | echo "<option value='$key'>$year</option>" . PHP_EOL; |
549 | 549 | } |
550 | 550 | ?> |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | array( |
563 | 563 | 'name' => $this->id . '[cc_cvv2]', |
564 | 564 | 'id' => "$id_prefix-cc-cvv2", |
565 | - 'label' => __( 'CCV', 'invoicing' ), |
|
565 | + 'label' => __('CCV', 'invoicing'), |
|
566 | 566 | 'label_type' => 'vertical', |
567 | 567 | 'class' => 'form-control-sm', |
568 | 568 | 'extra_attributes' => array( |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | |
578 | 578 | <?php |
579 | 579 | |
580 | - if ( $save ) { |
|
580 | + if ($save) { |
|
581 | 581 | echo $this->save_payment_method_checkbox(); |
582 | 582 | } |
583 | 583 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @since 1.0.19 |
598 | 598 | */ |
599 | - public function new_payment_method_entry( $form ) { |
|
599 | + public function new_payment_method_entry($form) { |
|
600 | 600 | echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
601 | 601 | } |
602 | 602 | |
@@ -606,16 +606,16 @@ discard block |
||
606 | 606 | * @since 1.0.19 |
607 | 607 | */ |
608 | 608 | public function saved_payment_methods() { |
609 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
609 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
610 | 610 | |
611 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
611 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
612 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | $html .= $this->get_new_payment_method_option_html(); |
616 | 616 | $html .= '</ul>'; |
617 | 617 | |
618 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
618 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * @param array $token Payment Token. |
626 | 626 | * @return string Generated payment method HTML |
627 | 627 | */ |
628 | - public function get_saved_payment_method_option_html( $token ) { |
|
628 | + public function get_saved_payment_method_option_html($token) { |
|
629 | 629 | |
630 | 630 | return sprintf( |
631 | 631 | '<li class="getpaid-payment-method form-group"> |
@@ -634,11 +634,11 @@ discard block |
||
634 | 634 | <span>%3$s</span> |
635 | 635 | </label> |
636 | 636 | </li>', |
637 | - esc_attr( $this->id ), |
|
638 | - esc_attr( $token['id'] ), |
|
639 | - esc_html( $token['name'] ), |
|
640 | - checked( empty( $token['default'] ), false, false ), |
|
641 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
637 | + esc_attr($this->id), |
|
638 | + esc_attr($token['id']), |
|
639 | + esc_html($token['name']), |
|
640 | + checked(empty($token['default']), false, false), |
|
641 | + empty($token['currency']) ? 'none' : esc_attr($token['currency']) |
|
642 | 642 | ); |
643 | 643 | |
644 | 644 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | */ |
651 | 651 | public function get_new_payment_method_option_html() { |
652 | 652 | |
653 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
653 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
654 | 654 | |
655 | 655 | return sprintf( |
656 | 656 | '<li class="getpaid-new-payment-method"> |
@@ -659,8 +659,8 @@ discard block |
||
659 | 659 | <span>%2$s</span> |
660 | 660 | </label> |
661 | 661 | </li>', |
662 | - esc_attr( $this->id ), |
|
663 | - esc_html( $label ) |
|
662 | + esc_attr($this->id), |
|
663 | + esc_html($label) |
|
664 | 664 | ); |
665 | 665 | |
666 | 666 | } |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | return aui()->input( |
676 | 676 | array( |
677 | 677 | 'type' => 'checkbox', |
678 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
679 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
678 | + 'name' => esc_attr("getpaid-$this->id-new-payment-method"), |
|
679 | + 'id' => esc_attr(uniqid($this->id)), |
|
680 | 680 | 'required' => false, |
681 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
681 | + 'label' => esc_html__('Save payment method', 'invoicing'), |
|
682 | 682 | 'value' => 'true', |
683 | 683 | 'checked' => true, |
684 | 684 | 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return array |
694 | 694 | */ |
695 | - public function register_gateway( $gateways ) { |
|
695 | + public function register_gateway($gateways) { |
|
696 | 696 | |
697 | - $gateways[ $this->id ] = array( |
|
697 | + $gateways[$this->id] = array( |
|
698 | 698 | |
699 | 699 | 'admin_label' => $this->method_title, |
700 | 700 | 'checkout_label' => $this->title, |
@@ -712,13 +712,13 @@ discard block |
||
712 | 712 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
713 | 713 | * @return bool |
714 | 714 | */ |
715 | - public function is_sandbox( $invoice = null ) { |
|
715 | + public function is_sandbox($invoice = null) { |
|
716 | 716 | |
717 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
717 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
718 | 718 | return $invoice->get_mode() == 'test'; |
719 | 719 | } |
720 | 720 | |
721 | - return wpinv_is_test_mode( $this->id ); |
|
721 | + return wpinv_is_test_mode($this->id); |
|
722 | 722 | |
723 | 723 | } |
724 | 724 | |
@@ -736,15 +736,15 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return bool |
738 | 738 | */ |
739 | - public function validate_currency( $validation, $currency ) { |
|
739 | + public function validate_currency($validation, $currency) { |
|
740 | 740 | |
741 | 741 | // Required currencies. |
742 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
742 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
743 | 743 | return false; |
744 | 744 | } |
745 | 745 | |
746 | 746 | // Excluded currencies. |
747 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
747 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | |
@@ -755,13 +755,13 @@ discard block |
||
755 | 755 | * Displays an error |
756 | 756 | * |
757 | 757 | */ |
758 | - public function show_error( $code, $message, $type ) { |
|
758 | + public function show_error($code, $message, $type) { |
|
759 | 759 | |
760 | - if ( is_admin() ) { |
|
761 | - getpaid_admin()->{"show_$type"}( $message ); |
|
760 | + if (is_admin()) { |
|
761 | + getpaid_admin()->{"show_$type"}($message); |
|
762 | 762 | } |
763 | 763 | |
764 | - wpinv_set_error( $code, $message, $type ); |
|
764 | + wpinv_set_error($code, $message, $type); |
|
765 | 765 | |
766 | 766 | } |
767 | 767 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Authorize.net Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
27 | + protected $supports = array('subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
55 | + public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD'); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * URL to view a transaction. |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function __construct() { |
68 | 68 | |
69 | - $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
|
70 | - $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
|
71 | - $this->notify_url = getpaid_get_non_query_string_ipn_url( $this->id ); |
|
69 | + $this->title = __('Credit Card / Debit Card', 'invoicing'); |
|
70 | + $this->method_title = __('Authorize.Net', 'invoicing'); |
|
71 | + $this->notify_url = getpaid_get_non_query_string_ipn_url($this->id); |
|
72 | 72 | |
73 | - add_filter( 'getpaid_daily_maintenance_should_expire_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 ); |
|
74 | - add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
73 | + add_filter('getpaid_daily_maintenance_should_expire_subscription', array($this, 'maybe_renew_subscription'), 10, 2); |
|
74 | + add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice')); |
|
75 | 75 | parent::__construct(); |
76 | 76 | } |
77 | 77 | |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * @param int $invoice_id 0 or invoice id. |
82 | 82 | * @param GetPaid_Payment_Form $form Current payment form. |
83 | 83 | */ |
84 | - public function payment_fields( $invoice_id, $form ) { |
|
84 | + public function payment_fields($invoice_id, $form) { |
|
85 | 85 | |
86 | 86 | // Let the user select a payment method. |
87 | 87 | echo $this->saved_payment_methods(); |
88 | 88 | |
89 | 89 | // Show the credit card entry form. |
90 | - echo $this->new_payment_method_entry( $this->get_cc_form( true ) ); |
|
90 | + echo $this->new_payment_method_entry($this->get_cc_form(true)); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -100,64 +100,64 @@ discard block |
||
100 | 100 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
101 | 101 | * @return string|WP_Error Payment profile id. |
102 | 102 | */ |
103 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
103 | + public function create_customer_profile($invoice, $submission_data, $save = true) { |
|
104 | 104 | |
105 | 105 | // Remove non-digits from the number |
106 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
106 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
107 | 107 | |
108 | 108 | // Generate args. |
109 | 109 | $args = array( |
110 | 110 | 'createCustomerProfileRequest' => array( |
111 | 111 | 'merchantAuthentication' => $this->get_auth_params(), |
112 | 112 | 'profile' => array( |
113 | - 'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ), |
|
114 | - 'description' => getpaid_limit_length( $invoice->get_full_name(), 255 ), |
|
115 | - 'email' => getpaid_limit_length( $invoice->get_email(), 255 ), |
|
113 | + 'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20), |
|
114 | + 'description' => getpaid_limit_length($invoice->get_full_name(), 255), |
|
115 | + 'email' => getpaid_limit_length($invoice->get_email(), 255), |
|
116 | 116 | 'paymentProfiles' => array( |
117 | 117 | 'customerType' => 'individual', |
118 | 118 | |
119 | 119 | // Billing information. |
120 | 120 | 'billTo' => array( |
121 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
122 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
123 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
124 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
125 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
126 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
127 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
121 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
122 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
123 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
124 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
125 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
126 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
127 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
128 | 128 | ), |
129 | 129 | |
130 | 130 | // Payment information. |
131 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ), |
|
131 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']), |
|
132 | 132 | ) |
133 | 133 | ), |
134 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
134 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
135 | 135 | ) |
136 | 136 | ); |
137 | 137 | |
138 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice ); |
|
138 | + $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice); |
|
139 | 139 | |
140 | - if ( is_wp_error( $response ) ) { |
|
140 | + if (is_wp_error($response)) { |
|
141 | 141 | return $response; |
142 | 142 | } |
143 | 143 | |
144 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId ); |
|
144 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId); |
|
145 | 145 | |
146 | 146 | // Save the payment token. |
147 | - if ( $save ) { |
|
147 | + if ($save) { |
|
148 | 148 | $this->save_token( |
149 | 149 | array( |
150 | 150 | 'id' => $response->customerPaymentProfileIdList[0], |
151 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
151 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
152 | 152 | 'default' => true, |
153 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
153 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
154 | 154 | ) |
155 | 155 | ); |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Add a note about the validation response. |
159 | 159 | $invoice->add_note( |
160 | - sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ), |
|
160 | + sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]), |
|
161 | 161 | false, |
162 | 162 | false, |
163 | 163 | true |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @return string|WP_Error Profile id. |
175 | 175 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
176 | 176 | */ |
177 | - public function get_customer_profile( $profile_id ) { |
|
177 | + public function get_customer_profile($profile_id) { |
|
178 | 178 | |
179 | 179 | // Generate args. |
180 | 180 | $args = array( |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ) |
185 | 185 | ); |
186 | 186 | |
187 | - return $this->post( $args, false ); |
|
187 | + return $this->post($args, false); |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
@@ -199,18 +199,18 @@ discard block |
||
199 | 199 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
200 | 200 | * @return string|WP_Error Profile id. |
201 | 201 | */ |
202 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
202 | + public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) { |
|
203 | 203 | |
204 | 204 | // Remove non-digits from the number |
205 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
205 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
206 | 206 | |
207 | 207 | // Prepare card details. |
208 | - $payment_information = $this->get_payment_information( $submission_data['authorizenet'] ); |
|
208 | + $payment_information = $this->get_payment_information($submission_data['authorizenet']); |
|
209 | 209 | |
210 | 210 | // Authorize.NET does not support saving the same card twice. |
211 | - $cached_information = $this->retrieve_payment_profile_from_cache( $payment_information, $customer_profile, $invoice ); |
|
211 | + $cached_information = $this->retrieve_payment_profile_from_cache($payment_information, $customer_profile, $invoice); |
|
212 | 212 | |
213 | - if ( $cached_information ) { |
|
213 | + if ($cached_information) { |
|
214 | 214 | return $cached_information; |
215 | 215 | } |
216 | 216 | |
@@ -223,46 +223,46 @@ discard block |
||
223 | 223 | |
224 | 224 | // Billing information. |
225 | 225 | 'billTo' => array( |
226 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
227 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
228 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
229 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
230 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
231 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
232 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
226 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
227 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
228 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
229 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
230 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
231 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
232 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
233 | 233 | ), |
234 | 234 | |
235 | 235 | // Payment information. |
236 | 236 | 'payment' => $payment_information |
237 | 237 | ), |
238 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
238 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
239 | 239 | ) |
240 | 240 | ); |
241 | 241 | |
242 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
242 | + $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice); |
|
243 | 243 | |
244 | - if ( is_wp_error( $response ) ) { |
|
244 | + if (is_wp_error($response)) { |
|
245 | 245 | return $response; |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Save the payment token. |
249 | - if ( $save ) { |
|
249 | + if ($save) { |
|
250 | 250 | $this->save_token( |
251 | 251 | array( |
252 | 252 | 'id' => $response->customerPaymentProfileId, |
253 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
253 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
254 | 254 | 'default' => true, |
255 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
255 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
256 | 256 | ) |
257 | 257 | ); |
258 | 258 | } |
259 | 259 | |
260 | 260 | // Cache payment profile id. |
261 | - $this->add_payment_profile_to_cache( $payment_information, $response->customerPaymentProfileId ); |
|
261 | + $this->add_payment_profile_to_cache($payment_information, $response->customerPaymentProfileId); |
|
262 | 262 | |
263 | 263 | // Add a note about the validation response. |
264 | 264 | $invoice->add_note( |
265 | - sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ), |
|
265 | + sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse), |
|
266 | 266 | false, |
267 | 267 | false, |
268 | 268 | true |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | * @param array $payment_details. |
280 | 280 | * @return array|false Profile id. |
281 | 281 | */ |
282 | - public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) { |
|
282 | + public function retrieve_payment_profile_from_cache($payment_details, $customer_profile, $invoice) { |
|
283 | 283 | |
284 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
285 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
284 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
285 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
286 | 286 | |
287 | - if ( ! is_array( $cached_information ) || ! array_key_exists( $payment_details, $cached_information ) ) { |
|
287 | + if (!is_array($cached_information) || !array_key_exists($payment_details, $cached_information)) { |
|
288 | 288 | return false; |
289 | 289 | } |
290 | 290 | |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | 'getCustomerPaymentProfileRequest' => array( |
294 | 294 | 'merchantAuthentication' => $this->get_auth_params(), |
295 | 295 | 'customerProfileId' => $customer_profile, |
296 | - 'customerPaymentProfileId' => $cached_information[ $payment_details ], |
|
296 | + 'customerPaymentProfileId' => $cached_information[$payment_details], |
|
297 | 297 | ) |
298 | 298 | ); |
299 | 299 | |
300 | - $response = $this->post( $args, $invoice ); |
|
300 | + $response = $this->post($args, $invoice); |
|
301 | 301 | |
302 | - return is_wp_error( $response ) ? false : $cached_information[ $payment_details ]; |
|
302 | + return is_wp_error($response) ? false : $cached_information[$payment_details]; |
|
303 | 303 | |
304 | 304 | } |
305 | 305 | |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | * @param array $payment_details. |
311 | 311 | * @param string $payment_profile_id. |
312 | 312 | */ |
313 | - public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) { |
|
313 | + public function add_payment_profile_to_cache($payment_details, $payment_profile_id) { |
|
314 | 314 | |
315 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
316 | - $cached_information = is_array( $cached_information ) ? $cached_information : array(); |
|
317 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
315 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
316 | + $cached_information = is_array($cached_information) ? $cached_information : array(); |
|
317 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
318 | 318 | |
319 | - $cached_information[ $payment_details ] = $payment_profile_id; |
|
320 | - update_option( 'getpaid_authorize_net_cached_profiles', $cached_information ); |
|
319 | + $cached_information[$payment_details] = $payment_profile_id; |
|
320 | + update_option('getpaid_authorize_net_cached_profiles', $cached_information); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @return string|WP_Error Profile id. |
331 | 331 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
332 | 332 | */ |
333 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
333 | + public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) { |
|
334 | 334 | |
335 | 335 | // Generate args. |
336 | 336 | $args = array( |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | ) |
342 | 342 | ); |
343 | 343 | |
344 | - return $this->post( $args, false ); |
|
344 | + return $this->post($args, false); |
|
345 | 345 | |
346 | 346 | } |
347 | 347 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
355 | 355 | * @return WP_Error|object |
356 | 356 | */ |
357 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
357 | + public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) { |
|
358 | 358 | |
359 | 359 | // Generate args. |
360 | 360 | $args = array( |
@@ -374,28 +374,28 @@ discard block |
||
374 | 374 | ) |
375 | 375 | ), |
376 | 376 | 'order' => array( |
377 | - 'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ), |
|
377 | + 'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20), |
|
378 | 378 | ), |
379 | - 'lineItems' => array( 'lineItem' => $this->get_line_items( $invoice ) ), |
|
379 | + 'lineItems' => array('lineItem' => $this->get_line_items($invoice)), |
|
380 | 380 | 'tax' => array( |
381 | 381 | 'amount' => $invoice->get_total_tax(), |
382 | - 'name' => __( 'TAX', 'invoicing' ), |
|
382 | + 'name' => __('TAX', 'invoicing'), |
|
383 | 383 | ), |
384 | - 'poNumber' => getpaid_limit_length( $invoice->get_number(), 25 ), |
|
384 | + 'poNumber' => getpaid_limit_length($invoice->get_number(), 25), |
|
385 | 385 | 'customer' => array( |
386 | - 'id' => getpaid_limit_length( $invoice->get_user_id(), 25 ), |
|
387 | - 'email' => getpaid_limit_length( $invoice->get_email(), 25 ), |
|
386 | + 'id' => getpaid_limit_length($invoice->get_user_id(), 25), |
|
387 | + 'email' => getpaid_limit_length($invoice->get_email(), 25), |
|
388 | 388 | ), |
389 | 389 | 'customerIP' => $invoice->get_ip(), |
390 | 390 | ) |
391 | 391 | ) |
392 | 392 | ); |
393 | 393 | |
394 | - if ( 0 == $invoice->get_total_tax() ) { |
|
395 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
394 | + if (0 == $invoice->get_total_tax()) { |
|
395 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
396 | 396 | } |
397 | 397 | |
398 | - return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
398 | + return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice); |
|
399 | 399 | |
400 | 400 | } |
401 | 401 | |
@@ -405,29 +405,29 @@ discard block |
||
405 | 405 | * @param stdClass $result Api response. |
406 | 406 | * @param WPInv_Invoice $invoice Invoice. |
407 | 407 | */ |
408 | - public function process_charge_response( $result, $invoice ) { |
|
408 | + public function process_charge_response($result, $invoice) { |
|
409 | 409 | |
410 | 410 | wpinv_clear_errors(); |
411 | 411 | $response_code = (int) $result->transactionResponse->responseCode; |
412 | 412 | |
413 | 413 | // Succeeded. |
414 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
414 | + if (1 == $response_code || 4 == $response_code) { |
|
415 | 415 | |
416 | 416 | // Maybe set a transaction id. |
417 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
418 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
417 | + if (!empty($result->transactionResponse->transId)) { |
|
418 | + $invoice->set_transaction_id($result->transactionResponse->transId); |
|
419 | 419 | } |
420 | 420 | |
421 | - $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
421 | + $invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true); |
|
422 | 422 | |
423 | - if ( 1 == $response_code ) { |
|
423 | + if (1 == $response_code) { |
|
424 | 424 | return $invoice->mark_paid(); |
425 | 425 | } |
426 | 426 | |
427 | - $invoice->set_status( 'wpi-onhold' ); |
|
427 | + $invoice->set_status('wpi-onhold'); |
|
428 | 428 | $invoice->add_note( |
429 | 429 | sprintf( |
430 | - __( 'Held for review: %s', 'invoicing' ), |
|
430 | + __('Held for review: %s', 'invoicing'), |
|
431 | 431 | $result->transactionResponse->messages->message[0]->description |
432 | 432 | ) |
433 | 433 | ); |
@@ -436,11 +436,11 @@ discard block |
||
436 | 436 | |
437 | 437 | } |
438 | 438 | |
439 | - wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) ); |
|
439 | + wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing')); |
|
440 | 440 | |
441 | - if ( ! empty( $result->transactionResponse->errors ) ) { |
|
441 | + if (!empty($result->transactionResponse->errors)) { |
|
442 | 442 | $errors = (object) $result->transactionResponse->errors; |
443 | - wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) ); |
|
443 | + wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText)); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | } |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | * @param array $card Card details. |
453 | 453 | * @return array |
454 | 454 | */ |
455 | - public function get_payment_information( $card ) { |
|
455 | + public function get_payment_information($card) { |
|
456 | 456 | return array( |
457 | 457 | |
458 | - 'creditCard' => array ( |
|
458 | + 'creditCard' => array( |
|
459 | 459 | 'cardNumber' => $card['cc_number'], |
460 | 460 | 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'], |
461 | 461 | 'cardCode' => $card['cc_cvv2'], |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * @param WPInv_Invoice $invoice Invoice. |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - public function get_customer_profile_meta_name( $invoice ) { |
|
475 | - return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
474 | + public function get_customer_profile_meta_name($invoice) { |
|
475 | + return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -483,34 +483,34 @@ discard block |
||
483 | 483 | * @param WPInv_Invoice $invoice |
484 | 484 | * @return WP_Error|string The payment profile id |
485 | 485 | */ |
486 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
486 | + public function validate_submission_data($submission_data, $invoice) { |
|
487 | 487 | |
488 | 488 | // Validate authentication details. |
489 | 489 | $auth = $this->get_auth_params(); |
490 | 490 | |
491 | - if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) { |
|
492 | - return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing') ); |
|
491 | + if (empty($auth['name']) || empty($auth['transactionKey'])) { |
|
492 | + return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing')); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | // Validate the payment method. |
496 | - if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) { |
|
497 | - return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') ); |
|
496 | + if (empty($submission_data['getpaid-authorizenet-payment-method'])) { |
|
497 | + return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing')); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // Are we adding a new payment method? |
501 | - if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) { |
|
501 | + if ('new' != $submission_data['getpaid-authorizenet-payment-method']) { |
|
502 | 502 | return $submission_data['getpaid-authorizenet-payment-method']; |
503 | 503 | } |
504 | 504 | |
505 | 505 | // Retrieve the customer profile id. |
506 | - $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
506 | + $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
507 | 507 | |
508 | 508 | // Create payment method. |
509 | - if ( empty( $profile_id ) ) { |
|
510 | - return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
509 | + if (empty($profile_id)) { |
|
510 | + return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
511 | 511 | } |
512 | 512 | |
513 | - return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
513 | + return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
514 | 514 | |
515 | 515 | } |
516 | 516 | |
@@ -521,32 +521,32 @@ discard block |
||
521 | 521 | * @param WPInv_Invoice $invoice Invoice. |
522 | 522 | * @return array |
523 | 523 | */ |
524 | - public function get_line_items( $invoice ) { |
|
524 | + public function get_line_items($invoice) { |
|
525 | 525 | $items = array(); |
526 | 526 | |
527 | - foreach ( $invoice->get_items() as $item ) { |
|
527 | + foreach ($invoice->get_items() as $item) { |
|
528 | 528 | |
529 | 529 | $amount = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
530 | 530 | $items[] = array( |
531 | - 'itemId' => getpaid_limit_length( $item->get_id(), 31 ), |
|
532 | - 'name' => getpaid_limit_length( $item->get_raw_name(), 31 ), |
|
533 | - 'description' => getpaid_limit_length( $item->get_description(), 255 ), |
|
534 | - 'quantity' => (string) ( $invoice->get_template() == 'amount' ? 1 : $item->get_quantity() ), |
|
531 | + 'itemId' => getpaid_limit_length($item->get_id(), 31), |
|
532 | + 'name' => getpaid_limit_length($item->get_raw_name(), 31), |
|
533 | + 'description' => getpaid_limit_length($item->get_description(), 255), |
|
534 | + 'quantity' => (string) ($invoice->get_template() == 'amount' ? 1 : $item->get_quantity()), |
|
535 | 535 | 'unitPrice' => (float) $amount, |
536 | 536 | 'taxable' => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(), |
537 | 537 | ); |
538 | 538 | |
539 | 539 | } |
540 | 540 | |
541 | - foreach ( $invoice->get_fees() as $fee_name => $fee ) { |
|
541 | + foreach ($invoice->get_fees() as $fee_name => $fee) { |
|
542 | 542 | |
543 | - $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
543 | + $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
544 | 544 | |
545 | - if ( $amount > 0 ) { |
|
545 | + if ($amount > 0) { |
|
546 | 546 | $items[] = array( |
547 | - 'itemId' => getpaid_limit_length( $fee_name, 31 ), |
|
548 | - 'name' => getpaid_limit_length( $fee_name, 31 ), |
|
549 | - 'description' => getpaid_limit_length( $fee_name, 255 ), |
|
547 | + 'itemId' => getpaid_limit_length($fee_name, 31), |
|
548 | + 'name' => getpaid_limit_length($fee_name, 31), |
|
549 | + 'description' => getpaid_limit_length($fee_name, 255), |
|
550 | 550 | 'quantity' => '1', |
551 | 551 | 'unitPrice' => (float) $amount, |
552 | 552 | 'taxable' => false, |
@@ -567,36 +567,36 @@ discard block |
||
567 | 567 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
568 | 568 | * @return array |
569 | 569 | */ |
570 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
570 | + public function process_payment($invoice, $submission_data, $submission) { |
|
571 | 571 | |
572 | 572 | // Validate the submitted data. |
573 | - $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
|
573 | + $payment_profile_id = $this->validate_submission_data($submission_data, $invoice); |
|
574 | 574 | |
575 | 575 | // Do we have an error? |
576 | - if ( is_wp_error( $payment_profile_id ) ) { |
|
577 | - wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() ); |
|
578 | - wpinv_send_back_to_checkout( $invoice ); |
|
576 | + if (is_wp_error($payment_profile_id)) { |
|
577 | + wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message()); |
|
578 | + wpinv_send_back_to_checkout($invoice); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | // Save the payment method to the order. |
582 | - update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id ); |
|
582 | + update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id); |
|
583 | 583 | |
584 | 584 | // Check if this is a subscription or not. |
585 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
586 | - if ( ! empty( $subscriptions ) ) { |
|
587 | - $this->process_subscription( $invoice, $subscriptions ); |
|
585 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
586 | + if (!empty($subscriptions)) { |
|
587 | + $this->process_subscription($invoice, $subscriptions); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | // If it is free, send to the success page. |
591 | - if ( ! $invoice->needs_payment() ) { |
|
591 | + if (!$invoice->needs_payment()) { |
|
592 | 592 | $invoice->mark_paid(); |
593 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
593 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | // Charge the payment profile. |
597 | - $this->process_initial_payment( $invoice ); |
|
597 | + $this->process_initial_payment($invoice); |
|
598 | 598 | |
599 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
599 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
600 | 600 | |
601 | 601 | exit; |
602 | 602 | |
@@ -607,23 +607,23 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @param WPInv_Invoice $invoice Invoice. |
609 | 609 | */ |
610 | - protected function process_initial_payment( $invoice ) { |
|
610 | + protected function process_initial_payment($invoice) { |
|
611 | 611 | |
612 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
613 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
614 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
612 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
613 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
614 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
615 | 615 | |
616 | 616 | // Do we have an error? |
617 | - if ( is_wp_error( $result ) ) { |
|
618 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
619 | - wpinv_send_back_to_checkout( $invoice ); |
|
617 | + if (is_wp_error($result)) { |
|
618 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
619 | + wpinv_send_back_to_checkout($invoice); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | // Process the response. |
623 | - $this->process_charge_response( $result, $invoice ); |
|
623 | + $this->process_charge_response($result, $invoice); |
|
624 | 624 | |
625 | - if ( wpinv_get_errors() ) { |
|
626 | - wpinv_send_back_to_checkout( $invoice ); |
|
625 | + if (wpinv_get_errors()) { |
|
626 | + wpinv_send_back_to_checkout($invoice); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | } |
@@ -634,30 +634,30 @@ discard block |
||
634 | 634 | * @param WPInv_Invoice $invoice Invoice. |
635 | 635 | * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions. |
636 | 636 | */ |
637 | - public function process_subscription( $invoice, $subscriptions ) { |
|
637 | + public function process_subscription($invoice, $subscriptions) { |
|
638 | 638 | |
639 | 639 | // Check if there is an initial amount to charge. |
640 | - if ( (float) $invoice->get_total() > 0 ) { |
|
641 | - $this->process_initial_payment( $invoice ); |
|
640 | + if ((float) $invoice->get_total() > 0) { |
|
641 | + $this->process_initial_payment($invoice); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | // Activate the subscriptions. |
645 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
645 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
646 | 646 | |
647 | - foreach ( $subscriptions as $subscription ) { |
|
648 | - if ( $subscription->exists() ) { |
|
649 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
650 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
647 | + foreach ($subscriptions as $subscription) { |
|
648 | + if ($subscription->exists()) { |
|
649 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
650 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
651 | 651 | |
652 | - $subscription->set_next_renewal_date( $expiry ); |
|
653 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
654 | - $subscription->set_profile_id( $invoice->generate_key( 'authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) ); |
|
652 | + $subscription->set_next_renewal_date($expiry); |
|
653 | + $subscription->set_date_created(current_time('mysql')); |
|
654 | + $subscription->set_profile_id($invoice->generate_key('authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id())); |
|
655 | 655 | $subscription->activate(); |
656 | 656 | } |
657 | 657 | } |
658 | 658 | |
659 | 659 | // Redirect to the success page. |
660 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
660 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
661 | 661 | |
662 | 662 | } |
663 | 663 | |
@@ -668,20 +668,20 @@ discard block |
||
668 | 668 | * @param bool $should_expire |
669 | 669 | * @param WPInv_Subscription $subscription |
670 | 670 | */ |
671 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
671 | + public function maybe_renew_subscription($should_expire, $subscription) { |
|
672 | 672 | |
673 | 673 | // Ensure its our subscription && it's active. |
674 | - if ( $this->id != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
|
674 | + if ($this->id != $subscription->get_gateway() || !$subscription->has_status('active trialling')) { |
|
675 | 675 | return $should_expire; |
676 | 676 | } |
677 | 677 | |
678 | 678 | // If this is the last renewal, complete the subscription. |
679 | - if ( $subscription->is_last_renewal() ) { |
|
679 | + if ($subscription->is_last_renewal()) { |
|
680 | 680 | $subscription->complete(); |
681 | 681 | return false; |
682 | 682 | } |
683 | 683 | |
684 | - $this->renew_subscription( $subscription ); |
|
684 | + $this->renew_subscription($subscription); |
|
685 | 685 | |
686 | 686 | return false; |
687 | 687 | |
@@ -692,28 +692,28 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @param WPInv_Subscription $subscription |
694 | 694 | */ |
695 | - public function renew_subscription( $subscription ) { |
|
695 | + public function renew_subscription($subscription) { |
|
696 | 696 | |
697 | 697 | // Generate the renewal invoice. |
698 | 698 | $new_invoice = $subscription->create_payment(); |
699 | 699 | $old_invoice = $subscription->get_parent_payment(); |
700 | 700 | |
701 | - if ( empty( $new_invoice ) ) { |
|
702 | - $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
|
701 | + if (empty($new_invoice)) { |
|
702 | + $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false); |
|
703 | 703 | $subscription->failing(); |
704 | 704 | return; |
705 | 705 | } |
706 | 706 | |
707 | 707 | // Charge the payment method. |
708 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
709 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
710 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
708 | + $payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
709 | + $customer_profile = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true); |
|
710 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice); |
|
711 | 711 | |
712 | 712 | // Do we have an error? |
713 | - if ( is_wp_error( $result ) ) { |
|
713 | + if (is_wp_error($result)) { |
|
714 | 714 | |
715 | 715 | $old_invoice->add_note( |
716 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
716 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()), |
|
717 | 717 | true, |
718 | 718 | false, |
719 | 719 | true |
@@ -724,12 +724,12 @@ discard block |
||
724 | 724 | } |
725 | 725 | |
726 | 726 | // Process the response. |
727 | - $this->process_charge_response( $result, $new_invoice ); |
|
727 | + $this->process_charge_response($result, $new_invoice); |
|
728 | 728 | |
729 | - if ( wpinv_get_errors() ) { |
|
729 | + if (wpinv_get_errors()) { |
|
730 | 730 | |
731 | 731 | $old_invoice->add_note( |
732 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
732 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()), |
|
733 | 733 | true, |
734 | 734 | false, |
735 | 735 | true |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | |
740 | 740 | } |
741 | 741 | |
742 | - $subscription->add_payment( array(), $new_invoice ); |
|
742 | + $subscription->add_payment(array(), $new_invoice); |
|
743 | 743 | $subscription->renew(); |
744 | 744 | } |
745 | 745 | |
@@ -750,34 +750,34 @@ discard block |
||
750 | 750 | * @param GetPaid_Form_Item[] $items |
751 | 751 | * @return WPInv_Invoice |
752 | 752 | */ |
753 | - public function process_addons( $invoice, $items ) { |
|
753 | + public function process_addons($invoice, $items) { |
|
754 | 754 | |
755 | 755 | global $getpaid_authorize_addons; |
756 | 756 | |
757 | 757 | $getpaid_authorize_addons = array(); |
758 | - foreach ( $items as $item ) { |
|
758 | + foreach ($items as $item) { |
|
759 | 759 | |
760 | - if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) { |
|
760 | + if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) { |
|
761 | 761 | $getpaid_authorize_addons[] = $item; |
762 | 762 | } |
763 | 763 | |
764 | 764 | } |
765 | 765 | |
766 | - if ( empty( $getpaid_authorize_addons ) ) { |
|
766 | + if (empty($getpaid_authorize_addons)) { |
|
767 | 767 | return; |
768 | 768 | } |
769 | 769 | |
770 | 770 | $invoice->recalculate_total(); |
771 | 771 | |
772 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
773 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
772 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
773 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
774 | 774 | |
775 | - add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
|
776 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
777 | - remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) ); |
|
775 | + add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2); |
|
776 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
777 | + remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request')); |
|
778 | 778 | |
779 | - if ( is_wp_error( $result ) ) { |
|
780 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
779 | + if (is_wp_error($result)) { |
|
780 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
781 | 781 | return; |
782 | 782 | } |
783 | 783 | |
@@ -790,19 +790,19 @@ discard block |
||
790 | 790 | * @param array $args |
791 | 791 | * @return array |
792 | 792 | */ |
793 | - public function filter_addons_request( $args ) { |
|
793 | + public function filter_addons_request($args) { |
|
794 | 794 | |
795 | 795 | global $getpaid_authorize_addons; |
796 | 796 | $total = 0; |
797 | 797 | |
798 | - foreach ( $getpaid_authorize_addons as $addon ) { |
|
798 | + foreach ($getpaid_authorize_addons as $addon) { |
|
799 | 799 | $total += $addon->get_sub_total(); |
800 | 800 | } |
801 | 801 | |
802 | 802 | $args['createTransactionRequest']['transactionRequest']['amount'] = $total; |
803 | 803 | |
804 | - if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) { |
|
805 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
804 | + if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) { |
|
805 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | return $args; |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | public function sandbox_notice() { |
816 | 816 | |
817 | 817 | return sprintf( |
818 | - __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
818 | + __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
819 | 819 | '<a href="https://developer.authorize.net/hello_world/testing_guide.html">', |
820 | 820 | '</a>' |
821 | 821 | ); |
@@ -827,42 +827,42 @@ discard block |
||
827 | 827 | * |
828 | 828 | * @param array $admin_settings |
829 | 829 | */ |
830 | - public function admin_settings( $admin_settings ) { |
|
830 | + public function admin_settings($admin_settings) { |
|
831 | 831 | |
832 | 832 | $currencies = sprintf( |
833 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
834 | - implode( ', ', $this->currencies ) |
|
833 | + __('Supported Currencies: %s', 'invoicing'), |
|
834 | + implode(', ', $this->currencies) |
|
835 | 835 | ); |
836 | 836 | |
837 | 837 | $admin_settings['authorizenet_active']['desc'] .= " ($currencies)"; |
838 | - $admin_settings['authorizenet_desc']['std'] = __( 'Pay securely using your credit or debit card.', 'invoicing' ); |
|
838 | + $admin_settings['authorizenet_desc']['std'] = __('Pay securely using your credit or debit card.', 'invoicing'); |
|
839 | 839 | |
840 | 840 | $admin_settings['authorizenet_login_id'] = array( |
841 | 841 | 'type' => 'text', |
842 | 842 | 'id' => 'authorizenet_login_id', |
843 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
844 | - 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>', |
|
843 | + 'name' => __('API Login ID', 'invoicing'), |
|
844 | + 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>', |
|
845 | 845 | ); |
846 | 846 | |
847 | 847 | $admin_settings['authorizenet_transaction_key'] = array( |
848 | 848 | 'type' => 'text', |
849 | 849 | 'id' => 'authorizenet_transaction_key', |
850 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
850 | + 'name' => __('Transaction Key', 'invoicing'), |
|
851 | 851 | ); |
852 | 852 | |
853 | 853 | $admin_settings['authorizenet_signature_key'] = array( |
854 | 854 | 'type' => 'text', |
855 | 855 | 'id' => 'authorizenet_signature_key', |
856 | - 'name' => __( 'Signature Key', 'invoicing' ), |
|
857 | - 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
856 | + 'name' => __('Signature Key', 'invoicing'), |
|
857 | + 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
858 | 858 | ); |
859 | 859 | |
860 | 860 | $admin_settings['authorizenet_ipn_url'] = array( |
861 | 861 | 'type' => 'ipn_url', |
862 | 862 | 'id' => 'authorizenet_ipn_url', |
863 | - 'name' => __( 'Webhook URL', 'invoicing' ), |
|
863 | + 'name' => __('Webhook URL', 'invoicing'), |
|
864 | 864 | 'std' => $this->notify_url, |
865 | - 'desc' => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
865 | + 'desc' => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
866 | 866 | 'custom' => 'authorizenet', |
867 | 867 | 'readonly' => true, |
868 | 868 | ); |