Skip to content

Commit

Permalink
Merge branch 'release/4.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Sep 26, 2022
2 parents 58ed620 + e205b87 commit 41d9ab6
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 156 deletions.
13 changes: 13 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"core": null,
"plugins": [
".",
"../../../",
"https://downloads.wordpress.org/plugin/easy-digital-downloads.3.0.3.zip",
"https://downloads.wordpress.org/plugin/query-monitor.zip",
"https://downloads.wordpress.org/plugin/one-time-login.zip"
],
"config": {
"PRONAMIC_PAY_DEBUG": true
}
}
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## [Unreleased][unreleased]
-

## [4.2.0] - 2022-09-26
- Fixed Easy Digital Downloads 3 compatibility.
- Updated for new payment methods and fields registration.

## [4.1.0] - 2022-04-11
- Add company name controller.

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

[unreleased]: https://github.com/wp-pay-extensions/easy-digital-downloads/compare/4.1.0...HEAD
[unreleased]: https://github.com/wp-pay-extensions/easy-digital-downloads/compare/4.2.0...HEAD
[4.2.0]: https://github.com/pronamic/wp-pronamic-pay-easy-digital-downloads/compare/4.1.0...4.2.0
[4.1.0]: https://github.com/pronamic/wp-pronamic-pay-easy-digital-downloads/compare/4.0.0...4.1.0
[4.0.0]: https://github.com/wp-pay-extensions/easy-digital-downloads/compare/3.0.0...4.0.0
[3.0.0]: https://github.com/wp-pay-extensions/easy-digital-downloads/compare/2.2.0...3.0.0
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "easy-digital-downloads",
"version": "4.1.0",
"version": "4.2.0",
"description": "Easy Digital Downloads driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -35,12 +35,17 @@
},
"homepage": "http://www.wp-pay.org/extensions/easy-digital-downloads/",
"devDependencies": {
"@wordpress/env": "^5.2.0",
"grunt": "~1.0.4",
"grunt-contrib-jshint": "^2.1.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"
},
"scripts": {
"start": "wp-env start",
"login": "wp-env run cli wp user one-time-login admin"
}
}
41 changes: 41 additions & 0 deletions pronamic-pay-easy-digital-downloads.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Plugin Name: Pronamic Pay Easy Digital Downloads Add-On
* Plugin URI: https://www.pronamic.eu/plugins/pronamic-pay-easy-digital-downloads/
* Description: Extend the Pronamic Pay plugin with Easy Digital Downloads 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-easy-digital-downloads
* Domain Path: /languages/
*
* License: GPL-3.0-or-later
*
* Depends: wp-pay/core
*
* GitHub URI: https://github.com/pronamic/wp-pronamic-pay-easy-digital-downloads
*
* @author Pronamic <[email protected]>
* @copyright 2005-2022 Pronamic
* @license GPL-3.0-or-later
* @package Pronamic\WordPress\Pay\Extensions\EasyDigitalDownloads
*/

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

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

return $integrations;
}
);
2 changes: 1 addition & 1 deletion src/CompanyNameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function purchase_form() {
);

?>

</div>
</fieldset>
<?php
Expand Down
148 changes: 10 additions & 138 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,22 @@ public function __construct() {
$dependencies = $this->get_dependencies();

$dependencies->add( new EasyDigitalDownloadsDependency() );

/**
* Plugins loaded.
*
* @link https://github.com/pronamic/wp-pronamic-pay-easy-digital-downloads/issues/3
*/
add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
}

/**
* Setup plugin integration.
* Plugins loaded.
*
* @link https://github.com/pronamic/wp-pronamic-pay-easy-digital-downloads/issues/3
* @return void
*/
public function setup() {
public function plugins_loaded() {
add_filter( 'pronamic_payment_source_text_easydigitaldownloads', [ $this, 'source_text' ], 10, 2 );
add_filter( 'pronamic_payment_source_description_easydigitaldownloads', [ $this, 'source_description' ], 10, 2 );

Expand Down Expand Up @@ -97,12 +105,6 @@ public function setup() {
// Icons.
add_filter( 'edd_accepted_payment_icons', [ __CLASS__, 'accepted_payment_icons' ] );

// Currencies.
add_filter( 'edd_currencies', [ __CLASS__, 'currencies' ], 10, 1 );
add_filter( 'edd_currency_symbol', [ __CLASS__, 'currency_symbol' ], 10, 2 );
add_filter( 'edd_nlg_currency_filter_before', [ __CLASS__, 'currency_filter_before' ], 10, 3 );
add_filter( 'edd_nlg_currency_filter_after', [ __CLASS__, 'currency_filter_after' ], 10, 3 );

// Statuses.
add_filter( 'edd_payment_statuses', [ __CLASS__, 'edd_payment_statuses' ] );
add_filter( 'edd_payments_table_views', [ $this, 'payments_table_views' ] );
Expand Down Expand Up @@ -150,7 +152,6 @@ private static function get_payment_methods() {
'pronamic_pay_direct_debit_sofort' => PaymentMethods::DIRECT_DEBIT_SOFORT,
'pronamic_pay_focum' => PaymentMethods::FOCUM,
'pronamic_pay_giropay' => PaymentMethods::GIROPAY,
'pronamic_pay_gulden' => PaymentMethods::GULDEN,
'pronamic_pay_idealqr' => PaymentMethods::IDEALQR,
'pronamic_pay_in3' => PaymentMethods::IN3,
'pronamic_pay_kbc' => PaymentMethods::KBC,
Expand Down Expand Up @@ -220,7 +221,6 @@ public static function redirect_url( $url, $payment ) {
\edd_get_payment_key( $source_id ),
\edd_get_success_page_uri()
);
case Core_Statuses::RESERVED:
case Core_Statuses::OPEN:
return \home_url( '/' );
}
Expand Down Expand Up @@ -281,48 +281,6 @@ public static function status_update( Payment $payment ) {
case Core_Statuses::FAILURE:
\edd_update_payment_status( $source_id, EasyDigitalDownloads::ORDER_STATUS_FAILED );

break;
case Core_Statuses::RESERVED:
$note = [
\sprintf(
'%s %s.',
PaymentMethods::get_name( $payment->get_payment_method() ),
\__( 'payment reserved at gateway', 'pronamic_ideal' )
),
];

$gateway = Plugin::get_gateway( (int) $payment->get_config_id() );

if ( null !== $gateway && $gateway->supports( 'reservation_payments' ) ) {
$payment_edit_link = \add_query_arg(
[
'post' => $payment->get_id(),
'action' => 'edit',
],
\admin_url( 'post.php' )
);

$payment_link = \sprintf(
'<a href="%1$s">%2$s</a>',
$payment_edit_link,
\sprintf(
/* translators: %s: payment id */
\esc_html( __( 'payment #%s', 'pronamic_ideal' ) ),
$payment->get_id()
)
);

$note[] = \sprintf(
/* translators: %s: payment edit link */
__( 'Create an invoice at payment gateway for %1$s after processing the order.', 'pronamic_ideal' ),
$payment_link // WPCS: xss ok.
);
}

$note = \implode( ' ', $note );

\edd_insert_payment_note( $source_id, $note );

break;
case Core_Statuses::SUCCESS:
\edd_insert_payment_note( $source_id, __( 'Payment completed.', 'pronamic_ideal' ) );
Expand All @@ -348,92 +306,6 @@ public static function status_update( Payment $payment ) {
}
}

/**
* Filter currencies.
*
* @param array<string, string> $currencies Available currencies.
* @return array<string, string>
*/
public static function currencies( $currencies ) {
if ( PaymentMethods::is_active( PaymentMethods::GULDEN ) ) {
$currencies['NLG'] = sprintf(
/* translators: %s: Gulden */
'%s (G)',
PaymentMethods::get_name( PaymentMethods::GULDEN )
);
}

return $currencies;
}

/**
* Filter currency symbol.
*
* @param string $symbol Symbol.
* @param string $currency Currency.
*
* @return string
*/
public static function currency_symbol( $symbol, $currency ) {
if ( 'NLG' === $currency ) {
$symbol = 'G';
}

return $symbol;
}

/**
* Filter currency before.
*
* @param string $formatted Formatted symbol and price.
* @param string $currency Currency.
* @param string $price Price.
*
* @return string
*/
public static function currency_filter_before( $formatted, $currency, $price ) {
if ( ! function_exists( 'edd_currency_symbol' ) ) {
return $formatted;
}

$symbol = edd_currency_symbol( $currency );

switch ( $currency ) {
case 'NLG':
$formatted = $symbol . $price;

break;
}

return $formatted;
}

/**
* Filter currency after.
*
* @param string $formatted Formatted symbol and price.
* @param string $currency Currency.
* @param string $price Price.
*
* @return string
*/
public static function currency_filter_after( $formatted, $currency, $price ) {
if ( ! function_exists( 'edd_currency_symbol' ) ) {
return $formatted;
}

$symbol = edd_currency_symbol( $currency );

switch ( $currency ) {
case 'NLG':
$formatted = $price . $symbol;

break;
}

return $formatted;
}

/**
* Source column
*
Expand Down
37 changes: 23 additions & 14 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,30 +227,39 @@ public function payment_fields() {
return;
}

/*
* Let the gateway know which payment method to use so it can return the correct inputs.
* @since 1.2.1
*/
$gateway->set_payment_method( $this->payment_method );
$payment_method = $gateway->get_payment_method( $this->payment_method );

if ( null === $payment_method ) {
return;
}

$fields = $gateway->get_input_fields();
$fields = $payment_method->get_fields();

// Check if there are fields to display.
if ( empty( $fields ) ) {
return;
}

echo '<fieldset id="edd_cc_fields" class="edd-do-validate">';
echo '<fieldset class="edd-do-validate">';
echo '<legend>', \esc_html( $this->checkout_label ), '</legend>';

foreach ( $fields as $field ) {
// Make field required.
$field['label'] .= ' <span class="edd-required-indicator">*</span>';
$field['required'] = true;
$label = $field->get_label();

if ( $field->is_required() ) {
$label .= ' <span class="edd-required-indicator">*</span>';
}

echo '<p>';

\printf(
'<label for="%s">%s</label>',
\esc_attr( $field->get_id() ),
\esc_html( $label )
);

$field->output();

// @codingStandardsIgnoreStart
\printf( '<p>%s</p>', Util::input_fields_html( [ $field ] ) );
// @codingStandardsIgnoreEnd
echo '</p>';
}

echo '</fieldset>';
Expand Down

0 comments on commit 41d9ab6

Please sign in to comment.