Skip to content

Commit

Permalink
Merge pull request #17 from wirecard/TPWDCEE-2079
Browse files Browse the repository at this point in the history
TPWDCEE-2079
  • Loading branch information
rinnhofer authored Nov 12, 2018
2 parents c4dd8a7 + 976502b commit 5b43427
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Wirecard Checkout Page plugin for PrestaShop

[![License](https://img.shields.io/badge/license-GPLv2-blue.svg)](https://raw.githubusercontent.com/wirecard/prestashop-wcp/master/LICENSE)
[![PrestaShop](https://img.shields.io/badge/PrestaShop-v1.7.2.2-green.svg)](https://www.prestashop.com/)
[![PrestaShop](https://img.shields.io/badge/PrestaShop-v1.7.4.3-green.svg)](https://www.prestashop.com/)
[![PHP v5.6](https://img.shields.io/badge/php-v5.6-yellow.svg)](http://www.php.net)
[![PHP v7.0](https://img.shields.io/badge/php-v7.0-yellow.svg)](http://www.php.net)
[![PHP v7.1](https://img.shields.io/badge/php-v7.1-yellow.svg)](http://www.php.net)
Expand Down
2 changes: 1 addition & 1 deletion wirecardceecheckoutpage/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>wirecardceecheckoutpage</name>
<displayName><![CDATA[Wirecard Checkout Page]]></displayName>
<version>2.1.3</version>
<version>2.1.4</version>
<description><![CDATA[Wirecard Checkout Page payment module]]></description>
<author>Wirecard</author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
39 changes: 32 additions & 7 deletions wirecardceecheckoutpage/wirecardceecheckoutpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class WirecardCEECheckoutPage extends PaymentModule
const WCP_PT_TRUSTPAY = 'WCP_PT_TRUSTPAY';
const WCP_PT_INVOICE = 'WCP_PT_INVOICE';
const WCP_PT_INSTALLMENT = 'WCP_PT_INSTALLMENT';
const WCP_PT_BANCONTACT = 'WCP_PT_BANCONTACT';
const WCP_PT_BANCONTACT_MISTERCASH = 'WCP_PT_BANCONTACT_MISTERCASH';
const WCP_PT_P24 = 'WCP_PT_PRZELEWY24';
const WCP_PT_MONETA = 'WCP_PT_MONETA';
const WCP_PT_POLI = 'WCP_PT_POLI';
Expand Down Expand Up @@ -143,7 +143,7 @@ public function __construct()
$this->config = $this->config();
$this->name = 'wirecardceecheckoutpage';
$this->tab = 'payments_gateways';
$this->version = '2.1.3';
$this->version = '2.1.4';
$this->author = 'Wirecard';
$this->controllers = array('breakoutIFrame', 'confirm', 'payment', 'paymentIFrame');
$this->is_eu_compatible = 1;
Expand Down Expand Up @@ -1280,6 +1280,7 @@ private function initiate($paymentType, $additionalData)
$init = $this->setConsumerInformation($init);
}


return $init->initiate()->getRedirectUrl();
}

Expand Down Expand Up @@ -1330,14 +1331,38 @@ private function setConsumerInformation(WirecardCEE_QPay_FrontendClient $request
->setIpAddress($this->getConsumerIpAddress());

$customer = new Customer($this->getOrder()->id_customer);
$consumerData->setBirthDate(DateTime::createFromFormat("Y-m-d", $customer->birthday))
->setEmail($customer->email);

$request->setConsumerData($consumerData);
$consumerData->setBirthDate($this->getValidDate($customer->birthday, "Y-m-d"))
->setEmail($customer->email);

return $request;
}

/*
* Returns today's date if $date is invalid
*/
public function getValidDate($date, $format)
{
if (!empty($date) && strtotime($date) !== false) {
if ($this->isValidDateFormat($date)) {
return DateTime::createFromFormat($format, $date);
}
}
return new DateTime();
}

/*
* Checks if format is Y-m-d
*/
public function isValidDateFormat($date)
{
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $date)) {
return true;
} else {
return false;
}
}

public function confirmResponse()
{
if (!$this->active) {
Expand Down Expand Up @@ -1518,7 +1543,7 @@ private function getPaymentTypes()
self::WCP_PT_EPS, self::WCP_PT_IDL, self::WCP_PT_GIROPAY, self::WCP_PT_TATRAPAY,
self::WCP_PT_SOFORTUEBERWEISUNG, self::WCP_PT_PBX, self::WCP_PT_QUICK, self::WCP_PT_PAYPAL,
self::WCP_PT_EPAY_BG, self::WCP_PT_SEPA_DD, self::WCP_PT_TRUSTPAY, self::WCP_PT_INVOICE,
self::WCP_PT_INSTALLMENT, self::WCP_PT_BANCONTACT, self::WCP_PT_P24, self::WCP_PT_MONETA,
self::WCP_PT_INSTALLMENT, self::WCP_PT_BANCONTACT_MISTERCASH, self::WCP_PT_P24, self::WCP_PT_MONETA,
self::WCP_PT_POLI, self::WCP_PT_EKONTO, self::WCP_PT_TRUSTLY, self::WCP_PT_SKRILLWALLET,
self::WCP_PT_VOUCHER);
}
Expand Down Expand Up @@ -1580,7 +1605,7 @@ private function getPaymentTypeInfo($type)
case self::WCP_PT_INSTALLMENT:
return array('title' => $this->l('Installment'),
'value' => WirecardCEE_QPay_PaymentType::INSTALLMENT);
case self::WCP_PT_BANCONTACT:
case self::WCP_PT_BANCONTACT_MISTERCASH:
return array('title' => $this->l('Bancontact'),
'value' => WirecardCEE_QPay_PaymentType::BMC);
case self::WCP_PT_P24:
Expand Down

0 comments on commit 5b43427

Please sign in to comment.