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

Commit

Permalink
Merge branch 'release/2.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Oct 4, 2019
2 parents 8dd5f35 + c877278 commit 0ab575f
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 16 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [2.0.4] - 2019-10-04
- Send user first and last name to list servers.
- Added s2Member plugin dependency.
- Added support for list server opt-in.

## [2.0.3] - 2019-08-26
- Updated packages.

Expand Down Expand Up @@ -50,15 +55,16 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
- Added HTML admin views from the Pronamic iDEAL plugin.

## [1.1.1] - 2015-03-03
- Changed WordPress pay core library requirment from ~1.0.0 to >=1.0.0.
- Changed WordPress pay core library requirment from `~1.0.0` to `>=1.0.0`.

## [1.1.0] - 2015-02-12
- Show errors if they occur.

## 1.0.0 - 2015-01-20
- First release.

[unreleased]: https://github.com/wp-pay-extensions/s2member/compare/2.0.3...HEAD
[unreleased]: https://github.com/wp-pay-extensions/s2member/compare/2.0.4...HEAD
[2.0.4]: https://github.com/wp-pay-extensions/s2member/compare/2.0.3...2.0.4
[2.0.3]: https://github.com/wp-pay-extensions/s2member/compare/2.0.2...2.0.3
[2.0.2]: https://github.com/wp-pay-extensions/s2member/compare/2.0.1...2.0.2
[2.0.1]: https://github.com/wp-pay-extensions/s2member/compare/2.0.0...2.0.1
Expand Down
22 changes: 21 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@
"config": {
"sort-packages": true
},
"repositories": [
{
"type": "package",
"package": {
"name": "wpsharks/s2member",
"version": "190822",
"source": {
"url": "https://github.com/wpsharks/s2member",
"type": "git",
"reference": "master"
},
"autoload": {
"classmap": [
"."
]
}
}
}
],
"require": {
"php": ">=5.6.20",
"wp-pay/core": "^2.2"
Expand All @@ -45,7 +64,8 @@
"roots/wordpress": "^5.2",
"squizlabs/php_codesniffer": "^3.4",
"wp-coding-standards/wpcs": "^2.1",
"wp-phpunit/wp-phpunit": "^5.2"
"wp-phpunit/wp-phpunit": "^5.2",
"wpsharks/s2member": "190822"
},
"scripts": {
"coveralls": "vendor/bin/coveralls -v",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s2member",
"version": "2.0.3",
"version": "2.0.4",
"description": "s2Member driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
44 changes: 35 additions & 9 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace Pronamic\WordPress\Pay\Extensions\S2Member;

use c_ws_plugin__s2member_list_servers;
use c_ws_plugin__s2member_utils_time;
use Pronamic\WordPress\Pay\Core\Statuses;
use Pronamic\WordPress\Pay\Core\Server;
use Pronamic\WordPress\Pay\Payments\PaymentStatus;
use Pronamic\WordPress\Pay\Core\Util as Core_Util;
use Pronamic\WordPress\Pay\Payments\Payment;
use Pronamic\WordPress\Pay\Subscriptions\Subscription;
use WP_User;
Expand Down Expand Up @@ -132,7 +135,7 @@ public static function default_option_s2member_subscription_renewal_notice_email
* @param Payment $payment Payment.
*/
public static function update_status( Payment $payment ) {
if ( Statuses::SUCCESS !== $payment->get_status() ) {
if ( PaymentStatus::SUCCESS !== $payment->get_status() ) {
return;
}

Expand All @@ -150,6 +153,8 @@ public static function update_status( Payment $payment ) {
return;
}

$random_string = '';

// No valid user?
if ( ! $user ) {
// Make a random string for password.
Expand Down Expand Up @@ -253,15 +258,36 @@ public static function update_status( Payment $payment ) {
add_filter( 'ws_plugin__s2member_eot_grace_time', '__return_zero' );

// Calculate EOT time for period from today.
$eot_time_new = c_ws_plugin__s2member_utils_time::auto_eot_time( 0, false, false, $period, 0, $eot_time_current );
$eot_time_new = c_ws_plugin__s2member_utils_time::auto_eot_time( 0, '', '', $period, 0, $eot_time_current );

remove_filter( 'ws_plugin__s2member_eot_grace_time', '__return_zero' );
} else {
$eot_time_new = c_ws_plugin__s2member_utils_time::auto_eot_time( $user->ID, false, $period, false, $eot_time_current );
$eot_time_new = c_ws_plugin__s2member_utils_time::auto_eot_time( $user->ID, '', $period, false, $eot_time_current );
}

update_user_option( $user->ID, 's2member_auto_eot_time', $eot_time_new );
}

// Subscribe with list servers.
if ( Core_Util::class_method_exists( 'c_ws_plugin__s2member_list_servers', 'process_list_servers' ) ) {
// IP address.
$ip = Server::get( 'REMOTE_ADDR' );

$customer = $payment->customer;

if ( null !== $customer ) {
$ip = $customer->get_ip_address();
}

// Name.
$first_name = $user->first_name;
$last_name = $user->last_name;

// Opt in?
$opt_in = 1 === \intval( get_post_meta( $payment->get_id(), '_pronamic_payment_s2member_opt_in', true ) );

c_ws_plugin__s2member_list_servers::process_list_servers( $role, $level, $email, $random_string, $email, $first_name, $last_name, $ip, $opt_in, true, $user->ID );
}
}

/**
Expand All @@ -281,35 +307,35 @@ public static function status_update( Payment $payment, $can_redirect = false )
$user = get_user_by( 'email', $payment->get_email() );

switch ( $payment->status ) {
case Statuses::CANCELLED:
case PaymentStatus::CANCELLED:
$url = $data->get_cancel_url();

if ( $payment->get_recurring() ) {
Util::auto_eot_now_user_update( $user );
}

break;
case Statuses::EXPIRED:
case PaymentStatus::EXPIRED:
$url = $data->get_error_url();

if ( $payment->get_recurring() ) {
Util::auto_eot_now_user_update( $user );
}

break;
case Statuses::FAILURE:
case PaymentStatus::FAILURE:
$url = $data->get_error_url();

if ( $payment->get_recurring() ) {
Util::auto_eot_now_user_update( $user );
}

break;
case Statuses::SUCCESS:
case PaymentStatus::SUCCESS:
$url = $data->get_success_url();

break;
case Statuses::OPEN:
case PaymentStatus::OPEN:
$url = $data->get_normal_return_url();

break;
Expand Down
26 changes: 23 additions & 3 deletions src/Shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Pronamic\WordPress\Pay\Extensions\S2Member;

use c_ws_plugin__s2member_list_servers;
use Pronamic\WordPress\Pay\Core\Util as Core_Util;
use Pronamic\WordPress\Pay\Exceptions\PayException;
use Pronamic\WordPress\Pay\Plugin;
use Pronamic\WordPress\Pay\Util as Pay_Util;

Expand Down Expand Up @@ -152,6 +155,17 @@ public function shortcode_pay( $atts ) {
$output .= ' ';
}

// List servers opt-in checkbox.
if ( Core_Util::class_method_exists( 'c_ws_plugin__s2member_list_servers', 'list_servers_integrated' ) && ! empty( $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in'] ) && c_ws_plugin__s2member_list_servers::list_servers_integrated() ) {
$output .= sprintf(
'<label for="pronamic_pay_s2member_opt_in">
<input type="checkbox" name="pronamic_pay_s2member_opt_in" id="pronamic_pay_s2member_opt_in" value="1" %1$s /> %2$s
</label><br />',
checked( $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in'], 1, false ),
$GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in_label']
);
}

$output .= $gateway->get_input_html();

$output .= ' ';
Expand Down Expand Up @@ -191,9 +205,10 @@ public function handle_payment() {
return;
}

$index = filter_input( INPUT_POST, 'pronamic_pay_s2member_index', FILTER_SANITIZE_STRING );
$hash = filter_input( INPUT_POST, 'pronamic_pay_s2member_hash', FILTER_SANITIZE_STRING );
$data = filter_input( INPUT_POST, 'pronamic_pay_s2member_data', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
$index = filter_input( INPUT_POST, 'pronamic_pay_s2member_index', FILTER_SANITIZE_STRING );
$hash = filter_input( INPUT_POST, 'pronamic_pay_s2member_hash', FILTER_SANITIZE_STRING );
$data = filter_input( INPUT_POST, 'pronamic_pay_s2member_data', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
$opt_in = filter_input( INPUT_POST, 'pronamic_pay_s2member_opt_in', FILTER_SANITIZE_NUMBER_INT );

if ( $hash !== $this->create_hash( $data ) ) {
return;
Expand Down Expand Up @@ -221,6 +236,11 @@ public function handle_payment() {
update_post_meta( $payment->get_id(), '_pronamic_payment_s2member_level', $data->get_level() );
update_post_meta( $payment->get_id(), '_pronamic_payment_s2member_ccaps', $data->get_ccaps() );

// List server opt-in.
if ( ! empty( $opt_in ) ) {
update_post_meta( $payment->get_id(), '_pronamic_payment_s2member_opt_in', $opt_in );
}

if ( $payment->get_subscription_id() ) {
update_post_meta( $payment->get_subscription_id(), '_pronamic_subscription_s2member_period', $data->get_period() );
update_post_meta( $payment->get_subscription_id(), '_pronamic_subscription_s2member_level', $data->get_level() );
Expand Down

0 comments on commit 0ab575f

Please sign in to comment.