Skip to content

Commit

Permalink
Merge branch 'release/4.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Jan 10, 2022
2 parents 6113584 + 9b4ebf3 commit 1926934
Show file tree
Hide file tree
Showing 18 changed files with 317 additions and 227 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -285,32 +285,3 @@ jobs:
run: |
composer run-script coveralls
bash <(curl -s https://codecov.io/bash)
es-sass-linting:
name: Scripts and Styles

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

# https://github.com/actions/cache/blob/master/examples.md#macos-and-ubuntu
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v1
with:
node-version: '12'

- name: Install Node packages
run: npm install

- name: ESLint
run: npm run-script eslint

- name: Sass Lint
run: npm run-script sass-lint
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [4.0.0] - 2022-01-10
### Changed
- Updated to https://github.com/pronamic/wp-pay-core/releases/tag/4.0.0.
- Added support for checkboxes field type.
- Don't force description to have a dynamic part (use `[id]` in transaction description setting instead).

## [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`.
Expand Down Expand Up @@ -66,7 +72,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0 - 2015-11-05
- First release.

[unreleased]: https://github.com/wp-pay-extensions/formidable-forms/compare/3.0.0...HEAD
[unreleased]: https://github.com/wp-pay-extensions/formidable-forms/compare/4.0.0...HEAD
[4.0.0]: https://github.com/wp-pay-extensions/formidable-forms/compare/3.0.0...4.0.0
[3.0.0]: https://github.com/wp-pay-extensions/formidable-forms/compare/2.2.1...3.0.0
[2.2.1]: https://github.com/wp-pay-extensions/formidable-forms/compare/2.2.0...2.2.1
[2.2.0]: https://github.com/wp-pay-extensions/formidable-forms/compare/2.1.4...2.2.0
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"require": {
"php": ">=5.6.20",
"wp-pay/core": "^3.0"
"wp-pay/core": "^4.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
Expand All @@ -48,7 +48,9 @@
"phpunit/phpunit": "^5.7 || ^6.0",
"pronamic/wp-coding-standards": "^1.0",
"roots/wordpress": "^5.8",
"wp-phpunit/wp-phpunit": "^5.8"
"wp-phpunit/wp-phpunit": "^5.8",
"wpackagist-plugin/formidable": "^5.0",
"yoast/phpunit-polyfills": "^1.0"
},
"scripts": {
"coveralls": "vendor/bin/php-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": "formidable-forms",
"version": "3.0.0",
"version": "4.0.0",
"description": "Formidable Forms driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ parameters:
level: max
bootstrapFiles:
- tests/phpstan/bootstrap.php
scanDirectories:
- wp-content/formidable
paths:
- src/
2 changes: 1 addition & 1 deletion src/BankSelectFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Title: Formidable Forms bank select field type
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
39 changes: 21 additions & 18 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Title: Formidable Forms extension
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down Expand Up @@ -370,16 +370,18 @@ public function redirect_for_payment( $entry_id, $form_id ) {
$payment->source_id = $entry_id;
$payment->order_id = $entry_id;

$payment->description = FormidableFormsHelper::get_description( $this->action, $form_id, $entry, $entry_id );
$description = FormidableFormsHelper::get_description( $this->action, $form_id, $entry, $entry_id );

if ( empty( $payment->description ) ) {
$payment->description = sprintf(
if ( empty( $description ) ) {
$description = \sprintf(
'%s #%s',
__( 'Submission', 'pronamic_ideal' ),
$payment->source_id
);
}

$payment->set_description( $description );

$payment->title = \sprintf(
/* translators: %s: payment data title */
__( 'Payment for %s', 'pronamic_ideal' ),
Expand All @@ -390,30 +392,31 @@ public function redirect_for_payment( $entry_id, $form_id ) {
)
);

// Currency.
$currency = Currency::get_instance( FormidableFormsHelper::get_currency_from_settings() );

// Amount.
$payment->set_total_amount( new Money( FormidableFormsHelper::get_amount_from_field( $this->action, $entry ), $currency ) );
$payment->set_total_amount( FormidableFormsHelper::get_amount_from_field( $this->action, $entry ) );

// Payment method.
$payment_method = FormidableFormsHelper::get_payment_method_from_action_entry( $this->action, $entry );

// Method.
$payment->method = FormidableFormsHelper::get_payment_method_from_action_entry( $this->action, $entry );
$payment->set_payment_method( $payment_method );

// Only start payments for known/active payment methods.
if ( is_string( $payment->method ) && ! PaymentMethods::is_active( $payment->method ) ) {
if ( null !== $payment_method && ! PaymentMethods::is_active( $payment_method ) ) {
return;
}

if ( empty( $payment->method ) ) {
if ( null !== FormidableFormsHelper::get_issuer_from_form_entry( $form_id, $entry ) ) {
$payment->method = PaymentMethods::IDEAL;
} elseif ( $gateway->payment_method_is_required() ) {
$payment->method = PaymentMethods::IDEAL;
}
// Check issuer in form entry.
if ( empty( $payment_method ) && null !== FormidableFormsHelper::get_issuer_from_form_entry( $form_id, $entry ) ) {
$payment->set_payment_method( PaymentMethods::IDEAL );
}

// Check if gateway requires payment method.
if ( empty( $payment_method ) && $gateway->payment_method_is_required() ) {
$payment->set_payment_method( PaymentMethods::IDEAL );
}

// Issuer.
$payment->issuer = FormidableFormsHelper::get_issuer_from_form_entry( $form_id, $entry );
$payment->set_meta( 'issuer', FormidableFormsHelper::get_issuer_from_form_entry( $form_id, $entry ) );

// Origin.
$payment->set_origin_id( FormidableFormsHelper::get_origin_id_from_entry( $entry ) );
Expand Down
2 changes: 1 addition & 1 deletion src/FormidableForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Title: WordPress pay Formidable Forms
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
2 changes: 1 addition & 1 deletion src/FormidableFormsDependency.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Formidable Forms Dependency
*
* @author Pronamic <info@pronamic.eu>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay\Extensions\FormidableForms
*/
Expand Down
37 changes: 26 additions & 11 deletions src/FormidableFormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Formidable Forms Helper
*
* @author Pronamic <info@pronamic.eu>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay\Extensions\FormidableForms
*/
Expand All @@ -13,6 +13,7 @@
use FrmField;
use FrmFieldsHelper;
use FrmProAppHelper;
use Pronamic\WordPress\Money\Money;
use Pronamic\WordPress\Money\Parser;

/**
Expand Down Expand Up @@ -73,11 +74,6 @@ public static function get_description( $action, $form_id, $entry, $entry_id ) {
*/
$description = FrmFieldsHelper::replace_content_shortcodes( $description_template, $entry, $shortcodes );

// Check if there was a replacement to make sure the description has a dynamic part.
if ( $description_template === $description ) {
$description .= $entry_id;
}

return $description;
}

Expand Down Expand Up @@ -137,17 +133,36 @@ public static function get_issuer_from_form_entry( $form_id, $entry ) {
*
* @param unknowm $action Action.
* @param unknown $entry Entry.
* @return float
* @return Money
*/
public static function get_amount_from_field( $action, $entry ) {
$amount = 0;
$amount = new Money( 0, self::get_currency_from_settings() );

// Check amount field.
$amount_field = $action->post_content['pronamic_pay_amount_field'];

if ( ! empty( $amount_field ) && isset( $entry->metas[ $amount_field ] ) ) {
$parser = new Parser();
if ( empty( $amount_field ) || ! isset( $entry->metas[ $amount_field ] ) ) {
return $amount;
}

$amount = $parser->parse( $entry->metas[ $amount_field ] )->get_value();
// Make sure to use an array (for checkboxes fields).
$values = $entry->metas[ $amount_field ];

if ( ! \is_array( $values ) ) {
$values = array( $values );
}

// Add values to amount.
$parser = new Parser();

foreach ( $values as $value ) {
try {
$money = $parser->parse( $value );

$amount = $amount->add( $money );
} catch ( \Exception $e ) {
continue;
}
}

return $amount;
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Title: Formidable Forms payment action
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentMethodSelectFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Title: Formidable Forms payment method select field type
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Bootstrap tests
*
* @author Pronamic <info@pronamic.eu>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay\Extensions\FormidableForms
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/phpstan/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Definitions for PHPStan.
*
* @author Pronamic <info@pronamic.eu>
* @copyright 2005-2021 Pronamic
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/src/FormidableFormsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Title: WordPress pay Formidable Forms test
* Description:
* Copyright: 2005-2021 Pronamic
* Copyright: 2005-2022 Pronamic
* Company: Pronamic
*
* @author Remco Tolsma
Expand Down
Loading

0 comments on commit 1926934

Please sign in to comment.