Skip to content

Commit

Permalink
Merge pull request #14 from afosto/master
Browse files Browse the repository at this point in the history
first name is now inserted
  • Loading branch information
Andy Pieters authored Nov 9, 2016
2 parents 987470b + 455c781 commit 034e0be
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,12 @@ public function getData() {
}

if ($card = $this->getCard()) {
$firstLetterInWord = function($word) {
return strtoupper(substr($word, 0, 1));
};

$initials = implode('.', array_map($firstLetterInWord, explode(' ', trim($card->getFirstName()))));
$invoiceInitials = implode('.', array_map($firstLetterInWord, explode(' ', trim($card->getBillingFirstName()))));

$addressParts = [];
preg_match($this->addressRegex, $card->getBillingAddress1(), $addressParts);
$addressParts = array_filter($addressParts, 'trim');

$data['enduser'] = array(
'initials' => $initials ? $initials.'.' : '',
'initials' => $card->getFirstName(), //Pay has no support for firstName, but some methods require full name. Conversion to initials is handled by Pay.nl based on the payment method.
'lastName' => $card->getLastName(),
'gender' => $card->getGender(), //Should be inserted in the CreditCard as M/F
'dob' => $card->getBirthday('d-m-Y'),
Expand All @@ -68,7 +61,7 @@ public function getData() {
'countryCode' => $card->getCountry(),
),
'invoiceAddress' => array(
'initials' => $invoiceInitials ? $invoiceInitials.'.' : '',
'initials' => $card->getBillingFirstName(),
'lastName' => $card->getBillingLastName(),
'streetName' => $addressParts[1],
'streetNumber' => isset($addressParts[2]) ? $addressParts[2] : null,
Expand Down

0 comments on commit 034e0be

Please sign in to comment.