Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pronamic/ideal-issuers for iDEAL issuers. #19

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"roots/wordpress-core-installer": true,
"bamarni/composer-bin-plugin": true
"bamarni/composer-bin-plugin": true,
"automattic/jetpack-autoloader": true
}
},
"require": {
"php": ">=8.0",
"php": ">=8.1",
"ext-simplexml": "*",
"pronamic/ideal-issuers": "^1.0",
"pronamic/wp-http": "^1.2",
"wp-pay/core": "^4.13"
},
Expand Down
7 changes: 7 additions & 0 deletions src/OrderStandard/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ class Config extends Ingenico_Config {
*/
public $alias_usage = '';

/**
* Live or test mode.
*
* @var string
*/
public $mode = '';

/**
* Get the Ogone e-Commerce direct query URL.
*
Expand Down
39 changes: 15 additions & 24 deletions src/OrderStandard/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Pronamic\WordPress\Pay\Gateways\Ingenico\OrderStandard;

use Pronamic\IDealIssuers\IDealIssuerService;
use Pronamic\WordPress\Pay\Core\Gateway as Core_Gateway;
use Pronamic\WordPress\Pay\Core\PaymentMethod;
use Pronamic\WordPress\Pay\Core\PaymentMethods as Core_PaymentMethods;
Expand Down Expand Up @@ -55,6 +56,8 @@ public function __construct( Config $config ) {

$this->config = $config;

$this->set_mode( $config->mode );

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

// Supported features.
Expand Down Expand Up @@ -83,17 +86,10 @@ public function __construct( Config $config ) {
$this->register_payment_method( new PaymentMethod( Core_PaymentMethods::PAYPAL ) );

// Payment method iDEAL.
$ideal_options = new CachedCallbackOptions(
function () {
return $this->get_ideal_issuers();
},
'pronamic_pay_ideal_issuers_' . \md5( (string) \wp_json_encode( $config ) )
);

$payment_method_ideal = new PaymentMethod( Core_PaymentMethods::IDEAL );

$field_ideal_issuer = new IDealIssuerSelectField( 'pronamic_pay_ingenico_ideal_issuer' );
$field_ideal_issuer->set_options( $ideal_options );
$field_ideal_issuer->set_options( $this->get_ideal_issuers() );

$payment_method_ideal->add_field( $field_ideal_issuer );

Expand All @@ -113,22 +109,17 @@ private function get_ideal_issuers() {
];
}

return [
new SelectFieldOption( 'ABNANL2A', \__( 'ABN AMRO', 'pronamic_ideal' ) ),
new SelectFieldOption( 'RABONL2U', \__( 'Rabobank', 'pronamic_ideal' ) ),
new SelectFieldOption( 'INGBNL2A', \__( 'ING', 'pronamic_ideal' ) ),
new SelectFieldOption( 'SNSBNL2A', \__( 'SNS Bank', 'pronamic_ideal' ) ),
new SelectFieldOption( 'RBRBNL21', \__( 'Regio Bank', 'pronamic_ideal' ) ),
new SelectFieldOption( 'ASNBNL21', \__( 'ASN Bank', 'pronamic_ideal' ) ),
new SelectFieldOption( 'BUNQNL2A', \__( 'Bunq', 'pronamic_ideal' ) ),
new SelectFieldOption( 'TRIONL2U', \__( 'Triodos Bank', 'pronamic_ideal' ) ),
new SelectFieldOption( 'FVLBNL22', \__( 'van Lanschot Bankiers', 'pronamic_ideal' ) ),
new SelectFieldOption( 'KNABNL2H', \__( 'Knab bank', 'pronamic_ideal' ) ),
new SelectFieldOption( 'REVOLT21', \__( 'Revolut', 'pronamic_ideal' ) ),
new SelectFieldOption( 'BITSNL2A', \__( 'Yoursafe', 'pronamic_ideal' ) ),
new SelectFieldOption( 'NTSBDEB1', \__( 'N26', 'pronamic_ideal' ) ),
new SelectFieldOption( 'NNBANL2G', \__( 'Nationale Nederlanden', 'pronamic_ideal' ) ),
];
$ideal_issuer_service = new IDealIssuerService();

$issuers = $ideal_issuer_service->get_issuers();

$items = [];

foreach ( $issuers as $issuer ) {
$items[] = new SelectFieldOption( $issuer->code, $issuer->name );
}

return $items;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/OrderStandard/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public function get_settings_fields() {
public function get_config( $post_id ) {
$config = new Config();

$config->mode = $this->get_mode();

$config->set_form_action_url( $this->action_url );
$config->set_direct_query_url( $this->direct_query_url );

Expand Down Expand Up @@ -95,8 +97,6 @@ public function get_config( $post_id ) {
public function get_gateway( $post_id ) {
$gateway = new Gateway( $this->get_config( $post_id ) );

$gateway->set_mode( $this->get_mode() );

return $gateway;
}
}
Loading