Skip to content

Commit

Permalink
Merge branch 'release/3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Sep 26, 2022
2 parents c87100a + c52a2c5 commit 23eae09
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 99 deletions.
15 changes: 15 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"core": null,
"plugins": [
".",
"../../../",
"https://downloads.wordpress.org/plugin/ninja-forms.3.6.13.zip",
"pronamic/wp-pronamic-pay-test-helper",
"https://downloads.wordpress.org/plugin/pronamic-client.zip",
"https://downloads.wordpress.org/plugin/query-monitor.zip",
"https://downloads.wordpress.org/plugin/one-time-login.zip"
],
"config": {
"PRONAMIC_PAY_DEBUG": true
}
}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [3.1.0] - 2022-09-26
- Updated for new payment methods and fields registration.

## [3.0.1] - 2022-02-16
- Fixed delaying all actions ([#4](https://github.com/pronamic/wp-pronamic-pay-ninjaforms/issues/4)).

Expand Down Expand Up @@ -57,7 +60,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0 - 2018-05-16
- First release.

[unreleased]: https://github.com/pronamic/wp-pronamic-pay-ninjaforms/compare/3.0.1...HEAD
[unreleased]: https://github.com/pronamic/wp-pronamic-pay-ninjaforms/compare/3.1.0...HEAD
[3.1.0]: https://github.com/pronamic/wp-pronamic-pay-ninjaforms/compare/3.0.1...3.1.0
[3.0.1]: https://github.com/pronamic/wp-pronamic-pay-ninjaforms/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/wp-pay-extensions/ninjaforms/compare/2.0.0...3.0.0
[2.0.0]: https://github.com/wp-pay-extensions/ninjaforms/compare/1.5.0...2.0.0
Expand Down
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"roots/wordpress-core-installer": true,
"bamarni/composer-bin-plugin": true
}
},
"repositories":[
{
Expand Down Expand Up @@ -55,7 +61,7 @@
},
"scripts": {
"coveralls": "vendor/bin/php-coveralls -v",
"phpcbf": "vendor/bin/phpcbf",
"phpcbf": "XDEBUG_MODE=off vendor/bin/phpcbf",
"phpcs": "XDEBUG_MODE=off vendor/bin/phpcs -s -v",
"phplint": "find src tests -name '*.php' | xargs -n 1 -P 4 php -l",
"phpmd": "vendor/bin/phpmd src,tests text phpmd.ruleset.xml --suffixes php",
Expand Down
16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wp-pay-extensions/ninjaforms",
"version": "3.0.1",
"version": "3.1.0",
"description": "Ninja Forms extension for making payments with Pronamic Pay.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -34,13 +34,23 @@
"last 2 versions"
],
"devDependencies": {
"@wordpress/env": "^5.2.0",
"grunt": "^1.3.0",
"grunt-contrib-jshint": "^3.0.0",
"grunt-phpcs": "^0.4.0",
"grunt-phplint": "0.1.0",
"grunt-phpmd": "^0.1.1",
"grunt-phpunit": "^0.3.6",
"load-grunt-tasks": "^5.1.0"
"load-grunt-tasks": "^5.1.0",
"npm-run-all": "^4.1.5"
},
"private": true
"private": true,
"scripts": {
"start": "wp-env start && npm run setup && npm run login",
"setup": "npm-run-all setup-*",
"setup-mollie": "wp-env run cli wp config set MOLLIE_API_KEY $MOLLIE_API_KEY",
"setup-buckaroo-website-key": "wp-env run cli wp config set BUCKAROO_WEBSITE_KEY $BUCKAROO_WEBSITE_KEY",
"setup-buckaroo-secret-key": "wp-env run cli wp config set BUCKAROO_SECRET_KEY $BUCKAROO_SECRET_KEY",
"login": "wp-env run cli wp user one-time-login admin"
}
}
41 changes: 41 additions & 0 deletions pronamic-pay-ninja-forms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Plugin Name: Pronamic Pay Ninja Forms Add-On
* Plugin URI: https://www.pronamic.eu/plugins/pronamic-pay-ninja-forms/
* Description: Extend the Pronamic Pay plugin with Ninja Forms support to receive payments through a variety of payment providers.
*
* Version: 4.1.0
* Requires at least: 4.7
*
* Author: Pronamic
* Author URI: https://www.pronamic.eu/
*
* Text Domain: pronamic-pay-ninja-forms
* Domain Path: /languages/
*
* License: GPL-3.0-or-later
*
* Depends: wp-pay/core
*
* GitHub URI: https://github.com/pronamic/wp-pronamic-pay-ninja-forms
*
* @author Pronamic <info@pronamic.eu>
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay\Extensions\NinjaForms
*/

add_filter(
'pronamic_pay_plugin_integrations',
function ( $integrations ) {
foreach ( $integrations as $integration ) {
if ( $integration instanceof \Pronamic\WordPress\Pay\Extensions\NinjaForms\Extension ) {
return $integrations;
}
}

$integrations[] = new \Pronamic\WordPress\Pay\Extensions\NinjaForms\Extension();

return $integrations;
}
);
48 changes: 24 additions & 24 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class Extension extends AbstractPluginIntegration {
*/
public function __construct() {
parent::__construct(
array(
[
'name' => __( 'Ninja Forms', 'pronamic_ideal' ),
)
]
);

// Dependencies.
Expand All @@ -49,26 +49,26 @@ public function __construct() {
* Setup.
*/
public function setup() {
\add_filter( 'pronamic_payment_source_description_' . self::SLUG, array( $this, 'source_description' ), 10, 2 );
\add_filter( 'pronamic_payment_source_text_' . self::SLUG, array( $this, 'source_text' ), 10, 2 );
\add_filter( 'pronamic_payment_source_description_' . self::SLUG, [ $this, 'source_description' ], 10, 2 );
\add_filter( 'pronamic_payment_source_text_' . self::SLUG, [ $this, 'source_text' ], 10, 2 );

// Check if dependencies are met and integration is active.
if ( ! $this->is_active() ) {
return;
}

\add_filter( 'pronamic_payment_source_url_' . self::SLUG, array( $this, 'source_url' ), 10, 2 );
\add_filter( 'pronamic_payment_redirect_url_' . self::SLUG, array( $this, 'redirect_url' ), 10, 2 );
\add_action( 'pronamic_payment_status_update_' . self::SLUG, array( $this, 'update_status' ) );
\add_filter( 'pronamic_payment_source_url_' . self::SLUG, [ $this, 'source_url' ], 10, 2 );
\add_filter( 'pronamic_payment_redirect_url_' . self::SLUG, [ $this, 'redirect_url' ], 10, 2 );
\add_action( 'pronamic_payment_status_update_' . self::SLUG, [ $this, 'update_status' ] );

\add_filter( 'ninja_forms_field_type_sections', array( $this, 'field_type_sections' ) );
\add_filter( 'ninja_forms_register_fields', array( $this, 'register_fields' ), 10, 3 );
\add_filter( 'ninja_forms_register_payment_gateways', array( $this, 'register_payment_gateways' ), 10, 1 );
\add_filter( 'ninja_forms_field_settings_groups', array( $this, 'register_settings_groups' ) );
\add_filter( 'ninja_forms_field_type_sections', [ $this, 'field_type_sections' ] );
\add_filter( 'ninja_forms_register_fields', [ $this, 'register_fields' ], 10, 3 );
\add_filter( 'ninja_forms_register_payment_gateways', [ $this, 'register_payment_gateways' ], 10, 1 );
\add_filter( 'ninja_forms_field_settings_groups', [ $this, 'register_settings_groups' ] );

// Delayed actions.
\add_filter( 'ninja_forms_submission_actions', array( $this, 'submission_actions' ), 10, 3 );
\add_action( 'ninja_forms_before_response', array( $this, 'maybe_update_session_before_response' ), 10, 1 );
\add_filter( 'ninja_forms_submission_actions', [ $this, 'submission_actions' ], 10, 3 );
\add_action( 'ninja_forms_before_response', [ $this, 'maybe_update_session_before_response' ], 10, 1 );
}

/**
Expand All @@ -79,11 +79,11 @@ public function setup() {
* @return array
*/
public function field_type_sections( $sections ) {
$sections['pronamic_pay'] = array(
$sections['pronamic_pay'] = [
'id' => 'pronamic_pay',
'nicename' => __( 'Pronamic Pay', 'pronamic_ideal' ),
'fieldTypes' => array(),
);
'fieldTypes' => [],
];

return $sections;
}
Expand Down Expand Up @@ -122,11 +122,11 @@ public function register_payment_gateways( $gateways ) {
* @return array
*/
public function register_settings_groups( $groups ) {
$groups['pronamic_pay'] = array(
$groups['pronamic_pay'] = [
'id' => 'pronamic_pay',
'label' => __( 'Pronamic Pay', 'pronamic_ideal' ),
'priority' => 200,
);
];

return $groups;
}
Expand Down Expand Up @@ -251,7 +251,7 @@ function( $handler ) {
* @param array $actions Actions.
* @param array $form_cache Form cache.
* @param array $form_data Form data.
* @retrun array
* @return array
*/
public function submission_actions( $actions, $form_cache, $form_data ) {
// Find active 'Collect payment' actions with our gateway.
Expand Down Expand Up @@ -326,7 +326,7 @@ public function submission_actions( $actions, $form_cache, $form_data ) {
* Maybe update Ninja Forms session before response.
*
* @param array $data Data.
* @retrun void
* @return void
*/
public function maybe_update_session_before_response( $data ) {
// Check if there are delayed actions.
Expand Down Expand Up @@ -417,10 +417,10 @@ public function source_url( $url, Payment $payment ) {
// Source ID could be a submission ID.
if ( 'nf_sub' === get_post_type( $source_id ) ) {
$url = add_query_arg(
array(
[
'post' => $source_id,
'action' => 'edit',
),
],
admin_url( 'post.php' )
);
}
Expand Down Expand Up @@ -451,10 +451,10 @@ public function source_text( $text, Payment $payment ) {
$text .= sprintf(
'<a href="%s">%s</a>',
add_query_arg(
array(
[
'post' => $source_id,
'action' => 'edit',
),
],
admin_url( 'post.php' )
),
/* translators: %s: source id */
Expand Down
40 changes: 18 additions & 22 deletions src/IssuersField.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Pronamic\WordPress\Pay\Extensions\NinjaForms;

use NF_Abstracts_List;
use Pronamic\WordPress\Pay\Fields\IDealIssuerSelectField;
use Pronamic\WordPress\Pay\Plugin;
use Pronamic\WordPress\Pay\Core\PaymentMethods;

Expand Down Expand Up @@ -76,7 +77,7 @@ class IssuersField extends NF_Abstracts_List {
*
* @var array
*/
protected $_settings = array();
protected $_settings = [];

/**
* Form ID.
Expand All @@ -93,11 +94,11 @@ public function __construct() {

$this->_nicename = __( 'Issuer', 'pronamic_ideal' );

$this->_settings['options']['value'] = array();
$this->_settings['options']['value'] = [];

// Actions.
\add_action( 'ninja_forms_render_options_' . $this->_type, array( $this, 'render_options' ), 10, 0 );
\add_action( 'nf_get_form_id', array( $this, 'set_form_id' ) );
\add_action( 'ninja_forms_render_options_' . $this->_type, [ $this, 'render_options' ], 10, 0 );
\add_action( 'nf_get_form_id', [ $this, 'set_form_id' ] );
}

/**
Expand Down Expand Up @@ -130,43 +131,38 @@ public function get_settings() {
* @return array
*/
public function render_options() {
$options = array();
$order = 0;

$action_settings = NinjaFormsHelper::get_collect_payment_action_settings( $this->form_id );

if ( null === $action_settings ) {
return $options;
return [];
}

$config_id = NinjaFormsHelper::get_config_id_from_action_settings( $action_settings );

$gateway = Plugin::get_gateway( $config_id );

if ( null === $gateway ) {
return $options;
return [];
}

$gateway->set_payment_method( PaymentMethods::IDEAL );
$issuer_field = $gateway->first_payment_method_field( PaymentMethods::IDEAL, IDealIssuerSelectField::class );

try {
$issuers = $gateway->get_transient_issuers();
} catch ( \Exception $e ) {
$issuers = null;
if ( null === $issuer_field ) {
return [];
}

if ( empty( $issuers ) ) {
return $options;
}
$options = [];

$order = 0;

foreach ( $issuers[0]['options'] as $value => $label ) {
$options[] = array(
'label' => $label,
'value' => $value,
foreach ( $issuer_field->get_flat_options() as $option ) {
$options[] = [
'label' => $option->label,
'value' => $option->value,
'calc' => '',
'selected' => 0,
'order' => ++$order,
);
];
}

return $options;
Expand Down
2 changes: 1 addition & 1 deletion src/NinjaFormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function get_collect_payment_action_settings( $form_id ) {
* @return array<int>
*/
public static function get_delayed_action_ids_from_settings( $action_settings ) {
$delayed_actions = array();
$delayed_actions = [];

foreach ( $action_settings as $key => $value ) {
// Check settings key.
Expand Down
Loading

0 comments on commit 23eae09

Please sign in to comment.