Skip to content
This repository was archived by the owner on Jan 10, 2022. It is now read-only.

Commit 50665a5

Browse files
committed
Merge branch 'release/2.1.1'
2 parents 9ee16ea + 55e7eac commit 50665a5

4 files changed

Lines changed: 81 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
77
## [Unreleased][unreleased]
88
-
99

10+
## [2.1.1] - 2020-04-03
11+
- Updated integration dependencies.
12+
- Set plugin integration name.
13+
1014
## [2.1.0] - 2020-03-19
1115
- Extend `Extension` class from `AbstractPluginIntegration`.
1216

@@ -50,7 +54,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
5054
### Added
5155
- First release.
5256

53-
[unreleased]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.1.0...HEAD
57+
[unreleased]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.1.1...HEAD
58+
[2.1.1]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.1.0...2.1.1
5459
[2.1.0]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.0.4...2.1.0
5560
[2.0.4]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.0.2...2.0.4
5661
[2.0.3]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.0.2...2.0.3

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wp-e-commerce",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "WP eCommerce driver for the WordPress payment processing library.",
55
"repository": {
66
"type": "git",

src/Extension.php

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Pronamic\WordPress\Pay\Extensions\WPeCommerce;
1212

13+
use Pronamic\WordPress\Pay\AbstractPluginIntegration;
1314
use Pronamic\WordPress\Pay\Payments\PaymentStatus;
1415
use Pronamic\WordPress\Pay\Extensions\WPeCommerce\Gateways\Gateway;
1516
use Pronamic\WordPress\Pay\Payments\Payment;
@@ -22,10 +23,10 @@
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',

src/WPeCommerceDependency.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* WP eCommerce Dependency
4+
*
5+
* @author Pronamic <info@pronamic.eu>
6+
* @copyright 2005-2020 Pronamic
7+
* @license GPL-3.0-or-later
8+
* @package Pronamic\WordPress\Pay\Extensions\WPeCommerce
9+
*/
10+
11+
namespace Pronamic\WordPress\Pay\Extensions\WPeCommerce;
12+
13+
use Pronamic\WordPress\Pay\Dependencies\Dependency;
14+
15+
/**
16+
* WP eCommerce Dependency
17+
*
18+
* @author Reüel van der Steege
19+
* @version 2.1.1
20+
* @since 2.1.1
21+
*/
22+
class WPeCommerceDependency extends Dependency {
23+
/**
24+
* Is met.
25+
*
26+
* @link
27+
* @return bool True if dependency is met, false otherwise.
28+
*/
29+
public function is_met() {
30+
if ( ! \class_exists( '\WP_eCommerce' ) ) {
31+
return false;
32+
}
33+
34+
return true;
35+
}
36+
}

0 commit comments

Comments
 (0)