Skip to content

Commit

Permalink
Merge branch 'release/4.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Apr 11, 2022
2 parents 4ddf1d6 + 1b45ae5 commit 9182ff0
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 30 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.1.0] - 2022-04-11
- No longer use core gateweay mode.

## [4.0.0] - 2022-01-11
### Changed
- Updated to https://github.com/pronamic/wp-pay-core/releases/tag/4.0.0.
Expand Down Expand Up @@ -65,7 +68,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.0.0...HEAD
[unreleased]: https://github.com/wp-pay-gateways/ems-e-commerce/compare/4.1.0...HEAD
[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
[3.0.0]: https://github.com/wp-pay-gateways/ems-e-commerce/compare/2.1.2...3.0.0
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"bamarni/composer-bin-plugin": true,
"roots/wordpress-core-installer": true,
"composer/installers": true
}
},
"require": {
"php": ">=5.6.20",
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.0.0",
"version": "4.1.0",
"description": "EMS e-Commerce Gateway driver for the WordPress payment processing library.",
"repository": {
"type": "git",
Expand Down
16 changes: 8 additions & 8 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Client {
/**
* Payment method
*
* @var array
* @var string
*/
private $payment_method;

Expand Down Expand Up @@ -319,7 +319,7 @@ public function set_order_id( $order_id ) {
/**
* Get payment ID
*
* @return int
* @return string
*/
public function get_payment_id() {
return $this->payment_id;
Expand All @@ -328,7 +328,7 @@ public function get_payment_id() {
/**
* Set payment ID
*
* @param int $payment_id Payment ID.
* @param string $payment_id Payment ID.
* @return void
*/
public function set_payment_id( $payment_id ) {
Expand All @@ -343,7 +343,7 @@ public function set_payment_id( $payment_id ) {
*/
public function get_transaction_datetime( $create_new = false ) {
if ( null === $this->transaction_datetime || $create_new ) {
$this->transaction_datetime = new DateTime( null, new DateTimeZone( 'UTC' ) );
$this->transaction_datetime = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
}

return $this->transaction_datetime;
Expand All @@ -362,7 +362,7 @@ public function set_transaction_datetime( DateTime $datetime ) {
/**
* Get data
*
* @return array
* @return array<string, string>
*/
public function get_data() {
// Required fields for payment request.
Expand Down Expand Up @@ -396,7 +396,7 @@ public function get_data() {
'responseSuccessURL' => $this->get_return_url(),
'transactionNotificationURL' => $this->get_notification_url(),
'idealIssuerID' => $this->get_issuer_id(),
'ems_notify_payment_id' => $this->get_payment_id(),
'ems_notify_payment_id' => (string) $this->get_payment_id(),
);

// @link http://briancray.com/2009/04/25/remove-null-values-php-arrays/
Expand Down Expand Up @@ -450,7 +450,7 @@ public function get_hash() {
/**
* Compute hash
*
* @param array $values Values to compute hash for.
* @param string[] $values Values to compute hash for.
* @return string
*/
public static function compute_hash( $values ) {
Expand All @@ -464,7 +464,7 @@ public static function compute_hash( $values ) {
* Get fields
*
* @since 1.0.0
* @return array
* @return array<string, string>
*/
public function get_fields() {
$fields = $this->get_data();
Expand Down
33 changes: 33 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
* @since 1.0.0
*/
class Config extends GatewayConfig {
/**
* Action URL.
*
* @var string
*/
private $action_url;

/**
* Store name.
*
Expand All @@ -35,4 +42,30 @@ class Config extends GatewayConfig {
* @var string|null
*/
public $order_id;

/**
* Construct config.
*/
public function __construct() {
$this->action_url = Client::ACTION_URL_PRODUCTION;
}

/**
* Get action URL.
*
* @return string
*/
public function get_action_url() {
return $this->action_url;
}

/**
* Set action URL.
*
* @param string $action_url Action URL.
* @return void
*/
public function set_action_url( $action_url ) {
$this->action_url = $action_url;
}
}
31 changes: 18 additions & 13 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ class Gateway extends Core_Gateway {
*/
protected $client;

/**
* Config.
*
* @var Config
*/
protected $config;

/**
* Constructs and initializes an EMS e-Commerce gateway
*
Expand All @@ -34,20 +41,16 @@ class Gateway extends Core_Gateway {
public function __construct( Config $config ) {
parent::__construct( $config );

$this->config = $config;

$this->set_method( self::METHOD_HTML_FORM );

// Client.
$this->client = new Client();

$action_url = Client::ACTION_URL_PRODUCTION;

if ( self::MODE_TEST === $config->mode ) {
$action_url = Client::ACTION_URL_TEST;
}

$this->client->set_action_url( $action_url );
$this->client->set_storename( $config->storename );
$this->client->set_secret( $config->secret );
$this->client->set_action_url( $config->get_action_url() );
$this->client->set_storename( (string) $config->storename );
$this->client->set_secret( (string) $config->secret );
}

/**
Expand Down Expand Up @@ -82,16 +85,16 @@ public function start( Payment $payment ) {
* Get the output HTML
*
* @param Payment $payment Payment.
* @return array
* @return array<string, string>
*
* @see Core_Gateway::get_output_html()
* @since 1.0.0
* @version 2.0.4
*/
public function get_output_fields( Payment $payment ) {
$this->client->set_payment_id( (int) $payment->get_id() );
$this->client->set_payment_id( (string) $payment->get_id() );
$this->client->set_currency_numeric_code( (string) $payment->get_total_amount()->get_currency()->get_numeric_code() );
$this->client->set_order_id( $payment->format_string( $this->config->order_id ) );
$this->client->set_order_id( $payment->format_string( (string) $this->config->order_id ) );
$this->client->set_return_url( home_url( '/' ) );
$this->client->set_notification_url( home_url( '/' ) );
$this->client->set_amount( $payment->get_total_amount() );
Expand All @@ -116,7 +119,9 @@ public function get_output_fields( Payment $payment ) {
$payment_method = $payment->get_payment_method();
}

$this->client->set_payment_method( $payment_method );
if ( null !== $payment_method ) {
$this->client->set_payment_method( $payment_method );
}

return $this->client->get_fields();
}
Expand Down
20 changes: 14 additions & 6 deletions src/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,28 @@
* @since 1.0.0
*/
class Integration extends AbstractGatewayIntegration {
/**
* Action URL.
*
* @var string
*/
private $action_url;

/**
* Construct EMS e-Commerce integration.
*
* @param array $args Arguments.
* @param array<string, mixed> $args Arguments.
*/
public function __construct( $args = array() ) {
$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' => array(
\__( 'test', 'pronamic_ideal' ) => 'https://test.ipg-online.com/vt/login',
\__( 'live', 'pronamic_ideal' ) => 'https://www.ipg-online.com/vt/login',
),
'dashboard_url' => 'https://www.ipg-online.com/vt/login',
'supports' => array(
'webhook',
'webhook_log',
Expand All @@ -43,6 +48,8 @@ public function __construct( $args = array() ) {

parent::__construct( $args );

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

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

Expand Down Expand Up @@ -140,9 +147,10 @@ public function get_settings_fields() {
public function get_config( $post_id ) {
$config = new Config();

$config->set_action_url( $this->action_url );

$config->storename = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_storename', true );
$config->secret = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_secret', true );
$config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true );
$config->order_id = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_order_id', true );

return $config;
Expand Down

0 comments on commit 9182ff0

Please sign in to comment.