1010
1111namespace Pronamic \WordPress \Pay \Extensions \WPeCommerce ;
1212
13+ use Pronamic \WordPress \Pay \AbstractPluginIntegration ;
1314use Pronamic \WordPress \Pay \Payments \PaymentStatus ;
1415use Pronamic \WordPress \Pay \Extensions \WPeCommerce \Gateways \Gateway ;
1516use Pronamic \WordPress \Pay \Payments \Payment ;
2223 * Company: Pronamic
2324 *
2425 * @author Remco Tolsma
25- * @version 2.0.4
26+ * @version 2.1.1
2627 * @since 1.0.0
2728 */
28- class Extension extends \ Pronamic \ WordPress \ Pay \ AbstractPluginIntegration {
29+ class Extension extends AbstractPluginIntegration {
2930 /**
3031 * Slug
3132 *
@@ -41,34 +42,45 @@ class Extension extends \Pronamic\WordPress\Pay\AbstractPluginIntegration {
4142 const OPTION_PRONAMIC_PAYMENT_METHOD = 'pronamic_pay_pronamic_wpsc_payment_method ' ;
4243
4344 /**
44- * Construct WP eCommerce extension.
45- *
46- * @param array $args Arguments.
45+ * Construct Ninja Forms plugin integration.
4746 */
48- public function __construct ( $ args = array () ) {
49- parent ::__construct ( $ args );
47+ public function __construct () {
48+ parent ::__construct (
49+ array (
50+ 'name ' => __ ( 'WP eCommerce ' , 'pronamic_ideal ' ),
51+ )
52+ );
53+
54+ // Dependencies.
55+ $ dependencies = $ this ->get_dependencies ();
5056
51- self :: bootstrap ( );
57+ $ dependencies -> add ( new WPeCommerceDependency () );
5258 }
5359
5460 /**
55- * Bootstrap
61+ * Setup.
5662 */
57- public static function bootstrap () {
63+ public function setup () {
64+ \add_filter ( 'pronamic_payment_source_description_ ' . self ::SLUG , array ( $ this , 'source_description ' ), 10 , 2 );
65+
66+ // Check if dependencies are met and integration is active.
67+ if ( ! $ this ->is_active () ) {
68+ return ;
69+ }
70+
5871 // Add gateways.
59- add_filter ( 'wpsc_merchants_modules ' , array ( __CLASS__ , 'merchants_modules ' ) );
72+ \ add_filter ( 'wpsc_merchants_modules ' , array ( $ this , 'merchants_modules ' ) );
6073
6174 // Save gateway options.
62- add_action ( 'wpsc_submit_gateway_options ' , array ( __CLASS__ , 'submit_gateway_options ' ) );
75+ \ add_action ( 'wpsc_submit_gateway_options ' , array ( $ this , 'submit_gateway_options ' ) );
6376
6477 // Update payment status.
65- add_action ( 'pronamic_payment_status_update_ ' . self ::SLUG , array ( __CLASS__ , 'status_update ' ), 10 , 2 );
78+ \ add_action ( 'pronamic_payment_status_update_ ' . self ::SLUG , array ( $ this , 'status_update ' ), 10 , 2 );
6679
6780 // Filters.
68- add_filter ( 'pronamic_payment_redirect_url_ ' . self ::SLUG , array ( __CLASS__ , 'redirect_url ' ), 10 , 2 );
69- add_filter ( 'pronamic_payment_source_text_ ' . self ::SLUG , array ( __CLASS__ , 'source_text ' ), 10 , 2 );
70- add_filter ( 'pronamic_payment_source_description_ ' . self ::SLUG , array ( __CLASS__ , 'source_description ' ), 10 , 2 );
71- add_filter ( 'pronamic_payment_source_url_ ' . self ::SLUG , array ( __CLASS__ , 'source_url ' ), 10 , 2 );
81+ \add_filter ( 'pronamic_payment_redirect_url_ ' . self ::SLUG , array ( $ this , 'redirect_url ' ), 10 , 2 );
82+ \add_filter ( 'pronamic_payment_source_text_ ' . self ::SLUG , array ( $ this , 'source_text ' ), 10 , 2 );
83+ \add_filter ( 'pronamic_payment_source_url_ ' . self ::SLUG , array ( $ this , 'source_url ' ), 10 , 2 );
7284 }
7385
7486 /**
@@ -78,7 +90,7 @@ public static function bootstrap() {
7890 *
7991 * @return array
8092 */
81- public static function merchants_modules ( $ gateways = array () ) {
93+ public function merchants_modules ( $ gateways = array () ) {
8294 global $ nzshpcrt_gateways , $ num , $ wpsc_gateways , $ gateway_checkout_form_fields ;
8395
8496 $ classes = array (
@@ -174,7 +186,7 @@ public static function merchants_modules( $gateways = array() ) {
174186 /**
175187 * Process gateway options submit.
176188 */
177- public static function submit_gateway_options () {
189+ public function submit_gateway_options () {
178190 // Get gateways.
179191 $ gateways = self ::merchants_modules ();
180192
@@ -194,19 +206,14 @@ public static function submit_gateway_options() {
194206 * @param Payment $payment Payment.
195207 * @param bool $can_redirect Whether or not to redirect.
196208 */
197- public static function status_update ( Payment $ payment , $ can_redirect = false ) {
209+ public function status_update ( Payment $ payment , $ can_redirect = false ) {
198210 $ merchant = new Gateway ( $ payment ->get_source_id () );
199211
200212 switch ( $ payment ->status ) {
201213 case PaymentStatus::CANCELLED :
202214 $ merchant ->set_purchase_processed_by_purchid ( WPeCommerce::PURCHASE_STATUS_INCOMPLETE_SALE );
203215
204216 break ;
205-
206- case PaymentStatus::EXPIRED :
207- case PaymentStatus::FAILURE :
208- break ;
209-
210217 case PaymentStatus::SUCCESS :
211218 /*
212219 * Transactions results
@@ -220,7 +227,8 @@ public static function status_update( Payment $payment, $can_redirect = false )
220227 $ merchant ->set_purchase_processed_by_purchid ( WPeCommerce::PURCHASE_STATUS_ACCEPTED_PAYMENT );
221228
222229 break ;
223-
230+ case PaymentStatus::EXPIRED :
231+ case PaymentStatus::FAILURE :
224232 case PaymentStatus::OPEN :
225233 default :
226234 break ;
@@ -235,7 +243,7 @@ public static function status_update( Payment $payment, $can_redirect = false )
235243 *
236244 * @return string
237245 */
238- public static function redirect_url ( $ url , Payment $ payment ) {
246+ public function redirect_url ( $ url , Payment $ payment ) {
239247 // URL arguments.
240248 $ args = array (
241249 'sessionid ' => $ payment ->get_meta ( 'wpsc_session_id ' ),
@@ -290,7 +298,7 @@ public static function redirect_url( $url, Payment $payment ) {
290298 *
291299 * @return string
292300 */
293- public static function source_text ( $ text , Payment $ payment ) {
301+ public function source_text ( $ text , Payment $ payment ) {
294302 $ text = __ ( 'WP e-Commerce ' , 'pronamic_ideal ' ) . '<br /> ' ;
295303
296304 $ text .= sprintf (
@@ -317,7 +325,7 @@ public static function source_text( $text, Payment $payment ) {
317325 *
318326 * @return string
319327 */
320- public static function source_description ( $ description , Payment $ payment ) {
328+ public function source_description ( $ description , Payment $ payment ) {
321329 return __ ( 'WP e-Commerce Purchase ' , 'pronamic_ideal ' );
322330 }
323331
@@ -329,7 +337,7 @@ public static function source_description( $description, Payment $payment ) {
329337 *
330338 * @return string
331339 */
332- public static function source_url ( $ url , Payment $ payment ) {
340+ public function source_url ( $ url , Payment $ payment ) {
333341 $ url = add_query_arg (
334342 array (
335343 'page ' => 'wpsc-purchase-logs ' ,
0 commit comments