@@ -13,58 +13,58 @@ discard block |
||
13 | 13 | class GetPaid_Authorize_Net_Gateway extends GetPaid_Authorize_Net_Legacy_Gateway { |
14 | 14 | |
15 | 15 | /** |
16 | - * Payment method id. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
16 | + * Payment method id. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | 20 | public $id = 'authorizenet'; |
21 | 21 | |
22 | 22 | /** |
23 | - * An array of features that this gateway supports. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
23 | + * An array of features that this gateway supports. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | 27 | protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons' ); |
28 | 28 | |
29 | 29 | /** |
30 | - * Payment method order. |
|
31 | - * |
|
32 | - * @var int |
|
33 | - */ |
|
30 | + * Payment method order. |
|
31 | + * |
|
32 | + * @var int |
|
33 | + */ |
|
34 | 34 | public $order = 4; |
35 | 35 | |
36 | 36 | /** |
37 | - * Endpoint for requests from Authorize.net. |
|
38 | - * |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - protected $notify_url; |
|
42 | - |
|
43 | - /** |
|
44 | - * Endpoint for requests to Authorize.net. |
|
45 | - * |
|
46 | - * @var string |
|
47 | - */ |
|
37 | + * Endpoint for requests from Authorize.net. |
|
38 | + * |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + protected $notify_url; |
|
42 | + |
|
43 | + /** |
|
44 | + * Endpoint for requests to Authorize.net. |
|
45 | + * |
|
46 | + * @var string |
|
47 | + */ |
|
48 | 48 | protected $endpoint; |
49 | 49 | |
50 | 50 | /** |
51 | - * Currencies this gateway is allowed for. |
|
52 | - * |
|
53 | - * @var array |
|
54 | - */ |
|
55 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
51 | + * Currencies this gateway is allowed for. |
|
52 | + * |
|
53 | + * @var array |
|
54 | + */ |
|
55 | + public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
56 | 56 | |
57 | 57 | /** |
58 | - * URL to view a transaction. |
|
59 | - * |
|
60 | - * @var string |
|
61 | - */ |
|
58 | + * URL to view a transaction. |
|
59 | + * |
|
60 | + * @var string |
|
61 | + */ |
|
62 | 62 | public $view_transaction_url = 'https://{sandbox}authorize.net/ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=%s'; |
63 | 63 | |
64 | 64 | /** |
65 | - * Class constructor. |
|
66 | - */ |
|
67 | - public function __construct() { |
|
65 | + * Class constructor. |
|
66 | + */ |
|
67 | + public function __construct() { |
|
68 | 68 | |
69 | 69 | $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
70 | 70 | $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * Displays the payment method select field. |
|
80 | - * |
|
81 | - * @param int $invoice_id 0 or invoice id. |
|
82 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
83 | - */ |
|
79 | + * Displays the payment method select field. |
|
80 | + * |
|
81 | + * @param int $invoice_id 0 or invoice id. |
|
82 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
83 | + */ |
|
84 | 84 | public function payment_fields( $invoice_id, $form ) { |
85 | 85 | |
86 | 86 | // Let the user select a payment method. |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | - * Creates a customer profile. |
|
95 | - * |
|
96 | - * |
|
97 | - * @param WPInv_Invoice $invoice Invoice. |
|
94 | + * Creates a customer profile. |
|
95 | + * |
|
96 | + * |
|
97 | + * @param WPInv_Invoice $invoice Invoice. |
|
98 | 98 | * @param array $submission_data Posted checkout fields. |
99 | 99 | * @param bool $save Whether or not to save the payment as a token. |
100 | 100 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
101 | - * @return string|WP_Error Payment profile id. |
|
102 | - */ |
|
103 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
101 | + * @return string|WP_Error Payment profile id. |
|
102 | + */ |
|
103 | + public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
104 | 104 | |
105 | 105 | // Remove non-digits from the number |
106 | 106 | $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
170 | - * Retrieves a customer profile. |
|
171 | - * |
|
172 | - * |
|
173 | - * @param string $profile_id profile id. |
|
174 | - * @return string|WP_Error Profile id. |
|
170 | + * Retrieves a customer profile. |
|
171 | + * |
|
172 | + * |
|
173 | + * @param string $profile_id profile id. |
|
174 | + * @return string|WP_Error Profile id. |
|
175 | 175 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
176 | - */ |
|
177 | - public function get_customer_profile( $profile_id ) { |
|
176 | + */ |
|
177 | + public function get_customer_profile( $profile_id ) { |
|
178 | 178 | |
179 | 179 | // Generate args. |
180 | 180 | $args = array( |
@@ -189,17 +189,17 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | - * Creates a customer profile. |
|
193 | - * |
|
194 | - * |
|
192 | + * Creates a customer profile. |
|
193 | + * |
|
194 | + * |
|
195 | 195 | * @param string $profile_id profile id. |
196 | - * @param WPInv_Invoice $invoice Invoice. |
|
196 | + * @param WPInv_Invoice $invoice Invoice. |
|
197 | 197 | * @param array $submission_data Posted checkout fields. |
198 | 198 | * @param bool $save Whether or not to save the payment as a token. |
199 | 199 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
200 | - * @return string|WP_Error Profile id. |
|
201 | - */ |
|
202 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
200 | + * @return string|WP_Error Profile id. |
|
201 | + */ |
|
202 | + public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
203 | 203 | |
204 | 204 | // Remove non-digits from the number |
205 | 205 | $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
@@ -272,13 +272,13 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
275 | - * Retrieves payment details from cache. |
|
276 | - * |
|
277 | - * |
|
275 | + * Retrieves payment details from cache. |
|
276 | + * |
|
277 | + * |
|
278 | 278 | * @param array $payment_details. |
279 | - * @return array|false Profile id. |
|
280 | - */ |
|
281 | - public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) { |
|
279 | + * @return array|false Profile id. |
|
280 | + */ |
|
281 | + public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) { |
|
282 | 282 | |
283 | 283 | $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
284 | 284 | $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
@@ -303,13 +303,13 @@ discard block |
||
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
306 | - * Securely adds payment details to cache. |
|
307 | - * |
|
308 | - * |
|
306 | + * Securely adds payment details to cache. |
|
307 | + * |
|
308 | + * |
|
309 | 309 | * @param array $payment_details. |
310 | 310 | * @param string $payment_profile_id. |
311 | - */ |
|
312 | - public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) { |
|
311 | + */ |
|
312 | + public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) { |
|
313 | 313 | |
314 | 314 | $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
315 | 315 | $cached_information = is_array( $cached_information ) ? $cached_information : array(); |
@@ -321,15 +321,15 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
324 | - * Retrieves a customer payment profile. |
|
325 | - * |
|
326 | - * |
|
327 | - * @param string $customer_profile_id customer profile id. |
|
324 | + * Retrieves a customer payment profile. |
|
325 | + * |
|
326 | + * |
|
327 | + * @param string $customer_profile_id customer profile id. |
|
328 | 328 | * @param string $payment_profile_id payment profile id. |
329 | - * @return string|WP_Error Profile id. |
|
329 | + * @return string|WP_Error Profile id. |
|
330 | 330 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
331 | - */ |
|
332 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
331 | + */ |
|
332 | + public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
333 | 333 | |
334 | 334 | // Generate args. |
335 | 335 | $args = array( |
@@ -345,15 +345,15 @@ discard block |
||
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
348 | - * Charges a customer payment profile. |
|
349 | - * |
|
348 | + * Charges a customer payment profile. |
|
349 | + * |
|
350 | 350 | * @param string $customer_profile_id customer profile id. |
351 | 351 | * @param string $payment_profile_id payment profile id. |
352 | - * @param WPInv_Invoice $invoice Invoice. |
|
352 | + * @param WPInv_Invoice $invoice Invoice. |
|
353 | 353 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
354 | - * @return WP_Error|object |
|
355 | - */ |
|
356 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
354 | + * @return WP_Error|object |
|
355 | + */ |
|
356 | + public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
357 | 357 | |
358 | 358 | // Generate args. |
359 | 359 | $args = array( |
@@ -399,41 +399,41 @@ discard block |
||
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
402 | - * Processes a customer charge. |
|
403 | - * |
|
402 | + * Processes a customer charge. |
|
403 | + * |
|
404 | 404 | * @param stdClass $result Api response. |
405 | - * @param WPInv_Invoice $invoice Invoice. |
|
406 | - */ |
|
407 | - public function process_charge_response( $result, $invoice ) { |
|
405 | + * @param WPInv_Invoice $invoice Invoice. |
|
406 | + */ |
|
407 | + public function process_charge_response( $result, $invoice ) { |
|
408 | 408 | |
409 | 409 | wpinv_clear_errors(); |
410 | - $response_code = (int) $result->transactionResponse->responseCode; |
|
410 | + $response_code = (int) $result->transactionResponse->responseCode; |
|
411 | 411 | |
412 | - // Succeeded. |
|
413 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
412 | + // Succeeded. |
|
413 | + if ( 1 == $response_code || 4 == $response_code ) { |
|
414 | 414 | |
415 | - // Maybe set a transaction id. |
|
416 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
417 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
418 | - } |
|
415 | + // Maybe set a transaction id. |
|
416 | + if ( ! empty( $result->transactionResponse->transId ) ) { |
|
417 | + $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
418 | + } |
|
419 | 419 | |
420 | - $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
420 | + $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
421 | 421 | |
422 | - if ( 1 == $response_code ) { |
|
423 | - return $invoice->mark_paid(); |
|
424 | - } |
|
422 | + if ( 1 == $response_code ) { |
|
423 | + return $invoice->mark_paid(); |
|
424 | + } |
|
425 | 425 | |
426 | - $invoice->set_status( 'wpi-onhold' ); |
|
427 | - $invoice->add_note( |
|
426 | + $invoice->set_status( 'wpi-onhold' ); |
|
427 | + $invoice->add_note( |
|
428 | 428 | sprintf( |
429 | 429 | __( 'Held for review: %s', 'invoicing' ), |
430 | 430 | $result->transactionResponse->messages->message[0]->description |
431 | 431 | ) |
432 | - ); |
|
432 | + ); |
|
433 | 433 | |
434 | - return $invoice->save(); |
|
434 | + return $invoice->save(); |
|
435 | 435 | |
436 | - } |
|
436 | + } |
|
437 | 437 | |
438 | 438 | wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) ); |
439 | 439 | |
@@ -445,13 +445,13 @@ discard block |
||
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
448 | - * Returns payment information. |
|
449 | - * |
|
450 | - * |
|
451 | - * @param array $card Card details. |
|
452 | - * @return array |
|
453 | - */ |
|
454 | - public function get_payment_information( $card ) { |
|
448 | + * Returns payment information. |
|
449 | + * |
|
450 | + * |
|
451 | + * @param array $card Card details. |
|
452 | + * @return array |
|
453 | + */ |
|
454 | + public function get_payment_information( $card ) { |
|
455 | 455 | return array( |
456 | 456 | |
457 | 457 | 'creditCard' => array ( |
@@ -464,25 +464,25 @@ discard block |
||
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
467 | - * Returns the customer profile meta name. |
|
468 | - * |
|
469 | - * |
|
470 | - * @param WPInv_Invoice $invoice Invoice. |
|
471 | - * @return string |
|
472 | - */ |
|
473 | - public function get_customer_profile_meta_name( $invoice ) { |
|
467 | + * Returns the customer profile meta name. |
|
468 | + * |
|
469 | + * |
|
470 | + * @param WPInv_Invoice $invoice Invoice. |
|
471 | + * @return string |
|
472 | + */ |
|
473 | + public function get_customer_profile_meta_name( $invoice ) { |
|
474 | 474 | return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
478 | - * Validates the submitted data. |
|
479 | - * |
|
480 | - * |
|
481 | - * @param array $submission_data Posted checkout fields. |
|
478 | + * Validates the submitted data. |
|
479 | + * |
|
480 | + * |
|
481 | + * @param array $submission_data Posted checkout fields. |
|
482 | 482 | * @param WPInv_Invoice $invoice |
483 | - * @return WP_Error|string The payment profile id |
|
484 | - */ |
|
485 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
483 | + * @return WP_Error|string The payment profile id |
|
484 | + */ |
|
485 | + public function validate_submission_data( $submission_data, $invoice ) { |
|
486 | 486 | |
487 | 487 | // Validate authentication details. |
488 | 488 | $auth = $this->get_auth_params(); |
@@ -514,13 +514,13 @@ discard block |
||
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
517 | - * Returns invoice line items. |
|
518 | - * |
|
519 | - * |
|
520 | - * @param WPInv_Invoice $invoice Invoice. |
|
521 | - * @return array |
|
522 | - */ |
|
523 | - public function get_line_items( $invoice ) { |
|
517 | + * Returns invoice line items. |
|
518 | + * |
|
519 | + * |
|
520 | + * @param WPInv_Invoice $invoice Invoice. |
|
521 | + * @return array |
|
522 | + */ |
|
523 | + public function get_line_items( $invoice ) { |
|
524 | 524 | $items = array(); |
525 | 525 | |
526 | 526 | foreach ( $invoice->get_items() as $item ) { |
@@ -558,15 +558,15 @@ discard block |
||
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
561 | - * Process Payment. |
|
562 | - * |
|
563 | - * |
|
564 | - * @param WPInv_Invoice $invoice Invoice. |
|
565 | - * @param array $submission_data Posted checkout fields. |
|
566 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
567 | - * @return array |
|
568 | - */ |
|
569 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
561 | + * Process Payment. |
|
562 | + * |
|
563 | + * |
|
564 | + * @param WPInv_Invoice $invoice Invoice. |
|
565 | + * @param array $submission_data Posted checkout fields. |
|
566 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
567 | + * @return array |
|
568 | + */ |
|
569 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
570 | 570 | |
571 | 571 | // Validate the submitted data. |
572 | 572 | $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
@@ -599,69 +599,69 @@ discard block |
||
599 | 599 | |
600 | 600 | exit; |
601 | 601 | |
602 | - } |
|
602 | + } |
|
603 | 603 | |
604 | - /** |
|
605 | - * Processes the initial payment. |
|
606 | - * |
|
604 | + /** |
|
605 | + * Processes the initial payment. |
|
606 | + * |
|
607 | 607 | * @param WPInv_Invoice $invoice Invoice. |
608 | - */ |
|
609 | - protected function process_initial_payment( $invoice ) { |
|
608 | + */ |
|
609 | + protected function process_initial_payment( $invoice ) { |
|
610 | 610 | |
611 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
611 | + $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
612 | 612 | $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
613 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
613 | + $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
614 | 614 | |
615 | - // Do we have an error? |
|
616 | - if ( is_wp_error( $result ) ) { |
|
617 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
618 | - wpinv_send_back_to_checkout( $invoice ); |
|
619 | - } |
|
615 | + // Do we have an error? |
|
616 | + if ( is_wp_error( $result ) ) { |
|
617 | + wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
618 | + wpinv_send_back_to_checkout( $invoice ); |
|
619 | + } |
|
620 | 620 | |
621 | - // Process the response. |
|
622 | - $this->process_charge_response( $result, $invoice ); |
|
621 | + // Process the response. |
|
622 | + $this->process_charge_response( $result, $invoice ); |
|
623 | 623 | |
624 | - if ( wpinv_get_errors() ) { |
|
625 | - wpinv_send_back_to_checkout( $invoice ); |
|
626 | - } |
|
624 | + if ( wpinv_get_errors() ) { |
|
625 | + wpinv_send_back_to_checkout( $invoice ); |
|
626 | + } |
|
627 | 627 | |
628 | - } |
|
628 | + } |
|
629 | 629 | |
630 | 630 | /** |
631 | - * Processes recurring payments. |
|
632 | - * |
|
631 | + * Processes recurring payments. |
|
632 | + * |
|
633 | 633 | * @param WPInv_Invoice $invoice Invoice. |
634 | 634 | * @param WPInv_Subscription $subscription Subscription. |
635 | - */ |
|
636 | - public function process_subscription( $invoice, $subscription ) { |
|
635 | + */ |
|
636 | + public function process_subscription( $invoice, $subscription ) { |
|
637 | 637 | |
638 | 638 | // Check if there is an initial amount to charge. |
639 | 639 | if ( (float) $invoice->get_total() > 0 ) { |
640 | - $this->process_initial_payment( $invoice ); |
|
640 | + $this->process_initial_payment( $invoice ); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | // Activate the subscription. |
644 | 644 | $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
645 | 645 | $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
646 | 646 | |
647 | - $subscription->set_next_renewal_date( $expiry ); |
|
648 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
649 | - $subscription->set_profile_id( $invoice->generate_key() ); |
|
650 | - $subscription->activate(); |
|
647 | + $subscription->set_next_renewal_date( $expiry ); |
|
648 | + $subscription->set_date_created( current_time( 'mysql' ) ); |
|
649 | + $subscription->set_profile_id( $invoice->generate_key() ); |
|
650 | + $subscription->activate(); |
|
651 | 651 | |
652 | - // Redirect to the success page. |
|
652 | + // Redirect to the success page. |
|
653 | 653 | wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
654 | 654 | |
655 | 655 | } |
656 | 656 | |
657 | - /** |
|
658 | - * (Maybe) renews an authorize.net subscription profile. |
|
659 | - * |
|
660 | - * |
|
661 | - * @param bool $should_expire |
|
657 | + /** |
|
658 | + * (Maybe) renews an authorize.net subscription profile. |
|
659 | + * |
|
660 | + * |
|
661 | + * @param bool $should_expire |
|
662 | 662 | * @param WPInv_Subscription $subscription |
663 | - */ |
|
664 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
663 | + */ |
|
664 | + public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
665 | 665 | |
666 | 666 | // Ensure its our subscription && it's active. |
667 | 667 | if ( $this->id != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
@@ -678,18 +678,18 @@ discard block |
||
678 | 678 | |
679 | 679 | return false; |
680 | 680 | |
681 | - } |
|
681 | + } |
|
682 | 682 | |
683 | 683 | /** |
684 | - * Renews a subscription. |
|
685 | - * |
|
684 | + * Renews a subscription. |
|
685 | + * |
|
686 | 686 | * @param WPInv_Subscription $subscription |
687 | - */ |
|
688 | - public function renew_subscription( $subscription ) { |
|
687 | + */ |
|
688 | + public function renew_subscription( $subscription ) { |
|
689 | 689 | |
690 | - // Generate the renewal invoice. |
|
691 | - $new_invoice = $subscription->create_payment(); |
|
692 | - $old_invoice = $subscription->get_parent_payment(); |
|
690 | + // Generate the renewal invoice. |
|
691 | + $new_invoice = $subscription->create_payment(); |
|
692 | + $old_invoice = $subscription->get_parent_payment(); |
|
693 | 693 | |
694 | 694 | if ( empty( $new_invoice ) ) { |
695 | 695 | $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
@@ -698,37 +698,37 @@ discard block |
||
698 | 698 | } |
699 | 699 | |
700 | 700 | // Charge the payment method. |
701 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
702 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
703 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
704 | - |
|
705 | - // Do we have an error? |
|
706 | - if ( is_wp_error( $result ) ) { |
|
707 | - |
|
708 | - $old_invoice->add_note( |
|
709 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
710 | - true, |
|
711 | - false, |
|
712 | - true |
|
713 | - ); |
|
714 | - $subscription->failing(); |
|
715 | - return; |
|
716 | - |
|
717 | - } |
|
718 | - |
|
719 | - // Process the response. |
|
720 | - $this->process_charge_response( $result, $new_invoice ); |
|
721 | - |
|
722 | - if ( wpinv_get_errors() ) { |
|
723 | - |
|
724 | - $old_invoice->add_note( |
|
725 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
726 | - true, |
|
727 | - false, |
|
728 | - true |
|
729 | - ); |
|
730 | - $subscription->failing(); |
|
731 | - return; |
|
701 | + $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
702 | + $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
703 | + $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
704 | + |
|
705 | + // Do we have an error? |
|
706 | + if ( is_wp_error( $result ) ) { |
|
707 | + |
|
708 | + $old_invoice->add_note( |
|
709 | + sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
710 | + true, |
|
711 | + false, |
|
712 | + true |
|
713 | + ); |
|
714 | + $subscription->failing(); |
|
715 | + return; |
|
716 | + |
|
717 | + } |
|
718 | + |
|
719 | + // Process the response. |
|
720 | + $this->process_charge_response( $result, $new_invoice ); |
|
721 | + |
|
722 | + if ( wpinv_get_errors() ) { |
|
723 | + |
|
724 | + $old_invoice->add_note( |
|
725 | + sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
726 | + true, |
|
727 | + false, |
|
728 | + true |
|
729 | + ); |
|
730 | + $subscription->failing(); |
|
731 | + return; |
|
732 | 732 | |
733 | 733 | } |
734 | 734 | |
@@ -737,13 +737,13 @@ discard block |
||
737 | 737 | } |
738 | 738 | |
739 | 739 | /** |
740 | - * Processes invoice addons. |
|
741 | - * |
|
742 | - * @param WPInv_Invoice $invoice |
|
743 | - * @param GetPaid_Form_Item[] $items |
|
744 | - * @return WPInv_Invoice |
|
745 | - */ |
|
746 | - public function process_addons( $invoice, $items ) { |
|
740 | + * Processes invoice addons. |
|
741 | + * |
|
742 | + * @param WPInv_Invoice $invoice |
|
743 | + * @param GetPaid_Form_Item[] $items |
|
744 | + * @return WPInv_Invoice |
|
745 | + */ |
|
746 | + public function process_addons( $invoice, $items ) { |
|
747 | 747 | |
748 | 748 | global $getpaid_authorize_addons; |
749 | 749 | |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | $invoice->recalculate_total(); |
764 | 764 | |
765 | 765 | $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
766 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
766 | + $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
767 | 767 | |
768 | 768 | add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
769 | 769 | $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
@@ -778,11 +778,11 @@ discard block |
||
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
781 | - * Processes invoice addons. |
|
782 | - * |
|
781 | + * Processes invoice addons. |
|
782 | + * |
|
783 | 783 | * @param array $args |
784 | - * @return array |
|
785 | - */ |
|
784 | + * @return array |
|
785 | + */ |
|
786 | 786 | public function filter_addons_request( $args ) { |
787 | 787 | |
788 | 788 | global $getpaid_authorize_addons; |
@@ -816,11 +816,11 @@ discard block |
||
816 | 816 | } |
817 | 817 | |
818 | 818 | /** |
819 | - * Filters the gateway settings. |
|
820 | - * |
|
821 | - * @param array $admin_settings |
|
822 | - */ |
|
823 | - public function admin_settings( $admin_settings ) { |
|
819 | + * Filters the gateway settings. |
|
820 | + * |
|
821 | + * @param array $admin_settings |
|
822 | + */ |
|
823 | + public function admin_settings( $admin_settings ) { |
|
824 | 824 | |
825 | 825 | $currencies = sprintf( |
826 | 826 | __( 'Supported Currencies: %s', 'invoicing' ), |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | 'readonly' => true, |
861 | 861 | ); |
862 | 862 | |
863 | - return $admin_settings; |
|
864 | - } |
|
863 | + return $admin_settings; |
|
864 | + } |
|
865 | 865 | |
866 | 866 | } |