Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Aug 5, 2021
2 parents a0ec541 + e03d49e commit 28f775e
Show file tree
Hide file tree
Showing 12 changed files with 361 additions and 219 deletions.
35 changes: 23 additions & 12 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
build:
nodes:
analysis:
tests:
override:
- php-scrutinizer-run

coverage:
tests:
override:
- command: ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
coverage:
file: build/logs/clover.xml
format: clover

environment:
php: 7.3.0
variables:
WP_TESTS_DB_NAME: 'wp_phpunit_tests'
WP_TESTS_DB_USER: 'root'
WP_TESTS_DB_PASS: ''
WP_TESTS_DB_HOST: 'localhost'
project_setup:
before:
- mysql -e "CREATE DATABASE wp_phpunit_tests"
WP_TESTS_DB_HOST: '127.0.0.1'

services:
mysql: 5.7

dependencies:
override:
- composer install --ignore-platform-reqs --no-interaction
nodes:
coverage:
tests:
override:
- command: ./vendor/bin/phpunit
coverage:
file: build/logs/clover.xml
format: clover

project_setup:
before:
- mysql -e "CREATE DATABASE wp_phpunit_tests"

checks:
php:
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [3.0.0] - 2021-08-05
- Updated to `pronamic/wp-pay-core` version `3.0.0`.
- Updated to `pronamic/wp-money` version `2.0.0`.
- Changed `TaxedMoney` to `Money`, no tax info.
- Switched to `pronamic/wp-coding-standards`.
- Process `0` value for frequency as infinite periods definition for subscription phase.

## [2.7.0] - 2021-06-18
- Added initial support for refunds [#119](https://github.com/pronamic/wp-pronamic-pay/issues/119).

Expand Down Expand Up @@ -306,7 +313,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0 - 2015-01-01
- First release.

[unreleased]: https://github.com/wp-pay-extensions/gravityforms/compare/2.7.0...HEAD
[unreleased]: https://github.com/wp-pay-extensions/gravityforms/compare/3.0.0...HEAD
[3.0.0]: https://github.com/wp-pay-extensions/gravityforms/compare/2.7.0...3.0.0
[2.7.0]: https://github.com/wp-pay-extensions/gravityforms/compare/2.6.1...2.7.0
[2.6.1]: https://github.com/wp-pay-extensions/gravityforms/compare/2.6.0...2.6.1
[2.6.0]: https://github.com/wp-pay-extensions/gravityforms/compare/2.5.2...2.6.0
Expand Down
12 changes: 4 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,16 @@
"require": {
"php": ">=5.6.20",
"pronamic/wp-gravityforms-nl": "^3.0",
"wp-pay/core": "^2.6"
"wp-pay/core": "^3.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"php-coveralls/php-coveralls": "^2.4",
"phpcompatibility/php-compatibility": "^9.3",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpmd/phpmd": "^2.9",
"phpunit/phpunit": "^5.7 || ^6.0",
"roots/wordpress": "^5.6",
"squizlabs/php_codesniffer": "^3.5",
"wp-coding-standards/wpcs": "^2.3",
"wp-phpunit/wp-phpunit": "^5.6",
"pronamic/wp-coding-standards": "^1.0",
"roots/wordpress": "^5.8",
"wp-phpunit/wp-phpunit": "^5.8",
"wp-premium/gravityforms": "^2.3"
},
"scripts": {
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": "gravityforms",
"version": "2.7.0",
"version": "3.0.0",
"description": "Gravity Forms driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
25 changes: 5 additions & 20 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,44 +1,29 @@
<?xml version="1.0"?>

<ruleset name="WordPress Pay Gravity Forms rules">
<config name="minimum_supported_wp_version" value="4.7" />

<config name="testVersion" value="5.6-" />

<file>.</file>

<arg name="colors"/>
<arg name="extensions" value="php" />
<arg name="parallel" value="8" />
<arg value="sp" />

<exclude-pattern>node_modules/*</exclude-pattern>
<exclude-pattern>tests/bootstrap.php</exclude-pattern>
<exclude-pattern>tests/wp-config.php</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>wordpress/*</exclude-pattern>
<exclude-pattern type="relative">^wp-content/*</exclude-pattern>

<rule ref="PHPCompatibilityWP" />

<rule ref="WordPress">
<exclude name="Generic.Files.LowercasedFilename.NotFound" />
<rule ref="PronamicWP">
<exclude name="Squiz.Commenting" />

<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />

<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_key" />
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_query" />

<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />

<exclude name="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase" />

<exclude name="WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize" />

<exclude name="WordPress.Security.SafeRedirect.wp_redirect_wp_redirect" />

<exclude name="WordPress.WP.GlobalVariablesOverride.Prohibited" />

<exclude name="WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsUnknown" />
<exclude name="WordPressVIPMinimum.Security.PHPFilterFunctions.MissingThirdParameter" />
</rule>

<rule ref="WordPress.WP.GlobalVariablesOverride.OverrideProhibited">
Expand Down
4 changes: 0 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>

<php>
<env name="WP_PHPUNIT__TESTS_CONFIG" value="tests/wp-config.php" />
</php>
Expand Down
4 changes: 2 additions & 2 deletions src/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public static function bootstrap() {
add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
add_action( 'admin_init', array( __CLASS__, 'maybe_redirect_to_entry' ) );

// Filters.
add_filter( 'gform_entry_info', array( __CLASS__, 'entry_info' ), 10, 2 );
add_action( 'gform_entry_info', array( __CLASS__, 'entry_info' ), 10, 2 );

// Filters.
add_filter( 'gform_custom_merge_tags', array( __CLASS__, 'custom_merge_tags' ), 10 );

// Actions - AJAX.
Expand Down
12 changes: 7 additions & 5 deletions src/PaymentData.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

use GFCommon;
use Pronamic\WordPress\DateTime\DateTime;
use Pronamic\WordPress\Money\Money;
use Pronamic\WordPress\Money\TaxedMoney;
use Pronamic\WordPress\Pay\Core\PaymentMethods;
use Pronamic\WordPress\Pay\Core\Util as Core_Util;
use Pronamic\WordPress\Pay\CreditCard;
Expand Down Expand Up @@ -233,22 +231,26 @@ public function get_credit_card() {
* @return int|null
*/
public function get_subscription_frequency() {
$frequency = null;

switch ( $this->feed->subscription_frequency_type ) {
case GravityForms::SUBSCRIPTION_FREQUENCY_FIELD:
$field = RGFormsModel::get_field( $this->form, $this->feed->subscription_frequency_field );

if ( ! RGFormsModel::is_field_hidden( $this->form, $field, array(), $this->lead ) ) {
if ( isset( $this->lead[ $this->feed->subscription_frequency_field ] ) ) {
return intval( $this->lead[ $this->feed->subscription_frequency_field ] );
$frequency = intval( $this->lead[ $this->feed->subscription_frequency_field ] );
}
}

break;
case GravityForms::SUBSCRIPTION_FREQUENCY_FIXED:
return \intval( $this->feed->subscription_number_periods );
$frequency = \intval( $this->feed->subscription_number_periods );

break;
}

return null;
return empty( $frequency ) ? null : $frequency;
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use GFCommon;
use Pronamic\WordPress\Money\Currency;
use Pronamic\WordPress\Money\TaxedMoney;
use Pronamic\WordPress\Money\Money;
use Pronamic\WordPress\Pay\AbstractGatewayIntegration;
use Pronamic\WordPress\Pay\Address;
use Pronamic\WordPress\Pay\Banks\BankAccountDetails;
Expand Down Expand Up @@ -350,13 +350,13 @@ public function entry_post_save( $lead, $form ) {
if ( array_key_exists( 'price', $product ) ) {
$value = GFCommon::to_number( $product['price'] );

$line->set_unit_price( new TaxedMoney( $value, $currency ) );
$line->set_unit_price( new Money( $value, $currency ) );

if ( array_key_exists( 'quantity', $product ) ) {
$value = ( $value * intval( $product['quantity'] ) );
}

$line->set_total_amount( new TaxedMoney( $value, $currency ) );
$line->set_total_amount( new Money( $value, $currency ) );
}

if ( array_key_exists( 'quantity', $product ) ) {
Expand All @@ -380,9 +380,9 @@ public function entry_post_save( $lead, $form ) {
if ( array_key_exists( 'price', $option ) ) {
$value = GFCommon::to_number( $option['price'] );

$line->set_unit_price( new TaxedMoney( $value, $currency ) );
$line->set_unit_price( new Money( $value, $currency ) );

$line->set_total_amount( new TaxedMoney( $value, $currency ) );
$line->set_total_amount( new Money( $value, $currency ) );
}
}
}
Expand Down Expand Up @@ -419,9 +419,9 @@ public function entry_post_save( $lead, $form ) {
if ( array_key_exists( 'price', $shipping ) ) {
$value = $shipping['price'];

$line->set_unit_price( new TaxedMoney( $value, $currency ) );
$line->set_unit_price( new Money( $value, $currency ) );

$line->set_total_amount( new TaxedMoney( $value, $currency ) );
$line->set_total_amount( new Money( $value, $currency ) );
}
}
}
Expand Down
Loading

0 comments on commit 28f775e

Please sign in to comment.