-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from OXID-eSales/UNZER-150_Save_Payment_Data
Unzer 150 save payment data
- Loading branch information
Showing
20 changed files
with
949 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
*/ | ||
|
||
use OxidSolutionCatalysts\Unzer\Model\DiscountList; | ||
use OxidSolutionCatalysts\Unzer\Controller\AccountSavedPaymentController; | ||
use OxidSolutionCatalysts\Unzer\Controller\Admin\AdminOrderController; | ||
use OxidSolutionCatalysts\Unzer\Controller\Admin\ModuleConfiguration; | ||
use OxidSolutionCatalysts\Unzer\Controller\Admin\OrderMain; | ||
|
@@ -52,7 +53,7 @@ | |
</ul>', | ||
], | ||
'thumbnail' => 'logo.svg', | ||
'version' => '1.1.4-rc.1', | ||
'version' => '1.1.4-rc.2', | ||
'author' => 'OXID eSales AG', | ||
'url' => 'https://www.oxid-esales.com', | ||
'email' => '[email protected]', | ||
|
@@ -75,6 +76,7 @@ | |
'unzer_dispatcher' => DispatcherController::class, | ||
'unzer_installment' => InstallmentController::class, | ||
'unzer_applepay_callback' => ApplePayCallbackController::class, | ||
'unzer_saved_payments' => AccountSavedPaymentController::class, | ||
], | ||
'templates' => [ | ||
// admin | ||
|
@@ -83,6 +85,7 @@ | |
// frontend | ||
'modules/osc/unzer/unzer_assets.tpl' => 'osc/unzer/views/frontend/tpl/order/unzer_assets.tpl', | ||
'modules/osc/unzer/unzer_card.tpl' => 'osc/unzer/views/frontend/tpl/order/unzer_card.tpl', | ||
'modules/osc/unzer/unzer_paypal.tpl' => 'osc/unzer/views/frontend/tpl/order/unzer_paypal.tpl', | ||
'modules/osc/unzer/unzer_eps_charge.tpl' => 'osc/unzer/views/frontend/tpl/order/unzer_eps_charge.tpl', | ||
'modules/osc/unzer/unzer_installment.tpl' => 'osc/unzer/views/frontend/tpl/order/unzer_installment.tpl', | ||
'modules/osc/unzer/unzer_installment_confirm.tpl' => 'osc/unzer/views/frontend/tpl/order/unzer_installment_confirm.tpl', | ||
|
@@ -99,6 +102,7 @@ | |
'modules/osc/unzer/payment/applepay_availibility_check.tpl' => 'osc/unzer/views/frontend/tpl/payment/applepay_availibility_check.tpl', | ||
'modules/osc/unzer/payment/payment_unzer.tpl' => 'osc/unzer/views/frontend/tpl/payment/payment_unzer.tpl', | ||
'modules/osc/unzer/order/applepay_button.tpl' => 'osc/unzer/views/frontend/tpl/order/applepay_button.tpl', | ||
'modules/osc/unzer/account_saved_payments.tpl' => 'osc/unzer/views/frontend/tpl/account/account_saved_payments.tpl', | ||
], | ||
'blocks' => [ | ||
//frontend | ||
|
@@ -129,6 +133,11 @@ | |
'block' => 'select_payment', | ||
'file' => 'views/frontend/blocks/page/checkout/select_payment.tpl' | ||
], | ||
[ | ||
'template' => 'page/account/inc/account_menu.tpl', | ||
'block' => 'account_menu', | ||
'file' => 'views/frontend/blocks/page/account/inc/account_menu.tpl' | ||
], | ||
//admin | ||
[ | ||
'template' => 'module_config.tpl', | ||
|
@@ -166,6 +175,12 @@ | |
'type' => 'bool', | ||
'value' => '0', | ||
], | ||
[ | ||
'group' => 'unzerenvironment', | ||
'name' => 'UnzerSavePaymentsForUser', | ||
'type' => 'bool', | ||
'value' => '0', | ||
], | ||
[ | ||
'group' => 'unzermerchant', | ||
'name' => 'sandbox-UnzerPublicKey', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidSolutionCatalysts\Unzer\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\DBAL\Types\Types; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20230927114315 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->updateTransactionTable($schema); | ||
} | ||
protected function updateTransactionTable(Schema $schema): void | ||
{ | ||
$transaction = $schema->getTable('oscunzertransaction'); | ||
|
||
if (!$transaction->hasColumn('PAYMENTTYPEID')) { | ||
$transaction->addColumn('PAYMENTTYPEID', Types::STRING, ['default' => ""]); | ||
} | ||
} | ||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidSolutionCatalysts\Unzer\Controller; | ||
|
||
use OxidEsales\Eshop\Application\Controller\AccountController; | ||
use OxidEsales\Eshop\Core\DatabaseProvider; | ||
use OxidSolutionCatalysts\Unzer\Service\UnzerSDKLoader; | ||
use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; | ||
use OxidEsales\Eshop\Core\Registry; | ||
|
||
class AccountSavedPaymentController extends AccountController | ||
{ | ||
use ServiceContainer; | ||
|
||
public function render() | ||
{ | ||
parent::render(); | ||
$this->redirectAfterLogin(); | ||
|
||
$user = $this->getUser(); | ||
if ($user && $user->getFieldData('oxpassword')) { | ||
$this->setPaymentListsToView(); | ||
return "modules/osc/unzer/account_saved_payments.tpl"; | ||
} | ||
return $this->_sThisLoginTemplate; | ||
} | ||
|
||
protected function setPaymentListsToView(): void | ||
{ | ||
$UnzerSdk = $this->getServiceFromContainer(UnzerSDKLoader::class); | ||
$unzerSDK = $UnzerSdk->getUnzerSDK(); | ||
|
||
$ids = $this->getTransactionIds(); | ||
$paymentTypes = false; | ||
foreach ($ids as $typeId) { | ||
if (empty($typeId['PAYMENTTYPEID'])) { | ||
continue; | ||
} | ||
$paymentType = $unzerSDK->fetchPaymentType($typeId['PAYMENTTYPEID']); | ||
|
||
if (strpos($typeId['PAYMENTTYPEID'], 'crd') && method_exists($paymentType, 'getBrand')) { | ||
$paymentTypes[$paymentType->getBrand()][$typeId['OXID']] = $paymentType->expose(); | ||
} | ||
if (strpos($typeId['PAYMENTTYPEID'], 'ppl')) { | ||
$paymentTypes['paypal'][$typeId['OXID']] = $paymentType->expose(); | ||
} | ||
if (strpos($typeId['PAYMENTTYPEID'], 'sdd')) { | ||
$paymentTypes['sepa'][$typeId['OXID']] = $paymentType->expose(); | ||
} | ||
} | ||
|
||
$this->_aViewData['unzerPaymentType'] = $paymentTypes; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
protected function getTransactionIds(): array | ||
{ | ||
$result = []; | ||
if ($this->getUser()) { | ||
$oDB = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); | ||
$result = $oDB->getAll( | ||
"SELECT OXID, PAYMENTTYPEID from oscunzertransaction | ||
where OXUSERID = :oxuserid AND PAYMENTTYPEID IS NOT NULL GROUP BY PAYMENTTYPEID ", | ||
[':oxuserid' => $this->getUser()->getId()] | ||
); | ||
} | ||
return $result; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
public function deletePayment(): void | ||
{ | ||
$paymenttypeid = Registry::getRequest()->getRequestParameter('paymenttypeid'); | ||
$oDB = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); | ||
$oDB->getAll( | ||
"UPDATE oscunzertransaction SET PAYMENTTYPEID = NULL | ||
WHERE OXUSERID = :oxuserid AND OXID = :oxid", | ||
[':oxuserid' => $this->getUser()->getId(), 'oxid' => $paymenttypeid] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.