diff --git a/src/IssuersField.php b/src/IssuersField.php index 63abb42..a3aff0d 100644 --- a/src/IssuersField.php +++ b/src/IssuersField.php @@ -11,11 +11,12 @@ namespace Pronamic\WordPress\Pay\Extensions\GravityForms; use GF_Field_Select; +use Pronamic\IDealIssuers\IDealIssuerCode; +use Pronamic\IDealIssuers\IDealIssuerService; use Pronamic\WordPress\Pay\Core\Gateway; use Pronamic\WordPress\Pay\Fields\IDealIssuerSelectField; use Pronamic\WordPress\Pay\Core\PaymentMethods; use Pronamic\WordPress\Pay\Plugin; -use Pronamic\WpPayLogos\ImageService; /** * Title: WordPress pay extension Gravity Forms issuers field @@ -251,6 +252,42 @@ private function set_choices( $form_id ) { } } + /** + * Get iDEAL issuer code from label. + * + * @param string $label Label. + * @return string|null + */ + private function get_ideal_issuer_code_from_label( $label ) { + $label = \strtolower( $label ); + + $map = [ + 'abn' => IDealIssuerCode::ABNANL2A, + 'asn' => IDealIssuerCode::ASNBNL21, + 'bunq' => IDealIssuerCode::BUNQNL2A, + 'ing' => IDealIssuerCode::INGBNL2A, + 'knab' => IDealIssuerCode::KNABNL2H, + 'n26' => IDealIssuerCode::NTSBDEB1, + 'nationale' => IDealIssuerCode::NNBANL2G, + 'nn' => IDealIssuerCode::NNBANL2G, + 'rabobank' => IDealIssuerCode::RABONL2U, + 'regiobank' => IDealIssuerCode::RBRBNL21, + 'revolut' => IDealIssuerCode::REVOLT21, + 'sns' => IDealIssuerCode::SNSBNL2A, + 'triodos' => IDealIssuerCode::TRIONL2U, + 'lanschot' => IDealIssuerCode::FVLBNL22, + 'yoursafe' => IDealIssuerCode::BITSNL2A, + ]; + + foreach ( $map as $needle => $ideal_issuer_code ) { + if ( \str_contains( $label, $needle ) ) { + return $ideal_issuer_code; + } + } + + return null; + } + /** * Get the field input. * @@ -286,12 +323,6 @@ public function get_field_input( $form, $value = '', $entry = null ) {