Skip to content

Commit

Permalink
Merge pull request #116 from paynl/feature/PLUG-234
Browse files Browse the repository at this point in the history
Add fix for logged in accounts and add the gender to the transaction …
  • Loading branch information
woutse authored Feb 9, 2021
2 parents e0932e2 + 15ab080 commit 3f20cae
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
1 change: 0 additions & 1 deletion Model/Paymentmethod/Paylink.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public function initialize($paymentAction, $stateObject)
parent::initialize($paymentAction, $stateObject);
}
}


public function assignData(\Magento\Framework\DataObject $data)
{
Expand Down
22 changes: 22 additions & 0 deletions Model/Paymentmethod/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ public function getCompany()
return $this->_scopeConfig->getValue('payment/' . $this->_code . '/showforcompany', 'store');
}

public function genderConversion($gender)
{
switch ($gender) {
case '1':
$gender = 'M';
break;
case '2':
$gender = 'F';
break;
default:
$gender = null;
break;
}
return $gender;
}

public function initialize($paymentAction, $stateObject)
{
$status = $this->getConfigData('order_status');
Expand Down Expand Up @@ -269,9 +285,15 @@ protected function doStartTransaction(Order $order)
'phoneNumber' => $arrBillingAddress['telephone'],
'emailAddress' => $arrBillingAddress['email'],
);

if (isset($additionalData['dob'])) {
$enduser['dob'] = $additionalData['dob'];
}

if (isset($additionalData['gender'])) {
$enduser['gender'] = $additionalData['gender'];
}
$enduser['gender'] = $this->genderConversion((empty($enduser['gender'])) ? $order->getCustomerGender($order) : $enduser['gender']);

if (isset($arrBillingAddress['company']) && !empty($arrBillingAddress['company'])) {
$enduser['company']['name'] = $arrBillingAddress['company'];
Expand Down
15 changes: 4 additions & 11 deletions Plugin/OrderPaymentAdditionalInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,11 @@ public function afterGetAdditionalInformation(Payment $subject, $result)
if (empty($result['dob']) && $order->getCustomerDob()) {
$result['dob'] = (new \DateTime($order->getCustomerDob()))->format('Y-m-d');
}
if (empty($result['gender']) && $order->getCustomerGender()) {
if (empty($result['gender']) && ($order->getCustomerGender() || !empty($order->getCustomerId()))) {
$gender = $order->getCustomerGender();
switch ($gender) {
case '1':
$gender = 'M';
break;
case '2':
$gender = 'F';
break;
default:
$gender = null;
break;
if (empty($gender) && !empty($order->getCustomerId())) {
$customer = $this->customerRepository->getById($order->getCustomerId());
$gender = $customer->getGender();
}
if (!empty($gender)) {
$result['gender'] = $gender;
Expand Down

0 comments on commit 3f20cae

Please sign in to comment.