Skip to content

Commit

Permalink
Added page check to only use user-id-token for order page
Browse files Browse the repository at this point in the history
  • Loading branch information
L3RAZ authored and Matt75 committed Apr 3, 2024
1 parent c34f72f commit 9af1ebe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Expand Up @@ -96,12 +96,12 @@ public function handle(CapturePayPalOrderCommand $capturePayPalOrderCommand)
$payload = [
'mode' => $capturePayPalOrderCommand->getFundingSource(),
'orderId' => $capturePayPalOrderCommand->getOrderId()->getValue(),
'payee' => ['merchant_id' => $merchantId]
'payee' => ['merchant_id' => $merchantId],
];

$order = $this->payPalOrderRepository->getPayPalOrderById($capturePayPalOrderCommand->getOrderId());

if($order->checkCustomerIntent(PayPalOrder::CUSTOMER_INTENT_USES_VAULTING)) {
if ($order->checkCustomerIntent(PayPalOrder::CUSTOMER_INTENT_USES_VAULTING)) {
$payload['vault'] = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/PayPal/Sdk/PayPalSdkConfigurationBuilder.php
Expand Up @@ -131,7 +131,7 @@ public function buildConfiguration()
'dataCspNonce' => $this->configuration->getCSPNonce(),
];

if ($this->prestaShopContext->customerIsLogged() && $this->prestaShopContext->getCustomerId()) {
if ($this->prestaShopContext->customerIsLogged() && $this->prestaShopContext->getCustomerId() && 'order' === $this->getPageName()) {
try {
/** @var GetPayPalGetUserIdTokenQueryResult $queryResult */
$queryResult = $this->commandBus->handle(new GetPayPalGetUserIdTokenQuery(new CustomerId($this->prestaShopContext->getCustomerId())));
Expand Down
11 changes: 11 additions & 0 deletions upgrade/upgrade-8.4.0.0.php
Expand Up @@ -90,6 +90,17 @@ function upgrade_module_8_4_0_0($module)
PRIMARY KEY (`reference_id`, `id_order`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
$db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_payment_token` (
`id` varchar(50) NOT NULL,
`paypal_customer_id` varchar(50) NOT NULL,
`payment_source` varchar(50) NOT NULL,
`data` text NOT NULL,
`merchant_id` varchar(50) NOT NULL,
`status` varchar(50) NOT NULL,
PRIMARY KEY (`id`, `paypal_customer_id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
} catch (Exception $exception) {
PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id);

Expand Down

0 comments on commit 9af1ebe

Please sign in to comment.