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 9182ff0 + 77ba9ea commit c6c1792
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 62 deletions.
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]
-

## [4.2.0] - 2022-09-26
- Updated payment methods registration.

## [4.1.0] - 2022-04-11
- No longer use core gateweay mode.

Expand Down Expand Up @@ -68,7 +71,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
## 1.0.0 - 2016-07-06
- First release.

[unreleased]: https://github.com/wp-pay-gateways/ems-e-commerce/compare/4.1.0...HEAD
[unreleased]: https://github.com/wp-pay-gateways/ems-e-commerce/compare/4.2.0...HEAD
[4.2.0]: https://github.com/pronamic/wp-pronamic-pay-ems-e-commerce/compare/4.1.0...4.2.0
[4.1.0]: https://github.com/wp-pay-gateways/ems-e-commerce/compare/4.0.0...4.1.0
[4.0.0]: https://github.com/wp-pay-gateways/ems-e-commerce/compare/3.0.1...4.0.0
[3.0.1]: https://github.com/wp-pay-gateways/ems-e-commerce/compare/3.0.0...3.0.1
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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": "vendor/bin/phplint",
"phpmd": "vendor/bin/phpmd src,tests text phpmd.ruleset.xml --suffixes php",
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": "ems-e-commerce",
"version": "4.1.0",
"version": "4.2.0",
"description": "EMS e-Commerce Gateway driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
12 changes: 6 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public function set_transaction_datetime( DateTime $datetime ) {
*/
public function get_data() {
// Required fields for payment request.
$required_fields = array(
$required_fields = [
'txntype' => 'sale',
// According the EMS documentation the timezone should be in `Area/Location` notation, but it seems like `UTC` is also working.
'timezone' => 'UTC',
Expand All @@ -385,10 +385,10 @@ public function get_data() {
*/
'chargetotal' => $this->amount->number_format( null, '.', '' ),
'currency' => $this->get_currency_numeric_code(),
);
];

// Optional fields for payment request.
$optional_fields = array(
$optional_fields = [
'oid' => $this->get_order_id(),
'language' => $this->get_language(),
'paymentMethod' => $this->get_payment_method(),
Expand All @@ -397,7 +397,7 @@ public function get_data() {
'transactionNotificationURL' => $this->get_notification_url(),
'idealIssuerID' => $this->get_issuer_id(),
'ems_notify_payment_id' => (string) $this->get_payment_id(),
);
];

// @link http://briancray.com/2009/04/25/remove-null-values-php-arrays/
$optional_fields = array_filter( $optional_fields );
Expand Down Expand Up @@ -436,13 +436,13 @@ public function get_hash() {
$data = $this->get_data();
$secret = $this->get_secret();

$values = array(
$values = [
$data['storename'],
$data['txndatetime'],
$data['chargetotal'],
$data['currency'],
$secret,
);
];

return self::compute_hash( $values );
}
Expand Down
35 changes: 13 additions & 22 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Pronamic\WordPress\Pay\Gateways\EMS\ECommerce;

use Pronamic\WordPress\Pay\Core\Gateway as Core_Gateway;
use Pronamic\WordPress\Pay\Core\PaymentMethod;
use Pronamic\WordPress\Pay\Core\PaymentMethods as Core_PaymentMethods;
use Pronamic\WordPress\Pay\Payments\PaymentStatus;
use Pronamic\WordPress\Pay\Payments\Payment;
Expand Down Expand Up @@ -39,7 +40,7 @@ class Gateway extends Core_Gateway {
* @return void
*/
public function __construct( Config $config ) {
parent::__construct( $config );
parent::__construct();

$this->config = $config;

Expand All @@ -51,22 +52,12 @@ public function __construct( Config $config ) {
$this->client->set_action_url( $config->get_action_url() );
$this->client->set_storename( (string) $config->storename );
$this->client->set_secret( (string) $config->secret );
}

/**
* Get supported payment methods.
*
* @return array<string>
*
* @see Core_Gateway::get_supported_payment_methods()
*/
public function get_supported_payment_methods() {
return array(
Core_PaymentMethods::BANCONTACT,
Core_PaymentMethods::IDEAL,
Core_PaymentMethods::PAYPAL,
Core_PaymentMethods::SOFORT,
);
// Methods.
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::BANCONTACT ) );
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::IDEAL ) );
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::PAYPAL ) );
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::SOFORT ) );
}

/**
Expand Down Expand Up @@ -137,26 +128,26 @@ public function update_status( Payment $payment ) {

$input_hash = filter_input( INPUT_POST, 'response_hash' );

$hash_values = array(
$hash_values = [
$this->client->get_secret(),
$approval_code,
filter_input( INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING ),
filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_STRING ),
filter_input( INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING ),
$this->client->get_storename(),
);
];

if ( filter_has_var( INPUT_POST, 'notification_hash' ) ) {
$input_hash = filter_input( INPUT_POST, 'notification_hash' );

$hash_values = array(
$hash_values = [
filter_input( INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING ),
$this->client->get_secret(),
filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_STRING ),
filter_input( INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING ),
$this->client->get_storename(),
$approval_code,
);
];
}

$hash = Client::compute_hash( $hash_values );
Expand Down Expand Up @@ -190,7 +181,7 @@ public function update_status( Payment $payment ) {
// Set the status of the payment.
$payment->set_status( $status );

$labels = array(
$labels = [
'approval_code' => __( 'Approval code', 'pronamic_ideal' ),
'oid' => __( 'Order ID', 'pronamic_ideal' ),
'refnumber' => _x( 'Reference number', 'creditcard', 'pronamic_ideal' ),
Expand All @@ -205,7 +196,7 @@ public function update_status( Payment $payment ) {
'ccbin' => __( 'Creditcard issuing bank', 'pronamic_ideal' ),
'cccountry' => __( 'Creditcard country', 'pronamic_ideal' ),
'ccbrand' => __( 'Creditcard brand', 'pronamic_ideal' ),
);
];

$note = '';

Expand Down
44 changes: 23 additions & 21 deletions src/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@ class Integration extends AbstractGatewayIntegration {
*
* @param array<string, mixed> $args Arguments.
*/
public function __construct( $args = array() ) {
public function __construct( $args = [] ) {
$args = wp_parse_args(
$args,
array(
[
'id' => 'ems-ecommerce',
'name' => 'EMS e-Commerce',
'action_url' => Client::ACTION_URL_PRODUCTION,
'provider' => 'ems',
'product_url' => null,
'dashboard_url' => 'https://www.ipg-online.com/vt/login',
'supports' => array(
'supports' => [
'webhook',
'webhook_log',
'webhook_no_config',
),
],
'manual_url' => \__( 'https://www.pronamic.eu/support/how-to-connect-ems-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ),
)
]
);

parent::__construct( $args );

$this->action_url = $args['action_url'];

// Actions
$function = array( __NAMESPACE__ . '\Listener', 'listen' );
$function = [ __NAMESPACE__ . '\Listener', 'listen' ];

if ( ! has_action( 'wp_loaded', $function ) ) {
add_action( 'wp_loaded', $function );
Expand All @@ -64,39 +64,41 @@ public function __construct( $args = array() ) {
* @return array<int, array<string, callable|int|string|bool|array<int|string,int|string>>>
*/
public function get_settings_fields() {
$fields = array();
$fields = [];

// Storename.
$fields[] = array(
$fields[] = [
'section' => 'general',
'filter' => FILTER_UNSAFE_RAW,
'meta_key' => '_pronamic_gateway_ems_ecommerce_storename',
'title' => _x( 'Storename', 'ems', 'pronamic_ideal' ),
'type' => 'text',
'classes' => array( 'code' ),
);
'classes' => [ 'code' ],
'required' => true,
];

// Shared secret.
$fields[] = array(
$fields[] = [
'section' => 'general',
'filter' => FILTER_UNSAFE_RAW,
'meta_key' => '_pronamic_gateway_ems_ecommerce_secret',
'title' => _x( 'Shared Secret', 'ems', 'pronamic_ideal' ),
'type' => 'text',
'classes' => array( 'large-text', 'code' ),
);
'classes' => [ 'large-text', 'code' ],
'required' => true,
];

// Purchase ID.
$fields[] = array(
$fields[] = [
'section' => 'advanced',
'filter' => array(
'filter' => [
'filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_FLAG_NO_ENCODE_QUOTES,
),
],
'meta_key' => '_pronamic_gateway_ems_ecommerce_order_id',
'title' => __( 'Order ID', 'pronamic_ideal' ),
'type' => 'text',
'classes' => array( 'regular-text', 'code' ),
'classes' => [ 'regular-text', 'code' ],
'tooltip' => sprintf(
/* translators: %s: <code>{orderId}</code> */
__( 'The EMS e-Commerce %s parameter.', 'pronamic_ideal' ),
Expand All @@ -116,15 +118,15 @@ public function get_settings_fields() {
'{payment_id}'
)
),
);
];

// Notification URL.
$fields[] = array(
$fields[] = [
'section' => 'feedback',
/* translators: Translate 'notification' the same as in the EMS e-Commerce dashboard. */
'title' => _x( 'Notification URL', 'EMS e-Commerce', 'pronamic_ideal' ),
'type' => 'text',
'classes' => array( 'large-text', 'code' ),
'classes' => [ 'large-text', 'code' ],
'value' => home_url( '/' ),
'readonly' => true,
/* translators: Translate 'notification' the same as in the EMS e-Commerce dashboard. */
Expand All @@ -133,7 +135,7 @@ public function get_settings_fields() {
'EMS e-Commerce',
'pronamic_ideal'
),
);
];

return $fields;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/src/PaymentMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public function test_transform( $wp_payment_method, $expected ) {
}

public function status_matrix_provider() {
return array(
array( Core_PaymentMethods::IDEAL, PaymentMethods::IDEAL ),
array( Core_PaymentMethods::PAYPAL, PaymentMethods::PAYPAL ),
array( Core_PaymentMethods::SOFORT, PaymentMethods::SOFORT ),
array( 'not existing payment method', null ),
);
return [
[ Core_PaymentMethods::IDEAL, PaymentMethods::IDEAL ],
[ Core_PaymentMethods::PAYPAL, PaymentMethods::PAYPAL ],
[ Core_PaymentMethods::SOFORT, PaymentMethods::SOFORT ],
[ 'not existing payment method', null ],
];
}
}
8 changes: 4 additions & 4 deletions tests/src/StatusesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function test_transform( $ems_status, $expected ) {
}

public function status_matrix_provider() {
return array(
array( Statuses::OPEN, Core_Statuses::OPEN ),
array( 'not existing status', null ),
);
return [
[ Statuses::OPEN, Core_Statuses::OPEN ],
[ 'not existing status', null ],
];
}
}

0 comments on commit c6c1792

Please sign in to comment.