@@ -13,30 +13,30 @@ discard block |
||
| 13 | 13 | class GetPaid_Manual_Gateway extends GetPaid_Payment_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 = 'manual'; |
| 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', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * Payment method order. |
|
| 31 | - * |
|
| 32 | - * @var int |
|
| 33 | - */ |
|
| 34 | - public $order = 11; |
|
| 30 | + * Payment method order. |
|
| 31 | + * |
|
| 32 | + * @var int |
|
| 33 | + */ |
|
| 34 | + public $order = 11; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Class constructor. |
|
| 38 | - */ |
|
| 39 | - public function __construct() { |
|
| 37 | + * Class constructor. |
|
| 38 | + */ |
|
| 39 | + public function __construct() { |
|
| 40 | 40 | parent::__construct(); |
| 41 | 41 | |
| 42 | 42 | $this->title = __( 'Test Gateway', 'invoicing' ); |
@@ -46,15 +46,15 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * Process Payment. |
|
| 50 | - * |
|
| 51 | - * |
|
| 52 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 53 | - * @param array $submission_data Posted checkout fields. |
|
| 54 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 49 | + * Process Payment. |
|
| 50 | + * |
|
| 51 | + * |
|
| 52 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 53 | + * @param array $submission_data Posted checkout fields. |
|
| 54 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 58 | 58 | |
| 59 | 59 | // Mark it as paid. |
| 60 | 60 | $invoice->mark_paid(); |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | - * (Maybe) renews a manual subscription profile. |
|
| 89 | - * |
|
| 90 | - * |
|
| 88 | + * (Maybe) renews a manual subscription profile. |
|
| 89 | + * |
|
| 90 | + * |
|
| 91 | 91 | * @param WPInv_Subscription $subscription |
| 92 | - */ |
|
| 93 | - public function maybe_renew_subscription( $subscription ) { |
|
| 92 | + */ |
|
| 93 | + public function maybe_renew_subscription( $subscription ) { |
|
| 94 | 94 | |
| 95 | 95 | // Ensure its our subscription && it's active. |
| 96 | 96 | if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | - * Processes invoice addons. |
|
| 114 | - * |
|
| 115 | - * @param WPInv_Invoice $invoice |
|
| 116 | - * @param GetPaid_Form_Item[] $items |
|
| 117 | - * @return WPInv_Invoice |
|
| 118 | - */ |
|
| 119 | - public function process_addons( $invoice, $items ) { |
|
| 113 | + * Processes invoice addons. |
|
| 114 | + * |
|
| 115 | + * @param WPInv_Invoice $invoice |
|
| 116 | + * @param GetPaid_Form_Item[] $items |
|
| 117 | + * @return WPInv_Invoice |
|
| 118 | + */ |
|
| 119 | + public function process_addons( $invoice, $items ) { |
|
| 120 | 120 | |
| 121 | 121 | foreach ( $items as $item ) { |
| 122 | 122 | $invoice->add_item( $item ); |
@@ -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 | * Manual Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
| 27 | + protected $supports = array('subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups'); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Payment method order. |
@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | public function __construct() { |
| 40 | 40 | parent::__construct(); |
| 41 | 41 | |
| 42 | - $this->title = __( 'Test Gateway', 'invoicing' ); |
|
| 43 | - $this->method_title = __( 'Test Gateway', 'invoicing' ); |
|
| 42 | + $this->title = __('Test Gateway', 'invoicing'); |
|
| 43 | + $this->method_title = __('Test Gateway', 'invoicing'); |
|
| 44 | 44 | |
| 45 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) ); |
|
| 45 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription')); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -54,25 +54,25 @@ discard block |
||
| 54 | 54 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 55 | 55 | * @return array |
| 56 | 56 | */ |
| 57 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 57 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 58 | 58 | |
| 59 | 59 | // Mark it as paid. |
| 60 | 60 | $invoice->mark_paid(); |
| 61 | 61 | |
| 62 | 62 | // (Maybe) activate subscriptions. |
| 63 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 63 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 64 | 64 | |
| 65 | - if ( ! empty( $subscriptions ) ) { |
|
| 66 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
| 65 | + if (!empty($subscriptions)) { |
|
| 66 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
| 67 | 67 | |
| 68 | - foreach ( $subscriptions as $subscription ) { |
|
| 69 | - if ( $subscription->exists() ) { |
|
| 70 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
| 71 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
| 68 | + foreach ($subscriptions as $subscription) { |
|
| 69 | + if ($subscription->exists()) { |
|
| 70 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
| 71 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
| 72 | 72 | |
| 73 | - $subscription->set_next_renewal_date( $expiry ); |
|
| 74 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 75 | - $subscription->set_profile_id( $invoice->generate_key( 'manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) ); |
|
| 73 | + $subscription->set_next_renewal_date($expiry); |
|
| 74 | + $subscription->set_date_created(current_time('mysql')); |
|
| 75 | + $subscription->set_profile_id($invoice->generate_key('manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id())); |
|
| 76 | 76 | $subscription->activate(); |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // Send to the success page. |
| 83 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
| 83 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param WPInv_Subscription $subscription |
| 92 | 92 | */ |
| 93 | - public function maybe_renew_subscription( $subscription ) { |
|
| 93 | + public function maybe_renew_subscription($subscription) { |
|
| 94 | 94 | |
| 95 | 95 | // Ensure its our subscription && it's active. |
| 96 | - if ( $this->id == $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
| 96 | + if ($this->id == $subscription->get_gateway() && $subscription->has_status('active trialling')) { |
|
| 97 | 97 | |
| 98 | 98 | // Renew the subscription. |
| 99 | 99 | $subscription->add_payment( |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | * @param GetPaid_Form_Item[] $items |
| 117 | 117 | * @return WPInv_Invoice |
| 118 | 118 | */ |
| 119 | - public function process_addons( $invoice, $items ) { |
|
| 119 | + public function process_addons($invoice, $items) { |
|
| 120 | 120 | |
| 121 | - foreach ( $items as $item ) { |
|
| 122 | - $invoice->add_item( $item ); |
|
| 121 | + foreach ($items as $item) { |
|
| 122 | + $invoice->add_item($item); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $invoice->recalculate_total(); |