@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
@@ -13,128 +13,128 @@ |
||
| 13 | 13 | class GetPaid_Payment_Forms { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Class constructor |
|
| 17 | - * |
|
| 18 | - */ |
|
| 19 | - public function __construct() { |
|
| 20 | - |
|
| 21 | - // Update a payment form's revenue whenever an invoice is paid for or refunded. |
|
| 22 | - add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) ); |
|
| 23 | - add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) ); |
|
| 24 | - |
|
| 25 | - // Sync form amount whenever invoice statuses change. |
|
| 26 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 ); |
|
| 27 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 ); |
|
| 28 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 ); |
|
| 29 | - |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Increments a form's revenue whenever there is a payment. |
|
| 34 | - * |
|
| 35 | - * @param WPInv_Invoice $invoice |
|
| 36 | - */ |
|
| 37 | - public function increment_form_revenue( $invoice ) { |
|
| 38 | - |
|
| 39 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 40 | - if ( $form->get_id() ) { |
|
| 41 | - $form->set_earned( $form->get_earned() + $invoice->get_total() ); |
|
| 42 | - $form->save(); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Decreases form revenue whenever invoice payment changes. |
|
| 49 | - * |
|
| 50 | - * @param WPInv_Invoice $invoice |
|
| 51 | - */ |
|
| 52 | - public function decrease_form_revenue( $invoice ) { |
|
| 53 | - |
|
| 54 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 55 | - if ( $form->get_id() ) { |
|
| 56 | - $form->set_earned( $form->get_earned() - $invoice->get_total() ); |
|
| 57 | - $form->save(); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Updates a form's failed amount. |
|
| 64 | - * |
|
| 65 | - * @param WPInv_Invoice $invoice |
|
| 66 | - * @param string $from |
|
| 67 | - * @param string $to |
|
| 68 | - */ |
|
| 69 | - public function update_form_failed_amount( $invoice, $from, $to ) { |
|
| 70 | - |
|
| 71 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 72 | - if ( $form->get_id() ) { |
|
| 73 | - return; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - if ( 'wpi-failed' == $from ) { |
|
| 77 | - $form->set_failed( $form->get_failed() - $invoice->get_total() ); |
|
| 78 | - $form->save(); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ( 'wpi-failed' == $to ) { |
|
| 82 | - $form->set_failed( $form->get_failed() + $invoice->get_total() ); |
|
| 83 | - $form->save(); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Updates a form's refunded amount. |
|
| 90 | - * |
|
| 91 | - * @param WPInv_Invoice $invoice |
|
| 92 | - * @param string $from |
|
| 93 | - * @param string $to |
|
| 94 | - */ |
|
| 95 | - public function update_form_refunded_amount( $invoice, $from, $to ) { |
|
| 96 | - |
|
| 97 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 98 | - if ( $form->get_id() ) { |
|
| 99 | - return; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - if ( 'wpi-refunded' == $from ) { |
|
| 103 | - $form->set_refunded( $form->get_refunded() - $invoice->get_total() ); |
|
| 104 | - $form->save(); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if ( 'wpi-refunded' == $to ) { |
|
| 108 | - $form->set_refunded( $form->get_refunded() + $invoice->get_total() ); |
|
| 109 | - $form->save(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Updates a form's cancelled amount. |
|
| 116 | - * |
|
| 117 | - * @param WPInv_Invoice $invoice |
|
| 118 | - * @param string $from |
|
| 119 | - * @param string $to |
|
| 120 | - */ |
|
| 121 | - public function update_form_cancelled_amount( $invoice, $from, $to ) { |
|
| 122 | - |
|
| 123 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 124 | - if ( $form->get_id() ) { |
|
| 125 | - return; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if ( 'wpi-cancelled' == $from ) { |
|
| 129 | - $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() ); |
|
| 130 | - $form->save(); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - if ( 'wpi-cancelled' == $to ) { |
|
| 134 | - $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() ); |
|
| 135 | - $form->save(); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - } |
|
| 16 | + * Class constructor |
|
| 17 | + * |
|
| 18 | + */ |
|
| 19 | + public function __construct() { |
|
| 20 | + |
|
| 21 | + // Update a payment form's revenue whenever an invoice is paid for or refunded. |
|
| 22 | + add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) ); |
|
| 23 | + add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) ); |
|
| 24 | + |
|
| 25 | + // Sync form amount whenever invoice statuses change. |
|
| 26 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 ); |
|
| 27 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 ); |
|
| 28 | + add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 ); |
|
| 29 | + |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Increments a form's revenue whenever there is a payment. |
|
| 34 | + * |
|
| 35 | + * @param WPInv_Invoice $invoice |
|
| 36 | + */ |
|
| 37 | + public function increment_form_revenue( $invoice ) { |
|
| 38 | + |
|
| 39 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 40 | + if ( $form->get_id() ) { |
|
| 41 | + $form->set_earned( $form->get_earned() + $invoice->get_total() ); |
|
| 42 | + $form->save(); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Decreases form revenue whenever invoice payment changes. |
|
| 49 | + * |
|
| 50 | + * @param WPInv_Invoice $invoice |
|
| 51 | + */ |
|
| 52 | + public function decrease_form_revenue( $invoice ) { |
|
| 53 | + |
|
| 54 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 55 | + if ( $form->get_id() ) { |
|
| 56 | + $form->set_earned( $form->get_earned() - $invoice->get_total() ); |
|
| 57 | + $form->save(); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Updates a form's failed amount. |
|
| 64 | + * |
|
| 65 | + * @param WPInv_Invoice $invoice |
|
| 66 | + * @param string $from |
|
| 67 | + * @param string $to |
|
| 68 | + */ |
|
| 69 | + public function update_form_failed_amount( $invoice, $from, $to ) { |
|
| 70 | + |
|
| 71 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 72 | + if ( $form->get_id() ) { |
|
| 73 | + return; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + if ( 'wpi-failed' == $from ) { |
|
| 77 | + $form->set_failed( $form->get_failed() - $invoice->get_total() ); |
|
| 78 | + $form->save(); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ( 'wpi-failed' == $to ) { |
|
| 82 | + $form->set_failed( $form->get_failed() + $invoice->get_total() ); |
|
| 83 | + $form->save(); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Updates a form's refunded amount. |
|
| 90 | + * |
|
| 91 | + * @param WPInv_Invoice $invoice |
|
| 92 | + * @param string $from |
|
| 93 | + * @param string $to |
|
| 94 | + */ |
|
| 95 | + public function update_form_refunded_amount( $invoice, $from, $to ) { |
|
| 96 | + |
|
| 97 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 98 | + if ( $form->get_id() ) { |
|
| 99 | + return; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + if ( 'wpi-refunded' == $from ) { |
|
| 103 | + $form->set_refunded( $form->get_refunded() - $invoice->get_total() ); |
|
| 104 | + $form->save(); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if ( 'wpi-refunded' == $to ) { |
|
| 108 | + $form->set_refunded( $form->get_refunded() + $invoice->get_total() ); |
|
| 109 | + $form->save(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Updates a form's cancelled amount. |
|
| 116 | + * |
|
| 117 | + * @param WPInv_Invoice $invoice |
|
| 118 | + * @param string $from |
|
| 119 | + * @param string $to |
|
| 120 | + */ |
|
| 121 | + public function update_form_cancelled_amount( $invoice, $from, $to ) { |
|
| 122 | + |
|
| 123 | + $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 124 | + if ( $form->get_id() ) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if ( 'wpi-cancelled' == $from ) { |
|
| 129 | + $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() ); |
|
| 130 | + $form->save(); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + if ( 'wpi-cancelled' == $to ) { |
|
| 134 | + $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() ); |
|
| 135 | + $form->save(); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | } |
@@ -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 | * Payment forms controller class |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | public function __construct() { |
| 20 | 20 | |
| 21 | 21 | // Update a payment form's revenue whenever an invoice is paid for or refunded. |
| 22 | - add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) ); |
|
| 23 | - add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) ); |
|
| 22 | + add_action('getpaid_invoice_payment_status_changed', array($this, 'increment_form_revenue')); |
|
| 23 | + add_action('getpaid_invoice_payment_status_reversed', array($this, 'decrease_form_revenue')); |
|
| 24 | 24 | |
| 25 | 25 | // Sync form amount whenever invoice statuses change. |
| 26 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 ); |
|
| 27 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 ); |
|
| 28 | - add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 ); |
|
| 26 | + add_action('getpaid_invoice_status_changed', array($this, 'update_form_failed_amount'), 10, 3); |
|
| 27 | + add_action('getpaid_invoice_status_changed', array($this, 'update_form_refunded_amount'), 10, 3); |
|
| 28 | + add_action('getpaid_invoice_status_changed', array($this, 'update_form_cancelled_amount'), 10, 3); |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param WPInv_Invoice $invoice |
| 36 | 36 | */ |
| 37 | - public function increment_form_revenue( $invoice ) { |
|
| 37 | + public function increment_form_revenue($invoice) { |
|
| 38 | 38 | |
| 39 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 40 | - if ( $form->get_id() ) { |
|
| 41 | - $form->set_earned( $form->get_earned() + $invoice->get_total() ); |
|
| 39 | + $form = new GetPaid_Payment_Form($invoice->get_payment_form()); |
|
| 40 | + if ($form->get_id()) { |
|
| 41 | + $form->set_earned($form->get_earned() + $invoice->get_total()); |
|
| 42 | 42 | $form->save(); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param WPInv_Invoice $invoice |
| 51 | 51 | */ |
| 52 | - public function decrease_form_revenue( $invoice ) { |
|
| 52 | + public function decrease_form_revenue($invoice) { |
|
| 53 | 53 | |
| 54 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 55 | - if ( $form->get_id() ) { |
|
| 56 | - $form->set_earned( $form->get_earned() - $invoice->get_total() ); |
|
| 54 | + $form = new GetPaid_Payment_Form($invoice->get_payment_form()); |
|
| 55 | + if ($form->get_id()) { |
|
| 56 | + $form->set_earned($form->get_earned() - $invoice->get_total()); |
|
| 57 | 57 | $form->save(); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -66,20 +66,20 @@ discard block |
||
| 66 | 66 | * @param string $from |
| 67 | 67 | * @param string $to |
| 68 | 68 | */ |
| 69 | - public function update_form_failed_amount( $invoice, $from, $to ) { |
|
| 69 | + public function update_form_failed_amount($invoice, $from, $to) { |
|
| 70 | 70 | |
| 71 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 72 | - if ( $form->get_id() ) { |
|
| 71 | + $form = new GetPaid_Payment_Form($invoice->get_payment_form()); |
|
| 72 | + if ($form->get_id()) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if ( 'wpi-failed' == $from ) { |
|
| 77 | - $form->set_failed( $form->get_failed() - $invoice->get_total() ); |
|
| 76 | + if ('wpi-failed' == $from) { |
|
| 77 | + $form->set_failed($form->get_failed() - $invoice->get_total()); |
|
| 78 | 78 | $form->save(); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( 'wpi-failed' == $to ) { |
|
| 82 | - $form->set_failed( $form->get_failed() + $invoice->get_total() ); |
|
| 81 | + if ('wpi-failed' == $to) { |
|
| 82 | + $form->set_failed($form->get_failed() + $invoice->get_total()); |
|
| 83 | 83 | $form->save(); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -92,20 +92,20 @@ discard block |
||
| 92 | 92 | * @param string $from |
| 93 | 93 | * @param string $to |
| 94 | 94 | */ |
| 95 | - public function update_form_refunded_amount( $invoice, $from, $to ) { |
|
| 95 | + public function update_form_refunded_amount($invoice, $from, $to) { |
|
| 96 | 96 | |
| 97 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 98 | - if ( $form->get_id() ) { |
|
| 97 | + $form = new GetPaid_Payment_Form($invoice->get_payment_form()); |
|
| 98 | + if ($form->get_id()) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if ( 'wpi-refunded' == $from ) { |
|
| 103 | - $form->set_refunded( $form->get_refunded() - $invoice->get_total() ); |
|
| 102 | + if ('wpi-refunded' == $from) { |
|
| 103 | + $form->set_refunded($form->get_refunded() - $invoice->get_total()); |
|
| 104 | 104 | $form->save(); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ( 'wpi-refunded' == $to ) { |
|
| 108 | - $form->set_refunded( $form->get_refunded() + $invoice->get_total() ); |
|
| 107 | + if ('wpi-refunded' == $to) { |
|
| 108 | + $form->set_refunded($form->get_refunded() + $invoice->get_total()); |
|
| 109 | 109 | $form->save(); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -118,20 +118,20 @@ discard block |
||
| 118 | 118 | * @param string $from |
| 119 | 119 | * @param string $to |
| 120 | 120 | */ |
| 121 | - public function update_form_cancelled_amount( $invoice, $from, $to ) { |
|
| 121 | + public function update_form_cancelled_amount($invoice, $from, $to) { |
|
| 122 | 122 | |
| 123 | - $form = new GetPaid_Payment_Form( $invoice->get_payment_form() ); |
|
| 124 | - if ( $form->get_id() ) { |
|
| 123 | + $form = new GetPaid_Payment_Form($invoice->get_payment_form()); |
|
| 124 | + if ($form->get_id()) { |
|
| 125 | 125 | return; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if ( 'wpi-cancelled' == $from ) { |
|
| 129 | - $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() ); |
|
| 128 | + if ('wpi-cancelled' == $from) { |
|
| 129 | + $form->set_cancelled($form->get_cancelled() - $invoice->get_total()); |
|
| 130 | 130 | $form->save(); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if ( 'wpi-cancelled' == $to ) { |
|
| 134 | - $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() ); |
|
| 133 | + if ('wpi-cancelled' == $to) { |
|
| 134 | + $form->set_cancelled($form->get_cancelled() + $invoice->get_total()); |
|
| 135 | 135 | $form->save(); |
| 136 | 136 | } |
| 137 | 137 | |