-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move getUserIdForVaulting from ViewConfig to Controller-Traits
- Loading branch information
1 parent
39b9bee
commit b20f652
Showing
4 changed files
with
55 additions
and
53 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
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,48 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidSolutionCatalysts\PayPal\Traits; | ||
|
||
use OxidEsales\Eshop\Core\Registry; | ||
use OxidSolutionCatalysts\PayPal\Core\ServiceFactory; | ||
|
||
trait AccountControllerTrait | ||
{ | ||
public function deleteVaultedPayment() | ||
{ | ||
$paymentTokenId = Registry::getRequest()->getRequestEscapedParameter("paymentTokenId"); | ||
$vaultingService = Registry::get(ServiceFactory::class)->getVaultingService(); | ||
|
||
if (!$vaultingService->deleteVaultedPayment($paymentTokenId)) { | ||
Registry::getUtilsView()->addErrorToDisplay( | ||
Registry::getLang()->translateString('OSC_PAYPAL_DELETE_FAILED'), | ||
false, | ||
true | ||
); | ||
} | ||
} | ||
|
||
public function getUserIdForVaulting(): string | ||
{ | ||
if (!$this->getUser()) { | ||
return ""; | ||
} | ||
|
||
$payPalCustomerId = $this->getUser()->getFieldData("oscpaypalcustomerid"); | ||
|
||
if (!$payPalCustomerId) { | ||
return ""; | ||
} | ||
|
||
$vaultingService = Registry::get(ServiceFactory::class)->getVaultingService(); | ||
$response = $vaultingService->generateUserIdToken($payPalCustomerId); | ||
|
||
return $response["id_token"] ?? ""; | ||
} | ||
} |