Skip to content

Commit

Permalink
Limit first and last name to 32 characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Oct 22, 2020
1 parent 48944ee commit e08f1e7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Gateway.php
Expand Up @@ -196,11 +196,14 @@ public function start( Payment $payment ) {

// Set name from customer.
if ( null !== $customer->get_name() ) {
$enduser['initials'] = $customer->get_name()->get_first_name();
$enduser['lastName'] = $customer->get_name()->get_last_name();
$first_name = \substr( (string) $customer->get_name()->get_first_name(), 0, 32 );
$last_name = \substr( (string) $customer->get_name()->get_last_name(), 0, 32 );

$invoice_address['initials'] = $customer->get_name()->get_first_name();
$invoice_address['lastName'] = $customer->get_name()->get_last_name();
$enduser['initials'] = $first_name;
$enduser['lastName'] = $last_name;

$invoice_address['initials'] = $first_name;
$invoice_address['lastName'] = $last_name;
}

// Set date of birth.
Expand Down

2 comments on commit e08f1e7

@remcotolsma
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rvdsteege Pay.nl doesn't support UTF-8 (multi-byte) strings?

<?php

echo strlen( 'ä' );

$test = substr( 'ä', 0, 1 );

var_dump( $test );

Use \mb_substr instead of \substr?

https://github.com/WordPress/WordPress/blob/5.5/wp-includes/compat.php#L43-L62

@rvdsteege
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope.

Please sign in to comment.