Skip to content

Commit

Permalink
Merge branch 'release/4.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Oct 11, 2022
2 parents f220aa2 + 8724a9f commit 7baee62
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 38 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ All notable changes to this project will be documented in this file.
This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com/).

## [Unreleased][unreleased]
-
- Removed `Gateway->update_subscription( Payment $payment )` method, no longer used. ([pronamic/wp-pay-core#41](https://github.com/pronamic/wp-pay-core/issues/41))
- Removed `Gateway->cancel_subscription( Subscription $subscription )` method, no longer used. ([pronamic/wp-pay-core#41](https://github.com/pronamic/wp-pay-core/issues/41)).
- Added support for multi-dimensional array in `Util::html_hidden_fields( $data )` method. ([pronamic/wp-pay-core#73](https://github.com/pronamic/wp-pay-core/issues/73))

## [4.4.1] - 2022-10-11
- Added support for multi-dimensional array in `Util::html_hidden_fields()` method (pronamic/wp-pay-core#73).
- Fixed setting empty consumer bank details object (pronamic/wp-pronamic-pay-mollie#11).
- Removed unused gateway subscription methods.

## [4.4.0] - 2022-09-26
- Fixed list table styling on mobile (pronamic/wp-pay-core#72).
Expand Down Expand Up @@ -524,7 +531,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0
- First release.

[unreleased]: https://github.com/pronamic/wp-pay-core/compare/4.4.0...HEAD
[unreleased]: https://github.com/pronamic/wp-pay-core/compare/4.4.1...HEAD
[4.4.1]: https://github.com/pronamic/wp-pay-core/compare/4.4.0...4.4.1
[4.4.0]: https://github.com/pronamic/wp-pay-core/compare/4.3.1...4.4.0
[4.3.1]: https://github.com/pronamic/wp-pay-core/compare/4.3.0...4.3.1
[4.3.0]: https://github.com/pronamic/wp-pay-core/compare/4.2.1...4.3.0
Expand Down
4 changes: 2 additions & 2 deletions docs/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ Argument | Type | Description
`$config_id` | `null\|int` | Gateway configuration ID.
`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment.

Source: [src/Plugin.php](../src/Plugin.php), [line 1134](../src/Plugin.php#L1134-L1140)
Source: [src/Plugin.php](../src/Plugin.php), [line 1135](../src/Plugin.php#L1135-L1141)

### `pronamic_payment_redirect_url_{$source}`

Expand All @@ -418,7 +418,7 @@ Argument | Type | Description
`$url` | `string` | Redirect URL.
`$payment` | `\Pronamic\WordPress\Pay\Payments\Payment` | Payment.

Source: [src/Plugin.php](../src/Plugin.php), [line 1384](../src/Plugin.php#L1384-L1390)
Source: [src/Plugin.php](../src/Plugin.php), [line 1385](../src/Plugin.php#L1385-L1391)

### `pronamic_gateway_configuration_display_value`

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": "@wp-pay/core",
"version": "4.4.0",
"version": "4.4.1",
"description": "Core components for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
20 changes: 0 additions & 20 deletions src/Core/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,26 +241,6 @@ public function start( Payment $payment ) {

}

/**
* Handle subscription update.
*
* @param Payment $payment The payment to handle subscription update for.
* @return void
*/
public function update_subscription( Payment $payment ) {

}

/**
* Handle subscription cancellation.
*
* @param Subscription $subscription The subscription to handle cancellation for.
* @return void
*/
public function cancel_subscription( Subscription $subscription ) {

}

/**
* Redirect to the gateway action URL.
*
Expand Down
27 changes: 14 additions & 13 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1032,26 +1032,27 @@ public static function complement_payment( Payment $payment ) {
}

// Consumer bank details.
$consumer_bank_details = $payment->get_consumer_bank_details();
$consumer_bank_details_name = $payment->get_meta( 'consumer_bank_details_name' );
$consumer_bank_details_iban = $payment->get_meta( 'consumer_bank_details_iban' );

if ( null === $consumer_bank_details ) {
$consumer_bank_details = new BankAccountDetails();
}
if ( null !== $consumer_bank_details_name || null !== $consumer_bank_details_iban ) {
$consumer_bank_details = $payment->get_consumer_bank_details();

$consumer_bank_details_name = $payment->get_meta( 'consumer_bank_details_name' );
if ( null === $consumer_bank_details ) {
$consumer_bank_details = new BankAccountDetails();
}

if ( null === $consumer_bank_details->get_name() && null !== $consumer_bank_details_name ) {
$consumer_bank_details->set_name( $consumer_bank_details_name );
}
if ( null === $consumer_bank_details->get_name() ) {
$consumer_bank_details->set_name( $consumer_bank_details_name );
}

$consumer_bank_details_iban = $payment->get_meta( 'consumer_bank_details_iban' );
if ( null === $consumer_bank_details->get_iban() ) {
$consumer_bank_details->set_iban( $consumer_bank_details_iban );
}

if ( null === $consumer_bank_details->get_iban() && null !== $consumer_bank_details_iban ) {
$consumer_bank_details->set_iban( $consumer_bank_details_iban );
$payment->set_consumer_bank_details( $consumer_bank_details );
}

$payment->set_consumer_bank_details( $consumer_bank_details );

// Payment lines payment.
$lines = $payment->get_lines();

Expand Down
26 changes: 26 additions & 0 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,30 @@ public static function format_frequency( $frequency ) {
return sprintf( _n( '%s period', '%s periods', $frequency, 'pronamic_ideal' ), $frequency );
}

/**
* Flattens a multi-dimensional array into a single level array that uses "square bracket" notation to indicate depth.
*
* @link https://github.com/pronamic/wp-pay-core/issues/73
* @param iterable $data Data.
* @param string $parent Parent.
* @param array $result Result.
* @return array
*/
private static function array_square_bracket( $data, $parent = '', $result = [] ) {
foreach ( $data as $key => $item ) {
if ( '' !== $parent ) {
$key = $parent . '[' . $key . ']';
}

if ( is_array( $item ) ) {
$result = self::array_square_bracket( $item, $key, $result );
} else {
$result[ $key ] = $item;
}
}

return $result;
}
/**
* Get hidden inputs HTML for data.
*
Expand All @@ -208,6 +232,8 @@ public static function format_frequency( $frequency ) {
public static function html_hidden_fields( $data ) {
$html = '';

$data = self::array_square_bracket( $data );

foreach ( $data as $name => $value ) {
$html .= sprintf( '<input type="hidden" name="%s" value="%s" />', esc_attr( $name ), esc_attr( $value ) );
}
Expand Down

0 comments on commit 7baee62

Please sign in to comment.