Skip to content

Commit

Permalink
Release 1.0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
sbossert committed Aug 22, 2019
1 parent 9b8f859 commit 97de911
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'pfc_postFinanceCheckout_Open in your PostFinance Checkout backend.' => 'Öffne im PostFinance Checkout backend.',
'pfc_postFinanceCheckout_Open' => 'Öffnen',
'pfc_postFinanceCheckout_PostFinance Checkout Link' => 'PostFinance Checkout Link',
'pfc_postFinanceCheckout_You must agree to the terms and conditions.' => 'Sie müssen den AGBs und Datenschutzvereinbarung zustimmen.',

// tpl translations
'pfc_postFinanceCheckout_Restock' => 'Lagerbestand wiederherstellen',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'pfc_postFinanceCheckout_Open in your PostFinance Checkout backend.' => 'Open in your PostFinance Checkout backend.',
'pfc_postFinanceCheckout_Open' => 'Open',
'pfc_postFinanceCheckout_PostFinance Checkout Link' => 'PostFinance Checkout Link',
'pfc_postFinanceCheckout_You must agree to the terms and conditions.' => 'You must agree to the terms and conditions.',

// tpl translations
'pfc_postFinanceCheckout_Restock' => 'Restock',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

'SHOP_MODULE_GROUP_pfcPostFinanceCheckoutPostFinance CheckoutSettings' => 'PostFinance Checkout Einstellungen',
'SHOP_MODULE_GROUP_pfcPostFinanceCheckoutShopSettings' => 'Shop Einstellungen',
'SHOP_MODULE_GROUP_pfcPostFinanceCheckoutSpaceViewId' => 'Space View Id',
'SHOP_MODULE_GROUP_pfcPostFinanceCheckoutSpaceSettings' => 'Space View Id',
'SHOP_MODULE_pfcPostFinanceCheckoutAppKey' => 'Authentication Key',
'SHOP_MODULE_pfcPostFinanceCheckoutUserId' => 'Benutzer Id',
'SHOP_MODULE_pfcPostFinanceCheckoutSpaceId' => 'Space Id',
'SHOP_MODULE_pfcPostFinanceCheckoutSpaceViewSettings' => 'Space View Optionen',
'SHOP_MODULE_pfcPostFinanceCheckoutSpaceViewViewId' => 'Space View Optionen',
'SHOP_MODULE_pfcPostFinanceCheckoutEmailConfirm' => 'Email Bestätigung',
'SHOP_MODULE_pfcPostFinanceCheckoutInvoiceDoc' => 'Rechnung',
'SHOP_MODULE_pfcPostFinanceCheckoutPackingDoc' => 'Lieferschein',
Expand Down
5 changes: 4 additions & 1 deletion Core/Adapter/AddressAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ private function convertAddress(\OxidEsales\Eshop\Core\Base $address)

$birthdate = $address->getFieldData('oxbirthdate');
if(!empty($birthdate) && $birthdate != '0000-00-00'){
$addressCreate->setDateOfBirth(new \DateTime($birthdate));
$date = new \DateTime($birthdate);
if(checkdate(intval($date->format('m')), intval($date->format('d')), intval($date->format('Y')))) {
$addressCreate->setDateOfBirth($date);
}
}
$salutation = $address->getFieldData('oxsal');
if (strtolower($salutation) === 'mr') {
Expand Down
27 changes: 25 additions & 2 deletions Core/Service/PaymentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use PostFinanceCheckout\Sdk\Service\PaymentMethodConfigurationService;
use Pfc\PostFinanceCheckout\Core\PostFinanceCheckoutModule;
use \PostFinanceCheckout\Sdk\Service\TransactionService as SdkTransactionService;
use PostFinanceCheckout\Sdk\Model\EntityQueryFilter;
use PostFinanceCheckout\Sdk\Model\EntityQueryFilterType;
use PostFinanceCheckout\Sdk\Model\CriteriaOperator;

/**
* Class PaymentService
Expand Down Expand Up @@ -74,7 +77,7 @@ public function fetchAvailablePaymentMethods($transactionId, $spaceId){
* @throws \PostFinanceCheckout\Sdk\ApiException
*/
public function synchronize(){
$paymentMethods = $this->getConfigurationService()->search(PostFinanceCheckoutModule::settings()->getSpaceId(), new EntityQuery());
$paymentMethods = $this->getConfigurationService()->search(PostFinanceCheckoutModule::settings()->getSpaceId(), $this->getQueryFilter('state', \PostFinanceCheckout\Sdk\Model\CreationEntityState::ACTIVE));

$paymentList = oxNew(\OxidEsales\Eshop\Application\Model\PaymentList::class);
/* @var $paymentList \Pfc\PostFinanceCheckout\Extend\Application\Model\PaymentList */
Expand All @@ -93,7 +96,27 @@ public function synchronize(){
}
}
}


private function getQueryFilter($fieldName, $fieldValue){
$query = new EntityQuery();
$filter = new EntityQueryFilter();
/**
* @noinspection PhpParamsInspection
*/
$filter->setType(EntityQueryFilterType::LEAF);
/**
* @noinspection PhpParamsInspection
*/
$filter->setOperator(CriteriaOperator::EQUALS);
$filter->setFieldName($fieldName);
/**
* @noinspection PhpParamsInspection
*/
$filter->setValue($fieldValue);
$query->setFilter($filter);
return $query;
}

/**
*
* @param $paymentId
Expand Down
69 changes: 37 additions & 32 deletions Extend/Application/Controller/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,43 @@ public function pfcConfirm()
);

if ($this->isPostFinanceCheckoutTransaction()) {
try {
$transaction = Transaction::loadPendingFromSession($this->getSession());
/* @var $order \Pfc\PostFinanceCheckout\Extend\Application\Model\Order */
/** @noinspection PhpParamsInspection */
$order->setConfirming(true);
$state = $order->finalizeOrder($this->getBasket(), $this->getUser());
$order->setConfirming(false);
if ($state === 'POSTFINANCECHECKOUT_' . TransactionState::PENDING) {
$transaction->setTempBasket($this->getBasket());
$transaction->setOrderId($order->getId());
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction();
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->startTransaction();
$transaction->updateFromSession(true);
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction();
$response['status'] = true;
} else if ($state == \OxidEsales\Eshop\Application\Model\Order::ORDER_STATE_ORDEREXISTS) {
// ensure new order can be created
$this->getSession()->deleteVariable('sess_challenge');
throw new \Exception(PostFinanceCheckoutModule::instance()->translate("Order already exists. Please check if you have already received a confirmation, then try again."));
} else {
throw new \Exception(PostFinanceCheckoutModule::instance()->translate("Unable to confirm order in state !state.", true, array('!state' => $state)));
}
} catch (\Exception $e) {
if (isset($transaction)) {
$state = $transaction->getState();
} else if (!isset($state)) {
$state = 'confirmation_error_unkown';
}
$order->PostFinanceCheckoutFail($e->getMessage(), $state, true);
PostFinanceCheckoutModule::log(Logger::ERROR, "Unable to confirm transaction: {$e->getMessage()}.");
$response['message'] = $e->getMessage();
}
if($this->_validateTermsAndConditions()) {
try {
$transaction = Transaction::loadPendingFromSession($this->getSession());
/* @var $order \Pfc\PostFinanceCheckout\Extend\Application\Model\Order */
/** @noinspection PhpParamsInspection */
$order->setConfirming(true);
$state = $order->finalizeOrder($this->getBasket(), $this->getUser());
$order->setConfirming(false);
if ($state === 'POSTFINANCECHECKOUT_' . TransactionState::PENDING) {
$transaction->setTempBasket($this->getBasket());
$transaction->setOrderId($order->getId());
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction();
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->startTransaction();
$transaction->updateFromSession(true);
\OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction();
$response['status'] = true;
} else if ($state == \OxidEsales\Eshop\Application\Model\Order::ORDER_STATE_ORDEREXISTS) {
// ensure new order can be created
$this->getSession()->deleteVariable('sess_challenge');
throw new \Exception(PostFinanceCheckoutModule::instance()->translate("Order already exists. Please check if you have already received a confirmation, then try again."));
} else {
throw new \Exception(PostFinanceCheckoutModule::instance()->translate("Unable to confirm order in state !state.", true, array('!state' => $state)));
}
} catch (\Exception $e) {
if (isset($transaction)) {
$state = $transaction->getState();
} else if (!isset($state)) {
$state = 'confirmation_error_unkown';
}
$order->PostFinanceCheckoutFail($e->getMessage(), $state, true);
PostFinanceCheckoutModule::log(Logger::ERROR, "Unable to confirm transaction: {$e->getMessage()}.");
$response['message'] = $e->getMessage();
}
}
else {
$response['message'] = PostFinanceCheckoutModule::instance()->translate("You must agree to the terms and conditions.");
}
} else {
$response['message'] = PostFinanceCheckoutModule::instance()->translate("Not a PostFinance Checkout order.");
}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OXID 6.0

v1.0.14, 2019-7
v1.0.15, 2019-8

This repository contains the OXID PostFinance Checkout payment module that enables the shop to process payments with [PostFinance Checkout](https://www.postfinance.ch/checkout).

Expand All @@ -13,8 +13,8 @@ This repository contains the OXID PostFinance Checkout payment module that enab

## Documentation

* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.14/docs/en/documentation.html)
* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.15/docs/en/documentation.html)

## License

Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.14/LICENSE) for more information.
Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.15/LICENSE) for more information.
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OXID 6.0

v1.0.14, 2019-7
v1.0.15, 2019-8

This repository contains the OXID PostFinance Checkout payment module that enables the shop to process payments with [PostFinance Checkout](https://www.postfinance.ch/checkout).

Expand All @@ -13,8 +13,8 @@ This repository contains the OXID PostFinance Checkout payment module that enab

## Documentation

* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.14/docs/en/documentation.html)
* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.15/docs/en/documentation.html)

## License

Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.14/LICENSE) for more information.
Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.15/LICENSE) for more information.
4 changes: 2 additions & 2 deletions docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/pfpayments/oxid-6.0/releases/tag/1.0.14/">
<a href="https://github.com/pfpayments/oxid-6.0/releases/tag/1.0.15/">
Source
</a>
</li>
Expand All @@ -48,7 +48,7 @@ <h1>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://github.com/pfpayments/oxid-6.0/releases/tag/1.0.14/">Download</a> the extension.</p>
<p><a href="https://github.com/pfpayments/oxid-6.0/releases/tag/1.0.15/">Download</a> the extension.</p>
</li>
<li>
<p>Extract the files and upload them to the root directory of your store using FTP/SSH.</p>
Expand Down
2 changes: 1 addition & 1 deletion metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'en' => 'PFC PostFinanceCheckout Module'
),
'thumbnail' => 'out/pictures/picture.png',
'version' => '1.0.14',
'version' => '1.0.15',
'author' => 'customweb GmbH',
'url' => 'https://www.customweb.com',
'email' => 'info@customweb.com',
Expand Down
12 changes: 12 additions & 0 deletions out/src/js/postfinancecheckout.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
$('#PostFinanceCheckout-iframe-container').parent().parent().hide();
}
},

getAgbParameter: function() {
var agb = $('#checkAgbTop');
if(!agb.length) {
agb = $('#checkAgbBottom');
}
if(agb.length && agb[0].checked) {
return '&ord_agb=1';
}
return '';
},

submit: function () {
if (PostFinanceCheckout.running) {
Expand All @@ -40,6 +51,7 @@
var params = '&stoken=' + $('input[name=stoken]').val();
params += '&sDeliveryAddressMD5=' + $('input[name=sDeliveryAddressMD5]').val();
params += '&challenge=' + $('input[name=challenge]').val();
params += this.getAgbParameter(),
$.getJSON('index.php?cl=order&fnc=pfcConfirm' + params, '', function (data, status, jqXHR) {
if (data.status) {
PostFinanceCheckout.handler.submit();
Expand Down

0 comments on commit 97de911

Please sign in to comment.