diff --git a/config/command-bus.yml b/config/command-bus.yml
new file mode 100644
index 000000000..4dbde4d50
--- /dev/null
+++ b/config/command-bus.yml
@@ -0,0 +1,47 @@
+services:
+ ps_checkout.tactician.bus:
+ class: 'League\Tactician\CommandBus'
+ factory: [ '@PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory', "create" ]
+
+ ps_checkout.bus.command:
+ class: 'PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusAdapter'
+ public: true
+ arguments:
+ - "@ps_checkout.tactician.bus"
+
+ PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory:
+ class: 'PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory'
+ public: true
+ arguments:
+ - "@ps_checkout.module"
+ - "@ps_checkout.logger"
+ - PrestaShop\Module\PrestashopCheckout\Order\Command\AddOrderPaymentCommand: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\AddOrderPaymentCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\Order\Command\CreateOrderCommand: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\CreateOrderCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\Order\Command\UpdateOrderStatusCommand: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\UpdateOrderStatusCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\Order\Matrice\Command\UpdateOrderMatriceCommand: 'PrestaShop\Module\PrestashopCheckout\Order\Matrice\CommandHandler\UpdateOrderMatriceCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\CreatePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CreatePayPalOrderCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\UpdatePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\UpdatePayPalOrderCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\CapturePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CapturePayPalOrderCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\Checkout\Command\CancelCheckoutCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\CancelCheckoutCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\Checkout\Command\SaveCheckoutCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\SaveCheckoutCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\Checkout\Command\SavePayPalOrderStatusCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\SavePayPalOrderStatusCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\Checkout\Command\UpdatePaymentMethodSelectedCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\UpdatePaymentMethodSelectedCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\Command\RefundPayPalCaptureCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\CommandHandler\RefundPayPalCaptureCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentCompletedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentCompletedQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentDeniedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentDeniedQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentPendingQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentPendingQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentRefundedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentRefundedQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentReversedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentReversedQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForApprovalReversedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForApprovalReversedQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCartIdQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForCartIdQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetCurrentPayPalOrderStatusQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetCurrentPayPalOrderStatusQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCheckoutCompletedQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForCheckoutCompletedQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForOrderConfirmationQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForOrderConfirmationQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Command\SavePaymentTokenCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\CommandHandler\SavePaymentTokenCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Command\DeletePaymentTokenCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\CommandHandler\DeletePaymentTokenCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Query\GetCustomerPaymentTokensQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Query\GetCustomerPaymentTokensQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Customer\Command\SavePayPalCustomerCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Customer\CommandHandler\SavePayPalCustomerCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalUserIdTokenQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalUserIdTokenQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\SavePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\SavePayPalOrderCommandHandler'
+ PrestaShop\Module\PrestashopCheckout\Configuration\ToggleShopConfigurationCommand: 'PrestaShop\Module\PrestashopCheckout\Configuration\ToggleShopConfigurationCommandHandler'
diff --git a/config/command-handlers.yml b/config/command-handlers.yml
index aa2bc42d1..c738a683a 100644
--- a/config/command-handlers.yml
+++ b/config/command-handlers.yml
@@ -120,3 +120,8 @@ services:
public: true
arguments:
- '@PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository'
+
+ PrestaShop\Module\PrestashopCheckout\Configuration\ToggleShopConfigurationCommandHandler:
+ class: 'PrestaShop\Module\PrestashopCheckout\Configuration\ToggleShopConfigurationCommandHandler'
+ arguments:
+ - '@ps_checkout.db'
diff --git a/config/common.yml b/config/common.yml
index 1d1b8e545..92a6847e7 100644
--- a/config/common.yml
+++ b/config/common.yml
@@ -1,6 +1,7 @@
imports:
- { resource: ./accounts.yml }
- { resource: ./cache.yml }
+ - { resource: ./command-bus.yml }
- { resource: ./command-handlers.yml }
- { resource: ./http-clients.yml }
- { resource: ./logger.yml }
@@ -42,52 +43,6 @@ services:
arguments:
- '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration'
- ps_checkout.tactician.bus:
- class: 'League\Tactician\CommandBus'
- factory: [ '@PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory', "create" ]
-
- ps_checkout.bus.command:
- class: 'PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusAdapter'
- public: true
- arguments:
- - "@ps_checkout.tactician.bus"
-
- PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory:
- class: 'PrestaShop\Module\PrestashopCheckout\CommandBus\TacticianCommandBusFactory'
- public: true
- arguments:
- - "@ps_checkout.module"
- - "@ps_checkout.logger"
- - PrestaShop\Module\PrestashopCheckout\Order\Command\AddOrderPaymentCommand: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\AddOrderPaymentCommandHandler'
- PrestaShop\Module\PrestashopCheckout\Order\Command\CreateOrderCommand: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\CreateOrderCommandHandler'
- PrestaShop\Module\PrestashopCheckout\Order\Command\UpdateOrderStatusCommand: 'PrestaShop\Module\PrestashopCheckout\Order\CommandHandler\UpdateOrderStatusCommandHandler'
- PrestaShop\Module\PrestashopCheckout\Order\Matrice\Command\UpdateOrderMatriceCommand: 'PrestaShop\Module\PrestashopCheckout\Order\Matrice\CommandHandler\UpdateOrderMatriceCommandHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\CreatePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CreatePayPalOrderCommandHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\UpdatePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\UpdatePayPalOrderCommandHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\CapturePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CapturePayPalOrderCommandHandler'
- PrestaShop\Module\PrestashopCheckout\Checkout\Command\CancelCheckoutCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\CancelCheckoutCommandHandler'
- PrestaShop\Module\PrestashopCheckout\Checkout\Command\SaveCheckoutCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\SaveCheckoutCommandHandler'
- PrestaShop\Module\PrestashopCheckout\Checkout\Command\SavePayPalOrderStatusCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\SavePayPalOrderStatusCommandHandler'
- PrestaShop\Module\PrestashopCheckout\Checkout\Command\UpdatePaymentMethodSelectedCommand: 'PrestaShop\Module\PrestashopCheckout\Checkout\CommandHandler\UpdatePaymentMethodSelectedCommandHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\Command\RefundPayPalCaptureCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\CommandHandler\RefundPayPalCaptureCommandHandler'
- PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentCompletedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentCompletedQueryHandler'
- PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentDeniedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentDeniedQueryHandler'
- PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentPendingQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentPendingQueryHandler'
- PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentRefundedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentRefundedQueryHandler'
- PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentReversedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForPaymentReversedQueryHandler'
- PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForApprovalReversedQuery: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForApprovalReversedQueryHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCartIdQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForCartIdQueryHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetCurrentPayPalOrderStatusQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetCurrentPayPalOrderStatusQueryHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderQueryHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCheckoutCompletedQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForCheckoutCompletedQueryHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForOrderConfirmationQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\QueryHandler\GetPayPalOrderForOrderConfirmationQueryHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Command\SavePaymentTokenCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\CommandHandler\SavePaymentTokenCommandHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Command\DeletePaymentTokenCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\CommandHandler\DeletePaymentTokenCommandHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Query\GetCustomerPaymentTokensQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Query\GetCustomerPaymentTokensQueryHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Customer\Command\SavePayPalCustomerCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Customer\CommandHandler\SavePayPalCustomerCommandHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalGetUserIdTokenQuery: 'PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalGetUserIdTokenQueryHandler'
- PrestaShop\Module\PrestashopCheckout\PayPal\Order\Command\SavePayPalOrderCommand: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\SavePayPalOrderCommandHandler'
-
PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherFactory:
class: 'PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherFactory'
public: true
@@ -100,7 +55,7 @@ services:
public: true
arguments:
- '@PrestaShop\Module\PrestashopCheckout\Checkout\CheckoutChecker'
- - '@ps_checkout.bus.command'
+ - '@ps_checkout.module'
- '@PrestaShop\Module\PrestashopCheckout\Repository\PsCheckoutCartRepository'
PrestaShop\Module\PrestashopCheckout\Order\EventSubscriber\OrderEventSubscriber:
@@ -257,6 +212,8 @@ services:
PrestaShop\Module\PrestashopCheckout\Builder\ModuleLink\ModuleLinkBuilder:
class: 'PrestaShop\Module\PrestashopCheckout\Builder\ModuleLink\ModuleLinkBuilder'
public: true
+ arguments:
+ - '@PrestaShop\Module\PrestashopCheckout\Adapter\LinkAdapter'
PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\LiveStep:
class: 'PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\LiveStep'
@@ -291,6 +248,7 @@ services:
- '@PrestaShop\Module\PrestashopCheckout\Shop\ShopProvider'
- '@PrestaShop\Module\PrestashopCheckout\Builder\ModuleLink\ModuleLinkBuilder'
- '@PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository'
+ - '@PrestaShop\Module\PrestashopCheckout\Adapter\LinkAdapter'
PrestaShop\Module\PrestashopCheckout\Adapter\LanguageAdapter:
class: 'PrestaShop\Module\PrestashopCheckout\Adapter\LanguageAdapter'
@@ -359,7 +317,6 @@ services:
arguments:
- '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration'
- '@PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository'
- - '@PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext'
PrestaShop\Module\PrestashopCheckout\Validator\FrontControllerValidator:
class: 'PrestaShop\Module\PrestashopCheckout\Validator\FrontControllerValidator'
@@ -423,10 +380,6 @@ services:
arguments:
- '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration'
- PrestaShop\Module\PrestashopCheckout\PayPal\Order\PayPalOrderStatus:
- class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\PayPalOrderStatus'
- public: true
-
PrestaShop\Module\PrestashopCheckout\PayPal\Order\CheckTransitionPayPalOrderStatusService:
class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CheckTransitionPayPalOrderStatusService'
public: true
@@ -471,5 +424,36 @@ services:
PrestaShop\Module\PrestashopCheckout\Provider\PaymentMethodLogoProvider:
class: 'PrestaShop\Module\PrestashopCheckout\Provider\PaymentMethodLogoProvider'
public: true
+ arguments:
+ - '@=service("ps_checkout.module").getPathUri()'
+
+ PrestaShop\Module\PrestashopCheckout\Dispatcher\OrderDispatcher:
+ class: 'PrestaShop\Module\PrestashopCheckout\Dispatcher\OrderDispatcher'
+ public: true
+ arguments:
+ - '@PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherAdapter'
+ - '@ps_checkout.logger'
+ - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration'
+
+ PrestaShop\Module\PrestashopCheckout\Presenter\Order\OrderPresenter:
+ class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Order\OrderPresenter'
+ public: true
arguments:
- '@ps_checkout.module'
+ - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceTranslationProvider'
+ - '@PrestaShop\Module\PrestashopCheckout\Provider\PaymentMethodLogoProvider'
+
+ PrestaShop\Module\PrestashopCheckout\Provider\PaymentOptionProvider:
+ class: 'PrestaShop\Module\PrestashopCheckout\Provider\PaymentOptionProvider'
+ public: true
+ arguments:
+ - '@ps_checkout.module'
+ - '@PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceProvider'
+ - '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration'
+
+ PrestaShop\Module\PrestashopCheckout\Adapter\LinkAdapter:
+ class: 'PrestaShop\Module\PrestashopCheckout\Adapter\LinkAdapter'
+ public: true
+ arguments:
+ - '@PrestaShop\Module\PrestashopCheckout\ShopContext'
+ - '@PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext'
diff --git a/config/query-handlers.yml b/config/query-handlers.yml
index 865d1df55..5ec57f089 100644
--- a/config/query-handlers.yml
+++ b/config/query-handlers.yml
@@ -73,8 +73,8 @@ services:
arguments:
- '@PrestaShop\Module\PrestashopCheckout\Repository\PaymentTokenRepository'
- PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalGetUserIdTokenQueryHandler:
- class: 'PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalGetUserIdTokenQueryHandler'
+ PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalUserIdTokenQueryHandler:
+ class: 'PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalUserIdTokenQueryHandler'
public: true
arguments:
- '@PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\OAuthService'
diff --git a/config/repository.yml b/config/repository.yml
index 771e5ac60..d0fc385bb 100644
--- a/config/repository.yml
+++ b/config/repository.yml
@@ -23,7 +23,6 @@ services:
class: 'PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository'
public: true
arguments:
- - '@PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration'
- "@ps_accounts.facade"
PrestaShop\Module\PrestashopCheckout\Repository\PayPalOrderRepository:
diff --git a/controllers/admin/AdminAjaxPrestashopCheckoutController.php b/controllers/admin/AdminAjaxPrestashopCheckoutController.php
index b107e13aa..87e7b9bf6 100755
--- a/controllers/admin/AdminAjaxPrestashopCheckoutController.php
+++ b/controllers/admin/AdminAjaxPrestashopCheckoutController.php
@@ -443,12 +443,13 @@ public function ajaxProcessFetchOrder()
/** @var FundingSourceTranslationProvider $fundingSourceTranslationProvider */
$fundingSourceTranslationProvider = $this->module->getService(FundingSourceTranslationProvider::class);
- $presenter = new OrderPresenter($this->module, $paypalOrder);
+ /** @var OrderPresenter $presenter */
+ $presenter = $this->module->getService(OrderPresenter::class);
$this->context->smarty->assign([
'moduleName' => $this->module->displayName,
'moduleUrl' => $this->context->link->getAdminLink('AdminModules', true, [], ['configure' => 'ps_checkout']),
- 'orderPayPal' => $presenter->present(),
+ 'orderPayPal' => $presenter->present($paypalOrder),
'orderPayPalBaseUrl' => $this->context->link->getAdminLink('AdminAjaxPrestashopCheckout'),
'moduleLogoUri' => $this->module->getPathUri() . 'logo.png',
'orderPaymentDisplayName' => $fundingSourceTranslationProvider->getPaymentMethodName($psCheckoutCart->paypal_funding),
diff --git a/controllers/admin/AdminPaypalOnboardingPrestashopCheckoutController.php b/controllers/admin/AdminPaypalOnboardingPrestashopCheckoutController.php
index 464791fa4..24eae7c3c 100755
--- a/controllers/admin/AdminPaypalOnboardingPrestashopCheckoutController.php
+++ b/controllers/admin/AdminPaypalOnboardingPrestashopCheckoutController.php
@@ -46,8 +46,11 @@ public function postProcess()
return false;
}
+ /** @var LinkAdapter $linkAdapter */
+ $linkAdapter = $this->module->getService(LinkAdapter::class);
+
Tools::redirect(
- (new LinkAdapter($this->context->link))->getAdminLink(
+ $linkAdapter->getAdminLink(
'AdminModules',
true,
[],
@@ -80,6 +83,9 @@ public function initCursedPage()
$this->addCSS(__PS_BASE_URI__ . $this->admin_webpath . '/themes/' . $this->bo_theme . '/css/' . $this->bo_css, 'all', 0);
}
+ /** @var LinkAdapter $linkAdapter */
+ $linkAdapter = $this->module->getService(LinkAdapter::class);
+
$this->context->smarty->assign([
'img_dir' => _PS_IMG_,
'iso' => $this->context->language->iso_code,
@@ -90,7 +96,7 @@ public function initCursedPage()
'js_files' => array_unique($this->js_files),
'errors' => $this->errors,
'logoSrc' => $this->module->getPathUri() . 'logo.png',
- 'moduleLink' => (new LinkAdapter($this->context->link))->getAdminLink(
+ 'moduleLink' => $linkAdapter->getAdminLink(
'AdminModules',
true,
[],
diff --git a/controllers/front/DispatchWebHook.php b/controllers/front/DispatchWebHook.php
index 0677ab9fb..088107032 100755
--- a/controllers/front/DispatchWebHook.php
+++ b/controllers/front/DispatchWebHook.php
@@ -227,6 +227,9 @@ private function checkExecutionPermissions()
*/
private function dispatchWebHook()
{
+ /** @var OrderDispatcher $orderDispatcher */
+ $orderDispatcher = $this->module->getService(OrderDispatcher::class);
+
$this->module->getLogger()->info(
'DispatchWebHook',
[
@@ -238,7 +241,7 @@ private function dispatchWebHook()
);
if ('ShopNotificationOrderChange' === $this->payload['category']) {
- return (new OrderDispatcher())->dispatchEventType($this->payload);
+ return $orderDispatcher->dispatchEventType($this->payload);
}
$this->module->getLogger()->info(
diff --git a/ps_checkout.php b/ps_checkout.php
index 0720d6294..bc79bad32 100755
--- a/ps_checkout.php
+++ b/ps_checkout.php
@@ -600,74 +600,10 @@ public function hookPaymentOptions(array $params)
return [];
}
- /** @var \PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceProvider $fundingSourceProvider */
- $fundingSourceProvider = $this->getService(\PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceProvider::class);
-
- /** @var \PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration $configurationPayPal */
- $configurationPayPal = $this->getService(\PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration::class);
-
- $paymentOptions = [];
-
- $vaultingEnabled = $configurationPayPal->isVaultingEnabled()
- && $this->context->customer->isLogged();
-
- $this->context->smarty->assign('lockIcon', Media::getMediaPath(_PS_MODULE_DIR_ . $this->name . '/views/img/icons/lock_fill.svg'));
- $vaultedPayPal = [];
-
- if ($vaultingEnabled) {
- foreach ($fundingSourceProvider->getSavedTokens($cart->id_customer) as $fundingSource) {
- if ($fundingSource->paymentSource === 'paypal') {
- $vaultedPayPal = [
- 'paymentIdentifier' => $fundingSource->name,
- 'fundingSource' => $fundingSource->paymentSource,
- 'isFavorite' => $fundingSource->isFavorite,
- 'label' => $fundingSource->label,
- 'vaultId' => explode('-', $fundingSource->name)[1],
- ];
- continue;
- }
- $paymentOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption();
- $paymentOption->setModuleName($this->name . '-' . $fundingSource->name);
- $paymentOption->setCallToActionText($fundingSource->label);
- $paymentOption->setBinary(true);
-
- $this->context->smarty->assign([
- 'paymentIdentifier' => $fundingSource->name,
- 'fundingSource' => $fundingSource->paymentSource,
- 'isFavorite' => $fundingSource->isFavorite,
- 'label' => $fundingSource->label,
- 'vaultId' => explode('-', $fundingSource->name)[1],
- ]);
- $paymentOption->setForm($this->context->smarty->fetch('module:ps_checkout/views/templates/hook/partials/vaultTokenForm.tpl'));
-
- $paymentOptions[] = $paymentOption;
- }
- }
-
- foreach ($fundingSourceProvider->getAll() as $fundingSource) {
- $paymentOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption();
- $paymentOption->setModuleName($this->name . '-' . $fundingSource->name);
- $paymentOption->setCallToActionText($fundingSource->label);
- $paymentOption->setBinary(true);
- $this->context->smarty->assign([
- 'vaultingEnabled' => $vaultingEnabled,
- 'paymentIdentifier' => $fundingSource->name,
- ]);
-
- if ('card' === $fundingSource->name && $configurationPayPal->isHostedFieldsEnabled() && in_array($configurationPayPal->getCardHostedFieldsStatus(), ['SUBSCRIBED', 'LIMITED'], true)) {
- $this->context->smarty->assign('modulePath', $this->getPathUri());
- $paymentOption->setForm($this->context->smarty->fetch('module:ps_checkout/views/templates/hook/partials/cardFields.tpl'));
- } elseif ($fundingSource->name === 'paypal' && empty($vaultedPayPal)) {
- $paymentOption->setForm($this->context->smarty->fetch('module:ps_checkout/views/templates/hook/partials/vaultPaymentForm.tpl'));
- } elseif ($fundingSource->name === 'paypal' && $vaultedPayPal) {
- $this->context->smarty->assign($vaultedPayPal);
- $paymentOption->setForm($this->context->smarty->fetch('module:ps_checkout/views/templates/hook/partials/vaultTokenForm.tpl'));
- }
+ /** @var \PrestaShop\Module\PrestashopCheckout\Provider\PaymentOptionProvider $paymentOptionProvider */
+ $paymentOptionProvider = $this->getService(\PrestaShop\Module\PrestashopCheckout\Provider\PaymentOptionProvider ::class);
- $paymentOptions[] = $paymentOption;
- }
-
- return $paymentOptions;
+ return $paymentOptionProvider->getPaymentOptions((int) $this->context->customer->id);
}
/**
@@ -764,14 +700,14 @@ public function hookDisplayAdminAfterHeader()
{
/** @var \PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration $paypalConfiguration */
$paypalConfiguration = $this->getService(\PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration::class);
- /** @var \PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository $psAccount */
- $psAccount = $this->getService(\PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository::class);
+ /** @var \PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository $psAccountRepository */
+ $psAccountRepository = $this->getService(\PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository::class);
/** @var \PrestaShop\Module\PrestashopCheckout\ShopContext $shopContext */
$shopContext = $this->getService(\PrestaShop\Module\PrestashopCheckout\ShopContext::class);
- /** @var \PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\ContextModule $moduleContext */
- $moduleContext = $this->getService(\PrestaShop\Module\PrestashopCheckout\Presenter\Store\Modules\ContextModule::class);
+ /** @var \PrestaShop\Module\PrestashopCheckout\Adapter\LinkAdapter $linkAdapter */
+ $linkAdapter = $this->getService(\PrestaShop\Module\PrestashopCheckout\Adapter\LinkAdapter::class);
$isShop17 = $shopContext->isShop17();
- $isFullyOnboarded = $psAccount->onBoardingIsCompleted() && $paypalConfiguration->getMerchantId();
+ $isFullyOnboarded = $psAccountRepository->onBoardingIsCompleted() && $paypalConfiguration->getMerchantId();
if ('AdminPayment' === Tools::getValue('controller') && $isShop17) { // Display on PrestaShop 1.7.x.x only
if (in_array($this->getShopDefaultCountryCode(), ['FR', 'IT'])
@@ -783,7 +719,7 @@ public function hookDisplayAdminAfterHeader()
$params = [
'imgPath' => $this->_path . 'views/img/',
- 'configureLink' => (new PrestaShop\Module\PrestashopCheckout\Adapter\LinkAdapter($this->context->link))->getAdminLink(
+ 'configureLink' => $linkAdapter->getAdminLink(
'AdminModules',
true,
[],
@@ -799,7 +735,7 @@ public function hookDisplayAdminAfterHeader()
'codesType' => 'countries',
'incompatibleCodes' => $paypalConfiguration->getIncompatibleCountryCodes(),
'paypalLink' => 'https://developer.paypal.com/docs/api/reference/country-codes/#',
- 'paymentPreferencesLink' => $moduleContext->getGeneratedLink($isShop17 ? 'AdminPaymentPreferences' : 'AdminPayment'),
+ 'paymentPreferencesLink' => $linkAdapter->getAdminLink($isShop17 ? 'AdminPaymentPreferences' : 'AdminPayment'),
];
$template = 'views/templates/hook/adminAfterHeader/incompatibleCodes.tpl';
} elseif ('AdminCurrencies' === Tools::getValue('controller') && $isFullyOnboarded) {
@@ -808,7 +744,7 @@ public function hookDisplayAdminAfterHeader()
'codesType' => 'currencies',
'incompatibleCodes' => $paypalConfiguration->getIncompatibleCurrencyCodes(),
'paypalLink' => 'https://developer.paypal.com/docs/api/reference/currency-codes/#',
- 'paymentPreferencesLink' => $moduleContext->getGeneratedLink($isShop17 ? 'AdminPaymentPreferences' : 'AdminPayment'),
+ 'paymentPreferencesLink' => $linkAdapter->getAdminLink($isShop17 ? 'AdminPaymentPreferences' : 'AdminPayment'),
];
$template = 'views/templates/hook/adminAfterHeader/incompatibleCodes.tpl';
} else {
@@ -827,41 +763,31 @@ public function hookActionAdminControllerSetMedia()
{
/** @var \PrestaShop\Module\PrestashopCheckout\Version\Version $version */
$version = $this->getService('ps_checkout.module.version');
+ $controller = Tools::getValue('controller');
- if ('AdminPayment' === Tools::getValue('controller')) {
- $this->context->controller->addCss(
- $this->_path . 'views/css/adminAfterHeader.css?version=' . $version->getSemVersion(),
- 'all',
- null,
- false
- );
- }
+ $pageCss = '';
- if ('AdminCountries' === Tools::getValue('controller')) {
- $this->context->controller->addCss(
- $this->_path . 'views/css/incompatible-banner.css?version=' . $version->getSemVersion(),
- 'all',
- null,
- false
- );
+ switch ($controller) {
+ case 'AdminPayment':
+ $pageCss = $this->getPathUri() . 'views/css/adminAfterHeader.css?version=' . $version->getSemVersion();
+ break;
+ case 'AdminCurrencies':
+ case 'AdminCountries':
+ $pageCss = $this->getPathUri() . 'views/css/incompatible-banner.css?version=' . $version->getSemVersion();
+ break;
}
- if ('AdminCurrencies' === Tools::getValue('controller')) {
- $this->context->controller->addCss(
- $this->_path . 'views/css/incompatible-banner.css?version=' . $version->getSemVersion(),
- 'all',
- null,
- false
- );
+ if (!empty($pageCss)) {
+ $this->context->controller->addCss($pageCss, 'all', null, false);
}
- if ('AdminOrders' === Tools::getValue('controller') || 'AdminOrders' === Tools::getValue('tab')) {
+ if ('AdminOrders' === $controller || 'AdminOrders' === Tools::getValue('tab')) {
$this->context->controller->addJS(
$this->getPathUri() . 'views/js/adminOrderView.js?version=' . $version->getSemVersion(),
false
);
$this->context->controller->addCss(
- $this->_path . 'views/css/adminOrderView.css?version=' . $version->getSemVersion(),
+ $this->getPathUri() . 'views/css/adminOrderView.css?version=' . $version->getSemVersion(),
'all',
null,
false
@@ -954,7 +880,7 @@ public function hookActionFrontControllerSetMedia()
$this->context->country->iso_code === 'GB' ? 'UK' : $this->context->country->iso_code,
$this->context->currency->iso_code
);
- $supportedCardBrands = $supportedCardBrandsByContext ? $supportedCardBrandsByContext : $supportedCardBrands;
+ $supportedCardBrands = $supportedCardBrandsByContext ?: $supportedCardBrands;
}
$fundingSourcesSorted = [];
@@ -1310,13 +1236,13 @@ public function hookActionObjectShopAddAfter(array $params)
$shop = $params['object'];
$now = date('Y-m-d H:i:s');
- $toggleShopConfigurationCommandHandler = new \PrestaShop\Module\PrestashopCheckout\Configuration\ToggleShopConfigurationCommandHandler();
- $toggleShopConfigurationCommandHandler->handle(
- new \PrestaShop\Module\PrestashopCheckout\Configuration\ToggleShopConfigurationCommand(
- (int) Configuration::get('PS_SHOP_DEFAULT'),
- (bool) Shop::isFeatureActive()
- )
- );
+ /** @var \PrestaShop\Module\PrestashopCheckout\CommandBus\CommandBusInterface $commandBus */
+ $commandBus = $this->getService('ps_checkout.bus.command');
+
+ $commandBus->handle(new \PrestaShop\Module\PrestashopCheckout\Configuration\ToggleShopConfigurationCommand(
+ (int) Configuration::get('PS_SHOP_DEFAULT'),
+ (bool) Shop::isFeatureActive()
+ ));
foreach ($this->configurationList as $name => $value) {
if (Configuration::hasKey($name, null, (int) $shop->id_shop_group, (int) $shop->id)) {
@@ -1678,8 +1604,9 @@ private function getShopDefaultCountryCode()
*/
public function hookActionObjectShopDeleteAfter(array $params)
{
- $toggleShopConfigurationCommandHandler = new \PrestaShop\Module\PrestashopCheckout\Configuration\ToggleShopConfigurationCommandHandler();
- $toggleShopConfigurationCommandHandler->handle(
+ /** @var \PrestaShop\Module\PrestashopCheckout\CommandBus\CommandBusInterface $commandBus */
+ $commandBus = $this->getService('ps_checkout.bus.command');
+ $commandBus->handle(
new \PrestaShop\Module\PrestashopCheckout\Configuration\ToggleShopConfigurationCommand(
(int) Configuration::get('PS_SHOP_DEFAULT'),
(bool) Shop::isFeatureActive()
diff --git a/src/Adapter/LinkAdapter.php b/src/Adapter/LinkAdapter.php
index f95b435d2..cdd9b49ae 100644
--- a/src/Adapter/LinkAdapter.php
+++ b/src/Adapter/LinkAdapter.php
@@ -20,6 +20,8 @@
namespace PrestaShop\Module\PrestashopCheckout\Adapter;
+use Link;
+use PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext;
use PrestaShop\Module\PrestashopCheckout\ShopContext;
/**
@@ -30,17 +32,23 @@ class LinkAdapter
/**
* Link object
*
- * @var \Link
+ * @var Link
*/
private $link;
+ /**
+ * @var ShopContext
+ */
+ private $shopContext;
+ /**
+ * @var PrestaShopContext
+ */
+ private $prestaShopContext;
- public function __construct(\Link $link = null)
+ public function __construct(ShopContext $shopContext, PrestaShopContext $prestaShopContext)
{
- if (null === $link) {
- $link = new \Link();
- }
-
- $this->link = $link;
+ $this->link = $prestaShopContext->getLink() ?: new Link();
+ $this->shopContext = $shopContext;
+ $this->prestaShopContext = $prestaShopContext;
}
/**
@@ -52,18 +60,12 @@ public function __construct(\Link $link = null)
* @param array $params
*
* @return string
- *
- * @throws \PrestaShopException
*/
public function getAdminLink($controller, $withToken = true, $sfRouteParams = [], $params = [])
{
- $shop = \Context::getContext()->shop;
- /** @var \Ps_checkout $module */
- $module = \Module::getInstanceByName('ps_checkout');
- /** @var ShopContext $shopContext */
- $shopContext = $module->getService(ShopContext::class);
+ $shop = $this->prestaShopContext->getShop();
- if ($shopContext->isShop17()) {
+ if ($this->shopContext->isShop17()) {
$adminLink = $this->link->getAdminLink($controller, $withToken, $sfRouteParams, $params);
if ($shop->virtual_uri !== '') {
diff --git a/src/Api/Payment/PaymentService.php b/src/Api/Payment/PaymentService.php
new file mode 100644
index 000000000..23ea648e4
--- /dev/null
+++ b/src/Api/Payment/PaymentService.php
@@ -0,0 +1,492 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
+ */
+
+namespace PrestaShop\Module\PrestashopCheckout\Api\Payment;
+
+use Http\Client\Exception\HttpException;
+use PrestaShop\Module\PrestashopCheckout\Exception\InvalidRequestException;
+use PrestaShop\Module\PrestashopCheckout\Exception\NotAuthorizedException;
+use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException;
+use PrestaShop\Module\PrestashopCheckout\Exception\UnprocessableEntityException;
+use PrestaShop\Module\PrestashopCheckout\Http\CheckoutHttpClient;
+use PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO\CreatePayPalOrderRequestInterface;
+use PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO\CreatePayPalOrderResponse;
+use PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO\UpdatePayPalOrderRequestInterface;
+use PrestaShop\Module\PrestashopCheckout\Serializer\ObjectSerializerInterface;
+use Psr\Http\Message\ResponseInterface;
+use Symfony\Component\Serializer\Encoder\JsonEncoder;
+
+class PaymentService
+{
+ /**
+ * @var CheckoutHttpClient
+ */
+ private $client;
+ /**
+ * @var ObjectSerializerInterface
+ */
+ private $serializer;
+
+ public function __construct(CheckoutHttpClient $client, ObjectSerializerInterface $serializer)
+ {
+ $this->client = $client;
+ $this->serializer = $serializer;
+ }
+
+ /**
+ * @param CreatePayPalOrderRequestInterface $request
+ *
+ * @return CreatePayPalOrderResponse
+ *
+ * @throws InvalidRequestException|NotAuthorizedException|UnprocessableEntityException|PsCheckoutException
+ */
+ public function createOrder(CreatePayPalOrderRequestInterface $request)
+ {
+ try {
+ $response = $this->client->createOrder($this->serializer->serialize($request, JsonEncoder::FORMAT, true));
+
+ return $this->serializer->deserialize($response->getBody()->getContents(), CreatePayPalOrderResponse::class, JsonEncoder::FORMAT);
+ } catch (HttpException $exception) {
+ $response = $exception->getResponse();
+ $errorMsg = $this->getErrorMessage($response->getBody()->getContents());
+ switch ($response->getStatusCode()) {
+ case 400:
+ switch ($errorMsg) {
+ case 'INVALID_ARRAY_MAX_ITEMS':
+ throw new InvalidRequestException('The number of items in an array parameter is too large', InvalidRequestException::INVALID_ARRAY_MAX_ITEMS);
+ case 'INVALID_ARRAY_MIN_ITEMS':
+ throw new InvalidRequestException('The number of items in an array parameter is too small', InvalidRequestException::INVALID_ARRAY_MIN_ITEMS);
+ case 'INVALID_COUNTRY_CODE':
+ throw new InvalidRequestException('Country code is invalid', InvalidRequestException::INVALID_COUNTRY_CODE);
+ case 'INVALID_PARAMETER_SYNTAX':
+ throw new InvalidRequestException('The value of a field does not conform to the expected format', InvalidRequestException::INVALID_PARAMETER_SYNTAX);
+ case 'INVALID_STRING_LENGTH':
+ throw new InvalidRequestException('The value of a field is either too short or too long', InvalidRequestException::INVALID_STRING_LENGTH);
+ case 'INVALID_PARAMETER_VALUE':
+ throw new InvalidRequestException('A parameter value is not valid', InvalidRequestException::INVALID_PARAMETER_VALUE);
+ case 'MISSING_REQUIRED_PARAMETER':
+ throw new InvalidRequestException('A required parameter is missing', InvalidRequestException::MISSING_REQUIRED_PARAMETER);
+ case 'NOT_SUPPORTED':
+ throw new InvalidRequestException('A field used is not currently supported', InvalidRequestException::NOT_SUPPORTED);
+ case 'PAYPAL_REQUEST_ID_REQUIRED':
+ throw new InvalidRequestException('A PayPal-Request-Id is required if you are trying to process payment for an Order', InvalidRequestException::PAYPAL_REQUEST_ID_REQUIRED);
+ case 'MALFORMED_REQUEST_JSON':
+ throw new InvalidRequestException('The request JSON is not well formed', InvalidRequestException::MALFORMED_REQUEST_JSON);
+ default:
+ throw new InvalidRequestException(sprintf('InvalidRequest unknown error : %s', $errorMsg), InvalidRequestException::UNKNOWN);
+ }
+ // no break
+ case 401:
+ switch ($errorMsg) {
+ case 'PERMISSION_DENIED':
+ throw new NotAuthorizedException('You do not have permission to access or perform operations on this resource', NotAuthorizedException::PERMISSION_DENIED);
+ case 'PERMISSION_DENIED_FOR_DONATION_ITEMS':
+ throw new NotAuthorizedException('The payee have not been granted appropriate permissions to send items.category as DONATION', NotAuthorizedException::PERMISSION_DENIED_FOR_DONATION_ITEMS);
+ case 'MALFORMED_REQUEST':
+ throw new NotAuthorizedException('You have sent a request that PayPal server could not understand', NotAuthorizedException::MALFORMED_REQUEST);
+ default:
+ throw new NotAuthorizedException(sprintf('NotAuthorized unknown error : %s', $errorMsg), NotAuthorizedException::UNKNOWN);
+ }
+ // no break
+ case 422:
+ switch ($errorMsg) {
+ case 'AMOUNT_MISMATCH':
+ throw new UnprocessableEntityException('Total amount mismatch with the breakdown', UnprocessableEntityException::AMOUNT_MISMATCH);
+ case 'BILLING_ADDRESS_INVALID':
+ throw new UnprocessableEntityException('Provided billing address is invalid', UnprocessableEntityException::BILLING_ADDRESS_INVALID);
+ case 'CANNOT_BE_NEGATIVE':
+ throw new UnprocessableEntityException('Currency must be greater than or equal to zero', UnprocessableEntityException::CANNOT_BE_NEGATIVE);
+ case 'CANNOT_BE_ZERO_OR_NEGATIVE':
+ throw new UnprocessableEntityException('Currency must be greater than zero', UnprocessableEntityException::CANNOT_BE_ZERO_OR_NEGATIVE);
+ case 'CARD_EXPIRED':
+ throw new UnprocessableEntityException('The payment card provided is expired', UnprocessableEntityException::CARD_EXPIRED);
+ case 'CITY_REQUIRED':
+ throw new UnprocessableEntityException('The specified country requires a city in address.admin_area_2', UnprocessableEntityException::CITY_REQUIRED);
+ case 'DECIMAL_PRECISION':
+ throw new UnprocessableEntityException('If the currency supports decimals, only two decimal places are supported', UnprocessableEntityException::DECIMAL_PRECISION);
+ case 'DONATION_ITEMS_NOT_SUPPORTED':
+ throw new UnprocessableEntityException('If purchase_unit has DONATION as the items.category, then the order can at most have one purchase_unit', UnprocessableEntityException::DONATION_ITEMS_NOT_SUPPORTED);
+ case 'DUPLICATE_REFERENCE_ID':
+ throw new UnprocessableEntityException('The reference_id must be unique', UnprocessableEntityException::DUPLICATE_REFERENCE_ID);
+ case 'INVALID_CURRENCY_CODE':
+ throw new UnprocessableEntityException('Currency code is invalid or is not currently supported', UnprocessableEntityException::INVALID_CURRENCY_CODE);
+ case 'INVALID_PAYER_ID':
+ throw new UnprocessableEntityException('The payer ID is not valid', UnprocessableEntityException::INVALID_PAYER_ID);
+ case 'ITEM_TOTAL_MISMATCH':
+ throw new UnprocessableEntityException('Should equal sum of unit_amount * quantity across all items for a given purchase_unit', UnprocessableEntityException::ITEM_TOTAL_MISMATCH);
+ case 'ITEM_TOTAL_REQUIRED':
+ throw new UnprocessableEntityException('If item details are specified, items.unit_amount, items.quantity and amount.breakdown.item_total are required', UnprocessableEntityException::ITEM_TOTAL_REQUIRED);
+ case 'MAX_VALUE_EXCEEDED':
+ throw new UnprocessableEntityException('Should be less than or equal to 9999999.99', UnprocessableEntityException::MAX_VALUE_EXCEEDED);
+ case 'MISSING_PICKUP_ADDRESS':
+ throw new UnprocessableEntityException('A pickup address (shipping.address) is required for the provided shipping.type', UnprocessableEntityException::MISSING_PICKUP_ADDRESS);
+ case 'MULTI_CURRENCY_ORDER':
+ throw new UnprocessableEntityException('Multiple differing values of currency_code are not supported', UnprocessableEntityException::MULTI_CURRENCY_ORDER);
+ case 'MULTIPLE_ITEM_CATEGORIES':
+ throw new UnprocessableEntityException('For a given purchase unit, items.category as DONATION cannot be combined with items with either PHYSICAL_GOODS or DIGITAL_GOODS', UnprocessableEntityException::MULTIPLE_ITEM_CATEGORIES);
+ case 'MULTIPLE_SHIPPING_ADDRESS_NOT_SUPPORTED':
+ throw new UnprocessableEntityException('Multiple shipping addresses are not supported', UnprocessableEntityException::MULTIPLE_SHIPPING_ADDRESS_NOT_SUPPORTED);
+ case 'MULTIPLE_SHIPPING_TYPE_NOT_SUPPORTED':
+ throw new UnprocessableEntityException('Different shipping.type are not supported across purchase units', UnprocessableEntityException::MULTIPLE_SHIPPING_TYPE_NOT_SUPPORTED);
+ case 'PAYEE_ACCOUNT_INVALID':
+ throw new UnprocessableEntityException('Mismatch between request payeeId and payeeEmail', UnprocessableEntityException::PAYEE_ACCOUNT_INVALID);
+ case 'PAYEE_ACCOUNT_LOCKED_OR_CLOSED':
+ throw new UnprocessableEntityException('The merchant account is locked or closed', UnprocessableEntityException::PAYEE_ACCOUNT_LOCKED_OR_CLOSED);
+ case 'PAYEE_ACCOUNT_RESTRICTED':
+ throw new UnprocessableEntityException('The merchant account is restricted', UnprocessableEntityException::PAYEE_ACCOUNT_RESTRICTED);
+ case 'REFERENCE_ID_REQUIRED':
+ throw new UnprocessableEntityException('The reference_id is required for each purchase_unit', UnprocessableEntityException::REFERENCE_ID_REQUIRED);
+ case 'PAYMENT_SOURCE_CANNOT_BE_USED':
+ throw new UnprocessableEntityException('The provided payment source cannot be used to pay for the order', UnprocessableEntityException::PAYMENT_SOURCE_CANNOT_BE_USED);
+ case 'PAYMENT_SOURCE_DECLINED_BY_PROCESSOR':
+ throw new UnprocessableEntityException('The provided payment source is declined by the processor', UnprocessableEntityException::PAYMENT_SOURCE_DECLINED_BY_PROCESSOR);
+ case 'PAYMENT_SOURCE_INFO_CANNOT_BE_VERIFIED':
+ throw new UnprocessableEntityException('The provided payment source is declined by the processor', UnprocessableEntityException::PAYMENT_SOURCE_INFO_CANNOT_BE_VERIFIED);
+ case 'POSTAL_CODE_REQUIRED':
+ throw new UnprocessableEntityException('The specified country requires a postal code', UnprocessableEntityException::POSTAL_CODE_REQUIRED);
+ case 'SHIPPING_ADDRESS_INVALID':
+ throw new UnprocessableEntityException('Provided shipping address is invalid', UnprocessableEntityException::SHIPPING_ADDRESS_INVALID);
+ case 'TAX_TOTAL_MISMATCH':
+ throw new UnprocessableEntityException('Should equal sum of tax * quantity across all items for a given purchase unit', UnprocessableEntityException::TAX_TOTAL_MISMATCH);
+ case 'TAX_TOTAL_REQUIRED':
+ throw new UnprocessableEntityException('If item details are specified, items.tax_total, items.quantity, and amount.breakdown.tax_total are required', UnprocessableEntityException::TAX_TOTAL_REQUIRED);
+ case 'UNSUPPORTED_INTENT':
+ throw new UnprocessableEntityException('The intent AUTHORIZE is not supported for multiple purchase units', UnprocessableEntityException::UNSUPPORTED_INTENT);
+ case 'UNSUPPORTED_PAYMENT_INSTRUCTION':
+ throw new UnprocessableEntityException('You must provide the payment instruction when you capture an authorized payment using intent AUTHORIZE', UnprocessableEntityException::UNSUPPORTED_PAYMENT_INSTRUCTION);
+ case 'SHIPPING_TYPE_NOT_SUPPORTED_FOR_CLIENT':
+ throw new UnprocessableEntityException('PayPal account is not setup to be able to support a shipping.type PICKUP_IN_PERSON', UnprocessableEntityException::SHIPPING_TYPE_NOT_SUPPORTED_FOR_CLIENT);
+ case 'UNSUPPORTED_SHIPPING_TYPE':
+ throw new UnprocessableEntityException('The provided shipping.type is only supported for application_context.shipping_preference SET_PROVIDED_ADDRESS or NO_SHIPPING', UnprocessableEntityException::UNSUPPORTED_SHIPPING_TYPE);
+ case 'SHIPPING_OPTION_NOT_SELECTED':
+ throw new UnprocessableEntityException('At least one of the shipping.option should be set to selected = true', UnprocessableEntityException::SHIPPING_OPTION_NOT_SELECTED);
+ case 'SHIPPING_OPTIONS_NOT_SUPPORTED':
+ throw new UnprocessableEntityException('Shipping options are not supported when application_context.shipping_preference is set to NO_SHIPPING or SET_PROVIDED_ADDRESS', UnprocessableEntityException::SHIPPING_OPTIONS_NOT_SUPPORTED);
+ case 'MULTIPLE_SHIPPING_OPTION_SELECTED':
+ throw new UnprocessableEntityException('Only one shipping.option can be set to selected = true', UnprocessableEntityException::MULTIPLE_SHIPPING_OPTION_SELECTED);
+ case 'PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH':
+ throw new UnprocessableEntityException('The amount provided in the preferred shipping option should match the amount provided in amount breakdown', UnprocessableEntityException::PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH);
+ case 'CARD_CLOSED':
+ throw new UnprocessableEntityException('The card is closed with the issuer', UnprocessableEntityException::CARD_CLOSED);
+ case 'ORDER_CANNOT_BE_SAVED':
+ throw new UnprocessableEntityException('The option to save an order is only available if the intent is AUTHORIZE and processing_instruction uses one of the ORDER_SAVED options', UnprocessableEntityException::ORDER_CANNOT_BE_SAVED);
+ case 'SAVE_ORDER_NOT_SUPPORTED':
+ throw new UnprocessableEntityException('PayPal account is setup in a way that does not allow it to be used for saving the order', UnprocessableEntityException::SAVE_ORDER_NOT_SUPPORTED);
+ case 'PUI_DUPLICATE_ORDER':
+ throw new UnprocessableEntityException('A Pay Upon Invoice order with the same payload has already been successfully processed in the last few seconds', UnprocessableEntityException::PUI_DUPLICATE_ORDER);
+ default:
+ throw new UnprocessableEntityException(sprintf('UnprocessableEntity unknown error : %s', $errorMsg), UnprocessableEntityException::UNKNOWN);
+ }
+ // no break
+ default:
+ throw new PsCheckoutException(sprintf('Unknown error : %s', $errorMsg), PsCheckoutException::UNKNOWN);
+ }
+ }
+ }
+
+ /**
+ * @param UpdatePayPalOrderRequestInterface $request
+ *
+ * @return ResponseInterface
+ *
+ * @throws InvalidRequestException|NotAuthorizedException|UnprocessableEntityException|PsCheckoutException
+ */
+ public function updateOrder(UpdatePayPalOrderRequestInterface $request)
+ {
+ try {
+ return $this->client->updateOrder($this->serializer->serialize($request, JsonEncoder::FORMAT, true));
+ } catch (HttpException $exception) {
+ $response = $exception->getResponse();
+ $errorMsg = $this->getErrorMessage($response->getBody()->getContents());
+ switch ($response->getStatusCode()) {
+ case 400:
+ switch ($errorMsg) {
+ case 'FIELD_NOT_PATCHABLE':
+ throw new InvalidRequestException('Field cannot be patched', InvalidRequestException::FIELD_NOT_PATCHABLE);
+ case 'INVALID_ARRAY_MAX_ITEMS':
+ throw new InvalidRequestException('The number of items in an array parameter is too large', InvalidRequestException::INVALID_ARRAY_MAX_ITEMS);
+ case 'INVALID_PARAMETER_SYNTAX':
+ throw new InvalidRequestException('The value of a field does not conform to the expected format', InvalidRequestException::INVALID_PARAMETER_SYNTAX);
+ case 'INVALID_STRING_LENGTH':
+ throw new InvalidRequestException('The value of a field is either too short or too long', InvalidRequestException::INVALID_STRING_LENGTH);
+ case 'INVALID_PARAMETER_VALUE':
+ throw new InvalidRequestException('The value of a field is invalid', InvalidRequestException::INVALID_PARAMETER_VALUE);
+ case 'MISSING_REQUIRED_PARAMETER':
+ throw new InvalidRequestException('A required field or parameter is missing', InvalidRequestException::MISSING_REQUIRED_PARAMETER);
+ case 'AMOUNT_NOT_PATCHABLE':
+ throw new InvalidRequestException('The amount cannot be updated as the payer has chosen and approved a specific financing offer for a given amount', InvalidRequestException::AMOUNT_NOT_PATCHABLE);
+ case 'INVALID_PATCH_OPERATION':
+ throw new InvalidRequestException('The operation cannot be honored. Cannot add a already existing property nor remove a property that is not present', InvalidRequestException::INVALID_PATCH_OPERATION);
+ default:
+ throw new InvalidRequestException(sprintf('InvalidRequest unknown error : %s', $errorMsg), InvalidRequestException::UNKNOWN);
+ }
+ // no break
+ case 401:
+ switch ($errorMsg) {
+ case 'PERMISSION_DENIED':
+ throw new NotAuthorizedException('You do not have permission to access or perform operations on this resource', NotAuthorizedException::PERMISSION_DENIED);
+ case 'PAYEE_ACCOUNT_NOT_SUPPORTED':
+ throw new NotAuthorizedException('Payee does not have an account', NotAuthorizedException::PAYEE_ACCOUNT_NOT_SUPPORTED);
+ case 'PAYEE_ACCOUNT_NOT_VERIFIED':
+ throw new NotAuthorizedException('Payee has not verified their account with PayPal', NotAuthorizedException::PAYEE_ACCOUNT_NOT_VERIFIED);
+ case 'PAYEE_NOT_CONSENTED':
+ throw new NotAuthorizedException('Payee does not have appropriate consent to allow the API caller to process this type of transaction on their behalf', NotAuthorizedException::PAYEE_NOT_CONSENTED);
+ default:
+ throw new NotAuthorizedException(sprintf('NotAuthorized unknown error : %s', $errorMsg), NotAuthorizedException::UNKNOWN);
+ }
+ // no break
+ case 422:
+ switch ($errorMsg) {
+ case 'INVALID_JSON_POINTER_FORMAT':
+ throw new UnprocessableEntityException('Path should be a valid JSON Pointer that references a location within the request', UnprocessableEntityException::INVALID_JSON_POINTER_FORMAT);
+ case 'INVALID_PARAMETER':
+ throw new UnprocessableEntityException('Cannot be specified as part of the request', UnprocessableEntityException::INVALID_PARAMETER);
+ case 'NOT_PATCHABLE':
+ throw new UnprocessableEntityException('Cannot be patched', UnprocessableEntityException::NOT_PATCHABLE);
+ case 'UNSUPPORTED_PATCH_PARAMETER_VALUE':
+ throw new UnprocessableEntityException('The value specified for this field is not currently supported', UnprocessableEntityException::UNSUPPORTED_PATCH_PARAMETER_VALUE);
+ case 'PATCH_VALUE_REQUIRED':
+ throw new UnprocessableEntityException('Specify a value for the field being patched', UnprocessableEntityException::PATCH_VALUE_REQUIRED);
+ case 'PATCH_PATH_REQUIRED':
+ throw new UnprocessableEntityException('Specify a value for the field in which the operation needs to be performed', UnprocessableEntityException::PATCH_PATH_REQUIRED);
+ case 'REFERENCE_ID_NOT_FOUND':
+ throw new UnprocessableEntityException('Filter expression value is incorrect. Check the value of the reference_id', UnprocessableEntityException::REFERENCE_ID_NOT_FOUND);
+ case 'MULTI_CURRENCY_ORDER':
+ throw new UnprocessableEntityException('Multiple differing values of currency_code are not supported', UnprocessableEntityException::MULTI_CURRENCY_ORDER);
+ case 'SHIPPING_OPTION_NOT_SELECTED':
+ throw new UnprocessableEntityException('At least one of the shipping.option should be set to selected = true', UnprocessableEntityException::SHIPPING_OPTION_NOT_SELECTED);
+ case 'SHIPPING_OPTIONS_NOT_SUPPORTED':
+ throw new UnprocessableEntityException('Shipping options are not supported when application_context.shipping_preference is set to NO_SHIPPING or SET_PROVIDED_ADDRESS', UnprocessableEntityException::SHIPPING_OPTIONS_NOT_SUPPORTED);
+ case 'MULTIPLE_SHIPPING_OPTION_SELECTED':
+ throw new UnprocessableEntityException('Only one shipping.option can be set to selected = true', UnprocessableEntityException::MULTIPLE_SHIPPING_OPTION_SELECTED);
+ case 'ORDER_ALREADY_COMPLETED':
+ throw new UnprocessableEntityException('The order cannot be patched after it is completed', UnprocessableEntityException::ORDER_ALREADY_COMPLETED);
+ case 'PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH':
+ throw new UnprocessableEntityException('The amount provided in the preferred shipping option should match the amount provided in amount breakdown', UnprocessableEntityException::PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH);
+ default:
+ throw new UnprocessableEntityException(sprintf('UnprocessableEntity unknown error : %s', $errorMsg), UnprocessableEntityException::UNKNOWN);
+ }
+ // no break
+ default:
+ throw new PsCheckoutException(sprintf('Unknown error : %s', $errorMsg), PsCheckoutException::UNKNOWN);
+ }
+ }
+ }
+
+ /**
+ * @param string $orderId
+ *
+ * @return ResponseInterface
+ *
+ * @throws NotAuthorizedException|PsCheckoutException
+ */
+ public function getOrder($orderId)
+ {
+ $payload = [
+ 'orderId' => $orderId,
+ ];
+
+ try {
+ return $this->client->fetchOrder($this->serializer->serialize($payload, JsonEncoder::FORMAT, true));
+ } catch (HttpException $exception) {
+ $response = $exception->getResponse();
+ $errorMsg = $this->getErrorMessage($response->getBody()->getContents());
+ switch ($response->getStatusCode()) {
+ case 401:
+ switch ($errorMsg) {
+ case 'PERMISSION_DENIED':
+ throw new NotAuthorizedException('You do not have permission to access or perform operations on this resource', NotAuthorizedException::PERMISSION_DENIED);
+ case 'invalid_token':
+ throw new NotAuthorizedException('Token signature verification failed', NotAuthorizedException::INVALID_TOKEN);
+ default:
+ throw new NotAuthorizedException(sprintf('NotAuthorized unknown error : %s', $errorMsg), NotAuthorizedException::UNKNOWN);
+ }
+ // no break
+ default:
+ throw new PsCheckoutException(sprintf('Unknown error : %s', $errorMsg), PsCheckoutException::UNKNOWN);
+ }
+ }
+ }
+
+ /**
+ * @param array{funding_source: string, order_id: string, merchant_id: string} $data
+ *
+ * @return ResponseInterface
+ *
+ * @throws InvalidRequestException|NotAuthorizedException|UnprocessableEntityException|PsCheckoutException
+ */
+ public function captureOrder(array $data)
+ {
+ $payload = [
+ 'mode' => $data['funding_source'],
+ 'orderId' => (string) $data['order_id'],
+ 'payee' => [
+ 'merchant_id' => $data['merchant_id'],
+ ],
+ ];
+
+ try {
+ return $this->client->captureOrder($this->serializer->serialize($payload, JsonEncoder::FORMAT, true));
+ } catch (HttpException $exception) {
+ $response = $exception->getResponse();
+ $errorMsg = $this->getErrorMessage($response->getBody()->getContents());
+ switch ($response->getStatusCode()) {
+ case 400:
+ switch ($errorMsg) {
+ case 'INVALID_PARAMETER_VALUE':
+ throw new InvalidRequestException('The value of a field is invalid', InvalidRequestException::INVALID_PARAMETER_VALUE);
+ case 'MISSING_REQUIRED_PARAMETER':
+ throw new InvalidRequestException('A required field or parameter is missing', InvalidRequestException::MISSING_REQUIRED_PARAMETER);
+ case 'INVALID_STRING_LENGTH':
+ throw new InvalidRequestException('The value of a field is either too short or too long', InvalidRequestException::INVALID_STRING_LENGTH);
+ default:
+ throw new InvalidRequestException(sprintf('InvalidRequest unknown error : %s', $errorMsg), InvalidRequestException::UNKNOWN);
+ }
+ // no break
+ case 401:
+ switch ($errorMsg) {
+ case 'CONSENT_NEEDED':
+ throw new NotAuthorizedException('Payee consent needed', NotAuthorizedException::CONSENT_NEEDED);
+ case 'PERMISSION_DENIED':
+ throw new NotAuthorizedException('You do not have permission to access or perform operations on this resource', NotAuthorizedException::PERMISSION_DENIED);
+ case 'PERMISSION_DENIED_FOR_DONATION_ITEMS':
+ throw new NotAuthorizedException('The payee have not been granted appropriate permissions to send items.category as DONATION', NotAuthorizedException::PERMISSION_DENIED_FOR_DONATION_ITEMS);
+ default:
+ throw new NotAuthorizedException(sprintf('NotAuthorized unknown error : %s', $errorMsg), NotAuthorizedException::UNKNOWN);
+ }
+ // no break
+ case 422:
+ switch ($errorMsg) {
+ case 'AGREEMENT_ALREADY_CANCELLED':
+ throw new UnprocessableEntityException('The requested agreement is already canceled', UnprocessableEntityException::AGREEMENT_ALREADY_CANCELLED);
+ case 'BILLING_AGREEMENT_NOT_FOUND':
+ throw new UnprocessableEntityException('The requested billing agreement token was not found', UnprocessableEntityException::BILLING_AGREEMENT_NOT_FOUND);
+ case 'CARD_EXPIRED':
+ throw new UnprocessableEntityException('The payment card provided is expired', UnprocessableEntityException::CARD_EXPIRED);
+ case 'COMPLIANCE_VIOLATION':
+ throw new UnprocessableEntityException('Transaction is declined due to compliance violation', UnprocessableEntityException::COMPLIANCE_VIOLATION);
+ case 'DOMESTIC_TRANSACTION_REQUIRED':
+ throw new UnprocessableEntityException('This transaction requires the payee and payer to be resident in the same country', UnprocessableEntityException::DOMESTIC_TRANSACTION_REQUIRED);
+ case 'DUPLICATE_INVOICE_ID':
+ throw new UnprocessableEntityException('Duplicate invoice ID detected', UnprocessableEntityException::DUPLICATE_INVOICE_ID);
+ case 'INSTRUMENT_DECLINED':
+ throw new UnprocessableEntityException('The instrument presented was either declined by the processor or bank or it cannot be used for this payment', UnprocessableEntityException::INSTRUMENT_DECLINED);
+ case 'ORDER_NOT_APPROVED':
+ throw new UnprocessableEntityException('Payer has not yet approved the Order for payment', UnprocessableEntityException::ORDER_NOT_APPROVED);
+ case 'MAX_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED':
+ throw new UnprocessableEntityException('The maximum number of payment attempts has been exceeded', UnprocessableEntityException::MAX_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED);
+ case 'PAYEE_BLOCKED_TRANSACTION':
+ throw new UnprocessableEntityException('The fraud settings for this seller are such that this payment cannot be executed', UnprocessableEntityException::PAYEE_BLOCKED_TRANSACTION);
+ case 'PAYER_ACCOUNT_LOCKED_OR_CLOSED':
+ throw new UnprocessableEntityException('The payer account cannot be used for this transaction', UnprocessableEntityException::PAYER_ACCOUNT_LOCKED_OR_CLOSED);
+ case 'PAYER_ACCOUNT_RESTRICTED':
+ throw new UnprocessableEntityException('The payer account is restricted', UnprocessableEntityException::PAYER_ACCOUNT_RESTRICTED);
+ case 'PAYER_CANNOT_PAY':
+ throw new UnprocessableEntityException('The payer cannot pay for this transaction', UnprocessableEntityException::PAYER_CANNOT_PAY);
+ case 'TRANSACTION_LIMIT_EXCEEDED':
+ throw new UnprocessableEntityException('Total payment amount exceeded transaction limit', UnprocessableEntityException::TRANSACTION_LIMIT_EXCEEDED);
+ case 'TRANSACTION_RECEIVING_LIMIT_EXCEEDED':
+ throw new UnprocessableEntityException('The transaction exceeds the receiver’s receiving limit', UnprocessableEntityException::TRANSACTION_RECEIVING_LIMIT_EXCEEDED);
+ case 'TRANSACTION_REFUSED':
+ throw new UnprocessableEntityException('The request was refused', UnprocessableEntityException::TRANSACTION_REFUSED);
+ case 'REDIRECT_PAYER_FOR_ALTERNATE_FUNDING':
+ throw new UnprocessableEntityException('Transaction failed. Redirect the payer to select another funding source', UnprocessableEntityException::REDIRECT_PAYER_FOR_ALTERNATE_FUNDING);
+ case 'ORDER_ALREADY_CAPTURED':
+ throw new UnprocessableEntityException('Order already captured', UnprocessableEntityException::ORDER_ALREADY_CAPTURED);
+ case 'TRANSACTION_BLOCKED_BY_PAYEE':
+ throw new UnprocessableEntityException('Transaction blocked by payee’s fraud protection settings', UnprocessableEntityException::TRANSACTION_BLOCKED_BY_PAYEE);
+ case 'AUTH_CAPTURE_NOT_ENABLED':
+ throw new UnprocessableEntityException('Authorization and capture feature is not enabled for the merchant', UnprocessableEntityException::AUTH_CAPTURE_NOT_ENABLED);
+ case 'NOT_ENABLED_FOR_CARD_PROCESSING':
+ throw new UnprocessableEntityException('The API caller account is not setup to be able to process card payments', UnprocessableEntityException::NOT_ENABLED_FOR_CARD_PROCESSING);
+ case 'PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING':
+ throw new UnprocessableEntityException('Payee account is not setup to be able to process card payments', UnprocessableEntityException::PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING);
+ case 'INVALID_PICKUP_ADDRESS':
+ throw new UnprocessableEntityException('If the shipping_option.type is set to PICKUP, then the shipping_detail.name.full_name should start with S2S', UnprocessableEntityException::INVALID_PICKUP_ADDRESS);
+ case 'SHIPPING_ADDRESS_INVALID':
+ throw new UnprocessableEntityException('Provided shipping address is invalid', UnprocessableEntityException::SHIPPING_ADDRESS_INVALID);
+ case 'CARD_CLOSED':
+ throw new UnprocessableEntityException('The card is closed with the issuer', UnprocessableEntityException::CARD_CLOSED);
+ default:
+ throw new UnprocessableEntityException(sprintf('UnprocessableEntity unknown error : %s', $errorMsg), UnprocessableEntityException::UNKNOWN);
+ }
+ // no break
+ default:
+ throw new PsCheckoutException(sprintf('Unknown error : %s', $errorMsg), PsCheckoutException::UNKNOWN);
+ }
+ }
+ }
+
+ /**
+ * @throws NotAuthorizedException|UnprocessableEntityException|PsCheckoutException
+ */
+ public function refundOrder(array $payload)
+ {
+ try {
+ return $this->client->refundOrder($this->serializer->serialize($payload, JsonEncoder::FORMAT, true));
+ } catch (HttpException $exception) {
+ $response = $exception->getResponse();
+ $errorMsg = $this->getErrorMessage($response->getBody()->getContents());
+ switch ($response->getStatusCode()) {
+ case 401:
+ switch ($errorMsg) {
+ case 'invalid_token':
+ throw new NotAuthorizedException('Token signature verification failed', NotAuthorizedException::INVALID_TOKEN);
+ default:
+ throw new NotAuthorizedException(sprintf('NotAuthorized unknown error : %s', $errorMsg), NotAuthorizedException::UNKNOWN);
+ }
+ // no break
+ case 422:
+ switch ($errorMsg) {
+ case 'CANNOT_PROCESS_REFUNDS':
+ throw new UnprocessableEntityException('Current invoice state does not support refunds', UnprocessableEntityException::CANNOT_PROCESS_REFUNDS);
+ case 'INVALID_REFUND_AMOUNT':
+ throw new UnprocessableEntityException('Recorded refunds cannot exceed recorded payments', UnprocessableEntityException::INVALID_REFUND_AMOUNT);
+ default:
+ throw new UnprocessableEntityException(sprintf('UnprocessableEntity unknown error : %s', $errorMsg), UnprocessableEntityException::UNKNOWN);
+ }
+ // no break
+ default:
+ throw new PsCheckoutException(sprintf('Unknown error : %s', $errorMsg), PsCheckoutException::UNKNOWN);
+ }
+ }
+ }
+
+ /**
+ * @param string $body
+ *
+ * @return string
+ */
+ private function getErrorMessage($body)
+ {
+ $body = json_decode($body, true);
+ if (isset($body['details'][0]['issue'])) {
+ return $body['details'][0]['issue'];
+ }
+ if (isset($body['name'])) {
+ return $body['name'];
+ }
+ if (isset($body['error'])) {
+ return $body['error'];
+ }
+
+ return '';
+ }
+}
diff --git a/src/Builder/Configuration/MaaslandHttpClientConfigurationBuilder.php b/src/Builder/Configuration/MaaslandHttpClientConfigurationBuilder.php
index 2787768ba..3a5ee221a 100644
--- a/src/Builder/Configuration/MaaslandHttpClientConfigurationBuilder.php
+++ b/src/Builder/Configuration/MaaslandHttpClientConfigurationBuilder.php
@@ -41,7 +41,7 @@ class MaaslandHttpClientConfigurationBuilder implements HttpClientConfigurationB
/**
* @var Env
*/
- private $paymentEnv;
+ private $env;
/**
* @var Router
@@ -74,7 +74,7 @@ class MaaslandHttpClientConfigurationBuilder implements HttpClientConfigurationB
private $logger;
public function __construct(
- Env $paymentEnv,
+ Env $env,
Router $router,
ShopContext $shopContext,
PsAccountRepository $psAccountRepository,
@@ -82,7 +82,7 @@ public function __construct(
LoggerConfiguration $loggerConfiguration,
LoggerInterface $logger
) {
- $this->paymentEnv = $paymentEnv;
+ $this->env = $env;
$this->router = $router;
$this->shopContext = $shopContext;
$this->psAccountRepository = $psAccountRepository;
@@ -97,7 +97,7 @@ public function __construct(
public function build()
{
$configuration = [
- 'base_url' => $this->paymentEnv->getPaymentApiUrl(),
+ 'base_url' => $this->env->getPaymentApiUrl(),
'verify' => $this->getVerify(),
'timeout' => static::TIMEOUT,
'headers' => [
diff --git a/src/Builder/ModuleLink/ModuleLinkBuilder.php b/src/Builder/ModuleLink/ModuleLinkBuilder.php
index 97d2a10e1..bb7c03461 100644
--- a/src/Builder/ModuleLink/ModuleLinkBuilder.php
+++ b/src/Builder/ModuleLink/ModuleLinkBuilder.php
@@ -24,6 +24,16 @@
class ModuleLinkBuilder
{
+ /**
+ * @var LinkAdapter
+ */
+ private $linkAdapter;
+
+ public function __construct(LinkAdapter $linkAdapter)
+ {
+ $this->linkAdapter = $linkAdapter;
+ }
+
/**
* Generate the callback url used by the paypal button
*
@@ -31,6 +41,6 @@ class ModuleLinkBuilder
*/
public function getPaypalOnboardingCallBackUrl()
{
- return (new LinkAdapter())->getAdminLink('AdminPaypalOnboardingPrestashopCheckout');
+ return $this->linkAdapter->getAdminLink('AdminPaypalOnboardingPrestashopCheckout');
}
}
diff --git a/src/Checkout/EventSubscriber/CheckoutEventSubscriber.php b/src/Checkout/EventSubscriber/CheckoutEventSubscriber.php
index b393f1907..5443ec59a 100644
--- a/src/Checkout/EventSubscriber/CheckoutEventSubscriber.php
+++ b/src/Checkout/EventSubscriber/CheckoutEventSubscriber.php
@@ -43,11 +43,6 @@
class CheckoutEventSubscriber implements EventSubscriberInterface
{
- /**
- * @var Ps_checkout
- */
- private $module;
-
/**
* @var CommandBusInterface
*/
@@ -62,11 +57,11 @@ class CheckoutEventSubscriber implements EventSubscriberInterface
*/
private $psCheckoutCartRepository;
- public function __construct(CheckoutChecker $checkoutChecker, CommandBusInterface $commandBus, PsCheckoutCartRepository $psCheckoutCartRepository)
+ public function __construct(CheckoutChecker $checkoutChecker, Ps_checkout $module, PsCheckoutCartRepository $psCheckoutCartRepository)
{
$this->checkoutChecker = $checkoutChecker;
- $this->commandBus = $commandBus;
$this->psCheckoutCartRepository = $psCheckoutCartRepository;
+ $this->commandBus = $module->getService('ps_checkout.bus.command');
}
/**
diff --git a/src/Configuration/ToggleShopConfigurationCommandHandler.php b/src/Configuration/ToggleShopConfigurationCommandHandler.php
index 9756cfd3f..74830e257 100644
--- a/src/Configuration/ToggleShopConfigurationCommandHandler.php
+++ b/src/Configuration/ToggleShopConfigurationCommandHandler.php
@@ -29,9 +29,9 @@ class ToggleShopConfigurationCommandHandler
*/
private $db;
- public function __construct()
+ public function __construct(Db $db)
{
- $this->db = Db::getInstance();
+ $this->db = $db;
}
/**
diff --git a/src/Context/PrestaShopContext.php b/src/Context/PrestaShopContext.php
index 065169d9d..34511a74e 100644
--- a/src/Context/PrestaShopContext.php
+++ b/src/Context/PrestaShopContext.php
@@ -20,19 +20,22 @@
namespace PrestaShop\Module\PrestashopCheckout\Context;
+use Context;
+use Link;
+
/**
* Class PrestaShopContext used to get information from PrestaShop Context
*/
class PrestaShopContext
{
/**
- * @var \Context
+ * @var Context
*/
private $context;
public function __construct()
{
- $this->context = \Context::getContext();
+ $this->context = Context::getContext();
}
/**
@@ -50,11 +53,19 @@ public function getLanguage()
return $this->context->language;
}
+ /**
+ * @return Link|null
+ */
public function getLink()
{
return $this->context->link;
}
+ public function getShop()
+ {
+ return $this->context->shop;
+ }
+
public function getShopId()
{
return $this->context->shop->id;
diff --git a/src/Database/TableManager.php b/src/Database/TableManager.php
index e721240e3..def1651f4 100644
--- a/src/Database/TableManager.php
+++ b/src/Database/TableManager.php
@@ -105,7 +105,8 @@ public function createTable()
`updated_at` varchar(50) NOT NULL,
`seller_protection` text,
`seller_receivable_breakdown` text,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ INDEX `pscheckout_capture_id_order` (`id_order`),
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
') && $this->db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_refund` (
@@ -117,7 +118,8 @@ public function createTable()
`acquirer_reference_number` varchar(50) NOT NULL,
`seller_payable_breakdown` text,
`id_order_slip` INT UNSIGNED,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ INDEX `pscheckout_refund_id_order` (`id_order`),
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
') && $this->db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_authorization` (
@@ -126,7 +128,8 @@ public function createTable()
`status` varchar(30) NOT NULL,
`expiration_time` varchar(50) NOT NULL,
`seller_protection` text,
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ INDEX `pscheckout_authorization_id_order` (`id_order`),
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
') && $this->db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_purchase_unit` (
@@ -134,7 +137,8 @@ public function createTable()
`checksum` varchar(50) NOT NULL,
`reference_id` varchar(50) NOT NULL,
`items` text,
- PRIMARY KEY (`reference_id`, `id_order`)
+ PRIMARY KEY (`reference_id`, `id_order`),
+ INDEX `pscheckout_purchase_unit_id_order` (`id_order`),
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
') && $this->db->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'pscheckout_customer` (
@@ -153,7 +157,7 @@ public function createTable()
`status` varchar(50) NOT NULL,
`is_favorite` tinyint(1) unsigned DEFAULT 0 NOT NULL,
PRIMARY KEY (`id`),
- UNIQUE KEY `token_id_merchant_id_paypal_customer_id` (`token_id`, `merchant_id`, `paypal_customer_id`)
+ UNIQUE KEY `token_id_merchant_id_paypal_customer_id` (`token_id`, `merchant_id`, `paypal_customer_id`),
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;
');
diff --git a/src/Dispatcher/Dispatcher.php b/src/Dispatcher/DispatcherInterface.php
similarity index 97%
rename from src/Dispatcher/Dispatcher.php
rename to src/Dispatcher/DispatcherInterface.php
index f0c718cfa..b2e98e6a5 100644
--- a/src/Dispatcher/Dispatcher.php
+++ b/src/Dispatcher/DispatcherInterface.php
@@ -20,7 +20,7 @@
namespace PrestaShop\Module\PrestashopCheckout\Dispatcher;
-interface Dispatcher
+interface DispatcherInterface
{
/**
* @param array $payload
diff --git a/src/Dispatcher/OrderDispatcher.php b/src/Dispatcher/OrderDispatcher.php
index 473e8614b..f88d4e50c 100644
--- a/src/Dispatcher/OrderDispatcher.php
+++ b/src/Dispatcher/OrderDispatcher.php
@@ -20,9 +20,7 @@
namespace PrestaShop\Module\PrestashopCheckout\Dispatcher;
-use Module;
use PrestaShop\Module\PrestashopCheckout\Event\EventDispatcherInterface;
-use PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherAdapter;
use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException;
use PrestaShop\Module\PrestashopCheckout\PayPal\Order\Event\PayPalOrderApprovalReversedEvent;
use PrestaShop\Module\PrestashopCheckout\PayPal\Order\Event\PayPalOrderApprovedEvent;
@@ -38,10 +36,9 @@
use PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Event\PaymentTokenDeletedEvent;
use PrestaShop\Module\PrestashopCheckout\PayPal\PaymentToken\Event\PaymentTokenDeletionInitiatedEvent;
use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration;
-use Ps_checkout;
use Psr\Log\LoggerInterface;
-class OrderDispatcher implements Dispatcher
+class OrderDispatcher implements DispatcherInterface
{
const PS_CHECKOUT_PAYMENT_REVERSED = 'PaymentCaptureReversed';
const PS_CHECKOUT_PAYMENT_REFUNDED = 'PaymentCaptureRefunded';
@@ -56,6 +53,26 @@ class OrderDispatcher implements Dispatcher
const PS_CHECKOUT_VAULT_PAYMENT_TOKEN_DELETED = 'VaultPaymentTokenDeleted';
const PS_CHECKOUT_VAULT_PAYMENT_TOKEN_DELETION_INITIATED = 'VaultPaymentTokenDeletionInitiated';
+ /**
+ * @var EventDispatcherInterface
+ */
+ private $eventDispatcher;
+ /**
+ * @var LoggerInterface
+ */
+ private $logger;
+ /**
+ * @var PayPalConfiguration
+ */
+ private $payPalConfiguration;
+
+ public function __construct(EventDispatcherInterface $eventDispatcher, LoggerInterface $logger, PayPalConfiguration $payPalConfiguration)
+ {
+ $this->eventDispatcher = $eventDispatcher;
+ $this->logger = $logger;
+ $this->payPalConfiguration = $payPalConfiguration;
+ }
+
/**
* Dispatch the Event Type to manage the merchant status
*
@@ -71,54 +88,42 @@ public function dispatchEventType($payload)
throw new PsCheckoutException('orderId must not be empty', PsCheckoutException::PSCHECKOUT_WEBHOOK_ORDER_ID_EMPTY);
}
- /** @var Ps_checkout $module */
- $module = Module::getInstanceByName('ps_checkout');
-
- /** @var EventDispatcherInterface $eventDispatcher */
- $eventDispatcher = $module->getService(SymfonyEventDispatcherAdapter::class);
-
- /** @var LoggerInterface $logger */
- $logger = $module->getService('ps_checkout.logger');
-
- /** @var PayPalConfiguration $payPalConfiguration */
- $payPalConfiguration = $module->get('ps_checkout.paypal.configuration');
-
switch ($payload['eventType']) {
case static::PS_CHECKOUT_PAYMENT_COMPLETED:
- $eventDispatcher->dispatch(new PayPalCaptureCompletedEvent($payload['resource']['id'], $payload['orderId'], $payload['resource']));
+ $this->eventDispatcher->dispatch(new PayPalCaptureCompletedEvent($payload['resource']['id'], $payload['orderId'], $payload['resource']));
break;
case static::PS_CHECKOUT_PAYMENT_PENDING:
- $eventDispatcher->dispatch(new PayPalCapturePendingEvent($payload['resource']['id'], $payload['orderId'], $payload['resource']));
+ $this->eventDispatcher->dispatch(new PayPalCapturePendingEvent($payload['resource']['id'], $payload['orderId'], $payload['resource']));
break;
case static::PS_CHECKOUT_PAYMENT_DENIED:
- $eventDispatcher->dispatch(new PayPalCaptureDeclinedEvent($payload['resource']['id'], $payload['orderId'], $payload['resource']));
+ $this->eventDispatcher->dispatch(new PayPalCaptureDeclinedEvent($payload['resource']['id'], $payload['orderId'], $payload['resource']));
break;
case static::PS_CHECKOUT_PAYMENT_REFUNDED:
- $eventDispatcher->dispatch(new PayPalCaptureRefundedEvent($payload['resource']['id'], $payload['orderId'], $payload['resource']));
+ $this->eventDispatcher->dispatch(new PayPalCaptureRefundedEvent($payload['resource']['id'], $payload['orderId'], $payload['resource']));
break;
case static::PS_CHECKOUT_PAYMENT_REVERSED:
- $eventDispatcher->dispatch(new PayPalCaptureReversedEvent($payload['resource']['id'], $payload['orderId'], $payload['resource']));
+ $this->eventDispatcher->dispatch(new PayPalCaptureReversedEvent($payload['resource']['id'], $payload['orderId'], $payload['resource']));
break;
case static::PS_CHECKOUT_ORDER_APPROVED:
- $eventDispatcher->dispatch(new PayPalOrderApprovedEvent($payload['orderId'], $payload['resource']));
+ $this->eventDispatcher->dispatch(new PayPalOrderApprovedEvent($payload['orderId'], $payload['resource']));
break;
case static::PS_CHECKOUT_ORDER_COMPLETED:
- $eventDispatcher->dispatch(new PayPalOrderCompletedEvent($payload['orderId'], $payload['resource']));
+ $this->eventDispatcher->dispatch(new PayPalOrderCompletedEvent($payload['orderId'], $payload['resource']));
break;
case static::PS_CHECKOUT_ORDER_APPROVAL_REVERSED:
- $eventDispatcher->dispatch(new PayPalOrderApprovalReversedEvent($payload['orderId'], $payload['resource']));
+ $this->eventDispatcher->dispatch(new PayPalOrderApprovalReversedEvent($payload['orderId'], $payload['resource']));
break;
case static::PS_CHECKOUT_VAULT_PAYMENT_TOKEN_CREATED:
- $eventDispatcher->dispatch(new PaymentTokenCreatedEvent($payload['resource'], $payPalConfiguration->getMerchantId()));
+ $this->eventDispatcher->dispatch(new PaymentTokenCreatedEvent($payload['resource'], $this->payPalConfiguration->getMerchantId()));
break;
case static::PS_CHECKOUT_VAULT_PAYMENT_TOKEN_DELETED:
- $eventDispatcher->dispatch(new PaymentTokenDeletedEvent($payload['resource']));
+ $this->eventDispatcher->dispatch(new PaymentTokenDeletedEvent($payload['resource']));
break;
case static::PS_CHECKOUT_VAULT_PAYMENT_TOKEN_DELETION_INITIATED:
- $eventDispatcher->dispatch(new PaymentTokenDeletionInitiatedEvent($payload['resource']));
+ $this->eventDispatcher->dispatch(new PaymentTokenDeletionInitiatedEvent($payload['resource']));
break;
default:
- $logger->warning(
+ $this->logger->warning(
'Unknown webhook, cannot be processed.',
[
'payload' => $payload,
diff --git a/src/Entity/PsAccount.php b/src/Entity/PsAccount.php
deleted file mode 100644
index 16145fa8f..000000000
--- a/src/Entity/PsAccount.php
+++ /dev/null
@@ -1,196 +0,0 @@
-
- * @copyright Since 2007 PrestaShop SA and Contributors
- * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
- */
-
-namespace PrestaShop\Module\PrestashopCheckout\Entity;
-
-use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException;
-
-/**
- * Not really an entity.
- * Allow to manage data regarding firebase account in database
- */
-class PsAccount
-{
- /**
- * Const list of databse fields used for store data
- */
- const PS_PSX_FIREBASE_EMAIL = 'PS_PSX_FIREBASE_EMAIL';
- const PS_PSX_FIREBASE_ID_TOKEN = 'PS_PSX_FIREBASE_ID_TOKEN';
- const PS_PSX_FIREBASE_LOCAL_ID = 'PS_PSX_FIREBASE_LOCAL_ID';
- const PS_PSX_FIREBASE_REFRESH_TOKEN = 'PS_PSX_FIREBASE_REFRESH_TOKEN';
- const PS_CHECKOUT_PSX_FORM = 'PS_CHECKOUT_PSX_FORM';
- const PS_CHECKOUT_SHOP_UUID_V4 = 'PS_CHECKOUT_SHOP_UUID_V4';
-
- /**
- * Firebase email
- *
- * @var string
- */
- private $email;
-
- /**
- * Firebase id token
- *
- * @var string
- */
- private $idToken;
-
- /**
- * Firebase local id
- *
- * @var string
- */
- private $localId;
-
- /**
- * Firebase refresh token
- *
- * @var string
- */
- private $refreshToken;
-
- /**
- * Psx Form (used to complete the onboarding)
- *
- * @var array
- */
- private $psxForm;
-
- /**
- * PsAccount constructor.
- *
- * @param string|null $idToken
- * @param string|null $refreshToken
- * @param string|null $email
- * @param string|null $localId
- * @param array|null $psxForm
- *
- * @throws PsCheckoutException
- */
- public function __construct($idToken = null, $refreshToken = null, $email = null, $localId = null, $psxForm = null)
- {
- $this->setIdToken($idToken);
- $this->setRefreshToken($refreshToken);
-
- if (null !== $localId) {
- $this->setLocalId($localId);
- }
-
- if (null !== $email) {
- $this->setEmail($email);
- }
-
- if (null !== $psxForm) {
- $this->setPsxForm($psxForm);
- }
- }
-
- /**
- * @param string $email
- */
- public function setEmail($email)
- {
- $this->email = $email;
- }
-
- /**
- * @param string $idToken
- *
- * @throws PsCheckoutException
- */
- public function setIdToken($idToken)
- {
- if (empty($idToken)) {
- throw new PsCheckoutException('idToken cannot be empty', PsCheckoutException::PSACCOUNT_TOKEN_MISSING);
- }
-
- $this->idToken = $idToken;
- }
-
- /**
- * @param string $localId
- */
- public function setLocalId($localId)
- {
- $this->localId = $localId;
- }
-
- /**
- * @param string $refreshToken
- *
- * @throws PsCheckoutException
- */
- public function setRefreshToken($refreshToken)
- {
- if (empty($refreshToken)) {
- throw new PsCheckoutException('refreshToken cannot be empty', PsCheckoutException::PSACCOUNT_REFRESH_TOKEN_MISSING);
- }
-
- $this->refreshToken = $refreshToken;
- }
-
- /**
- * @param mixed $form
- */
- public function setPsxForm($form)
- {
- $this->psxForm = $form;
- }
-
- /**
- * getter $email
- */
- public function getEmail()
- {
- return $this->email;
- }
-
- /**
- * getter $idToken
- */
- public function getIdToken()
- {
- return $this->idToken;
- }
-
- /**
- * getter $localId
- */
- public function getLocalId()
- {
- return $this->localId;
- }
-
- /**
- * getter $refreshToken
- */
- public function getRefreshToken()
- {
- return $this->refreshToken;
- }
-
- /**
- * getter $psxForm
- */
- public function getPsxForm()
- {
- return $this->psxForm;
- }
-}
diff --git a/src/ExpressCheckout/ExpressCheckoutConfiguration.php b/src/ExpressCheckout/ExpressCheckoutConfiguration.php
index 0b496a6f7..19a23c2cf 100644
--- a/src/ExpressCheckout/ExpressCheckoutConfiguration.php
+++ b/src/ExpressCheckout/ExpressCheckoutConfiguration.php
@@ -25,6 +25,10 @@
class ExpressCheckoutConfiguration
{
+ const PS_CHECKOUT_EC_PRODUCT_PAGE = 'PS_CHECKOUT_EC_PRODUCT_PAGE';
+ const PS_CHECKOUT_EC_ORDER_PAGE = 'PS_CHECKOUT_EC_ORDER_PAGE';
+ const PS_CHECKOUT_EC_CHECKOUT_PAGE = 'PS_CHECKOUT_EC_CHECKOUT_PAGE';
+
/**
* @var PrestaShopConfiguration
*/
@@ -37,17 +41,17 @@ public function __construct(PrestaShopConfiguration $configuration)
public function isOrderPageEnabled()
{
- return (bool) $this->configuration->get(ExpressCheckout::PS_CHECKOUT_EC_ORDER_PAGE);
+ return (bool) $this->configuration->get(static::PS_CHECKOUT_EC_ORDER_PAGE);
}
public function isCheckoutPageEnabled()
{
- return (bool) $this->configuration->get(ExpressCheckout::PS_CHECKOUT_EC_CHECKOUT_PAGE);
+ return (bool) $this->configuration->get(static::PS_CHECKOUT_EC_CHECKOUT_PAGE);
}
public function isProductPageEnabled()
{
- return (bool) $this->configuration->get(ExpressCheckout::PS_CHECKOUT_EC_PRODUCT_PAGE);
+ return (bool) $this->configuration->get(static::PS_CHECKOUT_EC_PRODUCT_PAGE);
}
/**
@@ -57,7 +61,7 @@ public function isProductPageEnabled()
*/
public function setProductPage($status)
{
- $this->configuration->set(ExpressCheckout::PS_CHECKOUT_EC_PRODUCT_PAGE, $status);
+ $this->configuration->set(static::PS_CHECKOUT_EC_PRODUCT_PAGE, $status);
}
/**
@@ -67,7 +71,7 @@ public function setProductPage($status)
*/
public function setOrderPage($status)
{
- $this->configuration->set(ExpressCheckout::PS_CHECKOUT_EC_ORDER_PAGE, $status);
+ $this->configuration->set(static::PS_CHECKOUT_EC_ORDER_PAGE, $status);
}
/**
@@ -77,6 +81,6 @@ public function setOrderPage($status)
*/
public function setCheckoutPage($status)
{
- $this->configuration->set(ExpressCheckout::PS_CHECKOUT_EC_CHECKOUT_PAGE, $status);
+ $this->configuration->set(static::PS_CHECKOUT_EC_CHECKOUT_PAGE, $status);
}
}
diff --git a/src/FundingSource/FundingSourcePresenter.php b/src/FundingSource/FundingSourcePresenter.php
index addad1d1d..1ad9e7d5a 100644
--- a/src/FundingSource/FundingSourcePresenter.php
+++ b/src/FundingSource/FundingSourcePresenter.php
@@ -43,6 +43,7 @@ class FundingSourcePresenter
/**
* @param FundingSourceTranslationProvider $translation
* @param CountryRepository $country
+ * @param PaymentMethodLogoProvider $paymentMethodLogoProvider
*/
public function __construct(FundingSourceTranslationProvider $translation, CountryRepository $country, PaymentMethodLogoProvider $paymentMethodLogoProvider)
{
diff --git a/src/FundingSource/FundingSourceProvider.php b/src/FundingSource/FundingSourceProvider.php
index 596f32340..68731422b 100644
--- a/src/FundingSource/FundingSourceProvider.php
+++ b/src/FundingSource/FundingSourceProvider.php
@@ -20,6 +20,7 @@
namespace PrestaShop\Module\PrestashopCheckout\FundingSource;
+use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException;
use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration;
use PrestaShop\Module\PrestashopCheckout\Repository\PaymentTokenRepository;
@@ -89,7 +90,7 @@ public function getAll($isAdmin = false)
*
* @return FundingSource[]
*
- * @throws \PrestaShopDatabaseException
+ * @throws PsCheckoutException
*/
public function getSavedTokens($customerId)
{
diff --git a/src/Handler/CreatePaypalOrderHandler.php b/src/Handler/CreatePaypalOrderHandler.php
deleted file mode 100644
index beb2d808f..000000000
--- a/src/Handler/CreatePaypalOrderHandler.php
+++ /dev/null
@@ -1,124 +0,0 @@
-
- * @copyright Since 2007 PrestaShop SA and Contributors
- * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
- */
-
-namespace PrestaShop\Module\PrestashopCheckout\Handler;
-
-use Context;
-use Module;
-use PrestaShop\Module\PrestashopCheckout\Builder\Payload\OrderPayloadBuilder;
-use PrestaShop\Module\PrestashopCheckout\Exception\PayPalException;
-use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException;
-use PrestaShop\Module\PrestashopCheckout\Handler\Response\ResponseApiHandler;
-use PrestaShop\Module\PrestashopCheckout\Http\MaaslandHttpClient;
-use PrestaShop\Module\PrestashopCheckout\Presenter\Cart\CartPresenter;
-use PrestaShop\Module\PrestashopCheckout\ShopContext;
-use Ps_checkout;
-
-class CreatePaypalOrderHandler
-{
- /**
- * Prestashop context object
- *
- * @var Context
- */
- private $context;
-
- public function __construct(Context $context)
- {
- $this->context = $context;
- }
-
- /**
- * @param bool $expressCheckout
- * @param bool $updateOrder
- * @param string|null $paypalOrderId
- *
- * @return array
- *
- * @throws PsCheckoutException
- */
- public function handle($expressCheckout = false, $isCardPayment = false, $updateOrder = false, $paypalOrderId = null)
- {
- // Present an improved cart in order to create the payload
- $cartPresenter = (new CartPresenter())->present();
-
- $builder = new OrderPayloadBuilder($cartPresenter, true);
-
- /** @var Ps_checkout $module */
- $module = Module::getInstanceByName('ps_checkout');
-
- /** @var ShopContext $shopContext */
- $shopContext = $module->getService(ShopContext::class);
-
- $builder->setIsCard($isCardPayment);
-
- // enable express checkout mode if in express checkout
- $builder->setExpressCheckout($expressCheckout);
-
- // enable update mode if we build an order for update it
- $builder->setIsUpdate($updateOrder);
- if ($updateOrder) {
- $builder->setPaypalOrderId($paypalOrderId);
- }
-
- if ($shopContext->isShop17()) {
- // Build full payload in 1.7
- $builder->buildFullPayload();
- } else {
- // if on 1.6 always build minimal payload
- $builder->buildMinimalPayload();
- }
-
- $payload = $builder->presentPayload()->getArray();
-
- /** @var MaaslandHttpClient $checkoutHttpClient */
- $checkoutHttpClient = $module->getService(MaaslandHttpClient::class);
-
- // Create the paypal order or update it
- try {
- if (true === $updateOrder) {
- $response = $checkoutHttpClient->updateOrder($payload);
- } else {
- $response = $checkoutHttpClient->createOrder($payload);
- }
- } catch (PayPalException $exception) {
- $previousException = $exception->getPrevious();
- $response = method_exists($previousException, 'getResponse') ? $previousException->getResponse() : null;
- // Retry with minimal payload when full payload failed (only on 1.7)
- if ($response && substr((string) $response->getStatusCode(), 0, 1) === '4' && $shopContext->isShop17()) {
- $builder->buildMinimalPayload();
- $payload = $builder->presentPayload()->getArray();
-
- if (true === $updateOrder) {
- $response = $checkoutHttpClient->updateOrder($payload);
- } else {
- $response = $checkoutHttpClient->createOrder($payload);
- }
- } else {
- throw $exception;
- }
- }
-
- $responseHandler = new ResponseApiHandler();
-
- return $responseHandler->handleResponse($response);
- }
-}
diff --git a/src/Http/MaaslandHttpClient.php b/src/Http/MaaslandHttpClient.php
index 36803df71..f37f93278 100644
--- a/src/Http/MaaslandHttpClient.php
+++ b/src/Http/MaaslandHttpClient.php
@@ -127,6 +127,34 @@ public function refundOrder(array $payload, array $options = [])
return $this->sendRequest(new Request('POST', '/payments/order/refund', $options, json_encode($payload)));
}
+ /**
+ * Tells if the webhook came from the PSL
+ *
+ * @param array $payload
+ *
+ * @return array
+ */
+ public function getShopSignature(array $payload, array $options = [])
+ {
+ $response = $this->sendRequest(new Request('POST', '/payments/shop/verify_webhook_signature', $options, json_encode($payload)));
+
+ return json_decode($response->getBody()->getContents(), true);
+ }
+
+ /**
+ * Used to notify PSL on settings update
+ *
+ * @return array
+ *
+ * @throws PayPalException
+ */
+ public function updateSettings(array $payload)
+ {
+ $response = $this->sendRequest(new Request('POST', '/payments/shop/update_settings', [], json_encode($payload)));
+
+ return json_decode($response->getBody()->getContents(), true);
+ }
+
/**
* @param RequestInterface $request
*
@@ -181,32 +209,4 @@ private function extractMessage(array $body)
return '';
}
-
- /**
- * Tells if the webhook came from the PSL
- *
- * @param array $payload
- *
- * @return array
- */
- public function getShopSignature(array $payload, array $options = [])
- {
- $response = $this->sendRequest(new Request('POST', '/payments/shop/verify_webhook_signature', $options, json_encode($payload)));
-
- return json_decode($response->getBody()->getContents(), true);
- }
-
- /**
- * Used to notify PSL on settings update
- *
- * @return array
- *
- * @throws PayPalException
- */
- public function updateSettings(array $payload)
- {
- $response = $this->sendRequest(new Request('POST', '/payments/shop/update_settings', [], json_encode($payload)));
-
- return json_decode($response->getBody()->getContents(), true);
- }
}
diff --git a/src/Order/EventSubscriber/OrderEventSubscriber.php b/src/Order/EventSubscriber/OrderEventSubscriber.php
index 59dff925a..a9f8edfb8 100644
--- a/src/Order/EventSubscriber/OrderEventSubscriber.php
+++ b/src/Order/EventSubscriber/OrderEventSubscriber.php
@@ -42,8 +42,10 @@ class OrderEventSubscriber implements EventSubscriberInterface
*/
private $commandBus;
- public function __construct(PsCheckoutCartRepository $psCheckoutCartRepository, Ps_checkout $module)
- {
+ public function __construct(
+ PsCheckoutCartRepository $psCheckoutCartRepository,
+ Ps_checkout $module
+ ) {
$this->psCheckoutCartRepository = $psCheckoutCartRepository;
$this->commandBus = $module->getService('ps_checkout.bus.command');
}
diff --git a/src/PayPal/OAuth/Query/GetPayPalGetUserIdTokenQuery.php b/src/PayPal/OAuth/Query/GetPayPalUserIdTokenQuery.php
similarity index 97%
rename from src/PayPal/OAuth/Query/GetPayPalGetUserIdTokenQuery.php
rename to src/PayPal/OAuth/Query/GetPayPalUserIdTokenQuery.php
index 5d94ff131..95c638da9 100644
--- a/src/PayPal/OAuth/Query/GetPayPalGetUserIdTokenQuery.php
+++ b/src/PayPal/OAuth/Query/GetPayPalUserIdTokenQuery.php
@@ -22,7 +22,7 @@
use PrestaShop\Module\PrestashopCheckout\Customer\ValueObject\CustomerId;
-class GetPayPalGetUserIdTokenQuery
+class GetPayPalUserIdTokenQuery
{
/**
* @var CustomerId|null
diff --git a/src/PayPal/OAuth/Query/GetPayPalGetUserIdTokenQueryHandler.php b/src/PayPal/OAuth/Query/GetPayPalUserIdTokenQueryHandler.php
similarity index 86%
rename from src/PayPal/OAuth/Query/GetPayPalGetUserIdTokenQueryHandler.php
rename to src/PayPal/OAuth/Query/GetPayPalUserIdTokenQueryHandler.php
index 821616b34..8f4338018 100644
--- a/src/PayPal/OAuth/Query/GetPayPalGetUserIdTokenQueryHandler.php
+++ b/src/PayPal/OAuth/Query/GetPayPalUserIdTokenQueryHandler.php
@@ -25,7 +25,7 @@
use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration;
use PrestaShop\Module\PrestashopCheckout\Repository\PayPalCustomerRepository;
-class GetPayPalGetUserIdTokenQueryHandler
+class GetPayPalUserIdTokenQueryHandler
{
/**
* @var OAuthService
@@ -53,17 +53,17 @@ public function __construct(OAuthService $OAuthService, PayPalCustomerRepository
}
/**
- * @param GetPayPalGetUserIdTokenQuery $query
+ * @param GetPayPalUserIdTokenQuery $query
*
- * @return GetPayPalGetUserIdTokenQueryResult
+ * @return GetPayPalUserIdTokenQueryResult
*
* @throws Exception
*/
- public function handle(GetPayPalGetUserIdTokenQuery $query)
+ public function handle(GetPayPalUserIdTokenQuery $query)
{
$customerIdPayPal = $query->getCustomerId() ? $this->customerRepository->findPayPalCustomerIdByCustomerId($query->getCustomerId()) : null;
$merchantId = $this->payPalConfiguration->getMerchantId();
- return new GetPayPalGetUserIdTokenQueryResult($this->OAuthService->getUserIdToken($merchantId, $customerIdPayPal));
+ return new GetPayPalUserIdTokenQueryResult($this->OAuthService->getUserIdToken($merchantId, $customerIdPayPal));
}
}
diff --git a/src/PayPal/OAuth/Query/GetPayPalGetUserIdTokenQueryResult.php b/src/PayPal/OAuth/Query/GetPayPalUserIdTokenQueryResult.php
similarity index 96%
rename from src/PayPal/OAuth/Query/GetPayPalGetUserIdTokenQueryResult.php
rename to src/PayPal/OAuth/Query/GetPayPalUserIdTokenQueryResult.php
index e3a3f4a9b..7270e9bf0 100644
--- a/src/PayPal/OAuth/Query/GetPayPalGetUserIdTokenQueryResult.php
+++ b/src/PayPal/OAuth/Query/GetPayPalUserIdTokenQueryResult.php
@@ -20,7 +20,7 @@
namespace PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query;
-class GetPayPalGetUserIdTokenQueryResult
+class GetPayPalUserIdTokenQueryResult
{
/**
* @var string
diff --git a/src/PayPal/Order/DTO/AddressDetails.php b/src/PayPal/Order/DTO/AddressDetails.php
new file mode 100644
index 000000000..784a2b5e1
--- /dev/null
+++ b/src/PayPal/Order/DTO/AddressDetails.php
@@ -0,0 +1,220 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
+ */
+
+namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO;
+
+class AddressDetails
+{
+ /**
+ * The street number.
+ *
+ * @var string|null
+ */
+ protected $street_number;
+ /**
+ * The street name. Just `Drury` in `Drury Lane`.
+ *
+ * @var string|null
+ */
+ protected $street_name;
+ /**
+ * The street type. For example, avenue, boulevard, road, or expressway.
+ *
+ * @var string|null
+ */
+ protected $street_type;
+ /**
+ * The delivery service. Post office box, bag number, or post office name.
+ *
+ * @var string|null
+ */
+ protected $delivery_service;
+ /**
+ * A named locations that represents the premise. Usually a building name or number or collection of buildings with a common name or number. For example, <code>Craven House</code>.
+ *
+ * @var string|null
+ */
+ protected $building_name;
+ /**
+ * The first-order entity below a named building or location that represents the sub-premises. Usually a single building within a collection of buildings with a common name. Can be a flat, story, floor, room, or apartment.
+ *
+ * @var string|null
+ */
+ protected $sub_building;
+
+ /**
+ * Constructor
+ *
+ * @param mixed[] $data Associated array of property values initializing the model
+ */
+ public function __construct(array $data = null)
+ {
+ $this->street_number = isset($data['street_number']) ? $data['street_number'] : null;
+ $this->street_name = isset($data['street_name']) ? $data['street_name'] : null;
+ $this->street_type = isset($data['street_type']) ? $data['street_type'] : null;
+ $this->delivery_service = isset($data['delivery_service']) ? $data['delivery_service'] : null;
+ $this->building_name = isset($data['building_name']) ? $data['building_name'] : null;
+ $this->sub_building = isset($data['sub_building']) ? $data['sub_building'] : null;
+ }
+
+ /**
+ * Gets street_number.
+ *
+ * @return string|null
+ */
+ public function getStreetNumber()
+ {
+ return $this->street_number;
+ }
+
+ /**
+ * Sets street_number.
+ *
+ * @param string|null $street_number the street number
+ *
+ * @return $this
+ */
+ public function setStreetNumber($street_number = null)
+ {
+ $this->street_number = $street_number;
+
+ return $this;
+ }
+
+ /**
+ * Gets street_name.
+ *
+ * @return string|null
+ */
+ public function getStreetName()
+ {
+ return $this->street_name;
+ }
+
+ /**
+ * Sets street_name.
+ *
+ * @param string|null $street_name The street name. Just `Drury` in `Drury Lane`.
+ *
+ * @return $this
+ */
+ public function setStreetName($street_name = null)
+ {
+ $this->street_name = $street_name;
+
+ return $this;
+ }
+
+ /**
+ * Gets street_type.
+ *
+ * @return string|null
+ */
+ public function getStreetType()
+ {
+ return $this->street_type;
+ }
+
+ /**
+ * Sets street_type.
+ *
+ * @param string|null $street_type The street type. For example, avenue, boulevard, road, or expressway.
+ *
+ * @return $this
+ */
+ public function setStreetType($street_type = null)
+ {
+ $this->street_type = $street_type;
+
+ return $this;
+ }
+
+ /**
+ * Gets delivery_service.
+ *
+ * @return string|null
+ */
+ public function getDeliveryService()
+ {
+ return $this->delivery_service;
+ }
+
+ /**
+ * Sets delivery_service.
+ *
+ * @param string|null $delivery_service The delivery service. Post office box, bag number, or post office name.
+ *
+ * @return $this
+ */
+ public function setDeliveryService($delivery_service = null)
+ {
+ $this->delivery_service = $delivery_service;
+
+ return $this;
+ }
+
+ /**
+ * Gets building_name.
+ *
+ * @return string|null
+ */
+ public function getBuildingName()
+ {
+ return $this->building_name;
+ }
+
+ /**
+ * Sets building_name.
+ *
+ * @param string|null $building_name A named locations that represents the premise. Usually a building name or number or collection of buildings with a common name or number. For example, Craven House
.
+ *
+ * @return $this
+ */
+ public function setBuildingName($building_name = null)
+ {
+ $this->building_name = $building_name;
+
+ return $this;
+ }
+
+ /**
+ * Gets sub_building.
+ *
+ * @return string|null
+ */
+ public function getSubBuilding()
+ {
+ return $this->sub_building;
+ }
+
+ /**
+ * Sets sub_building.
+ *
+ * @param string|null $sub_building The first-order entity below a named building or location that represents the sub-premises. Usually a single building within a collection of buildings with a common name. Can be a flat, story, floor, room, or apartment.
+ *
+ * @return $this
+ */
+ public function setSubBuilding($sub_building = null)
+ {
+ $this->sub_building = $sub_building;
+
+ return $this;
+ }
+}
diff --git a/src/PayPal/Order/DTO/AddressPortable2.php b/src/PayPal/Order/DTO/AddressPortable2.php
new file mode 100644
index 000000000..961a329da
--- /dev/null
+++ b/src/PayPal/Order/DTO/AddressPortable2.php
@@ -0,0 +1,342 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
+ */
+
+namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO;
+
+class AddressPortable2
+{
+ /**
+ * The [2-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote>
+ *
+ * @var string
+ */
+ protected $country_code;
+ /**
+ * The first line of the address, such as number and street, for example, `173 Drury Lane`. Needed for data entry, and Compliance and Risk checks. This field needs to pass the full address.
+ *
+ * @var string|null
+ */
+ protected $address_line_1;
+ /**
+ * The second line of the address, for example, a suite or apartment number.
+ *
+ * @var string|null
+ */
+ protected $address_line_2;
+ /**
+ * The third line of the address, if needed. Examples include a street complement for Brazil, direction text, such as `next to Walmart`, or a landmark in an Indian address.
+ *
+ * @var string|null
+ */
+ protected $address_line_3;
+ /**
+ * The neighborhood, ward, or district. This is smaller than `admin_area_level_3` or `sub_locality`. Value is:<ul><li>The postal sorting code that is used in Guernsey and many French territories, such as French Guiana.</li><li>The fine-grained administrative levels in China.</li></ul>
+ *
+ * @var string|null
+ */
+ protected $admin_area_4;
+ /**
+ * The sub-locality, suburb, neighborhood, or district. This is smaller than `admin_area_level_2`. Value is:<ul><li>Brazil. Suburb, *bairro*, or neighborhood.</li><li>India. Sub-locality or district. Street name information isn't always available, but a sub-locality or district can be a very small area.</li></ul>
+ *
+ * @var string|null
+ */
+ protected $admin_area_3;
+ /**
+ * A city, town, or village. Smaller than `admin_area_level_1`.
+ *
+ * @var string|null
+ */
+ protected $admin_area_2;
+ /**
+ * The highest-level sub-division in a country, which is usually a province, state, or ISO-3166-2 subdivision. This data is formatted for postal delivery, for example, `CA` and not `California`. Value, by country, is:<ul><li>UK. A county.</li><li>US. A state.</li><li>Canada. A province.</li><li>Japan. A prefecture.</li><li>Switzerland. A *kanton*.</li></ul>
+ *
+ * @var string|null
+ */
+ protected $admin_area_1;
+ /**
+ * The postal code, which is the ZIP code or equivalent. Typically required for countries with a postal code or an equivalent. See [postal code](https://en.wikipedia.org/wiki/Postal_code).
+ *
+ * @var string|null
+ */
+ protected $postal_code;
+ /**
+ * @var AddressDetails|null
+ */
+ protected $address_details;
+
+ /**
+ * Constructor
+ *
+ * @param mixed[] $data Associated array of property values initializing the model
+ */
+ public function __construct(array $data = null)
+ {
+ $this->country_code = isset($data['country_code']) ? $data['country_code'] : null;
+ $this->address_line_1 = isset($data['address_line_1']) ? $data['address_line_1'] : null;
+ $this->address_line_2 = isset($data['address_line_2']) ? $data['address_line_2'] : null;
+ $this->address_line_3 = isset($data['address_line_3']) ? $data['address_line_3'] : null;
+ $this->admin_area_4 = isset($data['admin_area_4']) ? $data['admin_area_4'] : null;
+ $this->admin_area_3 = isset($data['admin_area_3']) ? $data['admin_area_3'] : null;
+ $this->admin_area_2 = isset($data['admin_area_2']) ? $data['admin_area_2'] : null;
+ $this->admin_area_1 = isset($data['admin_area_1']) ? $data['admin_area_1'] : null;
+ $this->postal_code = isset($data['postal_code']) ? $data['postal_code'] : null;
+ $this->address_details = isset($data['address_details']) ? $data['address_details'] : null;
+ }
+
+ /**
+ * Gets country_code.
+ *
+ * @return string
+ */
+ public function getCountryCode()
+ {
+ return $this->country_code;
+ }
+
+ /**
+ * Sets country_code.
+ *
+ * @param string $country_code The [2-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + + return $this; + } + + /** + * Gets address_line_1. + * + * @return string|null + */ + public function getAddressLine1() + { + return $this->address_line_1; + } + + /** + * Sets address_line_1. + * + * @param string|null $address_line_1 The first line of the address, such as number and street, for example, `173 Drury Lane`. Needed for data entry, and Compliance and Risk checks. This field needs to pass the full address. + * + * @return $this + */ + public function setAddressLine1($address_line_1 = null) + { + $this->address_line_1 = $address_line_1; + + return $this; + } + + /** + * Gets address_line_2. + * + * @return string|null + */ + public function getAddressLine2() + { + return $this->address_line_2; + } + + /** + * Sets address_line_2. + * + * @param string|null $address_line_2 the second line of the address, for example, a suite or apartment number + * + * @return $this + */ + public function setAddressLine2($address_line_2 = null) + { + $this->address_line_2 = $address_line_2; + + return $this; + } + + /** + * Gets address_line_3. + * + * @return string|null + */ + public function getAddressLine3() + { + return $this->address_line_3; + } + + /** + * Sets address_line_3. + * + * @param string|null $address_line_3 The third line of the address, if needed. Examples include a street complement for Brazil, direction text, such as `next to Walmart`, or a landmark in an Indian address. + * + * @return $this + */ + public function setAddressLine3($address_line_3 = null) + { + $this->address_line_3 = $address_line_3; + + return $this; + } + + /** + * Gets admin_area_4. + * + * @return string|null + */ + public function getAdminArea4() + { + return $this->admin_area_4; + } + + /** + * Sets admin_area_4. + * + * @param string|null $admin_area_4 The neighborhood, ward, or district. This is smaller than `admin_area_level_3` or `sub_locality`. Value is:GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: The regular expression provides guidance but does not reject all invalid dates.+ * + * @return $this + */ + public function setExpirationTime($expiration_time = null) + { + $this->expiration_time = $expiration_time; + + return $this; + } + + /** + * Gets links. + * + * @return LinkDescription[]|null + */ + public function getLinks() + { + return $this->links; + } + + /** + * Sets links. + * + * @param LinkDescription[]|null $links an array of related [HATEOAS links](/docs/api/reference/api-responses/#hateoas-links) + * + * @return $this + */ + public function setLinks(array $links = null) + { + $this->links = $links; + + return $this; + } + + /** + * Gets create_time. + * + * @return string|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Sets create_time. + * + * @param string|null $create_time The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.
Note: The regular expression provides guidance but does not reject all invalid dates.+ * + * @return $this + */ + public function setCreateTime($create_time = null) + { + $this->create_time = $create_time; + + return $this; + } + + /** + * Gets update_time. + * + * @return string|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Sets update_time. + * + * @param string|null $update_time The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.
Note: The regular expression provides guidance but does not reject all invalid dates.+ * + * @return $this + */ + public function setUpdateTime($update_time = null) + { + $this->update_time = $update_time; + + return $this; + } + + /** + * Gets processor_response. + * + * @return ProcessorResponse|null + */ + public function getProcessorResponse() + { + return $this->processor_response; + } + + /** + * Sets processor_response. + * + * @param ProcessorResponse|null $processor_response + * + * @return $this + */ + public function setProcessorResponse(ProcessorResponse $processor_response = null) + { + $this->processor_response = $processor_response; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/Bancontact.php b/src/PayPal/Order/DTO/Bancontact.php new file mode 100644 index 000000000..1e68d30d3 --- /dev/null +++ b/src/PayPal/Order/DTO/Bancontact.php @@ -0,0 +1,223 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Bancontact +{ + /** + * The full name representation like Mr J Smith. + * + * @var string|null + */ + protected $name; + + /** + * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> + * + * @var string|null + */ + protected $country_code; + + /** + * The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @var string|null + */ + protected $bic; + + /** + * The last characters of the IBAN used to pay. + * + * @var string|null + */ + protected $iban_last_chars; + + /** + * The last digits of the card used to fund the Bancontact payment. + * + * @var string|null + */ + protected $card_last_digits; + + /** + * @var mixed|null + */ + protected $attributes; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->country_code = isset($data['country_code']) ? $data['country_code'] : null; + $this->bic = isset($data['bic']) ? $data['bic'] : null; + $this->iban_last_chars = isset($data['iban_last_chars']) ? $data['iban_last_chars'] : null; + $this->card_last_digits = isset($data['card_last_digits']) ? $data['card_last_digits'] : null; + $this->attributes = isset($data['attributes']) ? $data['attributes'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the full name representation like Mr J Smith + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets country_code. + * + * @return string|null + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Sets country_code. + * + * @param string|null $country_code The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setCountryCode($country_code = null) + { + $this->country_code = $country_code; + + return $this; + } + + /** + * Gets bic. + * + * @return string|null + */ + public function getBic() + { + return $this->bic; + } + + /** + * Sets bic. + * + * @param string|null $bic The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @return $this + */ + public function setBic($bic = null) + { + $this->bic = $bic; + + return $this; + } + + /** + * Gets iban_last_chars. + * + * @return string|null + */ + public function getIbanLastChars() + { + return $this->iban_last_chars; + } + + /** + * Sets iban_last_chars. + * + * @param string|null $iban_last_chars the last characters of the IBAN used to pay + * + * @return $this + */ + public function setIbanLastChars($iban_last_chars = null) + { + $this->iban_last_chars = $iban_last_chars; + + return $this; + } + + /** + * Gets card_last_digits. + * + * @return string|null + */ + public function getCardLastDigits() + { + return $this->card_last_digits; + } + + /** + * Sets card_last_digits. + * + * @param string|null $card_last_digits the last digits of the card used to fund the Bancontact payment + * + * @return $this + */ + public function setCardLastDigits($card_last_digits = null) + { + $this->card_last_digits = $card_last_digits; + + return $this; + } + + /** + * Gets attributes. + * + * @return mixed|null + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Sets attributes. + * + * @param mixed|null $attributes + * + * @return $this + */ + public function setAttributes($attributes = null) + { + $this->attributes = $attributes; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/BancontactRequest.php b/src/PayPal/Order/DTO/BancontactRequest.php new file mode 100644 index 000000000..f3aabb580 --- /dev/null +++ b/src/PayPal/Order/DTO/BancontactRequest.php @@ -0,0 +1,91 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class BancontactRequest +{ + /** + * @var string + */ + private $name; + /** + * @var string + */ + private $country_code; + /** + * @var ExperienceContextRequest + */ + private $experience_context; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * @param string $country_code + * + * @return void + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + } + + /** + * @return ExperienceContextRequest + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param ExperienceContextRequest $experience_context + * + * @return void + */ + public function setExperienceContext(ExperienceContextRequest $experience_context) + { + $this->experience_context = $experience_context; + } +} diff --git a/src/PayPal/Order/DTO/BinDetails.php b/src/PayPal/Order/DTO/BinDetails.php new file mode 100644 index 000000000..e4314cebf --- /dev/null +++ b/src/PayPal/Order/DTO/BinDetails.php @@ -0,0 +1,161 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class BinDetails +{ + /** + * The Bank Identification Number (BIN) signifies the number that is being used to identify the granular level details (except the PII information) of the card. + * + * @var string|null + */ + protected $bin; + + /** + * The issuer of the card instrument. + * + * @var string|null + */ + protected $issuing_bank; + + /** + * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> + * + * @var string|null + */ + protected $bin_country_code; + + /** + * The type of card product assigned to the BIN by the issuer. These values are defined by the issuer and may change over time. Some examples include: PREPAID_GIFT, CONSUMER, CORPORATE. + * + * @var string[]|null + */ + protected $products; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->bin = isset($data['bin']) ? $data['bin'] : null; + $this->issuing_bank = isset($data['issuing_bank']) ? $data['issuing_bank'] : null; + $this->bin_country_code = isset($data['bin_country_code']) ? $data['bin_country_code'] : null; + $this->products = isset($data['products']) ? $data['products'] : null; + } + + /** + * Gets bin. + * + * @return string|null + */ + public function getBin() + { + return $this->bin; + } + + /** + * Sets bin. + * + * @param string|null $bin the Bank Identification Number (BIN) signifies the number that is being used to identify the granular level details (except the PII information) of the card + * + * @return $this + */ + public function setBin($bin = null) + { + $this->bin = $bin; + + return $this; + } + + /** + * Gets issuing_bank. + * + * @return string|null + */ + public function getIssuingBank() + { + return $this->issuing_bank; + } + + /** + * Sets issuing_bank. + * + * @param string|null $issuing_bank the issuer of the card instrument + * + * @return $this + */ + public function setIssuingBank($issuing_bank = null) + { + $this->issuing_bank = $issuing_bank; + + return $this; + } + + /** + * Gets bin_country_code. + * + * @return string|null + */ + public function getBinCountryCode() + { + return $this->bin_country_code; + } + + /** + * Sets bin_country_code. + * + * @param string|null $bin_country_code The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setBinCountryCode($bin_country_code = null) + { + $this->bin_country_code = $bin_country_code; + + return $this; + } + + /** + * Gets products. + * + * @return string[]|null + */ + public function getProducts() + { + return $this->products; + } + + /** + * Sets products. + * + * @param string[]|null $products The type of card product assigned to the BIN by the issuer. These values are defined by the issuer and may change over time. Some examples include: PREPAID_GIFT, CONSUMER, CORPORATE. + * + * @return $this + */ + public function setProducts(array $products = null) + { + $this->products = $products; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/Blik.php b/src/PayPal/Order/DTO/Blik.php new file mode 100644 index 000000000..462ddbd81 --- /dev/null +++ b/src/PayPal/Order/DTO/Blik.php @@ -0,0 +1,159 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Blik +{ + /** + * The full name representation like Mr J Smith. + * + * @var string|null + */ + protected $name; + + /** + * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> + * + * @var string|null + */ + protected $country_code; + + /** + * The internationalized email address.<blockquote><strong>Note:</strong> Up to 64 characters are allowed before and 255 characters are allowed after the <code>@</code> sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted <code>@</code> sign exists.</blockquote> + * + * @var string|null + */ + protected $email; + + /** + * @var BlikOneClickResponse|null + */ + protected $one_click; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->country_code = isset($data['country_code']) ? $data['country_code'] : null; + $this->email = isset($data['email']) ? $data['email'] : null; + $this->one_click = isset($data['one_click']) ? $data['one_click'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the full name representation like Mr J Smith + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets country_code. + * + * @return string|null + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Sets country_code. + * + * @param string|null $country_code The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setCountryCode($country_code = null) + { + $this->country_code = $country_code; + + return $this; + } + + /** + * Gets email. + * + * @return string|null + */ + public function getEmail() + { + return $this->email; + } + + /** + * Sets email. + * + * @param string|null $email The internationalized email address.GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: Up to 64 characters are allowed before and 255 characters are allowed after the+ * + * @return $this + */ + public function setEmail($email = null) + { + $this->email = $email; + + return $this; + } + + /** + * Gets one_click. + * + * @return BlikOneClickResponse|null + */ + public function getOneClick() + { + return $this->one_click; + } + + /** + * Sets one_click. + * + * @param BlikOneClickResponse|null $one_click + * + * @return $this + */ + public function setOneClick(BlikOneClickResponse $one_click = null) + { + $this->one_click = $one_click; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/BlikOneClickResponse.php b/src/PayPal/Order/DTO/BlikOneClickResponse.php new file mode 100644 index 000000000..b94b96912 --- /dev/null +++ b/src/PayPal/Order/DTO/BlikOneClickResponse.php @@ -0,0 +1,65 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class BlikOneClickResponse +{ + /** + * The merchant generated, unique reference serving as a primary identifier for accounts connected between Blik and a merchant. + * + * @var string|null + */ + protected $consumer_reference; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->consumer_reference = isset($data['consumer_reference']) ? $data['consumer_reference'] : null; + } + + /** + * Gets consumer_reference. + * + * @return string|null + */ + public function getConsumerReference() + { + return $this->consumer_reference; + } + + /** + * Sets consumer_reference. + * + * @param string|null $consumer_reference the merchant generated, unique reference serving as a primary identifier for accounts connected between Blik and a merchant + * + * @return $this + */ + public function setConsumerReference($consumer_reference = null) + { + $this->consumer_reference = $consumer_reference; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/BlikRequest.php b/src/PayPal/Order/DTO/BlikRequest.php new file mode 100644 index 000000000..6af509354 --- /dev/null +++ b/src/PayPal/Order/DTO/BlikRequest.php @@ -0,0 +1,113 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class BlikRequest +{ + /** + * @var string + */ + private $name; + /** + * @var string + */ + private $country_code; + /** + * @var string + */ + private $email; + /** + * @var ExperienceContextRequest + */ + private $experience_context; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * @param string $country_code + * + * @return void + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + } + + /** + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param string $email + * + * @return void + */ + public function setEmail($email) + { + $this->email = $email; + } + + /** + * @return ExperienceContextRequest + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param ExperienceContextRequest $experience_context + * + * @return void + */ + public function setExperienceContext(ExperienceContextRequest $experience_context) + { + $this->experience_context = $experience_context; + } +} diff --git a/src/PayPal/Order/DTO/Capture.php b/src/PayPal/Order/DTO/Capture.php new file mode 100644 index 000000000..22148a0e4 --- /dev/null +++ b/src/PayPal/Order/DTO/Capture.php @@ -0,0 +1,499 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Capture +{ + /** + * The status of the captured payment. + * + * @var string|null + */ + protected $status; + + /** + * @var Reason|null + */ + protected $status_details; + + /** + * The PayPal-generated ID for the captured payment. + * + * @var string|null + */ + protected $id; + + /** + * @var Amount|null + */ + protected $amount; + + /** + * The API caller-provided external invoice number for this order. Appears in both the payer's transaction history and the emails that the payer receives. + * + * @var string|null + */ + protected $invoice_id; + + /** + * The API caller-provided external ID. Used to reconcile API caller-initiated transactions with PayPal transactions. Appears in transaction and settlement reports. + * + * @var string|null + */ + protected $custom_id; + + /** + * @var NetworkTransactionReference|null + */ + protected $network_transaction_reference; + + /** + * @var SellerProtection|null + */ + protected $seller_protection; + + /** + * Indicates whether you can make additional captures against the authorized payment. Set to `true` if you do not intend to capture additional payments against the authorization. Set to `false` if you intend to capture additional payments against the authorization. + * + * @var bool|null + */ + protected $final_capture; + + /** + * @var SellerReceivableBreakdown|null + */ + protected $seller_receivable_breakdown; + + /** + * @var string|null + */ + protected $disbursement_mode; + + /** + * An array of related [HATEOAS links](/docs/api/reference/api-responses/#hateoas-links). + * + * @var LinkDescription[]|null + */ + protected $links; + + /** + * @var ProcessorResponse|null + */ + protected $processor_response; + + /** + * The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote> + * + * @var string|null + */ + protected $create_time; + + /** + * The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote> + * + * @var string|null + */ + protected $update_time; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->status = isset($data['status']) ? $data['status'] : null; + $this->status_details = isset($data['status_details']) ? $data['status_details'] : null; + $this->id = isset($data['id']) ? $data['id'] : null; + $this->amount = isset($data['amount']) ? $data['amount'] : null; + $this->invoice_id = isset($data['invoice_id']) ? $data['invoice_id'] : null; + $this->custom_id = isset($data['custom_id']) ? $data['custom_id'] : null; + $this->network_transaction_reference = isset($data['network_transaction_reference']) ? $data['network_transaction_reference'] : null; + $this->seller_protection = isset($data['seller_protection']) ? $data['seller_protection'] : null; + $this->final_capture = isset($data['final_capture']) ? $data['final_capture'] : false; + $this->seller_receivable_breakdown = isset($data['seller_receivable_breakdown']) ? $data['seller_receivable_breakdown'] : null; + $this->disbursement_mode = isset($data['disbursement_mode']) ? $data['disbursement_mode'] : null; + $this->links = isset($data['links']) ? $data['links'] : null; + $this->processor_response = isset($data['processor_response']) ? $data['processor_response'] : null; + $this->create_time = isset($data['create_time']) ? $data['create_time'] : null; + $this->update_time = isset($data['update_time']) ? $data['update_time'] : null; + } + + /** + * Gets status. + * + * @return string|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * Sets status. + * + * @param string|null $status the status of the captured payment + * + * @return $this + */ + public function setStatus($status = null) + { + $this->status = $status; + + return $this; + } + + /** + * Gets status_details. + * + * @return Reason|null + */ + public function getStatusDetails() + { + return $this->status_details; + } + + /** + * Sets status_details. + * + * @param Reason|null $status_details + * + * @return $this + */ + public function setStatusDetails(Reason $status_details = null) + { + $this->status_details = $status_details; + + return $this; + } + + /** + * Gets id. + * + * @return string|null + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param string|null $id the PayPal-generated ID for the captured payment + * + * @return $this + */ + public function setId($id = null) + { + $this->id = $id; + + return $this; + } + + /** + * Gets amount. + * + * @return Amount|null + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Sets amount. + * + * @param Amount|null $amount + * + * @return $this + */ + public function setAmount(Amount $amount = null) + { + $this->amount = $amount; + + return $this; + } + + /** + * Gets invoice_id. + * + * @return string|null + */ + public function getInvoiceId() + { + return $this->invoice_id; + } + + /** + * Sets invoice_id. + * + * @param string|null $invoice_id The API caller-provided external invoice number for this order. Appears in both the payer's transaction history and the emails that the payer receives. + * + * @return $this + */ + public function setInvoiceId($invoice_id = null) + { + $this->invoice_id = $invoice_id; + + return $this; + } + + /** + * Gets custom_id. + * + * @return string|null + */ + public function getCustomId() + { + return $this->custom_id; + } + + /** + * Sets custom_id. + * + * @param string|null $custom_id The API caller-provided external ID. Used to reconcile API caller-initiated transactions with PayPal transactions. Appears in transaction and settlement reports. + * + * @return $this + */ + public function setCustomId($custom_id = null) + { + $this->custom_id = $custom_id; + + return $this; + } + + /** + * Gets network_transaction_reference. + * + * @return NetworkTransactionReference|null + */ + public function getNetworkTransactionReference() + { + return $this->network_transaction_reference; + } + + /** + * Sets network_transaction_reference. + * + * @param NetworkTransactionReference|null $network_transaction_reference + * + * @return $this + */ + public function setNetworkTransactionReference(NetworkTransactionReference $network_transaction_reference = null) + { + $this->network_transaction_reference = $network_transaction_reference; + + return $this; + } + + /** + * Gets seller_protection. + * + * @return SellerProtection|null + */ + public function getSellerProtection() + { + return $this->seller_protection; + } + + /** + * Sets seller_protection. + * + * @param SellerProtection|null $seller_protection + * + * @return $this + */ + public function setSellerProtection(SellerProtection $seller_protection = null) + { + $this->seller_protection = $seller_protection; + + return $this; + } + + /** + * Gets final_capture. + * + * @return bool|null + */ + public function isFinalCapture() + { + return $this->final_capture; + } + + /** + * Sets final_capture. + * + * @param bool|null $final_capture Indicates whether you can make additional captures against the authorized payment. Set to `true` if you do not intend to capture additional payments against the authorization. Set to `false` if you intend to capture additional payments against the authorization. + * + * @return $this + */ + public function setFinalCapture($final_capture = null) + { + $this->final_capture = $final_capture; + + return $this; + } + + /** + * Gets seller_receivable_breakdown. + * + * @return SellerReceivableBreakdown|null + */ + public function getSellerReceivableBreakdown() + { + return $this->seller_receivable_breakdown; + } + + /** + * Sets seller_receivable_breakdown. + * + * @param SellerReceivableBreakdown|null $seller_receivable_breakdown + * + * @return $this + */ + public function setSellerReceivableBreakdown(SellerReceivableBreakdown $seller_receivable_breakdown = null) + { + $this->seller_receivable_breakdown = $seller_receivable_breakdown; + + return $this; + } + + /** + * Gets disbursement_mode. + * + * @return string|null + */ + public function getDisbursementMode() + { + return $this->disbursement_mode; + } + + /** + * Sets disbursement_mode. + * + * @param string|null $disbursement_mode + * + * @return $this + */ + public function setDisbursementMode($disbursement_mode = null) + { + $this->disbursement_mode = $disbursement_mode; + + return $this; + } + + /** + * Gets links. + * + * @return LinkDescription[]|null + */ + public function getLinks() + { + return $this->links; + } + + /** + * Sets links. + * + * @param LinkDescription[]|null $links an array of related [HATEOAS links](/docs/api/reference/api-responses/#hateoas-links) + * + * @return $this + */ + public function setLinks(array $links = null) + { + $this->links = $links; + + return $this; + } + + /** + * Gets processor_response. + * + * @return ProcessorResponse|null + */ + public function getProcessorResponse() + { + return $this->processor_response; + } + + /** + * Sets processor_response. + * + * @param ProcessorResponse|null $processor_response + * + * @return $this + */ + public function setProcessorResponse(ProcessorResponse $processor_response = null) + { + $this->processor_response = $processor_response; + + return $this; + } + + /** + * Gets create_time. + * + * @return string|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Sets create_time. + * + * @param string|null $create_time The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.@
sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted@
sign exists.
Note: The regular expression provides guidance but does not reject all invalid dates.+ * + * @return $this + */ + public function setCreateTime($create_time = null) + { + $this->create_time = $create_time; + + return $this; + } + + /** + * Gets update_time. + * + * @return string|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Sets update_time. + * + * @param string|null $update_time The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.
Note: The regular expression provides guidance but does not reject all invalid dates.+ * + * @return $this + */ + public function setUpdateTime($update_time = null) + { + $this->update_time = $update_time; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/CardAttributesRequest.php b/src/PayPal/Order/DTO/CardAttributesRequest.php new file mode 100644 index 000000000..bb941cf6d --- /dev/null +++ b/src/PayPal/Order/DTO/CardAttributesRequest.php @@ -0,0 +1,91 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CardAttributesRequest +{ + /** + * @var CustomerRequest + */ + private $customer; + /** + * @var VaultAttributesRequest + */ + private $vault; + /** + * @var CardVerification + */ + private $verification; + + /** + * @return CustomerRequest + */ + public function getCustomer() + { + return $this->customer; + } + + /** + * @param CustomerRequest $customer + * + * @return void + */ + public function setCustomer(CustomerRequest $customer) + { + $this->customer = $customer; + } + + /** + * @return VaultAttributesRequest + */ + public function getVault() + { + return $this->vault; + } + + /** + * @param VaultAttributesRequest $vault + * + * @return void + */ + public function setVault(VaultAttributesRequest $vault) + { + $this->vault = $vault; + } + + /** + * @return CardVerification + */ + public function getVerification() + { + return $this->verification; + } + + /** + * @param CardVerification $verification + * + * @return void + */ + public function setVerification(CardVerification $verification) + { + $this->verification = $verification; + } +} diff --git a/src/PayPal/Order/DTO/CardAttributesResponse.php b/src/PayPal/Order/DTO/CardAttributesResponse.php new file mode 100644 index 000000000..656a105df --- /dev/null +++ b/src/PayPal/Order/DTO/CardAttributesResponse.php @@ -0,0 +1,63 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CardAttributesResponse +{ + /** + * @var VaultResponse|null + */ + protected $vault; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->vault = isset($data['vault']) ? $data['vault'] : null; + } + + /** + * Gets vault. + * + * @return VaultResponse|null + */ + public function getVault() + { + return $this->vault; + } + + /** + * Sets vault. + * + * @param VaultResponse|null $vault + * + * @return $this + */ + public function setVault(VaultResponse $vault = null) + { + $this->vault = $vault; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/CardExperienceContextRequest.php b/src/PayPal/Order/DTO/CardExperienceContextRequest.php new file mode 100644 index 000000000..beb85d4c5 --- /dev/null +++ b/src/PayPal/Order/DTO/CardExperienceContextRequest.php @@ -0,0 +1,69 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CardExperienceContextRequest +{ + /** + * @var string + */ + private $return_url; + /** + * @var string + */ + private $cancel_url; + + /** + * @return string + */ + public function getReturnUrl() + { + return $this->return_url; + } + + /** + * @param string $return_url + * + * @return void + */ + public function setReturnUrl($return_url) + { + $this->return_url = $return_url; + } + + /** + * @return string + */ + public function getCancelUrl() + { + return $this->cancel_url; + } + + /** + * @param string $cancel_url + * + * @return void + */ + public function setCancelUrl($cancel_url) + { + $this->cancel_url = $cancel_url; + } +} diff --git a/src/PayPal/Order/DTO/CardFromRequest.php b/src/PayPal/Order/DTO/CardFromRequest.php new file mode 100644 index 000000000..0d68f43a9 --- /dev/null +++ b/src/PayPal/Order/DTO/CardFromRequest.php @@ -0,0 +1,97 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CardFromRequest +{ + /** + * The year and month, in ISO-8601 `YYYY-MM` date format. See [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). + * + * @var string|null + */ + protected $expiry; + + /** + * The last digits of the payment card. + * + * @var string|null + */ + protected $last_digits; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->expiry = isset($data['expiry']) ? $data['expiry'] : null; + $this->last_digits = isset($data['last_digits']) ? $data['last_digits'] : null; + } + + /** + * Gets expiry. + * + * @return string|null + */ + public function getExpiry() + { + return $this->expiry; + } + + /** + * Sets expiry. + * + * @param string|null $expiry The year and month, in ISO-8601 `YYYY-MM` date format. See [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return $this + */ + public function setExpiry($expiry = null) + { + $this->expiry = $expiry; + + return $this; + } + + /** + * Gets last_digits. + * + * @return string|null + */ + public function getLastDigits() + { + return $this->last_digits; + } + + /** + * Sets last_digits. + * + * @param string|null $last_digits the last digits of the payment card + * + * @return $this + */ + public function setLastDigits($last_digits = null) + { + $this->last_digits = $last_digits; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/CardRequest.php b/src/PayPal/Order/DTO/CardRequest.php new file mode 100644 index 000000000..be0a2d6bd --- /dev/null +++ b/src/PayPal/Order/DTO/CardRequest.php @@ -0,0 +1,157 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CardRequest +{ + /** + * @var string + */ + private $name; + /** + * @var AddressRequest + */ + private $billing_address; + /** + * @var CardAttributesRequest + */ + private $attributes; + /** + * @var string + */ + private $vault_id; + /** + * @var CardStoredCredentialsRequest + */ + private $stored_credentials; + /** + * @var CardExperienceContextRequest + */ + private $experience_context; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return AddressRequest + */ + public function getBillingAddress() + { + return $this->billing_address; + } + + /** + * @param AddressRequest $billing_address + * + * @return void + */ + public function setBillingAddress(AddressRequest $billing_address) + { + $this->billing_address = $billing_address; + } + + /** + * @return CardAttributesRequest + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param CardAttributesRequest $attributes + * + * @return void + */ + public function setAttributes(CardAttributesRequest $attributes) + { + $this->attributes = $attributes; + } + + /** + * @return string + */ + public function getVaultId() + { + return $this->vault_id; + } + + /** + * @param string $vault_id + * + * @return void + */ + public function setVaultId($vault_id) + { + $this->vault_id = $vault_id; + } + + /** + * @return CardStoredCredentialsRequest + */ + public function getStoredCredentials() + { + return $this->stored_credentials; + } + + /** + * @param CardStoredCredentialsRequest $stored_credentials + * + * @return void + */ + public function setStoredCredentials(CardStoredCredentialsRequest $stored_credentials) + { + $this->stored_credentials = $stored_credentials; + } + + /** + * @return CardExperienceContextRequest + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param CardExperienceContextRequest $experience_context + * + * @return void + */ + public function setExperienceContext(CardExperienceContextRequest $experience_context) + { + $this->experience_context = $experience_context; + } +} diff --git a/src/PayPal/Order/DTO/CardResponse.php b/src/PayPal/Order/DTO/CardResponse.php new file mode 100644 index 000000000..9249a235e --- /dev/null +++ b/src/PayPal/Order/DTO/CardResponse.php @@ -0,0 +1,343 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CardResponse +{ + /** + * The card holder's name as it appears on the card. + * + * @var string|null + */ + protected $name; + + /** + * The last digits of the payment card. + * + * @var string|null + */ + protected $last_digits; + + /** + * @var string|null + */ + protected $brand; + + /** + * Array of brands or networks associated with the card. + * + * @var string[]|null + */ + protected $available_networks; + + /** + * The payment card type. + * + * @var string|null + */ + protected $type; + + /** + * @var AuthenticationResponse|null + */ + protected $authentication_result; + + /** + * @var CardAttributesResponse|null + */ + protected $attributes; + + /** + * @var CardFromRequest|null + */ + protected $from_request; + + /** + * The year and month, in ISO-8601 `YYYY-MM` date format. See [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). + * + * @var string|null + */ + protected $expiry; + + /** + * @var BinDetails|null + */ + protected $bin_details; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->last_digits = isset($data['last_digits']) ? $data['last_digits'] : null; + $this->brand = isset($data['brand']) ? $data['brand'] : null; + $this->available_networks = isset($data['available_networks']) ? $data['available_networks'] : null; + $this->type = isset($data['type']) ? $data['type'] : null; + $this->authentication_result = isset($data['authentication_result']) ? $data['authentication_result'] : null; + $this->attributes = isset($data['attributes']) ? $data['attributes'] : null; + $this->from_request = isset($data['from_request']) ? $data['from_request'] : null; + $this->expiry = isset($data['expiry']) ? $data['expiry'] : null; + $this->bin_details = isset($data['bin_details']) ? $data['bin_details'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the card holder's name as it appears on the card + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets last_digits. + * + * @return string|null + */ + public function getLastDigits() + { + return $this->last_digits; + } + + /** + * Sets last_digits. + * + * @param string|null $last_digits the last digits of the payment card + * + * @return $this + */ + public function setLastDigits($last_digits = null) + { + $this->last_digits = $last_digits; + + return $this; + } + + /** + * Gets brand. + * + * @return string|null + */ + public function getBrand() + { + return $this->brand; + } + + /** + * Sets brand. + * + * @param string|null $brand + * + * @return $this + */ + public function setBrand($brand = null) + { + $this->brand = $brand; + + return $this; + } + + /** + * Gets available_networks. + * + * @return string[]|null + */ + public function getAvailableNetworks() + { + return $this->available_networks; + } + + /** + * Sets available_networks. + * + * @param string[]|null $available_networks array of brands or networks associated with the card + * + * @return $this + */ + public function setAvailableNetworks(array $available_networks = null) + { + $this->available_networks = $available_networks; + + return $this; + } + + /** + * Gets type. + * + * @return string|null + */ + public function getType() + { + return $this->type; + } + + /** + * Sets type. + * + * @param string|null $type the payment card type + * + * @return $this + */ + public function setType($type = null) + { + $this->type = $type; + + return $this; + } + + /** + * Gets authentication_result. + * + * @return AuthenticationResponse|null + */ + public function getAuthenticationResult() + { + return $this->authentication_result; + } + + /** + * Sets authentication_result. + * + * @param AuthenticationResponse|null $authentication_result + * + * @return $this + */ + public function setAuthenticationResult(AuthenticationResponse $authentication_result = null) + { + $this->authentication_result = $authentication_result; + + return $this; + } + + /** + * Gets attributes. + * + * @return CardAttributesResponse|null + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Sets attributes. + * + * @param CardAttributesResponse|null $attributes + * + * @return $this + */ + public function setAttributes(CardAttributesResponse $attributes = null) + { + $this->attributes = $attributes; + + return $this; + } + + /** + * Gets from_request. + * + * @return CardFromRequest|null + */ + public function getFromRequest() + { + return $this->from_request; + } + + /** + * Sets from_request. + * + * @param CardFromRequest|null $from_request + * + * @return $this + */ + public function setFromRequest(CardFromRequest $from_request = null) + { + $this->from_request = $from_request; + + return $this; + } + + /** + * Gets expiry. + * + * @return string|null + */ + public function getExpiry() + { + return $this->expiry; + } + + /** + * Sets expiry. + * + * @param string|null $expiry The year and month, in ISO-8601 `YYYY-MM` date format. See [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return $this + */ + public function setExpiry($expiry = null) + { + $this->expiry = $expiry; + + return $this; + } + + /** + * Gets bin_details. + * + * @return BinDetails|null + */ + public function getBinDetails() + { + return $this->bin_details; + } + + /** + * Sets bin_details. + * + * @param BinDetails|null $bin_details + * + * @return $this + */ + public function setBinDetails(BinDetails $bin_details = null) + { + $this->bin_details = $bin_details; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/CardStoredCredentialsRequest.php b/src/PayPal/Order/DTO/CardStoredCredentialsRequest.php new file mode 100644 index 000000000..03a54c15b --- /dev/null +++ b/src/PayPal/Order/DTO/CardStoredCredentialsRequest.php @@ -0,0 +1,113 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CardStoredCredentialsRequest +{ + /** + * @var string + */ + private $payment_initiator; + /** + * @var string + */ + private $payment_type; + /** + * @var string + */ + private $usage; + /** + * @var NetworkTransactionReference + */ + private $previous_network_transaction_reference; + + /** + * @return string + */ + public function getPaymentInitiator() + { + return $this->payment_initiator; + } + + /** + * @param string $payment_initiator + * + * @return void + */ + public function setPaymentInitiator($payment_initiator) + { + $this->payment_initiator = $payment_initiator; + } + + /** + * @return string + */ + public function getPaymentType() + { + return $this->payment_type; + } + + /** + * @param string $payment_type + * + * @return void + */ + public function setPaymentType($payment_type) + { + $this->payment_type = $payment_type; + } + + /** + * @return string + */ + public function getUsage() + { + return $this->usage; + } + + /** + * @param string $usage + * + * @return void + */ + public function setUsage($usage) + { + $this->usage = $usage; + } + + /** + * @return NetworkTransactionReference + */ + public function getPreviousNetworkTransactionReference() + { + return $this->previous_network_transaction_reference; + } + + /** + * @param NetworkTransactionReference $previous_network_transaction_reference + * + * @return void + */ + public function setPreviousNetworkTransactionReference(NetworkTransactionReference $previous_network_transaction_reference) + { + $this->previous_network_transaction_reference = $previous_network_transaction_reference; + } +} diff --git a/src/PayPal/Order/DTO/CardSupplementaryData.php b/src/PayPal/Order/DTO/CardSupplementaryData.php new file mode 100644 index 000000000..0842d313f --- /dev/null +++ b/src/PayPal/Order/DTO/CardSupplementaryData.php @@ -0,0 +1,92 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CardSupplementaryData +{ + /** + * @var Level2CardProcessingData|null + */ + protected $level_2; + /** + * @var Level3CardProcessingData|null + */ + protected $level_3; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->level_2 = isset($data['level_2']) ? $data['level_2'] : null; + $this->level_3 = isset($data['level_3']) ? $data['level_3'] : null; + } + + /** + * Gets level_2. + * + * @return Level2CardProcessingData|null + */ + public function getLevel2() + { + return $this->level_2; + } + + /** + * Sets level_2. + * + * @param Level2CardProcessingData|null $level_2 + * + * @return $this + */ + public function setLevel2(Level2CardProcessingData $level_2 = null) + { + $this->level_2 = $level_2; + + return $this; + } + + /** + * Gets level_3. + * + * @return Level3CardProcessingData|null + */ + public function getLevel3() + { + return $this->level_3; + } + + /** + * Sets level_3. + * + * @param Level3CardProcessingData|null $level_3 + * + * @return $this + */ + public function setLevel3(Level3CardProcessingData $level_3 = null) + { + $this->level_3 = $level_3; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/CardSupplementaryDataRequest.php b/src/PayPal/Order/DTO/CardSupplementaryDataRequest.php new file mode 100644 index 000000000..04b76b9a5 --- /dev/null +++ b/src/PayPal/Order/DTO/CardSupplementaryDataRequest.php @@ -0,0 +1,69 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CardSupplementaryDataRequest +{ + /** + * @var Level2CardProcessingDataRequest + */ + private $level_2; + /** + * @var Level3CardProcessingDataRequest + */ + private $level_3; + + /** + * @return Level2CardProcessingDataRequest + */ + public function getLevel2() + { + return $this->level_2; + } + + /** + * @param Level2CardProcessingDataRequest $level_2 + * + * @return void + */ + public function setLevel2(Level2CardProcessingDataRequest $level_2) + { + $this->level_2 = $level_2; + } + + /** + * @return Level3CardProcessingDataRequest + */ + public function getLevel3() + { + return $this->level_3; + } + + /** + * @param Level3CardProcessingDataRequest $level_3 + * + * @return void + */ + public function setLevel3(Level3CardProcessingDataRequest $level_3) + { + $this->level_3 = $level_3; + } +} diff --git a/src/PayPal/Order/DTO/CardVerification.php b/src/PayPal/Order/DTO/CardVerification.php new file mode 100644 index 000000000..8891eddac --- /dev/null +++ b/src/PayPal/Order/DTO/CardVerification.php @@ -0,0 +1,47 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CardVerification +{ + /** + * @var string + */ + private $method; + + /** + * @return string + */ + public function getMethod() + { + return $this->method; + } + + /** + * @param string $method + * + * @return void + */ + public function setMethod($method) + { + $this->method = $method; + } +} diff --git a/src/PayPal/Order/DTO/CobrandedCard.php b/src/PayPal/Order/DTO/CobrandedCard.php new file mode 100644 index 000000000..8ad1728ff --- /dev/null +++ b/src/PayPal/Order/DTO/CobrandedCard.php @@ -0,0 +1,123 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CobrandedCard +{ + /** + * Array of labels for the cobranded card. + * + * @var string[]|null + */ + protected $labels; + /** + * @var Payee|null + */ + protected $payee; + /** + * @var Amount|null + */ + protected $amount; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->labels = isset($data['labels']) ? $data['labels'] : null; + $this->payee = isset($data['payee']) ? $data['payee'] : null; + $this->amount = isset($data['amount']) ? $data['amount'] : null; + } + + /** + * Gets labels. + * + * @return string[]|null + */ + public function getLabels() + { + return $this->labels; + } + + /** + * Sets labels. + * + * @param string[]|null $labels array of labels for the cobranded card + * + * @return $this + */ + public function setLabels(array $labels = null) + { + $this->labels = $labels; + + return $this; + } + + /** + * Gets payee. + * + * @return Payee|null + */ + public function getPayee() + { + return $this->payee; + } + + /** + * Sets payee. + * + * @param Payee|null $payee + * + * @return $this + */ + public function setPayee(Payee $payee = null) + { + $this->payee = $payee; + + return $this; + } + + /** + * Gets amount. + * + * @return Amount|null + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Sets amount. + * + * @param Amount|null $amount + * + * @return $this + */ + public function setAmount(Amount $amount = null) + { + $this->amount = $amount; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/CreatePayPalOrderRequest.php b/src/PayPal/Order/DTO/CreatePayPalOrderRequest.php new file mode 100644 index 000000000..6ce3c76db --- /dev/null +++ b/src/PayPal/Order/DTO/CreatePayPalOrderRequest.php @@ -0,0 +1,135 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CreatePayPalOrderRequest implements CreatePayPalOrderRequestInterface +{ + /** + * @var string + */ + private $intent; + /** + * @var PurchaseUnitRequest[] + */ + private $purchase_units; + /** + * @var PaymentSourceRequest + */ + private $payment_source; + /** + * @var ApplicationContextRequest + */ + private $application_context; + /** + * @var string + */ + private $processing_instruction; + + /** + * @return string + */ + public function getIntent() + { + return $this->intent; + } + + /** + * @param string $intent + * + * @return void + */ + public function setIntent($intent) + { + $this->intent = $intent; + } + + /** + * @return PurchaseUnitRequest[] + */ + public function getPurchaseUnits() + { + return $this->purchase_units; + } + + /** + * @param PurchaseUnitRequest[] $purchase_units + * + * @return void + */ + public function setPurchaseUnits(array $purchase_units) + { + $this->purchase_units = $purchase_units; + } + + /** + * @return PaymentSourceRequest + */ + public function getPaymentSource() + { + return $this->payment_source; + } + + /** + * @param PaymentSourceRequest $payment_source + * + * @return void + */ + public function setPaymentSource(PaymentSourceRequest $payment_source) + { + $this->payment_source = $payment_source; + } + + /** + * @return ApplicationContextRequest + */ + public function getApplicationContext() + { + return $this->application_context; + } + + /** + * @param ApplicationContextRequest $application_context + * + * @return void + */ + public function setApplicationContext(ApplicationContextRequest $application_context) + { + $this->application_context = $application_context; + } + + /** + * @return string + */ + public function getProcessingInstruction() + { + return $this->processing_instruction; + } + + /** + * @param string $processing_instruction + * + * @return void + */ + public function setProcessingInstruction($processing_instruction) + { + $this->processing_instruction = $processing_instruction; + } +} diff --git a/src/PayPal/Order/DTO/CreatePayPalOrderRequestInterface.php b/src/PayPal/Order/DTO/CreatePayPalOrderRequestInterface.php new file mode 100644 index 000000000..f61c62e28 --- /dev/null +++ b/src/PayPal/Order/DTO/CreatePayPalOrderRequestInterface.php @@ -0,0 +1,44 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +interface CreatePayPalOrderRequestInterface +{ + public function getIntent(); + + public function setIntent($intent); + + public function getPurchaseUnits(); + + public function setPurchaseUnits(array $purchase_units); + + public function getPaymentSource(); + + public function setPaymentSource(PaymentSourceRequest $payment_source); + + public function getApplicationContext(); + + public function setApplicationContext(ApplicationContextRequest $application_context); + + public function getProcessingInstruction(); + + public function setProcessingInstruction($processing_instruction); +} diff --git a/src/PayPal/Order/DTO/CreatePayPalOrderResponse.php b/src/PayPal/Order/DTO/CreatePayPalOrderResponse.php new file mode 100644 index 000000000..0347213a4 --- /dev/null +++ b/src/PayPal/Order/DTO/CreatePayPalOrderResponse.php @@ -0,0 +1,246 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CreatePayPalOrderResponse +{ + /** + * @var string + */ + private $id; + /** + * @var string + */ + private $create_time; + /** + * @var string + */ + private $update_time; + /** + * @var PaymentSourceResponse + */ + private $payment_source; + /** + * @var string + */ + private $intent; + /** + * @var string + */ + private $processing_instruction; + /** + * @var Payer + */ + private $payer; + /** + * @var PurchaseUnit[] + */ + private $purchase_units; + /** + * @var string + */ + private $status; + /** + * @var LinkDescription[] + */ + private $links; + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * @param string $create_time + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + + return $this; + } + + /** + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * @param string $update_time + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + + return $this; + } + + /** + * @return PaymentSourceResponse|null + */ + public function getPaymentSource() + { + return $this->payment_source; + } + + /** + * @param PaymentSourceResponse $payment_source + */ + public function setPaymentSource($payment_source) + { + $this->payment_source = $payment_source; + + return $this; + } + + /** + * @return string + */ + public function getIntent() + { + return $this->intent; + } + + /** + * @param string $intent + */ + public function setIntent($intent) + { + $this->intent = $intent; + + return $this; + } + + /** + * @return string + */ + public function getProcessingInstruction() + { + return $this->processing_instruction; + } + + /** + * @param string $processing_instruction + */ + public function setProcessingInstruction($processing_instruction) + { + $this->processing_instruction = $processing_instruction; + + return $this; + } + + /** + * @return Payer + */ + public function getPayer() + { + return $this->payer; + } + + /** + * @param Payer $payer + */ + public function setPayer($payer) + { + $this->payer = $payer; + + return $this; + } + + /** + * @return PurchaseUnit[] + */ + public function getPurchaseUnits() + { + return $this->purchase_units; + } + + /** + * @param PurchaseUnit[] $purchase_units + */ + public function setPurchaseUnits($purchase_units) + { + $this->purchase_units = $purchase_units; + + return $this; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param string $status + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * @return LinkDescription[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * @param LinkDescription[] $links + */ + public function setLinks($links) + { + $this->links = $links; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/Customer.php b/src/PayPal/Order/DTO/Customer.php new file mode 100644 index 000000000..827c98be1 --- /dev/null +++ b/src/PayPal/Order/DTO/Customer.php @@ -0,0 +1,127 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Customer +{ + /** + * The unique ID for a customer generated by PayPal. + * + * @var string|null + */ + protected $id; + + /** + * The internationalized email address.<blockquote><strong>Note:</strong> Up to 64 characters are allowed before and 255 characters are allowed after the <code>@</code> sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted <code>@</code> sign exists.</blockquote> + * + * @var string|null + */ + protected $email_address; + + /** + * @var PhoneWithType|null + */ + protected $phone; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->id = isset($data['id']) ? $data['id'] : null; + $this->email_address = isset($data['email_address']) ? $data['email_address'] : null; + $this->phone = isset($data['phone']) ? $data['phone'] : null; + } + + /** + * Gets id. + * + * @return string|null + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param string|null $id the unique ID for a customer generated by PayPal + * + * @return $this + */ + public function setId($id = null) + { + $this->id = $id; + + return $this; + } + + /** + * Gets email_address. + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->email_address; + } + + /** + * Sets email_address. + * + * @param string|null $email_address The internationalized email address.
Note: Up to 64 characters are allowed before and 255 characters are allowed after the+ * + * @return $this + */ + public function setEmailAddress($email_address = null) + { + $this->email_address = $email_address; + + return $this; + } + + /** + * Gets phone. + * + * @return PhoneWithType|null + */ + public function getPhone() + { + return $this->phone; + } + + /** + * Sets phone. + * + * @param PhoneWithType|null $phone + * + * @return $this + */ + public function setPhone(PhoneWithType $phone = null) + { + $this->phone = $phone; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/CustomerRequest.php b/src/PayPal/Order/DTO/CustomerRequest.php new file mode 100644 index 000000000..b764990ad --- /dev/null +++ b/src/PayPal/Order/DTO/CustomerRequest.php @@ -0,0 +1,91 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class CustomerRequest +{ + /** + * @var string + */ + private $id; + /** + * @var string + */ + private $email_address; + /** + * @var PhoneWithType + */ + private $phone; + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $id + * + * @return void + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * @return string + */ + public function getEmailAddress() + { + return $this->email_address; + } + + /** + * @param string $email_address + * + * @return void + */ + public function setEmailAddress($email_address) + { + $this->email_address = $email_address; + } + + /** + * @return PhoneWithType + */ + public function getPhone() + { + return $this->phone; + } + + /** + * @param PhoneWithType $phone + * + * @return void + */ + public function setPhone(PhoneWithType $phone) + { + $this->phone = $phone; + } +} diff --git a/src/PayPal/Order/DTO/Eps.php b/src/PayPal/Order/DTO/Eps.php new file mode 100644 index 000000000..213099ec1 --- /dev/null +++ b/src/PayPal/Order/DTO/Eps.php @@ -0,0 +1,129 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Eps +{ + /** + * The full name representation like Mr J Smith. + * + * @var string|null + */ + protected $name; + + /** + * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> + * + * @var string|null + */ + protected $country_code; + + /** + * The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @var string|null + */ + protected $bic; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->country_code = isset($data['country_code']) ? $data['country_code'] : null; + $this->bic = isset($data['bic']) ? $data['bic'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the full name representation like Mr J Smith + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets country_code. + * + * @return string|null + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Sets country_code. + * + * @param string|null $country_code The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.@
sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted@
sign exists.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setCountryCode($country_code = null) + { + $this->country_code = $country_code; + + return $this; + } + + /** + * Gets bic. + * + * @return string|null + */ + public function getBic() + { + return $this->bic; + } + + /** + * Sets bic. + * + * @param string|null $bic The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @return $this + */ + public function setBic($bic = null) + { + $this->bic = $bic; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/EpsRequest.php b/src/PayPal/Order/DTO/EpsRequest.php new file mode 100644 index 000000000..2d47fc765 --- /dev/null +++ b/src/PayPal/Order/DTO/EpsRequest.php @@ -0,0 +1,91 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class EpsRequest +{ + /** + * @var string + */ + private $name; + /** + * @var string + */ + private $country_code; + /** + * @var ExperienceContextRequest + */ + private $experience_context; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * @param string $country_code + * + * @return void + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + } + + /** + * @return ExperienceContextRequest + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param ExperienceContextRequest $experience_context + * + * @return void + */ + public function setExperienceContext(ExperienceContextRequest $experience_context) + { + $this->experience_context = $experience_context; + } +} diff --git a/src/PayPal/Order/DTO/ExchangeRate.php b/src/PayPal/Order/DTO/ExchangeRate.php new file mode 100644 index 000000000..974a5062e --- /dev/null +++ b/src/PayPal/Order/DTO/ExchangeRate.php @@ -0,0 +1,129 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class ExchangeRate +{ + /** + * The [three-character ISO-4217 currency code](/api/rest/reference/currency-codes/) that identifies the currency. + * + * @var string|null + */ + protected $source_currency; + + /** + * The [three-character ISO-4217 currency code](/api/rest/reference/currency-codes/) that identifies the currency. + * + * @var string|null + */ + protected $target_currency; + + /** + * The target currency amount. Equivalent to one unit of the source currency. Formatted as integer or decimal value with one to 15 digits to the right of the decimal point. + * + * @var string|null + */ + protected $value; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->source_currency = isset($data['source_currency']) ? $data['source_currency'] : null; + $this->target_currency = isset($data['target_currency']) ? $data['target_currency'] : null; + $this->value = isset($data['value']) ? $data['value'] : null; + } + + /** + * Gets source_currency. + * + * @return string|null + */ + public function getSourceCurrency() + { + return $this->source_currency; + } + + /** + * Sets source_currency. + * + * @param string|null $source_currency the [three-character ISO-4217 currency code](/api/rest/reference/currency-codes/) that identifies the currency + * + * @return $this + */ + public function setSourceCurrency($source_currency = null) + { + $this->source_currency = $source_currency; + + return $this; + } + + /** + * Gets target_currency. + * + * @return string|null + */ + public function getTargetCurrency() + { + return $this->target_currency; + } + + /** + * Sets target_currency. + * + * @param string|null $target_currency the [three-character ISO-4217 currency code](/api/rest/reference/currency-codes/) that identifies the currency + * + * @return $this + */ + public function setTargetCurrency($target_currency = null) + { + $this->target_currency = $target_currency; + + return $this; + } + + /** + * Gets value. + * + * @return string|null + */ + public function getValue() + { + return $this->value; + } + + /** + * Sets value. + * + * @param string|null $value The target currency amount. Equivalent to one unit of the source currency. Formatted as integer or decimal value with one to 15 digits to the right of the decimal point. + * + * @return $this + */ + public function setValue($value = null) + { + $this->value = $value; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/ExperienceContextRequest.php b/src/PayPal/Order/DTO/ExperienceContextRequest.php new file mode 100644 index 000000000..09b89e4c4 --- /dev/null +++ b/src/PayPal/Order/DTO/ExperienceContextRequest.php @@ -0,0 +1,135 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class ExperienceContextRequest +{ + /** + * @var string + */ + private $brand_name; + /** + * @var string + */ + private $locale; + /** + * @var string + */ + private $shipping_preference; + /** + * @var string + */ + private $return_url; + /** + * @var string + */ + private $cancel_url; + + /** + * @return string + */ + public function getBrandName() + { + return $this->brand_name; + } + + /** + * @param string $brand_name + * + * @return void + */ + public function setBrandName($brand_name) + { + $this->brand_name = $brand_name; + } + + /** + * @return string + */ + public function getLocale() + { + return $this->locale; + } + + /** + * @param string $locale + * + * @return void + */ + public function setLocale($locale) + { + $this->locale = $locale; + } + + /** + * @return string + */ + public function getShippingPreference() + { + return $this->shipping_preference; + } + + /** + * @param string $shipping_preference + * + * @return void + */ + public function setShippingPreference($shipping_preference) + { + $this->shipping_preference = $shipping_preference; + } + + /** + * @return string + */ + public function getReturnUrl() + { + return $this->return_url; + } + + /** + * @param string $return_url + * + * @return void + */ + public function setReturnUrl($return_url) + { + $this->return_url = $return_url; + } + + /** + * @return string + */ + public function getCancelUrl() + { + return $this->cancel_url; + } + + /** + * @param string $cancel_url + * + * @return void + */ + public function setCancelUrl($cancel_url) + { + $this->cancel_url = $cancel_url; + } +} diff --git a/src/PayPal/Order/DTO/Giropay.php b/src/PayPal/Order/DTO/Giropay.php new file mode 100644 index 000000000..cb8360172 --- /dev/null +++ b/src/PayPal/Order/DTO/Giropay.php @@ -0,0 +1,129 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Giropay +{ + /** + * The full name representation like Mr J Smith. + * + * @var string|null + */ + protected $name; + + /** + * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> + * + * @var string|null + */ + protected $country_code; + + /** + * The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @var string|null + */ + protected $bic; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->country_code = isset($data['country_code']) ? $data['country_code'] : null; + $this->bic = isset($data['bic']) ? $data['bic'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the full name representation like Mr J Smith + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets country_code. + * + * @return string|null + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Sets country_code. + * + * @param string|null $country_code The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setCountryCode($country_code = null) + { + $this->country_code = $country_code; + + return $this; + } + + /** + * Gets bic. + * + * @return string|null + */ + public function getBic() + { + return $this->bic; + } + + /** + * Sets bic. + * + * @param string|null $bic The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @return $this + */ + public function setBic($bic = null) + { + $this->bic = $bic; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/GiropayRequest.php b/src/PayPal/Order/DTO/GiropayRequest.php new file mode 100644 index 000000000..b85255465 --- /dev/null +++ b/src/PayPal/Order/DTO/GiropayRequest.php @@ -0,0 +1,91 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class GiropayRequest +{ + /** + * @var string + */ + private $name; + /** + * @var string + */ + private $country_code; + /** + * @var ExperienceContextRequest + */ + private $experience_context; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * @param string $country_code + * + * @return void + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + } + + /** + * @return ExperienceContextRequest + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param ExperienceContextRequest $experience_context + * + * @return void + */ + public function setExperienceContext(ExperienceContextRequest $experience_context) + { + $this->experience_context = $experience_context; + } +} diff --git a/src/PayPal/Order/DTO/GooglePayRequest.php b/src/PayPal/Order/DTO/GooglePayRequest.php new file mode 100644 index 000000000..357468971 --- /dev/null +++ b/src/PayPal/Order/DTO/GooglePayRequest.php @@ -0,0 +1,113 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class GooglePayRequest +{ + /** + * @var string + */ + private $name; + /** + * @var string + */ + private $email_address; + /** + * @var Phone + */ + private $phone_number; + /** + * @var CardAttributesRequest + */ + private $attributes; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getEmailAddress() + { + return $this->email_address; + } + + /** + * @param string $email_address + * + * @return void + */ + public function setEmailAddress($email_address) + { + $this->email_address = $email_address; + } + + /** + * @return Phone + */ + public function getPhoneNumber() + { + return $this->phone_number; + } + + /** + * @param Phone $phone_number + * + * @return void + */ + public function setPhoneNumber(Phone $phone_number) + { + $this->phone_number = $phone_number; + } + + /** + * @return CardAttributesRequest + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param CardAttributesRequest $attributes + * + * @return void + */ + public function setAttributes(CardAttributesRequest $attributes) + { + $this->attributes = $attributes; + } +} diff --git a/src/PayPal/Order/DTO/Ideal.php b/src/PayPal/Order/DTO/Ideal.php new file mode 100644 index 000000000..d0fb51824 --- /dev/null +++ b/src/PayPal/Order/DTO/Ideal.php @@ -0,0 +1,191 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Ideal +{ + /** + * The full name representation like Mr J Smith. + * + * @var string|null + */ + protected $name; + + /** + * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> + * + * @var string|null + */ + protected $country_code; + + /** + * The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @var string|null + */ + protected $bic; + + /** + * The last characters of the IBAN used to pay. + * + * @var string|null + */ + protected $iban_last_chars; + + /** + * @var mixed|null + */ + protected $attributes; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->country_code = isset($data['country_code']) ? $data['country_code'] : null; + $this->bic = isset($data['bic']) ? $data['bic'] : null; + $this->iban_last_chars = isset($data['iban_last_chars']) ? $data['iban_last_chars'] : null; + $this->attributes = isset($data['attributes']) ? $data['attributes'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the full name representation like Mr J Smith + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets country_code. + * + * @return string|null + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Sets country_code. + * + * @param string|null $country_code The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setCountryCode($country_code = null) + { + $this->country_code = $country_code; + + return $this; + } + + /** + * Gets bic. + * + * @return string|null + */ + public function getBic() + { + return $this->bic; + } + + /** + * Sets bic. + * + * @param string|null $bic The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @return $this + */ + public function setBic($bic = null) + { + $this->bic = $bic; + + return $this; + } + + /** + * Gets iban_last_chars. + * + * @return string|null + */ + public function getIbanLastChars() + { + return $this->iban_last_chars; + } + + /** + * Sets iban_last_chars. + * + * @param string|null $iban_last_chars the last characters of the IBAN used to pay + * + * @return $this + */ + public function setIbanLastChars($iban_last_chars = null) + { + $this->iban_last_chars = $iban_last_chars; + + return $this; + } + + /** + * Gets attributes. + * + * @return mixed|null + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Sets attributes. + * + * @param mixed|null $attributes + * + * @return $this + */ + public function setAttributes($attributes = null) + { + $this->attributes = $attributes; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/IdealRequest.php b/src/PayPal/Order/DTO/IdealRequest.php new file mode 100644 index 000000000..ad7bea777 --- /dev/null +++ b/src/PayPal/Order/DTO/IdealRequest.php @@ -0,0 +1,113 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class IdealRequest +{ + /** + * @var string + */ + private $name; + /** + * @var string + */ + private $country_code; + /** + * @var string + */ + private $bic; + /** + * @var ExperienceContextRequest + */ + private $experience_context; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * @param string $country_code + * + * @return void + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + } + + /** + * @return string + */ + public function getBic() + { + return $this->bic; + } + + /** + * @param string $bic + * + * @return void + */ + public function setBic($bic) + { + $this->bic = $bic; + } + + /** + * @return ExperienceContextRequest + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param ExperienceContextRequest $experience_context + * + * @return void + */ + public function setExperienceContext(ExperienceContextRequest $experience_context) + { + $this->experience_context = $experience_context; + } +} diff --git a/src/PayPal/Order/DTO/Item.php b/src/PayPal/Order/DTO/Item.php new file mode 100644 index 000000000..a0a916697 --- /dev/null +++ b/src/PayPal/Order/DTO/Item.php @@ -0,0 +1,253 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Item +{ + /** + * The item name or title. + * + * @var string + */ + protected $name; + + /** + * @var Amount + */ + protected $unit_amount; + + /** + * The item quantity. Must be a whole number. + * + * @var string + */ + protected $quantity; + + /** + * @var Amount|null + */ + protected $tax; + + /** + * The detailed item description. + * + * @var string|null + */ + protected $description; + + /** + * The stock keeping unit (SKU) for the item. + * + * @var string|null + */ + protected $sku; + + /** + * The item category type. + * + * @var string|null + */ + protected $category; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->unit_amount = isset($data['unit_amount']) ? $data['unit_amount'] : null; + $this->quantity = isset($data['quantity']) ? $data['quantity'] : null; + $this->tax = isset($data['tax']) ? $data['tax'] : null; + $this->description = isset($data['description']) ? $data['description'] : null; + $this->sku = isset($data['sku']) ? $data['sku'] : null; + $this->category = isset($data['category']) ? $data['category'] : null; + } + + /** + * Gets name. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string $name the item name or title + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Gets unit_amount. + * + * @return Amount + */ + public function getUnitAmount() + { + return $this->unit_amount; + } + + /** + * Sets unit_amount. + * + * @param Amount $unit_amount + * + * @return $this + */ + public function setUnitAmount(Amount $unit_amount) + { + $this->unit_amount = $unit_amount; + + return $this; + } + + /** + * Gets quantity. + * + * @return string + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * Sets quantity. + * + * @param string $quantity The item quantity. Must be a whole number. + * + * @return $this + */ + public function setQuantity($quantity) + { + $this->quantity = $quantity; + + return $this; + } + + /** + * Gets tax. + * + * @return Amount|null + */ + public function getTax() + { + return $this->tax; + } + + /** + * Sets tax. + * + * @param Amount|null $tax + * + * @return $this + */ + public function setTax(Amount $tax = null) + { + $this->tax = $tax; + + return $this; + } + + /** + * Gets description. + * + * @return string|null + */ + public function getDescription() + { + return $this->description; + } + + /** + * Sets description. + * + * @param string|null $description the detailed item description + * + * @return $this + */ + public function setDescription($description = null) + { + $this->description = $description; + + return $this; + } + + /** + * Gets sku. + * + * @return string|null + */ + public function getSku() + { + return $this->sku; + } + + /** + * Sets sku. + * + * @param string|null $sku the stock keeping unit (SKU) for the item + * + * @return $this + */ + public function setSku($sku = null) + { + $this->sku = $sku; + + return $this; + } + + /** + * Gets category. + * + * @return string|null + */ + public function getCategory() + { + return $this->category; + } + + /** + * Sets category. + * + * @param string|null $category the item category type + * + * @return $this + */ + public function setCategory($category = null) + { + $this->category = $category; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/ItemRequest.php b/src/PayPal/Order/DTO/ItemRequest.php new file mode 100644 index 000000000..fe50e7ded --- /dev/null +++ b/src/PayPal/Order/DTO/ItemRequest.php @@ -0,0 +1,179 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class ItemRequest +{ + /** + * @var string + */ + private $name; + /** + * @var Amount + */ + private $unit_amount; + /** + * @var Amount + */ + private $tax; + /** + * @var string + */ + private $quantity; + /** + * @var string + */ + private $description; + /** + * @var string + */ + private $sku; + /** + * @var string + */ + private $category; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return Amount + */ + public function getUnitAmount() + { + return $this->unit_amount; + } + + /** + * @param Amount $unit_amount + * + * @return void + */ + public function setUnitAmount(Amount $unit_amount) + { + $this->unit_amount = $unit_amount; + } + + /** + * @return Amount + */ + public function getTax() + { + return $this->tax; + } + + /** + * @param Amount $tax + * + * @return void + */ + public function setTax(Amount $tax) + { + $this->tax = $tax; + } + + /** + * @return string + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * @param string $quantity + * + * @return void + */ + public function setQuantity($quantity) + { + $this->quantity = $quantity; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + * + * @return void + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string + */ + public function getSku() + { + return $this->sku; + } + + /** + * @param string $sku + * + * @return void + */ + public function setSku($sku) + { + $this->sku = $sku; + } + + /** + * @return string + */ + public function getCategory() + { + return $this->category; + } + + /** + * @param string $category + * + * @return void + */ + public function setCategory($category) + { + $this->category = $category; + } +} diff --git a/src/PayPal/Order/DTO/Level2CardProcessingData.php b/src/PayPal/Order/DTO/Level2CardProcessingData.php new file mode 100644 index 000000000..1e118207e --- /dev/null +++ b/src/PayPal/Order/DTO/Level2CardProcessingData.php @@ -0,0 +1,94 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Level2CardProcessingData +{ + /** + * Use this field to pass a purchase identification value of up to 12 ASCII characters for AIB and 17 ASCII characters for all other processors. + * + * @var string|null + */ + protected $invoice_id; + /** + * @var Amount|null + */ + protected $tax_total; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->invoice_id = isset($data['invoice_id']) ? $data['invoice_id'] : null; + $this->tax_total = isset($data['tax_total']) ? $data['tax_total'] : null; + } + + /** + * Gets invoice_id. + * + * @return string|null + */ + public function getInvoiceId() + { + return $this->invoice_id; + } + + /** + * Sets invoice_id. + * + * @param string|null $invoice_id use this field to pass a purchase identification value of up to 12 ASCII characters for AIB and 17 ASCII characters for all other processors + * + * @return $this + */ + public function setInvoiceId($invoice_id = null) + { + $this->invoice_id = $invoice_id; + + return $this; + } + + /** + * Gets tax_total. + * + * @return Amount|null + */ + public function getTaxTotal() + { + return $this->tax_total; + } + + /** + * Sets tax_total. + * + * @param Amount|null $tax_total + * + * @return $this + */ + public function setTaxTotal(Amount $tax_total = null) + { + $this->tax_total = $tax_total; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/Level2CardProcessingDataRequest.php b/src/PayPal/Order/DTO/Level2CardProcessingDataRequest.php new file mode 100644 index 000000000..755d53217 --- /dev/null +++ b/src/PayPal/Order/DTO/Level2CardProcessingDataRequest.php @@ -0,0 +1,69 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Level2CardProcessingDataRequest +{ + /** + * @var string + */ + private $invoice_id; + /** + * @var Amount + */ + private $tax_total; + + /** + * @return string + */ + public function getInvoiceId() + { + return $this->invoice_id; + } + + /** + * @param string $invoice_id + * + * @return void + */ + public function setInvoiceId($invoice_id) + { + $this->invoice_id = $invoice_id; + } + + /** + * @return Amount + */ + public function getTaxTotal() + { + return $this->tax_total; + } + + /** + * @param Amount $tax_total + * + * @return void + */ + public function setTaxTotal(Amount $tax_total) + { + $this->tax_total = $tax_total; + } +} diff --git a/src/PayPal/Order/DTO/Level3CardProcessingData.php b/src/PayPal/Order/DTO/Level3CardProcessingData.php new file mode 100644 index 000000000..d06cd9ed7 --- /dev/null +++ b/src/PayPal/Order/DTO/Level3CardProcessingData.php @@ -0,0 +1,212 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Level3CardProcessingData +{ + /** + * @var Amount|null + */ + protected $shipping_amount; + /** + * @var Amount|null + */ + protected $duty_amount; + /** + * @var Amount|null + */ + protected $discount_amount; + /** + * @var AddressRequest|null + */ + protected $shipping_address; + /** + * Use this field to specify the postal code of the shipping location. + * + * @var string|null + */ + protected $ships_from_postal_code; + /** + * A list of the items that were purchased with this payment. If your merchant account has been configured for Level 3 processing this field will be passed to the processor on your behalf. + * + * @var LineItem[]|null + */ + protected $line_items; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->shipping_amount = isset($data['shipping_amount']) ? $data['shipping_amount'] : null; + $this->duty_amount = isset($data['duty_amount']) ? $data['duty_amount'] : null; + $this->discount_amount = isset($data['discount_amount']) ? $data['discount_amount'] : null; + $this->shipping_address = isset($data['shipping_address']) ? $data['shipping_address'] : null; + $this->ships_from_postal_code = isset($data['ships_from_postal_code']) ? $data['ships_from_postal_code'] : null; + $this->line_items = isset($data['line_items']) ? $data['line_items'] : null; + } + + /** + * Gets shipping_amount. + * + * @return Amount|null + */ + public function getShippingAmount() + { + return $this->shipping_amount; + } + + /** + * Sets shipping_amount. + * + * @param Amount|null $shipping_amount + * + * @return $this + */ + public function setShippingAmount(Amount $shipping_amount = null) + { + $this->shipping_amount = $shipping_amount; + + return $this; + } + + /** + * Gets duty_amount. + * + * @return Amount|null + */ + public function getDutyAmount() + { + return $this->duty_amount; + } + + /** + * Sets duty_amount. + * + * @param Amount|null $duty_amount + * + * @return $this + */ + public function setDutyAmount(Amount $duty_amount = null) + { + $this->duty_amount = $duty_amount; + + return $this; + } + + /** + * Gets discount_amount. + * + * @return Amount|null + */ + public function getDiscountAmount() + { + return $this->discount_amount; + } + + /** + * Sets discount_amount. + * + * @param Amount|null $discount_amount + * + * @return $this + */ + public function setDiscountAmount(Amount $discount_amount = null) + { + $this->discount_amount = $discount_amount; + + return $this; + } + + /** + * Gets shipping_address. + * + * @return AddressRequest|null + */ + public function getShippingAddress() + { + return $this->shipping_address; + } + + /** + * Sets shipping_address. + * + * @param AddressRequest|null $shipping_address + * + * @return $this + */ + public function setShippingAddress(AddressRequest $shipping_address = null) + { + $this->shipping_address = $shipping_address; + + return $this; + } + + /** + * Gets ships_from_postal_code. + * + * @return string|null + */ + public function getShipsFromPostalCode() + { + return $this->ships_from_postal_code; + } + + /** + * Sets ships_from_postal_code. + * + * @param string|null $ships_from_postal_code use this field to specify the postal code of the shipping location + * + * @return $this + */ + public function setShipsFromPostalCode($ships_from_postal_code = null) + { + $this->ships_from_postal_code = $ships_from_postal_code; + + return $this; + } + + /** + * Gets line_items. + * + * @return LineItem[]|null + */ + public function getLineItems() + { + return $this->line_items; + } + + /** + * Sets line_items. + * + * @param LineItem[]|null $line_items A list of the items that were purchased with this payment. If your merchant account has been configured for Level 3 processing this field will be passed to the processor on your behalf. + * + * @return $this + */ + public function setLineItems(array $line_items = null) + { + $this->line_items = $line_items; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/Level3CardProcessingDataRequest.php b/src/PayPal/Order/DTO/Level3CardProcessingDataRequest.php new file mode 100644 index 000000000..606cfe58d --- /dev/null +++ b/src/PayPal/Order/DTO/Level3CardProcessingDataRequest.php @@ -0,0 +1,157 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Level3CardProcessingDataRequest +{ + /** + * @var Amount + */ + private $shipping_amount; + /** + * @var Amount + */ + private $duty_amount; + /** + * @var Amount + */ + private $discount_amount; + /** + * @var AddressRequest + */ + private $shipping_address; + /** + * @var string + */ + private $ships_from_postal_code; + /** + * @var LineItemRequest[] + */ + private $line_items; + + /** + * @return Amount + */ + public function getShippingAmount() + { + return $this->shipping_amount; + } + + /** + * @param Amount $shipping_amount + * + * @return void + */ + public function setShippingAmount(Amount $shipping_amount) + { + $this->shipping_amount = $shipping_amount; + } + + /** + * @return Amount + */ + public function getDutyAmount() + { + return $this->duty_amount; + } + + /** + * @param Amount $duty_amount + * + * @return void + */ + public function setDutyAmount(Amount $duty_amount) + { + $this->duty_amount = $duty_amount; + } + + /** + * @return Amount + */ + public function getDiscountAmount() + { + return $this->discount_amount; + } + + /** + * @param Amount $discount_amount + * + * @return void + */ + public function setDiscountAmount(Amount $discount_amount) + { + $this->discount_amount = $discount_amount; + } + + /** + * @return AddressRequest + */ + public function getShippingAddress() + { + return $this->shipping_address; + } + + /** + * @param AddressRequest $shipping_address + * + * @return void + */ + public function setShippingAddress(AddressRequest $shipping_address) + { + $this->shipping_address = $shipping_address; + } + + /** + * @return string + */ + public function getShipsFromPostalCode() + { + return $this->ships_from_postal_code; + } + + /** + * @param string $ships_from_postal_code + * + * @return void + */ + public function setShipsFromPostalCode($ships_from_postal_code) + { + $this->ships_from_postal_code = $ships_from_postal_code; + } + + /** + * @return LineItemRequest[] + */ + public function getLineItems() + { + return $this->line_items; + } + + /** + * @param LineItemRequest[] $line_items + * + * @return void + */ + public function setLineItems(array $line_items) + { + $this->line_items = $line_items; + } +} diff --git a/src/PayPal/Order/DTO/LineItem.php b/src/PayPal/Order/DTO/LineItem.php new file mode 100644 index 000000000..bee9c0fbb --- /dev/null +++ b/src/PayPal/Order/DTO/LineItem.php @@ -0,0 +1,367 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class LineItem +{ + /** + * The item name or title. + * + * @var string + */ + protected $name; + /** + * @var Amount + */ + protected $unit_amount; + /** + * The item quantity. Must be a whole number. + * + * @var string + */ + protected $quantity; + /** + * @var Amount|null + */ + protected $tax; + /** + * The detailed item description. + * + * @var string|null + */ + protected $description; + /** + * The stock keeping unit (SKU) for the item. + * + * @var string|null + */ + protected $sku; + /** + * The item category type. + * + * @var string|null + */ + protected $category; + /** + * Code used to classify items purchased and track the total amount spent across various categories of products and services. Different corporate purchasing organizations may use different standards, but the United Nations Standard Products and Services Code (UNSPSC) is frequently used. + * + * @var string|null + */ + protected $commodity_code; + /** + * @var Amount|null + */ + protected $discount_amount; + /** + * @var Amount|null + */ + protected $total_amount; + /** + * Unit of measure is a standard used to express the magnitude of a quantity in international trade. Most commonly used (but not limited to) examples are: Acre (ACR), Ampere (AMP), Centigram (CGM), Centimetre (CMT), Cubic inch (INQ), Cubic metre (MTQ), Fluid ounce (OZA), Foot (FOT), Hour (HUR), Item (ITM), Kilogram (KGM), Kilometre (KMT), Kilowatt (KWT), Liquid gallon (GLL), Liter (LTR), Pounds (LBS), Square foot (FTK). + * + * @var string|null + */ + protected $unit_of_measure; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->unit_amount = isset($data['unit_amount']) ? $data['unit_amount'] : null; + $this->quantity = isset($data['quantity']) ? $data['quantity'] : null; + $this->tax = isset($data['tax']) ? $data['tax'] : null; + $this->description = isset($data['description']) ? $data['description'] : null; + $this->sku = isset($data['sku']) ? $data['sku'] : null; + $this->category = isset($data['category']) ? $data['category'] : null; + $this->commodity_code = isset($data['commodity_code']) ? $data['commodity_code'] : null; + $this->discount_amount = isset($data['discount_amount']) ? $data['discount_amount'] : null; + $this->total_amount = isset($data['total_amount']) ? $data['total_amount'] : null; + $this->unit_of_measure = isset($data['unit_of_measure']) ? $data['unit_of_measure'] : null; + } + + /** + * Gets name. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string $name the item name or title + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Gets unit_amount. + * + * @return Amount + */ + public function getUnitAmount() + { + return $this->unit_amount; + } + + /** + * Sets unit_amount. + * + * @param Amount $unit_amount + * + * @return $this + */ + public function setUnitAmount(Amount $unit_amount) + { + $this->unit_amount = $unit_amount; + + return $this; + } + + /** + * Gets quantity. + * + * @return string + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * Sets quantity. + * + * @param string $quantity The item quantity. Must be a whole number. + * + * @return $this + */ + public function setQuantity($quantity) + { + $this->quantity = $quantity; + + return $this; + } + + /** + * Gets tax. + * + * @return Amount|null + */ + public function getTax() + { + return $this->tax; + } + + /** + * Sets tax. + * + * @param Amount|null $tax + * + * @return $this + */ + public function setTax(Amount $tax = null) + { + $this->tax = $tax; + + return $this; + } + + /** + * Gets description. + * + * @return string|null + */ + public function getDescription() + { + return $this->description; + } + + /** + * Sets description. + * + * @param string|null $description the detailed item description + * + * @return $this + */ + public function setDescription($description = null) + { + $this->description = $description; + + return $this; + } + + /** + * Gets sku. + * + * @return string|null + */ + public function getSku() + { + return $this->sku; + } + + /** + * Sets sku. + * + * @param string|null $sku the stock keeping unit (SKU) for the item + * + * @return $this + */ + public function setSku($sku = null) + { + $this->sku = $sku; + + return $this; + } + + /** + * Gets category. + * + * @return string|null + */ + public function getCategory() + { + return $this->category; + } + + /** + * Sets category. + * + * @param string|null $category the item category type + * + * @return $this + */ + public function setCategory($category = null) + { + $this->category = $category; + + return $this; + } + + /** + * Gets commodity_code. + * + * @return string|null + */ + public function getCommodityCode() + { + return $this->commodity_code; + } + + /** + * Sets commodity_code. + * + * @param string|null $commodity_code Code used to classify items purchased and track the total amount spent across various categories of products and services. Different corporate purchasing organizations may use different standards, but the United Nations Standard Products and Services Code (UNSPSC) is frequently used. + * + * @return $this + */ + public function setCommodityCode($commodity_code = null) + { + $this->commodity_code = $commodity_code; + + return $this; + } + + /** + * Gets discount_amount. + * + * @return Amount|null + */ + public function getDiscountAmount() + { + return $this->discount_amount; + } + + /** + * Sets discount_amount. + * + * @param Amount|null $discount_amount + * + * @return $this + */ + public function setDiscountAmount(Amount $discount_amount = null) + { + $this->discount_amount = $discount_amount; + + return $this; + } + + /** + * Gets total_amount. + * + * @return Amount|null + */ + public function getTotalAmount() + { + return $this->total_amount; + } + + /** + * Sets total_amount. + * + * @param Amount|null $total_amount + * + * @return $this + */ + public function setTotalAmount(Amount $total_amount = null) + { + $this->total_amount = $total_amount; + + return $this; + } + + /** + * Gets unit_of_measure. + * + * @return string|null + */ + public function getUnitOfMeasure() + { + return $this->unit_of_measure; + } + + /** + * Sets unit_of_measure. + * + * @param string|null $unit_of_measure Unit of measure is a standard used to express the magnitude of a quantity in international trade. Most commonly used (but not limited to) examples are: Acre (ACR), Ampere (AMP), Centigram (CGM), Centimetre (CMT), Cubic inch (INQ), Cubic metre (MTQ), Fluid ounce (OZA), Foot (FOT), Hour (HUR), Item (ITM), Kilogram (KGM), Kilometre (KMT), Kilowatt (KWT), Liquid gallon (GLL), Liter (LTR), Pounds (LBS), Square foot (FTK). + * + * @return $this + */ + public function setUnitOfMeasure($unit_of_measure = null) + { + $this->unit_of_measure = $unit_of_measure; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/LineItemRequest.php b/src/PayPal/Order/DTO/LineItemRequest.php new file mode 100644 index 000000000..dec30d352 --- /dev/null +++ b/src/PayPal/Order/DTO/LineItemRequest.php @@ -0,0 +1,267 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class LineItemRequest +{ + /** + * @var string + */ + private $name; + /** + * @var Amount + */ + private $unit_amount; + /** + * @var Amount + */ + private $tax; + /** + * @var string + */ + private $quantity; + /** + * @var string + */ + private $description; + /** + * @var string + */ + private $sku; + /** + * @var string + */ + private $category; + /** + * @var string + */ + private $commodity_code; + /** + * @var Amount + */ + private $discount_amount; + /** + * @var Amount + */ + private $total_amount; + /** + * @var string + */ + private $unit_of_measure; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return Amount + */ + public function getUnitAmount() + { + return $this->unit_amount; + } + + /** + * @param Amount $unit_amount + * + * @return void + */ + public function setUnitAmount(Amount $unit_amount) + { + $this->unit_amount = $unit_amount; + } + + /** + * @return Amount + */ + public function getTax() + { + return $this->tax; + } + + /** + * @param Amount $tax + * + * @return void + */ + public function setTax(Amount $tax) + { + $this->tax = $tax; + } + + /** + * @return string + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * @param string $quantity + * + * @return void + */ + public function setQuantity($quantity) + { + $this->quantity = $quantity; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + * + * @return void + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string + */ + public function getSku() + { + return $this->sku; + } + + /** + * @param string $sku + * + * @return void + */ + public function setSku($sku) + { + $this->sku = $sku; + } + + /** + * @return string + */ + public function getCategory() + { + return $this->category; + } + + /** + * @param string $category + * + * @return void + */ + public function setCategory($category) + { + $this->category = $category; + } + + /** + * @return string + */ + public function getCommodityCode() + { + return $this->commodity_code; + } + + /** + * @param string $commodity_code + * + * @return void + */ + public function setCommodityCode($commodity_code) + { + $this->commodity_code = $commodity_code; + } + + /** + * @return Amount + */ + public function getDiscountAmount() + { + return $this->discount_amount; + } + + /** + * @param Amount $discount_amount + * + * @return void + */ + public function setDiscountAmount(Amount $discount_amount) + { + $this->discount_amount = $discount_amount; + } + + /** + * @return Amount + */ + public function getTotalAmount() + { + return $this->total_amount; + } + + /** + * @param Amount $total_amount + * + * @return void + */ + public function setTotalAmount(Amount $total_amount) + { + $this->total_amount = $total_amount; + } + + /** + * @return string + */ + public function getUnitOfMeasure() + { + return $this->unit_of_measure; + } + + /** + * @param string $unit_of_measure + * + * @return void + */ + public function setUnitOfMeasure($unit_of_measure) + { + $this->unit_of_measure = $unit_of_measure; + } +} diff --git a/src/PayPal/Order/DTO/LinkDescription.php b/src/PayPal/Order/DTO/LinkDescription.php new file mode 100644 index 000000000..656785bac --- /dev/null +++ b/src/PayPal/Order/DTO/LinkDescription.php @@ -0,0 +1,129 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class LinkDescription +{ + /** + * The complete target URL. To make the related call, combine the method with this [URI Template-formatted](https://tools.ietf.org/html/rfc6570) link. For pre-processing, include the `$`, `(`, and `)` characters. The `href` is the key HATEOAS component that links a completed call with a subsequent call. + * + * @var string + */ + protected $href; + + /** + * The [link relation type](https://tools.ietf.org/html/rfc5988#section-4), which serves as an ID for a link that unambiguously describes the semantics of the link. See [Link Relations](https://www.iana.org/assignments/link-relations/link-relations.xhtml). + * + * @var string + */ + protected $rel; + + /** + * The HTTP method required to make the related call. + * + * @var string|null + */ + protected $method; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->href = isset($data['href']) ? $data['href'] : null; + $this->rel = isset($data['rel']) ? $data['rel'] : null; + $this->method = isset($data['method']) ? $data['method'] : null; + } + + /** + * Gets href. + * + * @return string + */ + public function getHref() + { + return $this->href; + } + + /** + * Sets href. + * + * @param string $href The complete target URL. To make the related call, combine the method with this [URI Template-formatted](https://tools.ietf.org/html/rfc6570) link. For pre-processing, include the `$`, `(`, and `)` characters. The `href` is the key HATEOAS component that links a completed call with a subsequent call. + * + * @return $this + */ + public function setHref($href) + { + $this->href = $href; + + return $this; + } + + /** + * Gets rel. + * + * @return string + */ + public function getRel() + { + return $this->rel; + } + + /** + * Sets rel. + * + * @param string $rel The [link relation type](https://tools.ietf.org/html/rfc5988#section-4), which serves as an ID for a link that unambiguously describes the semantics of the link. See [Link Relations](https://www.iana.org/assignments/link-relations/link-relations.xhtml). + * + * @return $this + */ + public function setRel($rel) + { + $this->rel = $rel; + + return $this; + } + + /** + * Gets method. + * + * @return string|null + */ + public function getMethod() + { + return $this->method; + } + + /** + * Sets method. + * + * @param string|null $method the HTTP method required to make the related call + * + * @return $this + */ + public function setMethod($method = null) + { + $this->method = $method; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/MerchantPayableBreakdown.php b/src/PayPal/Order/DTO/MerchantPayableBreakdown.php new file mode 100644 index 000000000..cfdd794df --- /dev/null +++ b/src/PayPal/Order/DTO/MerchantPayableBreakdown.php @@ -0,0 +1,277 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class MerchantPayableBreakdown +{ + /** + * @var Amount|null + */ + protected $gross_amount; + + /** + * @var Amount|null + */ + protected $paypal_fee; + + /** + * @var Amount|null + */ + protected $paypal_fee_in_receivable_currency; + + /** + * @var Amount|null + */ + protected $net_amount; + + /** + * @var Amount|null + */ + protected $net_amount_in_receivable_currency; + + /** + * An array of platform or partner fees, commissions, or brokerage fees for the refund. + * + * @var PlatformFee[]|null + */ + protected $platform_fees; + + /** + * An array of breakdown values for the net amount. Returned when the currency of the refund is different from the currency of the PayPal account where the payee holds their funds. + * + * @var NetAmountBreakdownItem[]|null + */ + protected $net_amount_breakdown; + + /** + * @var Amount|null + */ + protected $total_refunded_amount; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->gross_amount = isset($data['gross_amount']) ? $data['gross_amount'] : null; + $this->paypal_fee = isset($data['paypal_fee']) ? $data['paypal_fee'] : null; + $this->paypal_fee_in_receivable_currency = isset($data['paypal_fee_in_receivable_currency']) ? $data['paypal_fee_in_receivable_currency'] : null; + $this->net_amount = isset($data['net_amount']) ? $data['net_amount'] : null; + $this->net_amount_in_receivable_currency = isset($data['net_amount_in_receivable_currency']) ? $data['net_amount_in_receivable_currency'] : null; + $this->platform_fees = isset($data['platform_fees']) ? $data['platform_fees'] : null; + $this->net_amount_breakdown = isset($data['net_amount_breakdown']) ? $data['net_amount_breakdown'] : null; + $this->total_refunded_amount = isset($data['total_refunded_amount']) ? $data['total_refunded_amount'] : null; + } + + /** + * Gets gross_amount. + * + * @return Amount|null + */ + public function getGrossAmount() + { + return $this->gross_amount; + } + + /** + * Sets gross_amount. + * + * @param Amount|null $gross_amount + * + * @return $this + */ + public function setGrossAmount(Amount $gross_amount = null) + { + $this->gross_amount = $gross_amount; + + return $this; + } + + /** + * Gets paypal_fee. + * + * @return Amount|null + */ + public function getPaypalFee() + { + return $this->paypal_fee; + } + + /** + * Sets paypal_fee. + * + * @param Amount|null $paypal_fee + * + * @return $this + */ + public function setPaypalFee(Amount $paypal_fee = null) + { + $this->paypal_fee = $paypal_fee; + + return $this; + } + + /** + * Gets paypal_fee_in_receivable_currency. + * + * @return Amount|null + */ + public function getPaypalFeeInReceivableCurrency() + { + return $this->paypal_fee_in_receivable_currency; + } + + /** + * Sets paypal_fee_in_receivable_currency. + * + * @param Amount|null $paypal_fee_in_receivable_currency + * + * @return $this + */ + public function setPaypalFeeInReceivableCurrency(Amount $paypal_fee_in_receivable_currency = null) + { + $this->paypal_fee_in_receivable_currency = $paypal_fee_in_receivable_currency; + + return $this; + } + + /** + * Gets net_amount. + * + * @return Amount|null + */ + public function getNetAmount() + { + return $this->net_amount; + } + + /** + * Sets net_amount. + * + * @param Amount|null $net_amount + * + * @return $this + */ + public function setNetAmount(Amount $net_amount = null) + { + $this->net_amount = $net_amount; + + return $this; + } + + /** + * Gets net_amount_in_receivable_currency. + * + * @return Amount|null + */ + public function getNetAmountInReceivableCurrency() + { + return $this->net_amount_in_receivable_currency; + } + + /** + * Sets net_amount_in_receivable_currency. + * + * @param Amount|null $net_amount_in_receivable_currency + * + * @return $this + */ + public function setNetAmountInReceivableCurrency(Amount $net_amount_in_receivable_currency = null) + { + $this->net_amount_in_receivable_currency = $net_amount_in_receivable_currency; + + return $this; + } + + /** + * Gets platform_fees. + * + * @return PlatformFee[]|null + */ + public function getPlatformFees() + { + return $this->platform_fees; + } + + /** + * Sets platform_fees. + * + * @param PlatformFee[]|null $platform_fees an array of platform or partner fees, commissions, or brokerage fees for the refund + * + * @return $this + */ + public function setPlatformFees(array $platform_fees = null) + { + $this->platform_fees = $platform_fees; + + return $this; + } + + /** + * Gets net_amount_breakdown. + * + * @return NetAmountBreakdownItem[]|null + */ + public function getNetAmountBreakdown() + { + return $this->net_amount_breakdown; + } + + /** + * Sets net_amount_breakdown. + * + * @param NetAmountBreakdownItem[]|null $net_amount_breakdown An array of breakdown values for the net amount. Returned when the currency of the refund is different from the currency of the PayPal account where the payee holds their funds. + * + * @return $this + */ + public function setNetAmountBreakdown(array $net_amount_breakdown = null) + { + $this->net_amount_breakdown = $net_amount_breakdown; + + return $this; + } + + /** + * Gets total_refunded_amount. + * + * @return Amount|null + */ + public function getTotalRefundedAmount() + { + return $this->total_refunded_amount; + } + + /** + * Sets total_refunded_amount. + * + * @param Amount|null $total_refunded_amount + * + * @return $this + */ + public function setTotalRefundedAmount(Amount $total_refunded_amount = null) + { + $this->total_refunded_amount = $total_refunded_amount; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/MyBankRequest.php b/src/PayPal/Order/DTO/MyBankRequest.php new file mode 100644 index 000000000..282d5a364 --- /dev/null +++ b/src/PayPal/Order/DTO/MyBankRequest.php @@ -0,0 +1,91 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class MyBankRequest +{ + /** + * @var string + */ + private $name; + /** + * @var string + */ + private $country_code; + /** + * @var ExperienceContextRequest + */ + private $experience_context; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * @param string $country_code + * + * @return void + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + } + + /** + * @return ExperienceContextRequest + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param ExperienceContextRequest $experience_context + * + * @return void + */ + public function setExperienceContext(ExperienceContextRequest $experience_context) + { + $this->experience_context = $experience_context; + } +} diff --git a/src/PayPal/Order/DTO/Mybank.php b/src/PayPal/Order/DTO/Mybank.php new file mode 100644 index 000000000..f79946321 --- /dev/null +++ b/src/PayPal/Order/DTO/Mybank.php @@ -0,0 +1,161 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Mybank +{ + /** + * The full name representation like Mr J Smith. + * + * @var string|null + */ + protected $name; + + /** + * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> + * + * @var string|null + */ + protected $country_code; + + /** + * The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @var string|null + */ + protected $bic; + + /** + * The last characters of the IBAN used to pay. + * + * @var string|null + */ + protected $iban_last_chars; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->country_code = isset($data['country_code']) ? $data['country_code'] : null; + $this->bic = isset($data['bic']) ? $data['bic'] : null; + $this->iban_last_chars = isset($data['iban_last_chars']) ? $data['iban_last_chars'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the full name representation like Mr J Smith + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets country_code. + * + * @return string|null + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Sets country_code. + * + * @param string|null $country_code The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setCountryCode($country_code = null) + { + $this->country_code = $country_code; + + return $this; + } + + /** + * Gets bic. + * + * @return string|null + */ + public function getBic() + { + return $this->bic; + } + + /** + * Sets bic. + * + * @param string|null $bic The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @return $this + */ + public function setBic($bic = null) + { + $this->bic = $bic; + + return $this; + } + + /** + * Gets iban_last_chars. + * + * @return string|null + */ + public function getIbanLastChars() + { + return $this->iban_last_chars; + } + + /** + * Sets iban_last_chars. + * + * @param string|null $iban_last_chars the last characters of the IBAN used to pay + * + * @return $this + */ + public function setIbanLastChars($iban_last_chars = null) + { + $this->iban_last_chars = $iban_last_chars; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/Name.php b/src/PayPal/Order/DTO/Name.php new file mode 100644 index 000000000..2ef3b62c7 --- /dev/null +++ b/src/PayPal/Order/DTO/Name.php @@ -0,0 +1,179 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Name +{ + /** + * @var string + */ + private $prefix; + /** + * @var string + */ + private $given_name; + /** + * @var string + */ + private $surname; + /** + * @var string + */ + private $middle_name; + /** + * @var string + */ + private $suffix; + /** + * @var string + */ + private $alternate_full_name; + /** + * @var string + */ + private $full_name; + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @param string $prefix + * + * @return void + */ + public function setPrefix($prefix) + { + $this->prefix = $prefix; + } + + /** + * @return string + */ + public function getGivenName() + { + return $this->given_name; + } + + /** + * @param string $given_name + * + * @return void + */ + public function setGivenName($given_name) + { + $this->given_name = $given_name; + } + + /** + * @return string + */ + public function getSurname() + { + return $this->surname; + } + + /** + * @param string $surname + * + * @return void + */ + public function setSurname($surname) + { + $this->surname = $surname; + } + + /** + * @return string + */ + public function getMiddleName() + { + return $this->middle_name; + } + + /** + * @param string $middle_name + * + * @return void + */ + public function setMiddleName($middle_name) + { + $this->middle_name = $middle_name; + } + + /** + * @return string + */ + public function getSuffix() + { + return $this->suffix; + } + + /** + * @param string $suffix + * + * @return void + */ + public function setSuffix($suffix) + { + $this->suffix = $suffix; + } + + /** + * @return string + */ + public function getAlternateFullName() + { + return $this->alternate_full_name; + } + + /** + * @param string $alternate_full_name + * + * @return void + */ + public function setAlternateFullName($alternate_full_name) + { + $this->alternate_full_name = $alternate_full_name; + } + + /** + * @return string + */ + public function getFullName() + { + return $this->full_name; + } + + /** + * @param string $full_name + * + * @return void + */ + public function setFullName($full_name) + { + $this->full_name = $full_name; + } +} diff --git a/src/PayPal/Order/DTO/NetAmountBreakdownItem.php b/src/PayPal/Order/DTO/NetAmountBreakdownItem.php new file mode 100644 index 000000000..8914d5de1 --- /dev/null +++ b/src/PayPal/Order/DTO/NetAmountBreakdownItem.php @@ -0,0 +1,123 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class NetAmountBreakdownItem +{ + /** + * @var Amount|null + */ + protected $payable_amount; + + /** + * @var Amount|null + */ + protected $converted_amount; + + /** + * @var ExchangeRate|null + */ + protected $exchange_rate; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->payable_amount = isset($data['payable_amount']) ? $data['payable_amount'] : null; + $this->converted_amount = isset($data['converted_amount']) ? $data['converted_amount'] : null; + $this->exchange_rate = isset($data['exchange_rate']) ? $data['exchange_rate'] : null; + } + + /** + * Gets payable_amount. + * + * @return Amount|null + */ + public function getPayableAmount() + { + return $this->payable_amount; + } + + /** + * Sets payable_amount. + * + * @param Amount|null $payable_amount + * + * @return $this + */ + public function setPayableAmount(Amount $payable_amount = null) + { + $this->payable_amount = $payable_amount; + + return $this; + } + + /** + * Gets converted_amount. + * + * @return Amount|null + */ + public function getConvertedAmount() + { + return $this->converted_amount; + } + + /** + * Sets converted_amount. + * + * @param Amount|null $converted_amount + * + * @return $this + */ + public function setConvertedAmount(Amount $converted_amount = null) + { + $this->converted_amount = $converted_amount; + + return $this; + } + + /** + * Gets exchange_rate. + * + * @return ExchangeRate|null + */ + public function getExchangeRate() + { + return $this->exchange_rate; + } + + /** + * Sets exchange_rate. + * + * @param ExchangeRate|null $exchange_rate + * + * @return $this + */ + public function setExchangeRate(ExchangeRate $exchange_rate = null) + { + $this->exchange_rate = $exchange_rate; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/NetworkTransactionReference.php b/src/PayPal/Order/DTO/NetworkTransactionReference.php new file mode 100644 index 000000000..fd9301651 --- /dev/null +++ b/src/PayPal/Order/DTO/NetworkTransactionReference.php @@ -0,0 +1,159 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class NetworkTransactionReference +{ + /** + * Transaction reference id returned by the scheme. For Visa and Amex, this is the \"Tran id\" field in response. For MasterCard, this is the \"BankNet reference id\" field in response. For Discover, this is the \"NRID\" field in response. The pattern we expect for this field from Visa/Amex/CB/Discover is numeric, Mastercard/BNPP is alphanumeric and Paysecure is alphanumeric with special character -. + * + * @var string + */ + protected $id; + + /** + * The date that the transaction was authorized by the scheme. This field may not be returned for all networks. MasterCard refers to this field as \"BankNet reference date. + * + * @var string|null + */ + protected $date; + + /** + * @var string|null + */ + protected $network; + + /** + * Reference ID issued for the card transaction. This ID can be used to track the transaction across processors, card brands and issuing banks. + * + * @var string|null + */ + protected $acquirer_reference_number; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->id = isset($data['id']) ? $data['id'] : null; + $this->date = isset($data['date']) ? $data['date'] : null; + $this->network = isset($data['network']) ? $data['network'] : null; + $this->acquirer_reference_number = isset($data['acquirer_reference_number']) ? $data['acquirer_reference_number'] : null; + } + + /** + * Gets id. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param string $id Transaction reference id returned by the scheme. For Visa and Amex, this is the \"Tran id\" field in response. For MasterCard, this is the \"BankNet reference id\" field in response. For Discover, this is the \"NRID\" field in response. The pattern we expect for this field from Visa/Amex/CB/Discover is numeric, Mastercard/BNPP is alphanumeric and Paysecure is alphanumeric with special character -. + * + * @return $this + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Gets date. + * + * @return string|null + */ + public function getDate() + { + return $this->date; + } + + /** + * Sets date. + * + * @param string|null $date The date that the transaction was authorized by the scheme. This field may not be returned for all networks. MasterCard refers to this field as \"BankNet reference date. + * + * @return $this + */ + public function setDate($date = null) + { + $this->date = $date; + + return $this; + } + + /** + * Gets network. + * + * @return string|null + */ + public function getNetwork() + { + return $this->network; + } + + /** + * Sets network. + * + * @param string|null $network + * + * @return $this + */ + public function setNetwork($network = null) + { + $this->network = $network; + + return $this; + } + + /** + * Gets acquirer_reference_number. + * + * @return string|null + */ + public function getAcquirerReferenceNumber() + { + return $this->acquirer_reference_number; + } + + /** + * Sets acquirer_reference_number. + * + * @param string|null $acquirer_reference_number Reference ID issued for the card transaction. This ID can be used to track the transaction across processors, card brands and issuing banks. + * + * @return $this + */ + public function setAcquirerReferenceNumber($acquirer_reference_number = null) + { + $this->acquirer_reference_number = $acquirer_reference_number; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/P24.php b/src/PayPal/Order/DTO/P24.php new file mode 100644 index 000000000..4a1821a07 --- /dev/null +++ b/src/PayPal/Order/DTO/P24.php @@ -0,0 +1,225 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class P24 +{ + /** + * The full name representation like Mr J Smith. + * + * @var string|null + */ + protected $name; + + /** + * The internationalized email address.<blockquote><strong>Note:</strong> Up to 64 characters are allowed before and 255 characters are allowed after the <code>@</code> sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted <code>@</code> sign exists.</blockquote> + * + * @var string|null + */ + protected $email; + + /** + * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> + * + * @var string|null + */ + protected $country_code; + + /** + * P24 generated payment description. + * + * @var string|null + */ + protected $payment_descriptor; + + /** + * Numeric identifier of the payment scheme or bank used for the payment. + * + * @var string|null + */ + protected $method_id; + + /** + * Friendly name of the payment scheme or bank used for the payment. + * + * @var string|null + */ + protected $method_description; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->email = isset($data['email']) ? $data['email'] : null; + $this->country_code = isset($data['country_code']) ? $data['country_code'] : null; + $this->payment_descriptor = isset($data['payment_descriptor']) ? $data['payment_descriptor'] : null; + $this->method_id = isset($data['method_id']) ? $data['method_id'] : null; + $this->method_description = isset($data['method_description']) ? $data['method_description'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the full name representation like Mr J Smith + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets email. + * + * @return string|null + */ + public function getEmail() + { + return $this->email; + } + + /** + * Sets email. + * + * @param string|null $email The internationalized email address.GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: Up to 64 characters are allowed before and 255 characters are allowed after the+ * + * @return $this + */ + public function setEmail($email = null) + { + $this->email = $email; + + return $this; + } + + /** + * Gets country_code. + * + * @return string|null + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Sets country_code. + * + * @param string|null $country_code The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.@
sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted@
sign exists.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setCountryCode($country_code = null) + { + $this->country_code = $country_code; + + return $this; + } + + /** + * Gets payment_descriptor. + * + * @return string|null + */ + public function getPaymentDescriptor() + { + return $this->payment_descriptor; + } + + /** + * Sets payment_descriptor. + * + * @param string|null $payment_descriptor P24 generated payment description + * + * @return $this + */ + public function setPaymentDescriptor($payment_descriptor = null) + { + $this->payment_descriptor = $payment_descriptor; + + return $this; + } + + /** + * Gets method_id. + * + * @return string|null + */ + public function getMethodId() + { + return $this->method_id; + } + + /** + * Sets method_id. + * + * @param string|null $method_id numeric identifier of the payment scheme or bank used for the payment + * + * @return $this + */ + public function setMethodId($method_id = null) + { + $this->method_id = $method_id; + + return $this; + } + + /** + * Gets method_description. + * + * @return string|null + */ + public function getMethodDescription() + { + return $this->method_description; + } + + /** + * Sets method_description. + * + * @param string|null $method_description friendly name of the payment scheme or bank used for the payment + * + * @return $this + */ + public function setMethodDescription($method_description = null) + { + $this->method_description = $method_description; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/P24Request.php b/src/PayPal/Order/DTO/P24Request.php new file mode 100644 index 000000000..192f32c8d --- /dev/null +++ b/src/PayPal/Order/DTO/P24Request.php @@ -0,0 +1,113 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class P24Request +{ + /** + * @var string + */ + private $name; + /** + * @var string + */ + private $country_code; + /** + * @var string + */ + private $email; + /** + * @var ExperienceContextRequest + */ + private $experience_context; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * @param string $country_code + * + * @return void + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + } + + /** + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param string $email + * + * @return void + */ + public function setEmail($email) + { + $this->email = $email; + } + + /** + * @return ExperienceContextRequest + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param ExperienceContextRequest $experience_context + * + * @return void + */ + public function setExperienceContext(ExperienceContextRequest $experience_context) + { + $this->experience_context = $experience_context; + } +} diff --git a/src/PayPal/Order/DTO/PayPalRequest.php b/src/PayPal/Order/DTO/PayPalRequest.php new file mode 100644 index 000000000..6ef76aa4c --- /dev/null +++ b/src/PayPal/Order/DTO/PayPalRequest.php @@ -0,0 +1,245 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PayPalRequest +{ + /** + * @var string + */ + private $vault_id; + /** + * @var string + */ + private $email_address; + /** + * @var Name + */ + private $name; + /** + * @var PhoneWithType + */ + private $phone; + /** + * @var string + */ + private $bith_date; + /** + * @var TaxInfo + */ + private $tax_info; + /** + * @var AddressRequest + */ + private $address; + /** + * @var PayPalWalletAttributesRequest + */ + private $attributes; + /** + * @var PayPalWalletExperienceContext + */ + private $experience_context; + /** + * @var string + */ + private $billing_agreement_id; + + /** + * @return string + */ + public function getVaultId() + { + return $this->vault_id; + } + + /** + * @param string $vault_id + * + * @return void + */ + public function setVaultId($vault_id) + { + $this->vault_id = $vault_id; + } + + /** + * @return string + */ + public function getEmailAddress() + { + return $this->email_address; + } + + /** + * @param string $email_address + * + * @return void + */ + public function setEmailAddress($email_address) + { + $this->email_address = $email_address; + } + + /** + * @return Name + */ + public function getName() + { + return $this->name; + } + + /** + * @param Name $name + * + * @return void + */ + public function setName(Name $name) + { + $this->name = $name; + } + + /** + * @return PhoneWithType + */ + public function getPhone() + { + return $this->phone; + } + + /** + * @param PhoneWithType $phone + * + * @return void + */ + public function setPhone(PhoneWithType $phone) + { + $this->phone = $phone; + } + + /** + * @return string + */ + public function getBithDate() + { + return $this->bith_date; + } + + /** + * @param string $bith_date + * + * @return void + */ + public function setBithDate($bith_date) + { + $this->bith_date = $bith_date; + } + + /** + * @return TaxInfo + */ + public function getTaxInfo() + { + return $this->tax_info; + } + + /** + * @param TaxInfo $tax_info + * + * @return void + */ + public function setTaxInfo(TaxInfo $tax_info) + { + $this->tax_info = $tax_info; + } + + /** + * @return AddressRequest + */ + public function getAddress() + { + return $this->address; + } + + /** + * @param AddressRequest $address + * + * @return void + */ + public function setAddress(AddressRequest $address) + { + $this->address = $address; + } + + /** + * @return PayPalWalletAttributesRequest + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param PayPalWalletAttributesRequest $attributes + * + * @return void + */ + public function setAttributes(PayPalWalletAttributesRequest $attributes) + { + $this->attributes = $attributes; + } + + /** + * @return PayPalWalletExperienceContext + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param PayPalWalletExperienceContext $experience_context + * + * @return void + */ + public function setExperienceContext(PayPalWalletExperienceContext $experience_context) + { + $this->experience_context = $experience_context; + } + + /** + * @return string + */ + public function getBillingAgreementId() + { + return $this->billing_agreement_id; + } + + /** + * @param string $billing_agreement_id + * + * @return void + */ + public function setBillingAgreementId($billing_agreement_id) + { + $this->billing_agreement_id = $billing_agreement_id; + } +} diff --git a/src/PayPal/Order/DTO/PayPalWalletAttributesRequest.php b/src/PayPal/Order/DTO/PayPalWalletAttributesRequest.php new file mode 100644 index 000000000..af45844f4 --- /dev/null +++ b/src/PayPal/Order/DTO/PayPalWalletAttributesRequest.php @@ -0,0 +1,69 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PayPalWalletAttributesRequest +{ + /** + * @var CustomerRequest + */ + private $customer; + /** + * @var PayPalWalletVaultAttributesRequest + */ + private $vault; + + /** + * @return CustomerRequest + */ + public function getCustomer() + { + return $this->customer; + } + + /** + * @param CustomerRequest $customer + * + * @return void + */ + public function setCustomer(CustomerRequest $customer) + { + $this->customer = $customer; + } + + /** + * @return PayPalWalletVaultAttributesRequest + */ + public function getVault() + { + return $this->vault; + } + + /** + * @param PayPalWalletVaultAttributesRequest $vault + * + * @return void + */ + public function setVault(PayPalWalletVaultAttributesRequest $vault) + { + $this->vault = $vault; + } +} diff --git a/src/PayPal/Order/DTO/PayPalWalletExperienceContext.php b/src/PayPal/Order/DTO/PayPalWalletExperienceContext.php new file mode 100644 index 000000000..38a9d422e --- /dev/null +++ b/src/PayPal/Order/DTO/PayPalWalletExperienceContext.php @@ -0,0 +1,201 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PayPalWalletExperienceContext +{ + /** + * @var string + */ + private $brand_name; + /** + * @var string + */ + private $locale; + /** + * @var string + */ + private $shipping_preference; + /** + * @var string + */ + private $return_url; + /** + * @var string + */ + private $cancel_url; + /** + * @var string + */ + private $landing_page; + /** + * @var string + */ + private $user_action; + /** + * @var string + */ + private $payment_method_preference; + + /** + * @return string + */ + public function getBrandName() + { + return $this->brand_name; + } + + /** + * @param string $brand_name + * + * @return void + */ + public function setBrandName($brand_name) + { + $this->brand_name = $brand_name; + } + + /** + * @return string + */ + public function getLocale() + { + return $this->locale; + } + + /** + * @param string $locale + * + * @return void + */ + public function setLocale($locale) + { + $this->locale = $locale; + } + + /** + * @return string + */ + public function getShippingPreference() + { + return $this->shipping_preference; + } + + /** + * @param string $shipping_preference + * + * @return void + */ + public function setShippingPreference($shipping_preference) + { + $this->shipping_preference = $shipping_preference; + } + + /** + * @return string + */ + public function getReturnUrl() + { + return $this->return_url; + } + + /** + * @param string $return_url + * + * @return void + */ + public function setReturnUrl($return_url) + { + $this->return_url = $return_url; + } + + /** + * @return string + */ + public function getCancelUrl() + { + return $this->cancel_url; + } + + /** + * @param string $cancel_url + * + * @return void + */ + public function setCancelUrl($cancel_url) + { + $this->cancel_url = $cancel_url; + } + + /** + * @return string + */ + public function getLandingPage() + { + return $this->landing_page; + } + + /** + * @param string $landing_page + * + * @return void + */ + public function setLandingPage($landing_page) + { + $this->landing_page = $landing_page; + } + + /** + * @return string + */ + public function getUserAction() + { + return $this->user_action; + } + + /** + * @param string $user_action + * + * @return void + */ + public function setUserAction($user_action) + { + $this->user_action = $user_action; + } + + /** + * @return string + */ + public function getPaymentMethodPreference() + { + return $this->payment_method_preference; + } + + /** + * @param string $payment_method_preference + * + * @return void + */ + public function setPaymentMethodPreference($payment_method_preference) + { + $this->payment_method_preference = $payment_method_preference; + } +} diff --git a/src/PayPal/Order/DTO/PayPalWalletVaultAttributesRequest.php b/src/PayPal/Order/DTO/PayPalWalletVaultAttributesRequest.php new file mode 100644 index 000000000..fbfc416c9 --- /dev/null +++ b/src/PayPal/Order/DTO/PayPalWalletVaultAttributesRequest.php @@ -0,0 +1,179 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PayPalWalletVaultAttributesRequest +{ + /** + * @var string + */ + private $store_in_vault; + /** + * @var string + */ + private $description; + /** + * @var string + */ + private $usage_pattern; + /** + * @var ShippingRequest + */ + private $shipping; + /** + * @var string + */ + private $usage_type = 'MERCHANT'; + /** + * @var string + */ + private $customer_type; + /** + * @var bool + */ + private $permit_multiple_payment_tokens; + + /** + * @return string + */ + public function getStoreInVault() + { + return $this->store_in_vault; + } + + /** + * @param string $store_in_vault + * + * @return void + */ + public function setStoreInVault($store_in_vault) + { + $this->store_in_vault = $store_in_vault; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + * + * @return void + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string + */ + public function getUsagePattern() + { + return $this->usage_pattern; + } + + /** + * @param string $usage_pattern + * + * @return void + */ + public function setUsagePattern($usage_pattern) + { + $this->usage_pattern = $usage_pattern; + } + + /** + * @return ShippingRequest + */ + public function getShipping() + { + return $this->shipping; + } + + /** + * @param ShippingRequest $shipping + * + * @return void + */ + public function setShipping(ShippingRequest $shipping) + { + $this->shipping = $shipping; + } + + /** + * @return string + */ + public function getUsageType() + { + return $this->usage_type; + } + + /** + * @param string $usage_type + * + * @return void + */ + public function setUsageType($usage_type) + { + $this->usage_type = $usage_type; + } + + /** + * @return string + */ + public function getCustomerType() + { + return $this->customer_type; + } + + /** + * @param string $customer_type + * + * @return void + */ + public function setCustomerType($customer_type) + { + $this->customer_type = $customer_type; + } + + /** + * @return bool + */ + public function isPermitMultiplePaymentTokens() + { + return $this->permit_multiple_payment_tokens; + } + + /** + * @param bool $permit_multiple_payment_tokens + * + * @return void + */ + public function setPermitMultiplePaymentTokens($permit_multiple_payment_tokens) + { + $this->permit_multiple_payment_tokens = $permit_multiple_payment_tokens; + } +} diff --git a/src/PayPal/Order/DTO/Payee.php b/src/PayPal/Order/DTO/Payee.php new file mode 100644 index 000000000..3276c8ad7 --- /dev/null +++ b/src/PayPal/Order/DTO/Payee.php @@ -0,0 +1,97 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Payee +{ + /** + * The internationalized email address.<blockquote><strong>Note:</strong> Up to 64 characters are allowed before and 255 characters are allowed after the <code>@</code> sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted <code>@</code> sign exists.</blockquote> + * + * @var string|null + */ + protected $email_address; + + /** + * The account identifier for a PayPal account. + * + * @var string|null + */ + protected $merchant_id; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->email_address = isset($data['email_address']) ? $data['email_address'] : null; + $this->merchant_id = isset($data['merchant_id']) ? $data['merchant_id'] : null; + } + + /** + * Gets email_address. + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->email_address; + } + + /** + * Sets email_address. + * + * @param string|null $email_address The internationalized email address.GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: Up to 64 characters are allowed before and 255 characters are allowed after the+ * + * @return $this + */ + public function setEmailAddress($email_address = null) + { + $this->email_address = $email_address; + + return $this; + } + + /** + * Gets merchant_id. + * + * @return string|null + */ + public function getMerchantId() + { + return $this->merchant_id; + } + + /** + * Sets merchant_id. + * + * @param string|null $merchant_id the account identifier for a PayPal account + * + * @return $this + */ + public function setMerchantId($merchant_id = null) + { + $this->merchant_id = $merchant_id; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/PayeeRequest.php b/src/PayPal/Order/DTO/PayeeRequest.php new file mode 100644 index 000000000..b854f98aa --- /dev/null +++ b/src/PayPal/Order/DTO/PayeeRequest.php @@ -0,0 +1,69 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PayeeRequest +{ + /** + * @var string + */ + private $email_address; + /** + * @var string + */ + private $merchant_id; + + /** + * @return string + */ + public function getEmailAddress() + { + return $this->email_address; + } + + /** + * @param string $email_address + * + * @return void + */ + public function setEmailAddress($email_address) + { + $this->email_address = $email_address; + } + + /** + * @return string + */ + public function getMerchantId() + { + return $this->merchant_id; + } + + /** + * @param string $merchant_id + * + * @return void + */ + public function setMerchantId($merchant_id) + { + $this->merchant_id = $merchant_id; + } +} diff --git a/src/PayPal/Order/DTO/Payer.php b/src/PayPal/Order/DTO/Payer.php new file mode 100644 index 000000000..9702a12b7 --- /dev/null +++ b/src/PayPal/Order/DTO/Payer.php @@ -0,0 +1,165 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Payer +{ + /** + * @var string + */ + private $email_address; + /** + * @var string + */ + private $payer_id; + /** + * @var Name + */ + private $name; + /** + * @var PhoneWithType + */ + private $phone; + /** + * @var string + */ + private $birth_date; + /** + * @var TaxInfo + */ + private $tax_info; + /** + * @var AddressRequest + */ + private $address; + + /** + * @return string + */ + public function getEmailAddress() + { + return $this->email_address; + } + + /** + * @param string $email_address + */ + public function setEmailAddress($email_address) + { + $this->email_address = $email_address; + } + + /** + * @return string + */ + public function getPayerId() + { + return $this->payer_id; + } + + /** + * @param string $payer_id + */ + public function setPayerId($payer_id) + { + $this->payer_id = $payer_id; + } + + /** + * @return Name + */ + public function getName() + { + return $this->name; + } + + /** + * @param Name $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return PhoneWithType + */ + public function getPhone() + { + return $this->phone; + } + + /** + * @param PhoneWithType $phone + */ + public function setPhone($phone) + { + $this->phone = $phone; + } + + /** + * @return string + */ + public function getBirthDate() + { + return $this->birth_date; + } + + /** + * @param string $birth_date + */ + public function setBirthDate($birth_date) + { + $this->birth_date = $birth_date; + } + + /** + * @return TaxInfo + */ + public function getTaxInfo() + { + return $this->tax_info; + } + + /** + * @param TaxInfo $tax_info + */ + public function setTaxInfo($tax_info) + { + $this->tax_info = $tax_info; + } + + /** + * @return AddressRequest + */ + public function getAddress() + { + return $this->address; + } + + /** + * @param AddressRequest $address + */ + public function setAddress($address) + { + $this->address = $address; + } +} diff --git a/src/PayPal/Order/DTO/PaymentCollection.php b/src/PayPal/Order/DTO/PaymentCollection.php new file mode 100644 index 000000000..e3f84592c --- /dev/null +++ b/src/PayPal/Order/DTO/PaymentCollection.php @@ -0,0 +1,129 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PaymentCollection +{ + /** + * An array of authorized payments for a purchase unit. A purchase unit can have zero or more authorized payments. + * + * @var AuthorizationWithAdditionalData[]|null + */ + protected $authorizations; + + /** + * An array of captured payments for a purchase unit. A purchase unit can have zero or more captured payments. + * + * @var Capture[]|null + */ + protected $captures; + + /** + * An array of refunds for a purchase unit. A purchase unit can have zero or more refunds. + * + * @var Refund[]|null + */ + protected $refunds; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->authorizations = isset($data['authorizations']) ? $data['authorizations'] : null; + $this->captures = isset($data['captures']) ? $data['captures'] : null; + $this->refunds = isset($data['refunds']) ? $data['refunds'] : null; + } + + /** + * Gets authorizations. + * + * @return AuthorizationWithAdditionalData[]|null + */ + public function getAuthorizations() + { + return $this->authorizations; + } + + /** + * Sets authorizations. + * + * @param AuthorizationWithAdditionalData[]|null $authorizations An array of authorized payments for a purchase unit. A purchase unit can have zero or more authorized payments. + * + * @return $this + */ + public function setAuthorizations(array $authorizations = null) + { + $this->authorizations = $authorizations; + + return $this; + } + + /** + * Gets captures. + * + * @return Capture[]|null + */ + public function getCaptures() + { + return $this->captures; + } + + /** + * Sets captures. + * + * @param Capture[]|null $captures An array of captured payments for a purchase unit. A purchase unit can have zero or more captured payments. + * + * @return $this + */ + public function setCaptures(array $captures = null) + { + $this->captures = $captures; + + return $this; + } + + /** + * Gets refunds. + * + * @return Refund[]|null + */ + public function getRefunds() + { + return $this->refunds; + } + + /** + * Sets refunds. + * + * @param Refund[]|null $refunds An array of refunds for a purchase unit. A purchase unit can have zero or more refunds. + * + * @return $this + */ + public function setRefunds(array $refunds = null) + { + $this->refunds = $refunds; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/PaymentInstruction.php b/src/PayPal/Order/DTO/PaymentInstruction.php new file mode 100644 index 000000000..e6640a3c1 --- /dev/null +++ b/src/PayPal/Order/DTO/PaymentInstruction.php @@ -0,0 +1,159 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PaymentInstruction +{ + /** + * An array of various fees, commissions, tips, or donations. This field is only applicable to merchants that been enabled for PayPal Commerce Platform for Marketplaces and Platforms capability. + * + * @var PlatformFee[]|null + */ + protected $platform_fees; + + /** + * @var string|null + */ + protected $disbursement_mode; + + /** + * This field is only enabled for selected merchants/partners to use and provides the ability to trigger a specific pricing rate/plan for a payment transaction. The list of eligible 'payee_pricing_tier_id' would be provided to you by your Account Manager. Specifying values other than the one provided to you by your account manager would result in an error. + * + * @var string|null + */ + protected $payee_pricing_tier_id; + + /** + * FX identifier generated returned by PayPal to be used for payment processing in order to honor FX rate (for eligible integrations) to be used when amount is settled/received into the payee account. + * + * @var string|null + */ + protected $payee_receivable_fx_rate_id; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->platform_fees = isset($data['platform_fees']) ? $data['platform_fees'] : null; + $this->disbursement_mode = isset($data['disbursement_mode']) ? $data['disbursement_mode'] : null; + $this->payee_pricing_tier_id = isset($data['payee_pricing_tier_id']) ? $data['payee_pricing_tier_id'] : null; + $this->payee_receivable_fx_rate_id = isset($data['payee_receivable_fx_rate_id']) ? $data['payee_receivable_fx_rate_id'] : null; + } + + /** + * Gets platform_fees. + * + * @return PlatformFee[]|null + */ + public function getPlatformFees() + { + return $this->platform_fees; + } + + /** + * Sets platform_fees. + * + * @param PlatformFee[]|null $platform_fees An array of various fees, commissions, tips, or donations. This field is only applicable to merchants that been enabled for PayPal Commerce Platform for Marketplaces and Platforms capability. + * + * @return $this + */ + public function setPlatformFees(array $platform_fees = null) + { + $this->platform_fees = $platform_fees; + + return $this; + } + + /** + * Gets disbursement_mode. + * + * @return string|null + */ + public function getDisbursementMode() + { + return $this->disbursement_mode; + } + + /** + * Sets disbursement_mode. + * + * @param string|null $disbursement_mode + * + * @return $this + */ + public function setDisbursementMode($disbursement_mode = null) + { + $this->disbursement_mode = $disbursement_mode; + + return $this; + } + + /** + * Gets payee_pricing_tier_id. + * + * @return string|null + */ + public function getPayeePricingTierId() + { + return $this->payee_pricing_tier_id; + } + + /** + * Sets payee_pricing_tier_id. + * + * @param string|null $payee_pricing_tier_id This field is only enabled for selected merchants/partners to use and provides the ability to trigger a specific pricing rate/plan for a payment transaction. The list of eligible 'payee_pricing_tier_id' would be provided to you by your Account Manager. Specifying values other than the one provided to you by your account manager would result in an error. + * + * @return $this + */ + public function setPayeePricingTierId($payee_pricing_tier_id = null) + { + $this->payee_pricing_tier_id = $payee_pricing_tier_id; + + return $this; + } + + /** + * Gets payee_receivable_fx_rate_id. + * + * @return string|null + */ + public function getPayeeReceivableFxRateId() + { + return $this->payee_receivable_fx_rate_id; + } + + /** + * Sets payee_receivable_fx_rate_id. + * + * @param string|null $payee_receivable_fx_rate_id FX identifier generated returned by PayPal to be used for payment processing in order to honor FX rate (for eligible integrations) to be used when amount is settled/received into the payee account + * + * @return $this + */ + public function setPayeeReceivableFxRateId($payee_receivable_fx_rate_id = null) + { + $this->payee_receivable_fx_rate_id = $payee_receivable_fx_rate_id; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/PaymentSourceRequest.php b/src/PayPal/Order/DTO/PaymentSourceRequest.php new file mode 100644 index 000000000..691a6f444 --- /dev/null +++ b/src/PayPal/Order/DTO/PaymentSourceRequest.php @@ -0,0 +1,333 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PaymentSourceRequest +{ + /** + * @var CardRequest + */ + private $card; + /** + * @var TokenRequest + */ + private $token; + /** + * @var PayPalRequest + */ + private $paypal; + /** + * @var BancontactRequest + */ + private $bancontact; + /** + * @var BlikRequest + */ + private $blik; + /** + * @var EpsRequest + */ + private $eps; + /** + * @var GiropayRequest + */ + private $giropay; + /** + * @var IdealRequest + */ + private $ideal; + /** + * @var MyBankRequest + */ + private $mybank; + /** + * @var P24Request + */ + private $p24; + /** + * @var SofortRequest + */ + private $sofort; + /** + * @var ApplePayRequest + */ + private $apple_pay; + /** + * @var GooglePayRequest + */ + private $google_pay; + /** + * @var VenmoRequest + */ + private $venmo; + + /** + * @return CardRequest + */ + public function getCard() + { + return $this->card; + } + + /** + * @param CardRequest $card + * + * @return void + */ + public function setCard(CardRequest $card) + { + $this->card = $card; + } + + /** + * @return TokenRequest + */ + public function getToken() + { + return $this->token; + } + + /** + * @param TokenRequest $token + * + * @return void + */ + public function setToken(TokenRequest $token) + { + $this->token = $token; + } + + /** + * @return PayPalRequest + */ + public function getPaypal() + { + return $this->paypal; + } + + /** + * @param PayPalRequest $paypal + * + * @return void + */ + public function setPaypal(PayPalRequest $paypal) + { + $this->paypal = $paypal; + } + + /** + * @return BancontactRequest + */ + public function getBancontact() + { + return $this->bancontact; + } + + /** + * @param BancontactRequest $bancontact + * + * @return void + */ + public function setBancontact(BancontactRequest $bancontact) + { + $this->bancontact = $bancontact; + } + + /** + * @return BlikRequest + */ + public function getBlik() + { + return $this->blik; + } + + /** + * @param BlikRequest $blik + * + * @return void + */ + public function setBlik(BlikRequest $blik) + { + $this->blik = $blik; + } + + /** + * @return EpsRequest + */ + public function getEps() + { + return $this->eps; + } + + /** + * @param EpsRequest $eps + * + * @return void + */ + public function setEps(EpsRequest $eps) + { + $this->eps = $eps; + } + + /** + * @return GiropayRequest + */ + public function getGiropay() + { + return $this->giropay; + } + + /** + * @param GiropayRequest $giropay + * + * @return void + */ + public function setGiropay(GiropayRequest $giropay) + { + $this->giropay = $giropay; + } + + /** + * @return IdealRequest + */ + public function getIdeal() + { + return $this->ideal; + } + + /** + * @param IdealRequest $ideal + * + * @return void + */ + public function setIdeal(IdealRequest $ideal) + { + $this->ideal = $ideal; + } + + /** + * @return MyBankRequest + */ + public function getMybank() + { + return $this->mybank; + } + + /** + * @param MyBankRequest $mybank + * + * @return void + */ + public function setMybank(MyBankRequest $mybank) + { + $this->mybank = $mybank; + } + + /** + * @return P24Request + */ + public function getP24() + { + return $this->p24; + } + + /** + * @param P24Request $p24 + * + * @return void + */ + public function setP24(P24Request $p24) + { + $this->p24 = $p24; + } + + /** + * @return SofortRequest + */ + public function getSofort() + { + return $this->sofort; + } + + /** + * @param SofortRequest $sofort + * + * @return void + */ + public function setSofort(SofortRequest $sofort) + { + $this->sofort = $sofort; + } + + /** + * @return ApplePayRequest + */ + public function getApplePay() + { + return $this->apple_pay; + } + + /** + * @param ApplePayRequest $apple_pay + * + * @return void + */ + public function setApplePay(ApplePayRequest $apple_pay) + { + $this->apple_pay = $apple_pay; + } + + /** + * @return GooglePayRequest + */ + public function getGooglePay() + { + return $this->google_pay; + } + + /** + * @param GooglePayRequest $google_pay + * + * @return void + */ + public function setGooglePay(GooglePayRequest $google_pay) + { + $this->google_pay = $google_pay; + } + + /** + * @return VenmoRequest + */ + public function getVenmo() + { + return $this->venmo; + } + + /** + * @param VenmoRequest $venmo + * + * @return void + */ + public function setVenmo(VenmoRequest $venmo) + { + $this->venmo = $venmo; + } +} diff --git a/src/PayPal/Order/DTO/PaymentSourceResponse.php b/src/PayPal/Order/DTO/PaymentSourceResponse.php new file mode 100644 index 000000000..b13dcbb6e --- /dev/null +++ b/src/PayPal/Order/DTO/PaymentSourceResponse.php @@ -0,0 +1,393 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PaymentSourceResponse +{ + /** + * @var CardResponse|null + */ + protected $card; + + /** + * @var PaypalWalletResponse|null + */ + protected $paypal; + + /** + * @var Bancontact|null + */ + protected $bancontact; + + /** + * @var Blik|null + */ + protected $blik; + + /** + * @var Eps|null + */ + protected $eps; + + /** + * @var Giropay|null + */ + protected $giropay; + + /** + * @var Ideal|null + */ + protected $ideal; + + /** + * @var Mybank|null + */ + protected $mybank; + + /** + * @var P24|null + */ + protected $p24; + + /** + * @var Sofort|null + */ + protected $sofort; + + /** + * @var Trustly|null + */ + protected $trustly; + + /** + * @var VenmoWalletResponse|null + */ + protected $venmo; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->card = isset($data['card']) ? $data['card'] : null; + $this->paypal = isset($data['paypal']) ? $data['paypal'] : null; + $this->bancontact = isset($data['bancontact']) ? $data['bancontact'] : null; + $this->blik = isset($data['blik']) ? $data['blik'] : null; + $this->eps = isset($data['eps']) ? $data['eps'] : null; + $this->giropay = isset($data['giropay']) ? $data['giropay'] : null; + $this->ideal = isset($data['ideal']) ? $data['ideal'] : null; + $this->mybank = isset($data['mybank']) ? $data['mybank'] : null; + $this->p24 = isset($data['p24']) ? $data['p24'] : null; + $this->sofort = isset($data['sofort']) ? $data['sofort'] : null; + $this->trustly = isset($data['trustly']) ? $data['trustly'] : null; + $this->venmo = isset($data['venmo']) ? $data['venmo'] : null; + } + + /** + * Gets card. + * + * @return CardResponse|null + */ + public function getCard() + { + return $this->card; + } + + /** + * Sets card. + * + * @param CardResponse|null $card + * + * @return $this + */ + public function setCard(CardResponse $card = null) + { + $this->card = $card; + + return $this; + } + + /** + * Gets paypal. + * + * @return PaypalWalletResponse|null + */ + public function getPaypal() + { + return $this->paypal; + } + + /** + * Sets paypal. + * + * @param PaypalWalletResponse|null $paypal + * + * @return $this + */ + public function setPaypal(PaypalWalletResponse $paypal = null) + { + $this->paypal = $paypal; + + return $this; + } + + /** + * Gets bancontact. + * + * @return Bancontact|null + */ + public function getBancontact() + { + return $this->bancontact; + } + + /** + * Sets bancontact. + * + * @param Bancontact|null $bancontact + * + * @return $this + */ + public function setBancontact(Bancontact $bancontact = null) + { + $this->bancontact = $bancontact; + + return $this; + } + + /** + * Gets blik. + * + * @return Blik|null + */ + public function getBlik() + { + return $this->blik; + } + + /** + * Sets blik. + * + * @param Blik|null $blik + * + * @return $this + */ + public function setBlik(Blik $blik = null) + { + $this->blik = $blik; + + return $this; + } + + /** + * Gets eps. + * + * @return Eps|null + */ + public function getEps() + { + return $this->eps; + } + + /** + * Sets eps. + * + * @param Eps|null $eps + * + * @return $this + */ + public function setEps(Eps $eps = null) + { + $this->eps = $eps; + + return $this; + } + + /** + * Gets giropay. + * + * @return Giropay|null + */ + public function getGiropay() + { + return $this->giropay; + } + + /** + * Sets giropay. + * + * @param Giropay|null $giropay + * + * @return $this + */ + public function setGiropay(Giropay $giropay = null) + { + $this->giropay = $giropay; + + return $this; + } + + /** + * Gets ideal. + * + * @return Ideal|null + */ + public function getIdeal() + { + return $this->ideal; + } + + /** + * Sets ideal. + * + * @param Ideal|null $ideal + * + * @return $this + */ + public function setIdeal(Ideal $ideal = null) + { + $this->ideal = $ideal; + + return $this; + } + + /** + * Gets mybank. + * + * @return Mybank|null + */ + public function getMybank() + { + return $this->mybank; + } + + /** + * Sets mybank. + * + * @param Mybank|null $mybank + * + * @return $this + */ + public function setMybank(Mybank $mybank = null) + { + $this->mybank = $mybank; + + return $this; + } + + /** + * Gets p24. + * + * @return P24|null + */ + public function getP24() + { + return $this->p24; + } + + /** + * Sets p24. + * + * @param P24|null $p24 + * + * @return $this + */ + public function setP24(P24 $p24 = null) + { + $this->p24 = $p24; + + return $this; + } + + /** + * Gets sofort. + * + * @return Sofort|null + */ + public function getSofort() + { + return $this->sofort; + } + + /** + * Sets sofort. + * + * @param Sofort|null $sofort + * + * @return $this + */ + public function setSofort(Sofort $sofort = null) + { + $this->sofort = $sofort; + + return $this; + } + + /** + * Gets trustly. + * + * @return Trustly|null + */ + public function getTrustly() + { + return $this->trustly; + } + + /** + * Sets trustly. + * + * @param Trustly|null $trustly + * + * @return $this + */ + public function setTrustly(Trustly $trustly = null) + { + $this->trustly = $trustly; + + return $this; + } + + /** + * Gets venmo. + * + * @return VenmoWalletResponse|null + */ + public function getVenmo() + { + return $this->venmo; + } + + /** + * Sets venmo. + * + * @param VenmoWalletResponse|null $venmo + * + * @return $this + */ + public function setVenmo(VenmoWalletResponse $venmo = null) + { + $this->venmo = $venmo; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/PaypalWalletAttributesResponse.php b/src/PayPal/Order/DTO/PaypalWalletAttributesResponse.php new file mode 100644 index 000000000..677cbe43a --- /dev/null +++ b/src/PayPal/Order/DTO/PaypalWalletAttributesResponse.php @@ -0,0 +1,94 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PaypalWalletAttributesResponse +{ + /** + * @var VaultResponse|null + */ + protected $vault; + /** + * An array of merchant cobranded cards used by buyer to complete an order. This array will be present if a merchant has onboarded their cobranded card with PayPal and provided corresponding label(s). + * + * @var CobrandedCard[]|null + */ + protected $cobranded_cards; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->vault = isset($data['vault']) ? $data['vault'] : null; + $this->cobranded_cards = isset($data['cobranded_cards']) ? $data['cobranded_cards'] : null; + } + + /** + * Gets vault. + * + * @return VaultResponse|null + */ + public function getVault() + { + return $this->vault; + } + + /** + * Sets vault. + * + * @param VaultResponse|null $vault + * + * @return $this + */ + public function setVault(VaultResponse $vault = null) + { + $this->vault = $vault; + + return $this; + } + + /** + * Gets cobranded_cards. + * + * @return CobrandedCard[]|null + */ + public function getCobrandedCards() + { + return $this->cobranded_cards; + } + + /** + * Sets cobranded_cards. + * + * @param CobrandedCard[]|null $cobranded_cards An array of merchant cobranded cards used by buyer to complete an order. This array will be present if a merchant has onboarded their cobranded card with PayPal and provided corresponding label(s). + * + * @return $this + */ + public function setCobrandedCards(array $cobranded_cards = null) + { + $this->cobranded_cards = $cobranded_cards; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/PaypalWalletResponse.php b/src/PayPal/Order/DTO/PaypalWalletResponse.php new file mode 100644 index 000000000..3db9cb634 --- /dev/null +++ b/src/PayPal/Order/DTO/PaypalWalletResponse.php @@ -0,0 +1,309 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PaypalWalletResponse +{ + /** + * The internationalized email address.<blockquote><strong>Note:</strong> Up to 64 characters are allowed before and 255 characters are allowed after the <code>@</code> sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted <code>@</code> sign exists.</blockquote> + * + * @var string|null + */ + protected $email_address; + + /** + * The PayPal payer ID, which is a masked version of the PayPal account number intended for use with third parties. The account number is reversibly encrypted and a proprietary variant of Base32 is used to encode the result. + * + * @var string|null + */ + protected $account_id; + + /** + * @var Name|null + */ + protected $name; + + /** + * @var string|null + */ + protected $phone_type; + + /** + * @var Phone|null + */ + protected $phone_number; + + /** + * The stand-alone date, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). To represent special legal values, such as a date of birth, you should use dates with no associated time or time-zone data. Whenever possible, use the standard `date_time` type. This regular expression does not validate all dates. For example, February 31 is valid and nothing is known about leap years. + * + * @var string|null + */ + protected $birth_date; + + /** + * @var TaxInfo|null + */ + protected $tax_info; + + /** + * @var AddressPortable2|null + */ + protected $address; + + /** + * @var PaypalWalletAttributesResponse|null + */ + protected $attributes; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->email_address = isset($data['email_address']) ? $data['email_address'] : null; + $this->account_id = isset($data['account_id']) ? $data['account_id'] : null; + $this->name = isset($data['name']) ? $data['name'] : null; + $this->phone_type = isset($data['phone_type']) ? $data['phone_type'] : null; + $this->phone_number = isset($data['phone_number']) ? $data['phone_number'] : null; + $this->birth_date = isset($data['birth_date']) ? $data['birth_date'] : null; + $this->tax_info = isset($data['tax_info']) ? $data['tax_info'] : null; + $this->address = isset($data['address']) ? $data['address'] : null; + $this->attributes = isset($data['attributes']) ? $data['attributes'] : null; + } + + /** + * Gets email_address. + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->email_address; + } + + /** + * Sets email_address. + * + * @param string|null $email_address The internationalized email address.@
sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted@
sign exists.
Note: Up to 64 characters are allowed before and 255 characters are allowed after the+ * + * @return $this + */ + public function setEmailAddress($email_address = null) + { + $this->email_address = $email_address; + + return $this; + } + + /** + * Gets account_id. + * + * @return string|null + */ + public function getAccountId() + { + return $this->account_id; + } + + /** + * Sets account_id. + * + * @param string|null $account_id The PayPal payer ID, which is a masked version of the PayPal account number intended for use with third parties. The account number is reversibly encrypted and a proprietary variant of Base32 is used to encode the result. + * + * @return $this + */ + public function setAccountId($account_id = null) + { + $this->account_id = $account_id; + + return $this; + } + + /** + * Gets name. + * + * @return Name|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param Name|null $name + * + * @return $this + */ + public function setName(Name $name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets phone_type. + * + * @return string|null + */ + public function getPhoneType() + { + return $this->phone_type; + } + + /** + * Sets phone_type. + * + * @param string|null $phone_type + * + * @return $this + */ + public function setPhoneType($phone_type = null) + { + $this->phone_type = $phone_type; + + return $this; + } + + /** + * Gets phone_number. + * + * @return Phone|null + */ + public function getPhoneNumber() + { + return $this->phone_number; + } + + /** + * Sets phone_number. + * + * @param Phone|null $phone_number + * + * @return $this + */ + public function setPhoneNumber(Phone $phone_number = null) + { + $this->phone_number = $phone_number; + + return $this; + } + + /** + * Gets birth_date. + * + * @return string|null + */ + public function getBirthDate() + { + return $this->birth_date; + } + + /** + * Sets birth_date. + * + * @param string|null $birth_date The stand-alone date, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). To represent special legal values, such as a date of birth, you should use dates with no associated time or time-zone data. Whenever possible, use the standard `date_time` type. This regular expression does not validate all dates. For example, February 31 is valid and nothing is known about leap years. + * + * @return $this + */ + public function setBirthDate($birth_date = null) + { + $this->birth_date = $birth_date; + + return $this; + } + + /** + * Gets tax_info. + * + * @return TaxInfo|null + */ + public function getTaxInfo() + { + return $this->tax_info; + } + + /** + * Sets tax_info. + * + * @param TaxInfo|null $tax_info + * + * @return $this + */ + public function setTaxInfo(TaxInfo $tax_info = null) + { + $this->tax_info = $tax_info; + + return $this; + } + + /** + * Gets address. + * + * @return AddressPortable2|null + */ + public function getAddress() + { + return $this->address; + } + + /** + * Sets address. + * + * @param AddressPortable2|null $address + * + * @return $this + */ + public function setAddress(AddressPortable2 $address = null) + { + $this->address = $address; + + return $this; + } + + /** + * Gets attributes. + * + * @return PaypalWalletAttributesResponse|null + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Sets attributes. + * + * @param PaypalWalletAttributesResponse|null $attributes + * + * @return $this + */ + public function setAttributes(PaypalWalletAttributesResponse $attributes = null) + { + $this->attributes = $attributes; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/Phone.php b/src/PayPal/Order/DTO/Phone.php new file mode 100644 index 000000000..c13e7d0e5 --- /dev/null +++ b/src/PayPal/Order/DTO/Phone.php @@ -0,0 +1,91 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Phone +{ + /** + * @var string + */ + private $country_code; + /** + * @var string + */ + private $national_number; + /** + * @var string + */ + private $extension_number; + + /** + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * @param string $country_code + * + * @return void + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + } + + /** + * @return string + */ + public function getNationalNumber() + { + return $this->national_number; + } + + /** + * @param string $national_number + * + * @return void + */ + public function setNationalNumber($national_number) + { + $this->national_number = $national_number; + } + + /** + * @return string + */ + public function getExtensionNumber() + { + return $this->extension_number; + } + + /** + * @param string $extension_number + * + * @return void + */ + public function setExtensionNumber($extension_number) + { + $this->extension_number = $extension_number; + } +} diff --git a/src/PayPal/Order/DTO/PhoneWithType.php b/src/PayPal/Order/DTO/PhoneWithType.php new file mode 100644 index 000000000..9049f0f32 --- /dev/null +++ b/src/PayPal/Order/DTO/PhoneWithType.php @@ -0,0 +1,69 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PhoneWithType +{ + /** + * @var Phone + */ + private $phone_number; + /** + * @var string + */ + private $phone_type; + + /** + * @return Phone + */ + public function getPhoneNumber() + { + return $this->phone_number; + } + + /** + * @param Phone $phone_number + * + * @return void + */ + public function setPhoneNumber(Phone $phone_number) + { + $this->phone_number = $phone_number; + } + + /** + * @return string + */ + public function getPhoneType() + { + return $this->phone_type; + } + + /** + * @param string $phone_type + * + * @return void + */ + public function setPhoneType($phone_type) + { + $this->phone_type = $phone_type; + } +} diff --git a/src/PayPal/Order/DTO/PlatformFee.php b/src/PayPal/Order/DTO/PlatformFee.php new file mode 100644 index 000000000..c01a43e98 --- /dev/null +++ b/src/PayPal/Order/DTO/PlatformFee.php @@ -0,0 +1,93 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PlatformFee +{ + /** + * @var Amount + */ + protected $amount; + + /** + * @var Payee|null + */ + protected $payee; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->amount = isset($data['amount']) ? $data['amount'] : null; + $this->payee = isset($data['payee']) ? $data['payee'] : null; + } + + /** + * Gets amount. + * + * @return Amount + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Sets amount. + * + * @param Amount $amount + * + * @return $this + */ + public function setAmount(Amount $amount) + { + $this->amount = $amount; + + return $this; + } + + /** + * Gets payee. + * + * @return Payee|null + */ + public function getPayee() + { + return $this->payee; + } + + /** + * Sets payee. + * + * @param Payee|null $payee + * + * @return $this + */ + public function setPayee(Payee $payee = null) + { + $this->payee = $payee; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/PreviousNetworkTransactionReferenceRequest.php b/src/PayPal/Order/DTO/PreviousNetworkTransactionReferenceRequest.php new file mode 100644 index 000000000..4c72d9005 --- /dev/null +++ b/src/PayPal/Order/DTO/PreviousNetworkTransactionReferenceRequest.php @@ -0,0 +1,113 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class PreviousNetworkTransactionReferenceRequest +{ + /** + * @var string + */ + private $id; + /** + * @var string + */ + private $date; + /** + * @var string + */ + private $network; + /** + * @var string + */ + private $acquirer_reference_number; + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $id + * + * @return void + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * @return string + */ + public function getDate() + { + return $this->date; + } + + /** + * @param string $date + * + * @return void + */ + public function setDate($date) + { + $this->date = $date; + } + + /** + * @return string + */ + public function getNetwork() + { + return $this->network; + } + + /** + * @param string $network + * + * @return void + */ + public function setNetwork($network) + { + $this->network = $network; + } + + /** + * @return string + */ + public function getAcquirerReferenceNumber() + { + return $this->acquirer_reference_number; + } + + /** + * @param string $acquirer_reference_number + * + * @return void + */ + public function setAcquirerReferenceNumber($acquirer_reference_number) + { + $this->acquirer_reference_number = $acquirer_reference_number; + } +} diff --git a/src/PayPal/Order/DTO/ProcessorResponse.php b/src/PayPal/Order/DTO/ProcessorResponse.php new file mode 100644 index 000000000..e7393f0f1 --- /dev/null +++ b/src/PayPal/Order/DTO/ProcessorResponse.php @@ -0,0 +1,161 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class ProcessorResponse +{ + /** + * The address verification code for Visa, Discover, Mastercard, or American Express transactions. + * + * @var string|null + */ + protected $avs_code; + + /** + * The card verification value code for for Visa, Discover, Mastercard, or American Express. + * + * @var string|null + */ + protected $cvv_code; + + /** + * Processor response code for the non-PayPal payment processor errors. + * + * @var string|null + */ + protected $response_code; + + /** + * The declined payment transactions might have payment advice codes. The card networks, like Visa and Mastercard, return payment advice codes. + * + * @var string|null + */ + protected $payment_advice_code; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->avs_code = isset($data['avs_code']) ? $data['avs_code'] : null; + $this->cvv_code = isset($data['cvv_code']) ? $data['cvv_code'] : null; + $this->response_code = isset($data['response_code']) ? $data['response_code'] : null; + $this->payment_advice_code = isset($data['payment_advice_code']) ? $data['payment_advice_code'] : null; + } + + /** + * Gets avs_code. + * + * @return string|null + */ + public function getAvsCode() + { + return $this->avs_code; + } + + /** + * Sets avs_code. + * + * @param string|null $avs_code the address verification code for Visa, Discover, Mastercard, or American Express transactions + * + * @return $this + */ + public function setAvsCode($avs_code = null) + { + $this->avs_code = $avs_code; + + return $this; + } + + /** + * Gets cvv_code. + * + * @return string|null + */ + public function getCvvCode() + { + return $this->cvv_code; + } + + /** + * Sets cvv_code. + * + * @param string|null $cvv_code the card verification value code for Visa, Discover, Mastercard, or American Express + * + * @return $this + */ + public function setCvvCode($cvv_code = null) + { + $this->cvv_code = $cvv_code; + + return $this; + } + + /** + * Gets response_code. + * + * @return string|null + */ + public function getResponseCode() + { + return $this->response_code; + } + + /** + * Sets response_code. + * + * @param string|null $response_code processor response code for the non-PayPal payment processor errors + * + * @return $this + */ + public function setResponseCode($response_code = null) + { + $this->response_code = $response_code; + + return $this; + } + + /** + * Gets payment_advice_code. + * + * @return string|null + */ + public function getPaymentAdviceCode() + { + return $this->payment_advice_code; + } + + /** + * Sets payment_advice_code. + * + * @param string|null $payment_advice_code The declined payment transactions might have payment advice codes. The card networks, like Visa and Mastercard, return payment advice codes. + * + * @return $this + */ + public function setPaymentAdviceCode($payment_advice_code = null) + { + $this->payment_advice_code = $payment_advice_code; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/PurchaseUnit.php b/src/PayPal/Order/DTO/PurchaseUnit.php new file mode 100644 index 000000000..211f215ae --- /dev/null +++ b/src/PayPal/Order/DTO/PurchaseUnit.php @@ -0,0 +1,444 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +/** + * Class representing the PurchaseUnit model. + * + * The purchase unit details. Used to capture required information for the payment contract. + * + * @author OpenAPI Generator team + */ +class PurchaseUnit +{ + /** + * The API caller-provided external ID for the purchase unit. Required for multiple purchase units when you must update the order through `PATCH`. If you omit this value and the order contains only one purchase unit, PayPal sets this value to `default`. <blockquote><strong>Note:</strong> If there are multiple purchase units, <code>reference_id</code> is required for each purchase unit.</blockquote> + * + * @var string|null + */ + protected $reference_id; + + /** + * @var AmountWithBreakdown|null + */ + protected $amount; + + /** + * @var Payee|null + */ + protected $payee; + + /** + * @var PaymentInstruction|null + */ + protected $payment_instruction; + + /** + * The purchase description. + * + * @var string|null + */ + protected $description; + + /** + * The API caller-provided external ID. Used to reconcile API caller-initiated transactions with PayPal transactions. Appears in transaction and settlement reports. + * + * @var string|null + */ + protected $custom_id; + + /** + * The API caller-provided external invoice ID for this order. + * + * @var string|null + */ + protected $invoice_id; + + /** + * The PayPal-generated ID for the purchase unit. This ID appears in both the payer's transaction history and the emails that the payer receives. In addition, this ID is available in transaction and settlement reports that merchants and API callers can use to reconcile transactions. This ID is only available when an order is saved by calling <code>v2/checkout/orders/id/save</code>. + * + * @var string|null + */ + protected $id; + + /** + * The payment descriptor on account transactions on the customer's credit card statement, that PayPal sends to processors. The maximum length of the soft descriptor information that you can pass in the API field is 22 characters, in the following format:<code>22 - len(PAYPAL * (8)) - len(<var>Descriptor in Payment Receiving Preferences of Merchant account</var> + 1)</code>The PAYPAL prefix uses 8 characters.<br/><br/>The soft descriptor supports the following ASCII characters:<ul><li>Alphanumeric characters</li><li>Dashes</li><li>Asterisks</li><li>Periods (.)</li><li>Spaces</li></ul>For Wallet payments marketplace integrations:<ul><li>The merchant descriptor in the Payment Receiving Preferences must be the marketplace name.</li><li>You can't use the remaining space to show the customer service number.</li><li>The remaining spaces can be a combination of seller name and country.</li></ul><br/>For unbranded payments (Direct Card) marketplace integrations, use a combination of the seller name and phone number. + * + * @var string|null + */ + protected $soft_descriptor; + + /** + * An array of items that the customer purchases from the merchant. + * + * @var Item[]|null + */ + protected $items; + + /** + * @var ShippingWithTrackingDetails|null + */ + protected $shipping; + + /** + * @var SupplementaryData|null + */ + protected $supplementary_data; + + /** + * @var PaymentCollection|null + */ + protected $payments; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->reference_id = isset($data['reference_id']) ? $data['reference_id'] : null; + $this->amount = isset($data['amount']) ? $data['amount'] : null; + $this->payee = isset($data['payee']) ? $data['payee'] : null; + $this->payment_instruction = isset($data['payment_instruction']) ? $data['payment_instruction'] : null; + $this->description = isset($data['description']) ? $data['description'] : null; + $this->custom_id = isset($data['custom_id']) ? $data['custom_id'] : null; + $this->invoice_id = isset($data['invoice_id']) ? $data['invoice_id'] : null; + $this->id = isset($data['id']) ? $data['id'] : null; + $this->soft_descriptor = isset($data['soft_descriptor']) ? $data['soft_descriptor'] : null; + $this->items = isset($data['items']) ? $data['items'] : null; + $this->shipping = isset($data['shipping']) ? $data['shipping'] : null; + $this->supplementary_data = isset($data['supplementary_data']) ? $data['supplementary_data'] : null; + $this->payments = isset($data['payments']) ? $data['payments'] : null; + } + + /** + * Gets reference_id. + * + * @return string|null + */ + public function getReferenceId() + { + return $this->reference_id; + } + + /** + * Sets reference_id. + * + * @param string|null $reference_id The API caller-provided external ID for the purchase unit. Required for multiple purchase units when you must update the order through `PATCH`. If you omit this value and the order contains only one purchase unit, PayPal sets this value to `default`.@
sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted@
sign exists.
Note: If there are multiple purchase units, reference_id
is required for each purchase unit.
+ *
+ * @return $this
+ */
+ public function setReferenceId($reference_id = null)
+ {
+ $this->reference_id = $reference_id;
+
+ return $this;
+ }
+
+ /**
+ * Gets amount.
+ *
+ * @return AmountWithBreakdown|null
+ */
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ /**
+ * Sets amount.
+ *
+ * @param AmountWithBreakdown|null $amount
+ *
+ * @return $this
+ */
+ public function setAmount(AmountWithBreakdown $amount = null)
+ {
+ $this->amount = $amount;
+
+ return $this;
+ }
+
+ /**
+ * Gets payee.
+ *
+ * @return Payee|null
+ */
+ public function getPayee()
+ {
+ return $this->payee;
+ }
+
+ /**
+ * Sets payee.
+ *
+ * @param Payee|null $payee
+ *
+ * @return $this
+ */
+ public function setPayee(Payee $payee = null)
+ {
+ $this->payee = $payee;
+
+ return $this;
+ }
+
+ /**
+ * Gets payment_instruction.
+ *
+ * @return PaymentInstruction|null
+ */
+ public function getPaymentInstruction()
+ {
+ return $this->payment_instruction;
+ }
+
+ /**
+ * Sets payment_instruction.
+ *
+ * @param PaymentInstruction|null $payment_instruction
+ *
+ * @return $this
+ */
+ public function setPaymentInstruction(PaymentInstruction $payment_instruction = null)
+ {
+ $this->payment_instruction = $payment_instruction;
+
+ return $this;
+ }
+
+ /**
+ * Gets description.
+ *
+ * @return string|null
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets description.
+ *
+ * @param string|null $description the purchase description
+ *
+ * @return $this
+ */
+ public function setDescription($description = null)
+ {
+ $this->description = $description;
+
+ return $this;
+ }
+
+ /**
+ * Gets custom_id.
+ *
+ * @return string|null
+ */
+ public function getCustomId()
+ {
+ return $this->custom_id;
+ }
+
+ /**
+ * Sets custom_id.
+ *
+ * @param string|null $custom_id The API caller-provided external ID. Used to reconcile API caller-initiated transactions with PayPal transactions. Appears in transaction and settlement reports.
+ *
+ * @return $this
+ */
+ public function setCustomId($custom_id = null)
+ {
+ $this->custom_id = $custom_id;
+
+ return $this;
+ }
+
+ /**
+ * Gets invoice_id.
+ *
+ * @return string|null
+ */
+ public function getInvoiceId()
+ {
+ return $this->invoice_id;
+ }
+
+ /**
+ * Sets invoice_id.
+ *
+ * @param string|null $invoice_id the API caller-provided external invoice ID for this order
+ *
+ * @return $this
+ */
+ public function setInvoiceId($invoice_id = null)
+ {
+ $this->invoice_id = $invoice_id;
+
+ return $this;
+ }
+
+ /**
+ * Gets id.
+ *
+ * @return string|null
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Sets id.
+ *
+ * @param string|null $id The PayPal-generated ID for the purchase unit. This ID appears in both the payer's transaction history and the emails that the payer receives. In addition, this ID is available in transaction and settlement reports that merchants and API callers can use to reconcile transactions. This ID is only available when an order is saved by calling v2/checkout/orders/id/save
.
+ *
+ * @return $this
+ */
+ public function setId($id = null)
+ {
+ $this->id = $id;
+
+ return $this;
+ }
+
+ /**
+ * Gets soft_descriptor.
+ *
+ * @return string|null
+ */
+ public function getSoftDescriptor()
+ {
+ return $this->soft_descriptor;
+ }
+
+ /**
+ * Sets soft_descriptor.
+ *
+ * @param string|null $soft_descriptor The payment descriptor on account transactions on the customer's credit card statement, that PayPal sends to processors. The maximum length of the soft descriptor information that you can pass in the API field is 22 characters, in the following format:22 - len(PAYPAL * (8)) - len(Descriptor in Payment Receiving Preferences of Merchant account + 1)
The PAYPAL prefix uses 8 characters.Note: The regular expression provides guidance but does not reject all invalid dates.+ * + * @return $this + */ + public function setCreateTime($create_time = null) + { + $this->create_time = $create_time; + + return $this; + } + + /** + * Gets update_time. + * + * @return string|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Sets update_time. + * + * @param string|null $update_time The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.
Note: The regular expression provides guidance but does not reject all invalid dates.+ * + * @return $this + */ + public function setUpdateTime($update_time = null) + { + $this->update_time = $update_time; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/SellerProtection.php b/src/PayPal/Order/DTO/SellerProtection.php new file mode 100644 index 000000000..5b8b6f2b7 --- /dev/null +++ b/src/PayPal/Order/DTO/SellerProtection.php @@ -0,0 +1,97 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class SellerProtection +{ + /** + * Indicates whether the transaction is eligible for seller protection. For information, see [PayPal Seller Protection for Merchants](https://www.paypal.com/us/webapps/mpp/security/seller-protection). + * + * @var string|null + */ + protected $status; + + /** + * An array of conditions that are covered for the transaction. + * + * @var string[]|null + */ + protected $dispute_categories; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->status = isset($data['status']) ? $data['status'] : null; + $this->dispute_categories = isset($data['dispute_categories']) ? $data['dispute_categories'] : null; + } + + /** + * Gets status. + * + * @return string|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * Sets status. + * + * @param string|null $status Indicates whether the transaction is eligible for seller protection. For information, see [PayPal Seller Protection for Merchants](https://www.paypal.com/us/webapps/mpp/security/seller-protection). + * + * @return $this + */ + public function setStatus($status = null) + { + $this->status = $status; + + return $this; + } + + /** + * Gets dispute_categories. + * + * @return string[]|null + */ + public function getDisputeCategories() + { + return $this->dispute_categories; + } + + /** + * Sets dispute_categories. + * + * @param string[]|null $dispute_categories an array of conditions that are covered for the transaction + * + * @return $this + */ + public function setDisputeCategories(array $dispute_categories = null) + { + $this->dispute_categories = $dispute_categories; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/SellerReceivableBreakdown.php b/src/PayPal/Order/DTO/SellerReceivableBreakdown.php new file mode 100644 index 000000000..4b231a41d --- /dev/null +++ b/src/PayPal/Order/DTO/SellerReceivableBreakdown.php @@ -0,0 +1,245 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class SellerReceivableBreakdown +{ + /** + * @var Amount + */ + protected $gross_amount; + + /** + * @var Amount|null + */ + protected $paypal_fee; + + /** + * @var Amount|null + */ + protected $paypal_fee_in_receivable_currency; + + /** + * @var Amount|null + */ + protected $net_amount; + + /** + * @var Amount|null + */ + protected $receivable_amount; + + /** + * @var ExchangeRate|null + */ + protected $exchange_rate; + + /** + * An array of platform or partner fees, commissions, or brokerage fees that associated with the captured payment. + * + * @var PlatformFee[]|null + */ + protected $platform_fees; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->gross_amount = isset($data['gross_amount']) ? $data['gross_amount'] : null; + $this->paypal_fee = isset($data['paypal_fee']) ? $data['paypal_fee'] : null; + $this->paypal_fee_in_receivable_currency = isset($data['paypal_fee_in_receivable_currency']) ? $data['paypal_fee_in_receivable_currency'] : null; + $this->net_amount = isset($data['net_amount']) ? $data['net_amount'] : null; + $this->receivable_amount = isset($data['receivable_amount']) ? $data['receivable_amount'] : null; + $this->exchange_rate = isset($data['exchange_rate']) ? $data['exchange_rate'] : null; + $this->platform_fees = isset($data['platform_fees']) ? $data['platform_fees'] : null; + } + + /** + * Gets gross_amount. + * + * @return Amount + */ + public function getGrossAmount() + { + return $this->gross_amount; + } + + /** + * Sets gross_amount. + * + * @param Amount $gross_amount + * + * @return $this + */ + public function setGrossAmount(Amount $gross_amount) + { + $this->gross_amount = $gross_amount; + + return $this; + } + + /** + * Gets paypal_fee. + * + * @return Amount|null + */ + public function getPaypalFee() + { + return $this->paypal_fee; + } + + /** + * Sets paypal_fee. + * + * @param Amount|null $paypal_fee + * + * @return $this + */ + public function setPaypalFee(Amount $paypal_fee = null) + { + $this->paypal_fee = $paypal_fee; + + return $this; + } + + /** + * Gets paypal_fee_in_receivable_currency. + * + * @return Amount|null + */ + public function getPaypalFeeInReceivableCurrency() + { + return $this->paypal_fee_in_receivable_currency; + } + + /** + * Sets paypal_fee_in_receivable_currency. + * + * @param Amount|null $paypal_fee_in_receivable_currency + * + * @return $this + */ + public function setPaypalFeeInReceivableCurrency(Amount $paypal_fee_in_receivable_currency = null) + { + $this->paypal_fee_in_receivable_currency = $paypal_fee_in_receivable_currency; + + return $this; + } + + /** + * Gets net_amount. + * + * @return Amount|null + */ + public function getNetAmount() + { + return $this->net_amount; + } + + /** + * Sets net_amount. + * + * @param Amount|null $net_amount + * + * @return $this + */ + public function setNetAmount(Amount $net_amount = null) + { + $this->net_amount = $net_amount; + + return $this; + } + + /** + * Gets receivable_amount. + * + * @return Amount|null + */ + public function getReceivableAmount() + { + return $this->receivable_amount; + } + + /** + * Sets receivable_amount. + * + * @param Amount|null $receivable_amount + * + * @return $this + */ + public function setReceivableAmount(Amount $receivable_amount = null) + { + $this->receivable_amount = $receivable_amount; + + return $this; + } + + /** + * Gets exchange_rate. + * + * @return ExchangeRate|null + */ + public function getExchangeRate() + { + return $this->exchange_rate; + } + + /** + * Sets exchange_rate. + * + * @param ExchangeRate|null $exchange_rate + * + * @return $this + */ + public function setExchangeRate(ExchangeRate $exchange_rate = null) + { + $this->exchange_rate = $exchange_rate; + + return $this; + } + + /** + * Gets platform_fees. + * + * @return PlatformFee[]|null + */ + public function getPlatformFees() + { + return $this->platform_fees; + } + + /** + * Sets platform_fees. + * + * @param PlatformFee[]|null $platform_fees an array of platform or partner fees, commissions, or brokerage fees that associated with the captured payment + * + * @return $this + */ + public function setPlatformFees(array $platform_fees = null) + { + $this->platform_fees = $platform_fees; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/ShippingOption.php b/src/PayPal/Order/DTO/ShippingOption.php new file mode 100644 index 000000000..0b0f18bc0 --- /dev/null +++ b/src/PayPal/Order/DTO/ShippingOption.php @@ -0,0 +1,189 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class ShippingOption +{ + /** + * A unique ID that identifies a payer-selected shipping option. + * + * @var string + */ + protected $id; + + /** + * A description that the payer sees, which helps them choose an appropriate shipping option. For example, `Free Shipping`, `USPS Priority Shipping`, `Expédition prioritaire USPS`, or `USPS yōuxiān fā huò`. Localize this description to the payer's locale. + * + * @var string + */ + protected $label; + + /** + * If the API request sets `selected = true`, it represents the shipping option that the payee or merchant expects to be pre-selected for the payer when they first view the `shipping.options` in the PayPal Checkout experience. As part of the response if a `shipping.option` contains `selected=true`, it represents the shipping option that the payer selected during the course of checkout with PayPal. Only one `shipping.option` can be set to `selected=true`. + * + * @var bool + */ + protected $selected; + + /** + * @var string|null + */ + protected $type; + + /** + * @var Amount|null + */ + protected $amount; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->id = isset($data['id']) ? $data['id'] : null; + $this->label = isset($data['label']) ? $data['label'] : null; + $this->selected = isset($data['selected']) ? $data['selected'] : null; + $this->type = isset($data['type']) ? $data['type'] : null; + $this->amount = isset($data['amount']) ? $data['amount'] : null; + } + + /** + * Gets id. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param string $id a unique ID that identifies a payer-selected shipping option + * + * @return $this + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Gets label. + * + * @return string + */ + public function getLabel() + { + return $this->label; + } + + /** + * Sets label. + * + * @param string $label A description that the payer sees, which helps them choose an appropriate shipping option. For example, `Free Shipping`, `USPS Priority Shipping`, `Expédition prioritaire USPS`, or `USPS yōuxiān fā huò`. Localize this description to the payer's locale. + * + * @return $this + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * Gets selected. + * + * @return bool + */ + public function isSelected() + { + return $this->selected; + } + + /** + * Sets selected. + * + * @param bool $selected If the API request sets `selected = true`, it represents the shipping option that the payee or merchant expects to be pre-selected for the payer when they first view the `shipping.options` in the PayPal Checkout experience. As part of the response if a `shipping.option` contains `selected=true`, it represents the shipping option that the payer selected during the course of checkout with PayPal. Only one `shipping.option` can be set to `selected=true`. + * + * @return $this + */ + public function setSelected($selected) + { + $this->selected = $selected; + + return $this; + } + + /** + * Gets type. + * + * @return string|null + */ + public function getType() + { + return $this->type; + } + + /** + * Sets type. + * + * @param string|null $type + * + * @return $this + */ + public function setType($type = null) + { + $this->type = $type; + + return $this; + } + + /** + * Gets amount. + * + * @return Amount|null + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Sets amount. + * + * @param Amount|null $amount + * + * @return $this + */ + public function setAmount(Amount $amount = null) + { + $this->amount = $amount; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/ShippingOptionRequest.php b/src/PayPal/Order/DTO/ShippingOptionRequest.php new file mode 100644 index 000000000..ca15231e8 --- /dev/null +++ b/src/PayPal/Order/DTO/ShippingOptionRequest.php @@ -0,0 +1,135 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class ShippingOptionRequest +{ + /** + * @var string + */ + private $id; + /** + * @var string + */ + private $label; + /** + * @var string + */ + private $type; + /** + * @var Amount + */ + private $amount; + /** + * @var bool + */ + private $selected; + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $id + * + * @return void + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * @return string + */ + public function getLabel() + { + return $this->label; + } + + /** + * @param string $label + * + * @return void + */ + public function setLabel($label) + { + $this->label = $label; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + * + * @return void + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @return Amount + */ + public function getAmount() + { + return $this->amount; + } + + /** + * @param Amount $amount + * + * @return void + */ + public function setAmount(Amount $amount) + { + $this->amount = $amount; + } + + /** + * @return bool + */ + public function isSelected() + { + return $this->selected; + } + + /** + * @param bool $selected + * + * @return void + */ + public function setSelected($selected) + { + $this->selected = $selected; + } +} diff --git a/src/PayPal/Order/DTO/ShippingRequest.php b/src/PayPal/Order/DTO/ShippingRequest.php new file mode 100644 index 000000000..92061c8e5 --- /dev/null +++ b/src/PayPal/Order/DTO/ShippingRequest.php @@ -0,0 +1,113 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class ShippingRequest +{ + /** + * @var Name + */ + private $name; + /** + * @var string + */ + private $type; + /** + * @var ShippingOptionRequest[] + */ + private $options; + /** + * @var AddressRequest + */ + private $address; + + /** + * @return Name + */ + public function getName() + { + return $this->name; + } + + /** + * @param Name $name + * + * @return void + */ + public function setName(Name $name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + * + * @return void + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @return ShippingOptionRequest[] + */ + public function getOptions() + { + return $this->options; + } + + /** + * @param ShippingOptionRequest[] $options + * + * @return void + */ + public function setOptions(array $options) + { + $this->options = $options; + } + + /** + * @return AddressRequest + */ + public function getAddress() + { + return $this->address; + } + + /** + * @param AddressRequest $address + * + * @return void + */ + public function setAddress(AddressRequest $address) + { + $this->address = $address; + } +} diff --git a/src/PayPal/Order/DTO/ShippingWithTrackingDetails.php b/src/PayPal/Order/DTO/ShippingWithTrackingDetails.php new file mode 100644 index 000000000..e854871fe --- /dev/null +++ b/src/PayPal/Order/DTO/ShippingWithTrackingDetails.php @@ -0,0 +1,189 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class ShippingWithTrackingDetails +{ + /** + * @var Name|null + */ + protected $name; + + /** + * The method by which the payer wants to get their items from the payee e.g shipping, in-person pickup. Either type or options but not both may be present. + * + * @var string|null + */ + protected $type; + + /** + * An array of shipping options that the payee or merchant offers to the payer to ship or pick up their items. + * + * @var ShippingOption[]|null + */ + protected $options; + + /** + * @var AddressRequest|null + */ + protected $address; + + /** + * An array of trackers for a transaction. + * + * @var Tracker[]|null + */ + protected $trackers; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->type = isset($data['type']) ? $data['type'] : null; + $this->options = isset($data['options']) ? $data['options'] : null; + $this->address = isset($data['address']) ? $data['address'] : null; + $this->trackers = isset($data['trackers']) ? $data['trackers'] : null; + } + + /** + * Gets name. + * + * @return Name|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param Name|null $name + * + * @return $this + */ + public function setName(Name $name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets type. + * + * @return string|null + */ + public function getType() + { + return $this->type; + } + + /** + * Sets type. + * + * @param string|null $type The method by which the payer wants to get their items from the payee e.g shipping, in-person pickup. Either type or options but not both may be present. + * + * @return $this + */ + public function setType($type = null) + { + $this->type = $type; + + return $this; + } + + /** + * Gets options. + * + * @return ShippingOption[]|null + */ + public function getOptions() + { + return $this->options; + } + + /** + * Sets options. + * + * @param ShippingOption[]|null $options an array of shipping options that the payee or merchant offers to the payer to ship or pick up their items + * + * @return $this + */ + public function setOptions(array $options = null) + { + $this->options = $options; + + return $this; + } + + /** + * Gets address. + * + * @return AddressRequest|null + */ + public function getAddress() + { + return $this->address; + } + + /** + * Sets address. + * + * @param AddressRequest|null $address + * + * @return $this + */ + public function setAddress(AddressRequest $address = null) + { + $this->address = $address; + + return $this; + } + + /** + * Gets trackers. + * + * @return Tracker[]|null + */ + public function getTrackers() + { + return $this->trackers; + } + + /** + * Sets trackers. + * + * @param Tracker[]|null $trackers an array of trackers for a transaction + * + * @return $this + */ + public function setTrackers(array $trackers = null) + { + $this->trackers = $trackers; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/Sofort.php b/src/PayPal/Order/DTO/Sofort.php new file mode 100644 index 000000000..253f13dbc --- /dev/null +++ b/src/PayPal/Order/DTO/Sofort.php @@ -0,0 +1,161 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Sofort +{ + /** + * The full name representation like Mr J Smith. + * + * @var string|null + */ + protected $name; + + /** + * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> + * + * @var string|null + */ + protected $country_code; + + /** + * The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @var string|null + */ + protected $bic; + + /** + * The last characters of the IBAN used to pay. + * + * @var string|null + */ + protected $iban_last_chars; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->country_code = isset($data['country_code']) ? $data['country_code'] : null; + $this->bic = isset($data['bic']) ? $data['bic'] : null; + $this->iban_last_chars = isset($data['iban_last_chars']) ? $data['iban_last_chars'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the full name representation like Mr J Smith + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets country_code. + * + * @return string|null + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Sets country_code. + * + * @param string|null $country_code The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setCountryCode($country_code = null) + { + $this->country_code = $country_code; + + return $this; + } + + /** + * Gets bic. + * + * @return string|null + */ + public function getBic() + { + return $this->bic; + } + + /** + * Sets bic. + * + * @param string|null $bic The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @return $this + */ + public function setBic($bic = null) + { + $this->bic = $bic; + + return $this; + } + + /** + * Gets iban_last_chars. + * + * @return string|null + */ + public function getIbanLastChars() + { + return $this->iban_last_chars; + } + + /** + * Sets iban_last_chars. + * + * @param string|null $iban_last_chars the last characters of the IBAN used to pay + * + * @return $this + */ + public function setIbanLastChars($iban_last_chars = null) + { + $this->iban_last_chars = $iban_last_chars; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/SofortRequest.php b/src/PayPal/Order/DTO/SofortRequest.php new file mode 100644 index 000000000..b2bf26508 --- /dev/null +++ b/src/PayPal/Order/DTO/SofortRequest.php @@ -0,0 +1,91 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class SofortRequest +{ + /** + * @var string + */ + private $name; + /** + * @var string + */ + private $country_code; + /** + * @var ExperienceContextRequest + */ + private $experience_context; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * @param string $country_code + * + * @return void + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + } + + /** + * @return ExperienceContextRequest + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param ExperienceContextRequest $experience_context + * + * @return void + */ + public function setExperienceContext(ExperienceContextRequest $experience_context) + { + $this->experience_context = $experience_context; + } +} diff --git a/src/PayPal/Order/DTO/StoredPaymentSourceRequest.php b/src/PayPal/Order/DTO/StoredPaymentSourceRequest.php new file mode 100644 index 000000000..c194d77eb --- /dev/null +++ b/src/PayPal/Order/DTO/StoredPaymentSourceRequest.php @@ -0,0 +1,113 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class StoredPaymentSourceRequest +{ + /** + * @var string + */ + private $payment_initiator; + /** + * @var string + */ + private $payment_type; + /** + * @var string + */ + private $usage; + /** + * @var PreviousNetworkTransactionReferenceRequest + */ + private $previous_network_transaction_reference; + + /** + * @return string + */ + public function getPaymentInitiator() + { + return $this->payment_initiator; + } + + /** + * @param string $payment_initiator + * + * @return void + */ + public function setPaymentInitiator($payment_initiator) + { + $this->payment_initiator = $payment_initiator; + } + + /** + * @return string + */ + public function getPaymentType() + { + return $this->payment_type; + } + + /** + * @param string $payment_type + * + * @return void + */ + public function setPaymentType($payment_type) + { + $this->payment_type = $payment_type; + } + + /** + * @return string + */ + public function getUsage() + { + return $this->usage; + } + + /** + * @param string $usage + * + * @return void + */ + public function setUsage($usage) + { + $this->usage = $usage; + } + + /** + * @return PreviousNetworkTransactionReferenceRequest + */ + public function getPreviousNetworkTransactionReference() + { + return $this->previous_network_transaction_reference; + } + + /** + * @param PreviousNetworkTransactionReferenceRequest $previous_network_transaction_reference + * + * @return void + */ + public function setPreviousNetworkTransactionReference(PreviousNetworkTransactionReferenceRequest $previous_network_transaction_reference) + { + $this->previous_network_transaction_reference = $previous_network_transaction_reference; + } +} diff --git a/src/PayPal/Order/DTO/SupplementaryData.php b/src/PayPal/Order/DTO/SupplementaryData.php new file mode 100644 index 000000000..a1122f49f --- /dev/null +++ b/src/PayPal/Order/DTO/SupplementaryData.php @@ -0,0 +1,63 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class SupplementaryData +{ + /** + * @var CardSupplementaryData|null + */ + protected $card; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->card = isset($data['card']) ? $data['card'] : null; + } + + /** + * Gets card. + * + * @return CardSupplementaryData|null + */ + public function getCard() + { + return $this->card; + } + + /** + * Sets card. + * + * @param CardSupplementaryData|null $card + * + * @return $this + */ + public function setCard(CardSupplementaryData $card = null) + { + $this->card = $card; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/SupplementaryDataRequest.php b/src/PayPal/Order/DTO/SupplementaryDataRequest.php new file mode 100644 index 000000000..5e848be5a --- /dev/null +++ b/src/PayPal/Order/DTO/SupplementaryDataRequest.php @@ -0,0 +1,47 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class SupplementaryDataRequest +{ + /** + * @var CardSupplementaryDataRequest + */ + private $card; + + /** + * @return CardSupplementaryDataRequest + */ + public function getCard() + { + return $this->card; + } + + /** + * @param CardSupplementaryDataRequest $card + * + * @return void + */ + public function setCard(CardSupplementaryDataRequest $card) + { + $this->card = $card; + } +} diff --git a/src/PayPal/Order/DTO/TaxInfo.php b/src/PayPal/Order/DTO/TaxInfo.php new file mode 100644 index 000000000..63547ecb5 --- /dev/null +++ b/src/PayPal/Order/DTO/TaxInfo.php @@ -0,0 +1,69 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class TaxInfo +{ + /** + * @var string + */ + private $tax_id; + /** + * @var string + */ + private $tax_id_type; + + /** + * @return string + */ + public function getTaxId() + { + return $this->tax_id; + } + + /** + * @param string $tax_id + * + * @return void + */ + public function setTaxId($tax_id) + { + $this->tax_id = $tax_id; + } + + /** + * @return string + */ + public function getTaxIdType() + { + return $this->tax_id_type; + } + + /** + * @param string $tax_id_type + * + * @return void + */ + public function setTaxIdType($tax_id_type) + { + $this->tax_id_type = $tax_id_type; + } +} diff --git a/src/PayPal/Order/DTO/ThreeDSecureAuthenticationResponse.php b/src/PayPal/Order/DTO/ThreeDSecureAuthenticationResponse.php new file mode 100644 index 000000000..05ccb3d5d --- /dev/null +++ b/src/PayPal/Order/DTO/ThreeDSecureAuthenticationResponse.php @@ -0,0 +1,93 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class ThreeDSecureAuthenticationResponse +{ + /** + * @var string|null + */ + protected $authentication_status; + + /** + * @var string|null + */ + protected $enrollment_status; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->authentication_status = isset($data['authentication_status']) ? $data['authentication_status'] : null; + $this->enrollment_status = isset($data['enrollment_status']) ? $data['enrollment_status'] : null; + } + + /** + * Gets authentication_status. + * + * @return string|null + */ + public function getAuthenticationStatus() + { + return $this->authentication_status; + } + + /** + * Sets authentication_status. + * + * @param string|null $authentication_status + * + * @return $this + */ + public function setAuthenticationStatus($authentication_status = null) + { + $this->authentication_status = $authentication_status; + + return $this; + } + + /** + * Gets enrollment_status. + * + * @return string|null + */ + public function getEnrollmentStatus() + { + return $this->enrollment_status; + } + + /** + * Sets enrollment_status. + * + * @param string|null $enrollment_status + * + * @return $this + */ + public function setEnrollmentStatus($enrollment_status = null) + { + $this->enrollment_status = $enrollment_status; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/TokenRequest.php b/src/PayPal/Order/DTO/TokenRequest.php new file mode 100644 index 000000000..3fd7c13c6 --- /dev/null +++ b/src/PayPal/Order/DTO/TokenRequest.php @@ -0,0 +1,69 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class TokenRequest +{ + /** + * @var string + */ + private $id; + /** + * @var string + */ + private $type; + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $id + * + * @return void + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + * + * @return void + */ + public function setType($type) + { + $this->type = $type; + } +} diff --git a/src/PayPal/Order/DTO/Tracker.php b/src/PayPal/Order/DTO/Tracker.php new file mode 100644 index 000000000..3261332d4 --- /dev/null +++ b/src/PayPal/Order/DTO/Tracker.php @@ -0,0 +1,223 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Tracker +{ + /** + * The tracker id. + * + * @var string|null + */ + protected $id; + + /** + * @var mixed|null + */ + protected $status; + + /** + * An array of details of items in the shipment. + * + * @var TrackerItem[]|null + */ + protected $items; + + /** + * An array of request-related HATEOAS links. + * + * @var LinkDescription[]|null + */ + protected $links; + + /** + * The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote> + * + * @var string|null + */ + protected $create_time; + + /** + * The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote> + * + * @var string|null + */ + protected $update_time; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->id = isset($data['id']) ? $data['id'] : null; + $this->status = isset($data['status']) ? $data['status'] : null; + $this->items = isset($data['items']) ? $data['items'] : null; + $this->links = isset($data['links']) ? $data['links'] : null; + $this->create_time = isset($data['create_time']) ? $data['create_time'] : null; + $this->update_time = isset($data['update_time']) ? $data['update_time'] : null; + } + + /** + * Gets id. + * + * @return string|null + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param string|null $id the tracker id + * + * @return $this + */ + public function setId($id = null) + { + $this->id = $id; + + return $this; + } + + /** + * Gets status. + * + * @return mixed|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * Sets status. + * + * @param mixed|null $status + * + * @return $this + */ + public function setStatus($status = null) + { + $this->status = $status; + + return $this; + } + + /** + * Gets items. + * + * @return TrackerItem[]|null + */ + public function getItems() + { + return $this->items; + } + + /** + * Sets items. + * + * @param TrackerItem[]|null $items an array of details of items in the shipment + * + * @return $this + */ + public function setItems(array $items = null) + { + $this->items = $items; + + return $this; + } + + /** + * Gets links. + * + * @return LinkDescription[]|null + */ + public function getLinks() + { + return $this->links; + } + + /** + * Sets links. + * + * @param LinkDescription[]|null $links an array of request-related HATEOAS links + * + * @return $this + */ + public function setLinks(array $links = null) + { + $this->links = $links; + + return $this; + } + + /** + * Gets create_time. + * + * @return string|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Sets create_time. + * + * @param string|null $create_time The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: The regular expression provides guidance but does not reject all invalid dates.+ * + * @return $this + */ + public function setCreateTime($create_time = null) + { + $this->create_time = $create_time; + + return $this; + } + + /** + * Gets update_time. + * + * @return string|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Sets update_time. + * + * @param string|null $update_time The date and time, in [Internet date and time format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds are required while fractional seconds are optional.
Note: The regular expression provides guidance but does not reject all invalid dates.+ * + * @return $this + */ + public function setUpdateTime($update_time = null) + { + $this->update_time = $update_time; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/TrackerItem.php b/src/PayPal/Order/DTO/TrackerItem.php new file mode 100644 index 000000000..67165d4a7 --- /dev/null +++ b/src/PayPal/Order/DTO/TrackerItem.php @@ -0,0 +1,187 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class TrackerItem +{ + /** + * The item name or title. + * + * @var string|null + */ + protected $name; + /** + * The item quantity. Must be a whole number. + * + * @var string|null + */ + protected $quantity; + /** + * The stock keeping unit (SKU) for the item. This can contain unicode characters. + * + * @var string|null + */ + protected $sku; + /** + * The URL of the item's image. File type and size restrictions apply. An image that violates these restrictions will not be honored. + * + * @var string|null + */ + protected $image_url; + /** + * @var mixed|null + */ + protected $upc; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->quantity = isset($data['quantity']) ? $data['quantity'] : null; + $this->sku = isset($data['sku']) ? $data['sku'] : null; + $this->image_url = isset($data['image_url']) ? $data['image_url'] : null; + $this->upc = isset($data['upc']) ? $data['upc'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the item name or title + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets quantity. + * + * @return string|null + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * Sets quantity. + * + * @param string|null $quantity The item quantity. Must be a whole number. + * + * @return $this + */ + public function setQuantity($quantity = null) + { + $this->quantity = $quantity; + + return $this; + } + + /** + * Gets sku. + * + * @return string|null + */ + public function getSku() + { + return $this->sku; + } + + /** + * Sets sku. + * + * @param string|null $sku The stock keeping unit (SKU) for the item. This can contain unicode characters. + * + * @return $this + */ + public function setSku($sku = null) + { + $this->sku = $sku; + + return $this; + } + + /** + * Gets image_url. + * + * @return string|null + */ + public function getImageUrl() + { + return $this->image_url; + } + + /** + * Sets image_url. + * + * @param string|null $image_url The URL of the item's image. File type and size restrictions apply. An image that violates these restrictions will not be honored. + * + * @return $this + */ + public function setImageUrl($image_url = null) + { + $this->image_url = $image_url; + + return $this; + } + + /** + * Gets upc. + * + * @return mixed|null + */ + public function getUpc() + { + return $this->upc; + } + + /** + * Sets upc. + * + * @param mixed|null $upc + * + * @return $this + */ + public function setUpc($upc = null) + { + $this->upc = $upc; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/Trustly.php b/src/PayPal/Order/DTO/Trustly.php new file mode 100644 index 000000000..07dc6d00e --- /dev/null +++ b/src/PayPal/Order/DTO/Trustly.php @@ -0,0 +1,161 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class Trustly +{ + /** + * The full name representation like Mr J Smith. + * + * @var string|null + */ + protected $name; + + /** + * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.<blockquote><strong>Note:</strong> The country code for Great Britain is <code>GB</code> and not <code>UK</code> as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.</blockquote> + * + * @var string|null + */ + protected $country_code; + + /** + * The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @var string|null + */ + protected $bic; + + /** + * The last characters of the IBAN used to pay. + * + * @var string|null + */ + protected $iban_last_chars; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->name = isset($data['name']) ? $data['name'] : null; + $this->country_code = isset($data['country_code']) ? $data['country_code'] : null; + $this->bic = isset($data['bic']) ? $data['bic'] : null; + $this->iban_last_chars = isset($data['iban_last_chars']) ? $data['iban_last_chars'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name the full name representation like Mr J Smith + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets country_code. + * + * @return string|null + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Sets country_code. + * + * @param string|null $country_code The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country or region.
Note: The country code for Great Britain is+ * + * @return $this + */ + public function setCountryCode($country_code = null) + { + $this->country_code = $country_code; + + return $this; + } + + /** + * Gets bic. + * + * @return string|null + */ + public function getBic() + { + return $this->bic; + } + + /** + * Sets bic. + * + * @param string|null $bic The business identification code (BIC). In payments systems, a BIC is used to identify a specific business, most commonly a bank. + * + * @return $this + */ + public function setBic($bic = null) + { + $this->bic = $bic; + + return $this; + } + + /** + * Gets iban_last_chars. + * + * @return string|null + */ + public function getIbanLastChars() + { + return $this->iban_last_chars; + } + + /** + * Sets iban_last_chars. + * + * @param string|null $iban_last_chars the last characters of the IBAN used to pay + * + * @return $this + */ + public function setIbanLastChars($iban_last_chars = null) + { + $this->iban_last_chars = $iban_last_chars; + + return $this; + } +} diff --git a/src/ExpressCheckout/ExpressCheckout.php b/src/PayPal/Order/DTO/UpdatePayPalOrderRequestInterface.php similarity index 73% rename from src/ExpressCheckout/ExpressCheckout.php rename to src/PayPal/Order/DTO/UpdatePayPalOrderRequestInterface.php index 5fc0f13d9..96488cc92 100644 --- a/src/ExpressCheckout/ExpressCheckout.php +++ b/src/PayPal/Order/DTO/UpdatePayPalOrderRequestInterface.php @@ -18,11 +18,8 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace PrestaShop\Module\PrestashopCheckout\ExpressCheckout; +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; -class ExpressCheckout +interface UpdatePayPalOrderRequestInterface { - const PS_CHECKOUT_EC_PRODUCT_PAGE = 'PS_CHECKOUT_EC_PRODUCT_PAGE'; - const PS_CHECKOUT_EC_ORDER_PAGE = 'PS_CHECKOUT_EC_ORDER_PAGE'; - const PS_CHECKOUT_EC_CHECKOUT_PAGE = 'PS_CHECKOUT_EC_CHECKOUT_PAGE'; } diff --git a/src/PayPal/Order/DTO/VaultAttributesRequest.php b/src/PayPal/Order/DTO/VaultAttributesRequest.php new file mode 100644 index 000000000..4e201217f --- /dev/null +++ b/src/PayPal/Order/DTO/VaultAttributesRequest.php @@ -0,0 +1,47 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class VaultAttributesRequest +{ + /** + * @var string + */ + public $store_in_vault; + + /** + * @return string + */ + public function getStoreInVault() + { + return $this->store_in_vault; + } + + /** + * @param string $store_in_vault + * + * @return void + */ + public function setStoreInVault($store_in_vault) + { + $this->store_in_vault = $store_in_vault; + } +} diff --git a/src/PayPal/Order/DTO/VaultResponse.php b/src/PayPal/Order/DTO/VaultResponse.php new file mode 100644 index 000000000..7432a4d41 --- /dev/null +++ b/src/PayPal/Order/DTO/VaultResponse.php @@ -0,0 +1,159 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class VaultResponse +{ + /** + * The PayPal-generated ID for the saved payment source. + * + * @var string|null + */ + protected $id; + + /** + * The vault status. + * + * @var string|null + */ + protected $status; + + /** + * @var Customer|null + */ + protected $customer; + + /** + * An array of request-related HATEOAS links. + * + * @var LinkDescription[]|null + */ + protected $links; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->id = isset($data['id']) ? $data['id'] : null; + $this->status = isset($data['status']) ? $data['status'] : null; + $this->customer = isset($data['customer']) ? $data['customer'] : null; + $this->links = isset($data['links']) ? $data['links'] : null; + } + + /** + * Gets id. + * + * @return string|null + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id. + * + * @param string|null $id the PayPal-generated ID for the saved payment source + * + * @return $this + */ + public function setId($id = null) + { + $this->id = $id; + + return $this; + } + + /** + * Gets status. + * + * @return string|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * Sets status. + * + * @param string|null $status the vault status + * + * @return $this + */ + public function setStatus($status = null) + { + $this->status = $status; + + return $this; + } + + /** + * Gets customer. + * + * @return Customer|null + */ + public function getCustomer() + { + return $this->customer; + } + + /** + * Sets customer. + * + * @param Customer|null $customer + * + * @return $this + */ + public function setCustomer(Customer $customer = null) + { + $this->customer = $customer; + + return $this; + } + + /** + * Gets links. + * + * @return LinkDescription[]|null + */ + public function getLinks() + { + return $this->links; + } + + /** + * Sets links. + * + * @param LinkDescription[]|null $links an array of request-related HATEOAS links + * + * @return $this + */ + public function setLinks(array $links = null) + { + $this->links = $links; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/VenmoExperienceContextRequest.php b/src/PayPal/Order/DTO/VenmoExperienceContextRequest.php new file mode 100644 index 000000000..d68da7fde --- /dev/null +++ b/src/PayPal/Order/DTO/VenmoExperienceContextRequest.php @@ -0,0 +1,69 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class VenmoExperienceContextRequest +{ + /** + * @var string + */ + private $brand_name; + /** + * @var string + */ + private $shipping_preference; + + /** + * @return string + */ + public function getBrandName() + { + return $this->brand_name; + } + + /** + * @param string $brand_name + * + * @return void + */ + public function setBrandName($brand_name) + { + $this->brand_name = $brand_name; + } + + /** + * @return string + */ + public function getShippingPreference() + { + return $this->shipping_preference; + } + + /** + * @param string $shipping_preference + * + * @return void + */ + public function setShippingPreference($shipping_preference) + { + $this->shipping_preference = $shipping_preference; + } +} diff --git a/src/PayPal/Order/DTO/VenmoRequest.php b/src/PayPal/Order/DTO/VenmoRequest.php new file mode 100644 index 000000000..7976829da --- /dev/null +++ b/src/PayPal/Order/DTO/VenmoRequest.php @@ -0,0 +1,113 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class VenmoRequest +{ + /** + * @var string + */ + private $vault_id; + /** + * @var string + */ + private $email_address; + /** + * @var VenmoExperienceContextRequest + */ + private $experience_context; + /** + * @var PayPalWalletAttributesRequest + */ + private $attributes; + + /** + * @return string + */ + public function getVaultId() + { + return $this->vault_id; + } + + /** + * @param string $vault_id + * + * @return void + */ + public function setVaultId($vault_id) + { + $this->vault_id = $vault_id; + } + + /** + * @return string + */ + public function getEmailAddress() + { + return $this->email_address; + } + + /** + * @param string $email_address + * + * @return void + */ + public function setEmailAddress($email_address) + { + $this->email_address = $email_address; + } + + /** + * @return VenmoExperienceContextRequest + */ + public function getExperienceContext() + { + return $this->experience_context; + } + + /** + * @param VenmoExperienceContextRequest $experience_context + * + * @return void + */ + public function setExperienceContext(VenmoExperienceContextRequest $experience_context) + { + $this->experience_context = $experience_context; + } + + /** + * @return PayPalWalletAttributesRequest + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param PayPalWalletAttributesRequest $attributes + * + * @return void + */ + public function setAttributes(PayPalWalletAttributesRequest $attributes) + { + $this->attributes = $attributes; + } +} diff --git a/src/PayPal/Order/DTO/VenmoWalletAttributesResponse.php b/src/PayPal/Order/DTO/VenmoWalletAttributesResponse.php new file mode 100644 index 000000000..95f106e6f --- /dev/null +++ b/src/PayPal/Order/DTO/VenmoWalletAttributesResponse.php @@ -0,0 +1,63 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class VenmoWalletAttributesResponse +{ + /** + * @var VaultResponse|null + */ + protected $vault; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->vault = isset($data['vault']) ? $data['vault'] : null; + } + + /** + * Gets vault. + * + * @return VaultResponse|null + */ + public function getVault() + { + return $this->vault; + } + + /** + * Sets vault. + * + * @param VaultResponse|null $vault + * + * @return $this + */ + public function setVault(VaultResponse $vault = null) + { + $this->vault = $vault; + + return $this; + } +} diff --git a/src/PayPal/Order/DTO/VenmoWalletResponse.php b/src/PayPal/Order/DTO/VenmoWalletResponse.php new file mode 100644 index 000000000..27eafa2cf --- /dev/null +++ b/src/PayPal/Order/DTO/VenmoWalletResponse.php @@ -0,0 +1,249 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO; + +class VenmoWalletResponse +{ + /** + * The internationalized email address.<blockquote><strong>Note:</strong> Up to 64 characters are allowed before and 255 characters are allowed after the <code>@</code> sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted <code>@</code> sign exists.</blockquote> + * + * @var string|null + */ + protected $email_address; + + /** + * The PayPal payer ID, which is a masked version of the PayPal account number intended for use with third parties. The account number is reversibly encrypted and a proprietary variant of Base32 is used to encode the result. + * + * @var string|null + */ + protected $account_id; + + /** + * The Venmo user name chosen by the user, also know as a Venmo handle. + * + * @var string|null + */ + protected $user_name; + + /** + * @var Name|null + */ + protected $name; + + /** + * @var Phone|null + */ + protected $phone_number; + + /** + * @var AddressPortable2|null + */ + protected $address; + + /** + * @var VenmoWalletAttributesResponse|null + */ + protected $attributes; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->email_address = isset($data['email_address']) ? $data['email_address'] : null; + $this->account_id = isset($data['account_id']) ? $data['account_id'] : null; + $this->user_name = isset($data['user_name']) ? $data['user_name'] : null; + $this->name = isset($data['name']) ? $data['name'] : null; + $this->phone_number = isset($data['phone_number']) ? $data['phone_number'] : null; + $this->address = isset($data['address']) ? $data['address'] : null; + $this->attributes = isset($data['attributes']) ? $data['attributes'] : null; + } + + /** + * Gets email_address. + * + * @return string|null + */ + public function getEmailAddress() + { + return $this->email_address; + } + + /** + * Sets email_address. + * + * @param string|null $email_address The internationalized email address.GB
and notUK
as used in the top-level domain names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
Note: Up to 64 characters are allowed before and 255 characters are allowed after the+ * + * @return $this + */ + public function setEmailAddress($email_address = null) + { + $this->email_address = $email_address; + + return $this; + } + + /** + * Gets account_id. + * + * @return string|null + */ + public function getAccountId() + { + return $this->account_id; + } + + /** + * Sets account_id. + * + * @param string|null $account_id The PayPal payer ID, which is a masked version of the PayPal account number intended for use with third parties. The account number is reversibly encrypted and a proprietary variant of Base32 is used to encode the result. + * + * @return $this + */ + public function setAccountId($account_id = null) + { + $this->account_id = $account_id; + + return $this; + } + + /** + * Gets user_name. + * + * @return string|null + */ + public function getUserName() + { + return $this->user_name; + } + + /** + * Sets user_name. + * + * @param string|null $user_name the Venmo user name chosen by the user, also know as a Venmo handle + * + * @return $this + */ + public function setUserName($user_name = null) + { + $this->user_name = $user_name; + + return $this; + } + + /** + * Gets name. + * + * @return Name|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param Name|null $name + * + * @return $this + */ + public function setName(Name $name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets phone_number. + * + * @return Phone|null + */ + public function getPhoneNumber() + { + return $this->phone_number; + } + + /** + * Sets phone_number. + * + * @param Phone|null $phone_number + * + * @return $this + */ + public function setPhoneNumber(Phone $phone_number = null) + { + $this->phone_number = $phone_number; + + return $this; + } + + /** + * Gets address. + * + * @return AddressPortable2|null + */ + public function getAddress() + { + return $this->address; + } + + /** + * Sets address. + * + * @param AddressPortable2|null $address + * + * @return $this + */ + public function setAddress(AddressPortable2 $address = null) + { + $this->address = $address; + + return $this; + } + + /** + * Gets attributes. + * + * @return VenmoWalletAttributesResponse|null + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Sets attributes. + * + * @param VenmoWalletAttributesResponse|null $attributes + * + * @return $this + */ + public function setAttributes(VenmoWalletAttributesResponse $attributes = null) + { + $this->attributes = $attributes; + + return $this; + } +} diff --git a/src/Entity/index.php b/src/PayPal/Order/DTO/index.php old mode 100755 new mode 100644 similarity index 100% rename from src/Entity/index.php rename to src/PayPal/Order/DTO/index.php diff --git a/src/PayPal/Sdk/PayPalSdkConfigurationBuilder.php b/src/PayPal/Sdk/PayPalSdkConfigurationBuilder.php index 87fcbdc25..e382ca741 100644 --- a/src/PayPal/Sdk/PayPalSdkConfigurationBuilder.php +++ b/src/PayPal/Sdk/PayPalSdkConfigurationBuilder.php @@ -27,8 +27,8 @@ use PrestaShop\Module\PrestashopCheckout\Environment\Env; use PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration; use PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfigurationRepository; -use PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalGetUserIdTokenQuery; -use PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalGetUserIdTokenQueryResult; +use PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalUserIdTokenQuery; +use PrestaShop\Module\PrestashopCheckout\PayPal\OAuth\Query\GetPayPalUserIdTokenQueryResult; use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration; use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayLaterConfiguration; use PrestaShop\Module\PrestashopCheckout\ShopContext; @@ -81,6 +81,7 @@ class PayPalSdkConfigurationBuilder /** * @param \Ps_checkout $module + * @param Env $env * @param PayPalConfiguration $configuration * @param PayPalPayLaterConfiguration $payLaterConfiguration * @param FundingSourceConfigurationRepository $fundingSourceConfigurationRepository @@ -147,8 +148,8 @@ public function buildConfiguration() if ($this->configuration->isVaultingEnabled() && $this->prestaShopContext->customerIsLogged() && $this->prestaShopContext->getCustomerId() && 'order' === $this->getPageName()) { try { - /** @var GetPayPalGetUserIdTokenQueryResult $queryResult */ - $queryResult = $this->commandBus->handle(new GetPayPalGetUserIdTokenQuery(new CustomerId($this->prestaShopContext->getCustomerId()))); + /** @var GetPayPalUserIdTokenQueryResult $queryResult */ + $queryResult = $this->commandBus->handle(new GetPayPalUserIdTokenQuery(new CustomerId($this->prestaShopContext->getCustomerId()))); $params['dataUserIdToken'] = $queryResult->getUserIdToken(); } catch (Exception $exception) { $this->logger->error('Failed to get PayPal User ID token.', ['exception' => $exception]); diff --git a/src/Presenter/Order/OrderPresenter.php b/src/Presenter/Order/OrderPresenter.php index 9e1a9a076..31d80ad29 100644 --- a/src/Presenter/Order/OrderPresenter.php +++ b/src/Presenter/Order/OrderPresenter.php @@ -42,25 +42,33 @@ class OrderPresenter * @var FundingSourceTranslationProvider */ private $fundingSourceTranslationProvider; + /** + * @var PaymentMethodLogoProvider + */ + private $paymentMethodLogoProvider; /** * @param Ps_checkout $module - * @param array $orderPayPal + * @param FundingSourceTranslationProvider $fundingSourceTranslationProvider + * @param PaymentMethodLogoProvider $paymentMethodLogoProvider */ - public function __construct(Ps_checkout $module, array $orderPayPal) - { + public function __construct( + Ps_checkout $module, + FundingSourceTranslationProvider $fundingSourceTranslationProvider, + PaymentMethodLogoProvider $paymentMethodLogoProvider + ) { $this->module = $module; - $this->orderPayPal = $orderPayPal; - /** @var FundingSourceTranslationProvider $fundingSourceTranslationProvider */ - $fundingSourceTranslationProvider = $this->module->getService(FundingSourceTranslationProvider::class); $this->fundingSourceTranslationProvider = $fundingSourceTranslationProvider; + $this->paymentMethodLogoProvider = $paymentMethodLogoProvider; } /** * @return array */ - public function present() + public function present(array $orderPayPal) { + $this->orderPayPal = $orderPayPal; + if (empty($this->orderPayPal)) { return []; } @@ -382,7 +390,7 @@ private function getPaymentSourceName(array $orderPayPal) private function getPaymentSourceLogo(array $orderPayPal) { if (isset($orderPayPal['payment_source'])) { - return (new PaymentMethodLogoProvider($this->module))->getLogoByPaymentSource($orderPayPal['payment_source']); + return $this->paymentMethodLogoProvider->getLogoByPaymentSource($orderPayPal['payment_source']); } return ''; diff --git a/src/Presenter/Store/Modules/ConfigurationModule.php b/src/Presenter/Store/Modules/ConfigurationModule.php index 8b8dc9284..7a9fb7472 100644 --- a/src/Presenter/Store/Modules/ConfigurationModule.php +++ b/src/Presenter/Store/Modules/ConfigurationModule.php @@ -63,6 +63,7 @@ class ConfigurationModule implements PresenterInterface * @param ExpressCheckoutConfiguration $ecConfiguration * @param PayPalConfiguration $paypalConfiguration * @param FundingSourceProvider $fundingSourceProvider + * @param Ps_checkout $module */ public function __construct( PayPalPayLaterConfiguration $payLaterConfiguration, diff --git a/src/Presenter/Store/Modules/ContextModule.php b/src/Presenter/Store/Modules/ContextModule.php index 0d1bb4119..884d6affc 100644 --- a/src/Presenter/Store/Modules/ContextModule.php +++ b/src/Presenter/Store/Modules/ContextModule.php @@ -92,6 +92,10 @@ class ContextModule implements PresenterInterface * @var PsAccountRepository */ private $psAccountRepository; + /** + * @var LinkAdapter + */ + private $linkAdapter; /** * @param string $moduleName @@ -115,7 +119,8 @@ public function __construct( ShopContext $shopContext, ShopProvider $shopProvider, ModuleLinkBuilder $moduleLinkBuilder, - PsAccountRepository $psAccountRepository + PsAccountRepository $psAccountRepository, + LinkAdapter $linkAdapter ) { $this->moduleName = $moduleName; $this->moduleKey = $moduleKey; @@ -128,6 +133,7 @@ public function __construct( $this->shopProvider = $shopProvider; $this->moduleLinkBuilder = $moduleLinkBuilder; $this->psAccountRepository = $psAccountRepository; + $this->linkAdapter = $linkAdapter; } /** @@ -137,7 +143,7 @@ public function __construct( */ public function present() { - $shopId = (int) \Context::getContext()->shop->id; + $shopId = (int) $this->psContext->getShopId(); return [ 'context' => [ @@ -154,7 +160,7 @@ public function present() 'shopsTree' => $this->getShopsTree(), 'faq' => $this->getFaq(), 'language' => $this->psContext->getLanguage(), - 'prestashopCheckoutAjax' => $this->getGeneratedLink('AdminAjaxPrestashopCheckout'), + 'prestashopCheckoutAjax' => $this->linkAdapter->getAdminLink('AdminAjaxPrestashopCheckout'), 'translations' => $this->translations->getTranslations(), 'readmeUrl' => $this->getReadme(), 'cguUrl' => $this->getCgu(), @@ -167,10 +173,10 @@ public function present() 'youtubeInstallerLink' => $this->getYoutubeInstallerLink(), 'incompatibleCountryCodes' => $this->paypalConfiguration->getIncompatibleCountryCodes(), 'incompatibleCurrencyCodes' => $this->paypalConfiguration->getIncompatibleCurrencyCodes(), - 'countriesLink' => $this->getGeneratedLink('AdminCountries'), - 'currenciesLink' => $this->getGeneratedLink('AdminCurrencies'), - 'paymentPreferencesLink' => $this->getGeneratedLink($this->shopContext->isShop17() ? 'AdminPaymentPreferences' : 'AdminPayment'), - 'maintenanceLink' => $this->getGeneratedLink('AdminMaintenance'), + 'countriesLink' => $this->linkAdapter->getAdminLink('AdminCountries'), + 'currenciesLink' => $this->linkAdapter->getAdminLink('AdminCurrencies'), + 'paymentPreferencesLink' => $this->linkAdapter->getAdminLink($this->shopContext->isShop17() ? 'AdminPaymentPreferences' : 'AdminPayment'), + 'maintenanceLink' => $this->linkAdapter->getAdminLink('AdminMaintenance'), 'overridesExist' => $this->overridesExist(), 'submitIdeaLink' => $this->getSubmitIdeaLink(), 'orderTotal' => (new OrderRepository())->count($this->psContext->getShopId()), @@ -207,8 +213,6 @@ private function getShopsTree() return $shopList; } - $linkAdapter = new LinkAdapter($this->psContext->getLink()); - foreach (\Shop::getTree() as $groupId => $groupData) { $shops = []; @@ -216,7 +220,7 @@ private function getShopsTree() $shops[] = [ 'id' => $shopId, 'name' => $shopData['name'], - 'url' => $linkAdapter->getAdminLink( + 'url' => $this->linkAdapter->getAdminLink( 'AdminModules', true, [], @@ -328,9 +332,7 @@ private function getYoutubeInstallerLink() */ private function getCountriesLink() { - $linkAdapter = new LinkAdapter($this->psContext->getLink()); - - return $linkAdapter->getAdminLink('AdminCountries'); + return $this->linkAdapter->getAdminLink('AdminCountries'); } /** @@ -342,9 +344,7 @@ private function getCountriesLink() */ public function getGeneratedLink($link) { - $linkAdapter = new LinkAdapter($this->psContext->getLink()); - - return $linkAdapter->getAdminLink($link); + return $this->linkAdapter->getAdminLink($link); } /** diff --git a/src/Provider/PaymentMethodLogoProvider.php b/src/Provider/PaymentMethodLogoProvider.php index 2c1879dd7..8df95a5a3 100644 --- a/src/Provider/PaymentMethodLogoProvider.php +++ b/src/Provider/PaymentMethodLogoProvider.php @@ -20,18 +20,16 @@ namespace PrestaShop\Module\PrestashopCheckout\Provider; -use Ps_checkout; - class PaymentMethodLogoProvider { /** - * @var Ps_checkout + * @var string */ - private $module; + private $modulePathUri; - public function __construct(Ps_checkout $module) + public function __construct($modulePathUri) { - $this->module = $module; + $this->modulePathUri = $modulePathUri; } /** @@ -46,26 +44,26 @@ public function getLogoByPaymentSource($paymentSource) if ($paymentSourceName === 'card' && isset($paymentSource['card']['brand'])) { switch ($paymentSource['card']['brand']) { case 'CB_NATIONALE': - return $this->module->getPathUri() . 'views/img/cb.svg'; + return $this->modulePathUri . 'views/img/cb.svg'; case 'VISA': - return $this->module->getPathUri() . 'views/img/visa.svg'; + return $this->modulePathUri . 'views/img/visa.svg'; case 'MASTERCARD': - return $this->module->getPathUri() . 'views/img/mastercard.svg'; + return $this->modulePathUri . 'views/img/mastercard.svg'; case 'AMEX': - return $this->module->getPathUri() . 'views/img/amex.svg'; + return $this->modulePathUri . 'views/img/amex.svg'; case 'DISCOVER': - return $this->module->getPathUri() . 'views/img/discover.svg'; + return $this->modulePathUri . 'views/img/discover.svg'; case 'JCB': - return $this->module->getPathUri() . 'views/img/jcb.svg'; + return $this->modulePathUri . 'views/img/jcb.svg'; case 'DINERS': - return $this->module->getPathUri() . 'views/img/diners.svg'; + return $this->modulePathUri . 'views/img/diners.svg'; case 'UNIONPAY': - return $this->module->getPathUri() . 'views/img/unionpay.svg'; + return $this->modulePathUri . 'views/img/unionpay.svg'; case 'MAESTRO': - return $this->module->getPathUri() . 'views/img/maestro.svg'; + return $this->modulePathUri . 'views/img/maestro.svg'; } } - return $this->module->getPathUri() . 'views/img/' . $paymentSourceName . '.svg'; + return $this->modulePathUri . 'views/img/' . $paymentSourceName . '.svg'; } } diff --git a/src/Provider/PaymentOptionProvider.php b/src/Provider/PaymentOptionProvider.php new file mode 100644 index 000000000..37c5dab61 --- /dev/null +++ b/src/Provider/PaymentOptionProvider.php @@ -0,0 +1,130 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\Provider; + +use Context; +use Media; +use PrestaShop\Module\PrestashopCheckout\Exception\PsCheckoutException; +use PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceProvider; +use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration; +use PrestaShop\PrestaShop\Core\Payment\PaymentOption; +use Ps_checkout; +use SmartyException; + +class PaymentOptionProvider +{ + /** + * @var FundingSourceProvider + */ + private $fundingSourceProvider; + /** + * @var PayPalConfiguration + */ + private $payPalConfiguration; + /** + * @var Context + */ + private $context; + /** + * @var Ps_checkout + */ + private $module; + + public function __construct(Ps_checkout $module, FundingSourceProvider $fundingSourceProvider, PayPalConfiguration $payPalConfiguration) + { + $this->module = $module; + $this->fundingSourceProvider = $fundingSourceProvider; + $this->payPalConfiguration = $payPalConfiguration; + $this->context = Context::getContext(); + } + + /** + * @param int $customerId + * + * @return PaymentOption[] + * + * @throws SmartyException + * @throws PsCheckoutException + */ + public function getPaymentOptions($customerId) + { + $paymentOptions = []; + + $vaultingEnabled = $this->payPalConfiguration->isVaultingEnabled() && $this->context->customer->isLogged(); + + $this->context->smarty->assign('lockIcon', Media::getMediaPath(_PS_MODULE_DIR_ . $this->module->name . '/views/img/icons/lock_fill.svg')); + + foreach ($this->fundingSourceProvider->getSavedTokens((int) $customerId) as $fundingSource) { + if ($fundingSource->paymentSource === 'paypal') { + $vaultedPayPal = [ + 'paymentIdentifier' => $fundingSource->name, + 'fundingSource' => $fundingSource->paymentSource, + 'isFavorite' => $fundingSource->isFavorite, + 'label' => $fundingSource->label, + 'vaultId' => explode('-', $fundingSource->name)[1], + ]; + continue; + } + $paymentOption = new PaymentOption(); + $paymentOption->setModuleName($this->module->name . '-' . $fundingSource->name); + $paymentOption->setCallToActionText($fundingSource->label); + $paymentOption->setBinary(true); + + $this->context->smarty->assign([ + 'paymentIdentifier' => $fundingSource->name, + 'fundingSource' => $fundingSource->paymentSource, + 'isFavorite' => $fundingSource->isFavorite, + 'label' => $fundingSource->label, + 'vaultId' => explode('-', $fundingSource->name)[1], + ]); + $paymentOption->setForm($this->context->smarty->fetch('module:ps_checkout/views/templates/hook/partials/vaultTokenForm.tpl')); + + $paymentOptions[] = $paymentOption; + } + + foreach ($this->fundingSourceProvider->getAll() as $fundingSource) { + $paymentOption = new PaymentOption(); + $paymentOption->setModuleName($this->module->name . '-' . $fundingSource->name); + $paymentOption->setCallToActionText($fundingSource->label); + $paymentOption->setBinary(true); + $this->context->smarty->assign([ + 'vaultingEnabled' => $vaultingEnabled, + 'paymentIdentifier' => $fundingSource->name, + ]); + + if ('card' === $fundingSource->name && $this->payPalConfiguration->isHostedFieldsEnabled() && in_array($this->payPalConfiguration->getCardHostedFieldsStatus(), ['SUBSCRIBED', 'LIMITED'], true)) { + $this->context->smarty->assign('modulePath', $this->module->getPathUri()); + $paymentOption->setForm($this->context->smarty->fetch('module:ps_checkout/views/templates/hook/partials/cardFields.tpl')); + } elseif ($fundingSource->name === 'paypal') { + if (empty($vaultedPayPal)) { + $paymentOption->setForm($this->context->smarty->fetch('module:ps_checkout/views/templates/hook/partials/vaultPaymentForm.tpl')); + } else { + $this->context->smarty->assign($vaultedPayPal); + $paymentOption->setForm($this->context->smarty->fetch('module:ps_checkout/views/templates/hook/partials/vaultTokenForm.tpl')); + } + } + + $paymentOptions[] = $paymentOption; + } + + return $paymentOptions; + } +} diff --git a/src/Repository/PsAccountRepository.php b/src/Repository/PsAccountRepository.php index 1e45463d3..ec520b26b 100644 --- a/src/Repository/PsAccountRepository.php +++ b/src/Repository/PsAccountRepository.php @@ -21,8 +21,6 @@ namespace PrestaShop\Module\PrestashopCheckout\Repository; use Exception; -use PrestaShop\Module\PrestashopCheckout\Configuration\PrestaShopConfiguration; -use PrestaShop\Module\PrestashopCheckout\Entity\PsAccount; use PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts; /** @@ -30,18 +28,13 @@ */ class PsAccountRepository { - /** @var PrestaShopConfiguration */ - private $configuration; - private $psAccountsService; /** - * @param PrestaShopConfiguration $configuration * @param PsAccounts $psAccountsFacade */ - public function __construct(PrestaShopConfiguration $configuration, PsAccounts $psAccountsFacade) + public function __construct(PsAccounts $psAccountsFacade) { - $this->configuration = $configuration; try { $this->psAccountsService = $psAccountsFacade->getPsAccountsService(); } catch (Exception $exception) { @@ -49,30 +42,6 @@ public function __construct(PrestaShopConfiguration $configuration, PsAccounts $ } } - /** - * Get current onboarded prestashop account - * - * @return PsAccount - */ - public function getOnboardedAccount() - { - return new PsAccount( - $this->getIdToken(), - $this->getRefreshToken(), - $this->getEmail() - ); - } - - /** - * @deprecated 3.0.0 Moved to PS Accounts - * - * @return bool - */ - public function psxFormIsCompleted() - { - return true; - } - /** * Check if user and shop are linked with PS Accounts * @@ -115,20 +84,6 @@ public function getIdToken() } } - /** - * @deprecated PS Accounts v5.1.1 - * - * @return string|bool - */ - public function getLocalId() - { - if (!$this->psAccountsService) { - return false; - } - - return $this->psAccountsService->getUserUuidV4(); - } - /** * Get firebase refreshToken from database * @@ -143,18 +98,6 @@ public function getRefreshToken() return $this->psAccountsService->getRefreshToken(); } - /** - * Get psx form from database - * - * @param bool $toArray - * - * @return string|array - */ - public function getPsxForm($toArray = false) - { - return $toArray ? '' : []; - } - /** * Get Shop UUID * diff --git a/src/Validator/MerchantValidator.php b/src/Validator/MerchantValidator.php index 4bc63a45e..a20381f55 100644 --- a/src/Validator/MerchantValidator.php +++ b/src/Validator/MerchantValidator.php @@ -20,7 +20,6 @@ namespace PrestaShop\Module\PrestashopCheckout\Validator; -use PrestaShop\Module\PrestashopCheckout\Context\PrestaShopContext; use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration; use PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository; @@ -34,19 +33,13 @@ class MerchantValidator * @var PsAccountRepository */ private $psAccountRepository; - /** - * @var PrestaShopContext - */ - private $prestaShopContext; public function __construct( PayPalConfiguration $configuration, - PsAccountRepository $psAccountRepository, - PrestaShopContext $prestaShopContext + PsAccountRepository $psAccountRepository ) { $this->configuration = $configuration; $this->psAccountRepository = $psAccountRepository; - $this->prestaShopContext = $prestaShopContext; } public function merchantIsValid() diff --git a/tests/Unit/PaymentService/PaymentServiceCreateOrderTest.php b/tests/Unit/PaymentService/PaymentServiceCreateOrderTest.php new file mode 100644 index 000000000..62ce5485e --- /dev/null +++ b/tests/Unit/PaymentService/PaymentServiceCreateOrderTest.php @@ -0,0 +1,225 @@ +handleTestErrorsCreateOrder(400, $errorName, $errorCode); + } + + /** + * @dataProvider notAuthorizedErrorsProvider + * + * @throws InvalidRequestException|NotAuthorizedException|UnprocessableEntityException + */ + public function testNotAuthorizedErrorsCreateOrder($errorName, $errorCode) + { + $this->handleTestErrorsCreateOrder(401, $errorName, $errorCode); + } + + /** + * @dataProvider unprocessableEntityErrorsProvider + * + * @throws InvalidRequestException|NotAuthorizedException|UnprocessableEntityException + */ + public function testUnprocessableEntityErrorsCreateOrder($errorName, $errorCode) + { + $this->handleTestErrorsCreateOrder(422, $errorName, $errorCode); + } + + /** + * @param int $statusCode + * @param string $errorName + * @param int $errorCode + * + * @throws InvalidRequestException|NotAuthorizedException|UnprocessableEntityException + */ + private function handleTestErrorsCreateOrder($statusCode, $errorName, $errorCode) + { + switch ($statusCode) { + case 400: + $error = $this->getInvalidRequestError($errorName); + break; + case 401: + $error = $this->getNotAuthorizedError($errorName); + break; + case 422: + default: + $error = $this->getUnprocessableEntityError($errorName); + break; + } + + $requestMock = $this->createMock(RequestInterface::class); + $createRequestMock = $this->createMock(CreatePayPalOrderRequestInterface::class); + + $streamMock = $this->createMock(StreamInterface::class); + $streamMock->method('getContents')->willReturn(json_encode($error)); + + $responseMock = $this->createMock(ResponseInterface::class); + $responseMock->method('getStatusCode')->willReturn($statusCode); + $responseMock->method('getBody')->willReturn($streamMock); + + $clientMock = $this->createMock(CheckoutHttpClient::class); + $clientMock->method('createOrder')->willThrowException(new HttpException('An error occurred', $requestMock, $responseMock)); + + $this->expectExceptionCode($errorCode); + $paymentService = new PaymentService($clientMock, new ObjectSerializer()); + $paymentService->createOrder($createRequestMock); + } + + private function getInvalidRequestError($issueError) + { + return [ + 'name' => 'INVALID_REQUEST', + 'message' => 'Request is not well-formed, syntactically incorrect, or violates schema.', + 'debug_id' => 'b6b9a374802ea', + 'details' => [ + [ + 'field' => '', + 'value' => '', + 'location' => 'body', + 'issue' => $issueError, + 'description' => '', + ], + ], + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_PARAMETER_VALUE', + 'rel' => 'information_link', + 'encType' => 'application/json', + ], + ], + ]; + } + + private function getNotAuthorizedError($issueError) + { + return [ + 'name' => $issueError, + 'message' => 'Authentication failed due to invalid authentication credentials or a missing Authorization header.', + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/overview/#error', + 'rel' => 'information_link', + ], + ], + ]; + } + + private function getUnprocessableEntityError($issueError) + { + return [ + 'name' => 'UNPROCESSABLE_ENTITY', + 'details' => [ + [ + 'field' => '', + 'value' => '', + 'issue' => $issueError, + 'description' => '', + ], + ], + 'message' => 'The requested action could not be performed, semantically incorrect, or failed business validation.', + 'debug_id' => 'c9a75b43fc807', + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/orders/v2/#error-MAX_VALUE_EXCEEDED', + 'rel' => 'information_link', + 'method' => 'GET', + ], + ], + ]; + } + + public function invalidRequestErrorsProvider() + { + return [ + ['INVALID_ARRAY_MAX_ITEMS', InvalidRequestException::INVALID_ARRAY_MAX_ITEMS], + ['INVALID_ARRAY_MIN_ITEMS', InvalidRequestException::INVALID_ARRAY_MIN_ITEMS], + ['INVALID_COUNTRY_CODE', InvalidRequestException::INVALID_COUNTRY_CODE], + ['INVALID_PARAMETER_SYNTAX', InvalidRequestException::INVALID_PARAMETER_SYNTAX], + ['INVALID_STRING_LENGTH', InvalidRequestException::INVALID_STRING_LENGTH], + ['INVALID_PARAMETER_VALUE', InvalidRequestException::INVALID_PARAMETER_VALUE], + ['MISSING_REQUIRED_PARAMETER', InvalidRequestException::MISSING_REQUIRED_PARAMETER], + ['NOT_SUPPORTED', InvalidRequestException::NOT_SUPPORTED], + ['PAYPAL_REQUEST_ID_REQUIRED', InvalidRequestException::PAYPAL_REQUEST_ID_REQUIRED], + ['MALFORMED_REQUEST_JSON', InvalidRequestException::MALFORMED_REQUEST_JSON], + ]; + } + + public function notAuthorizedErrorsProvider() + { + return [ + ['PERMISSION_DENIED', NotAuthorizedException::PERMISSION_DENIED], + ['PERMISSION_DENIED_FOR_DONATION_ITEMS', NotAuthorizedException::PERMISSION_DENIED_FOR_DONATION_ITEMS], + ['MALFORMED_REQUEST', NotAuthorizedException::MALFORMED_REQUEST], + ]; + } + + public function unprocessableEntityErrorsProvider() + { + return [ + ['AMOUNT_MISMATCH', UnprocessableEntityException::AMOUNT_MISMATCH], + ['BILLING_ADDRESS_INVALID', UnprocessableEntityException::BILLING_ADDRESS_INVALID], + ['CANNOT_BE_NEGATIVE', UnprocessableEntityException::CANNOT_BE_NEGATIVE], + ['CANNOT_BE_ZERO_OR_NEGATIVE', UnprocessableEntityException::CANNOT_BE_ZERO_OR_NEGATIVE], + ['CARD_EXPIRED', UnprocessableEntityException::CARD_EXPIRED], + ['CITY_REQUIRED', UnprocessableEntityException::CITY_REQUIRED], + ['DECIMAL_PRECISION', UnprocessableEntityException::DECIMAL_PRECISION], + ['DONATION_ITEMS_NOT_SUPPORTED', UnprocessableEntityException::DONATION_ITEMS_NOT_SUPPORTED], + ['DUPLICATE_REFERENCE_ID', UnprocessableEntityException::DUPLICATE_REFERENCE_ID], + ['INVALID_CURRENCY_CODE', UnprocessableEntityException::INVALID_CURRENCY_CODE], + ['INVALID_PAYER_ID', UnprocessableEntityException::INVALID_PAYER_ID], + ['ITEM_TOTAL_MISMATCH', UnprocessableEntityException::ITEM_TOTAL_MISMATCH], + ['ITEM_TOTAL_REQUIRED', UnprocessableEntityException::ITEM_TOTAL_REQUIRED], + ['MAX_VALUE_EXCEEDED', UnprocessableEntityException::MAX_VALUE_EXCEEDED], + ['MISSING_PICKUP_ADDRESS', UnprocessableEntityException::MISSING_PICKUP_ADDRESS], + ['MULTI_CURRENCY_ORDER', UnprocessableEntityException::MULTI_CURRENCY_ORDER], + ['MULTIPLE_ITEM_CATEGORIES', UnprocessableEntityException::MULTIPLE_ITEM_CATEGORIES], + ['MULTIPLE_SHIPPING_ADDRESS_NOT_SUPPORTED', UnprocessableEntityException::MULTIPLE_SHIPPING_ADDRESS_NOT_SUPPORTED], + ['MULTIPLE_SHIPPING_TYPE_NOT_SUPPORTED', UnprocessableEntityException::MULTIPLE_SHIPPING_TYPE_NOT_SUPPORTED], + ['PAYEE_ACCOUNT_INVALID', UnprocessableEntityException::PAYEE_ACCOUNT_INVALID], + ['PAYEE_ACCOUNT_LOCKED_OR_CLOSED', UnprocessableEntityException::PAYEE_ACCOUNT_LOCKED_OR_CLOSED], + ['PAYEE_ACCOUNT_RESTRICTED', UnprocessableEntityException::PAYEE_ACCOUNT_RESTRICTED], + ['REFERENCE_ID_REQUIRED', UnprocessableEntityException::REFERENCE_ID_REQUIRED], + ['PAYMENT_SOURCE_CANNOT_BE_USED', UnprocessableEntityException::PAYMENT_SOURCE_CANNOT_BE_USED], + ['PAYMENT_SOURCE_DECLINED_BY_PROCESSOR', UnprocessableEntityException::PAYMENT_SOURCE_DECLINED_BY_PROCESSOR], + ['PAYMENT_SOURCE_INFO_CANNOT_BE_VERIFIED', UnprocessableEntityException::PAYMENT_SOURCE_INFO_CANNOT_BE_VERIFIED], + ['POSTAL_CODE_REQUIRED', UnprocessableEntityException::POSTAL_CODE_REQUIRED], + ['SHIPPING_ADDRESS_INVALID', UnprocessableEntityException::SHIPPING_ADDRESS_INVALID], + ['TAX_TOTAL_MISMATCH', UnprocessableEntityException::TAX_TOTAL_MISMATCH], + ['TAX_TOTAL_REQUIRED', UnprocessableEntityException::TAX_TOTAL_REQUIRED], + ['UNSUPPORTED_INTENT', UnprocessableEntityException::UNSUPPORTED_INTENT], + ['UNSUPPORTED_PAYMENT_INSTRUCTION', UnprocessableEntityException::UNSUPPORTED_PAYMENT_INSTRUCTION], + ['SHIPPING_TYPE_NOT_SUPPORTED_FOR_CLIENT', UnprocessableEntityException::SHIPPING_TYPE_NOT_SUPPORTED_FOR_CLIENT], + ['UNSUPPORTED_SHIPPING_TYPE', UnprocessableEntityException::UNSUPPORTED_SHIPPING_TYPE], + ['SHIPPING_OPTION_NOT_SELECTED', UnprocessableEntityException::SHIPPING_OPTION_NOT_SELECTED], + ['SHIPPING_OPTIONS_NOT_SUPPORTED', UnprocessableEntityException::SHIPPING_OPTIONS_NOT_SUPPORTED], + ['MULTIPLE_SHIPPING_OPTION_SELECTED', UnprocessableEntityException::MULTIPLE_SHIPPING_OPTION_SELECTED], + ['PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH', UnprocessableEntityException::PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH], + ['CARD_CLOSED', UnprocessableEntityException::CARD_CLOSED], + ['ORDER_CANNOT_BE_SAVED', UnprocessableEntityException::ORDER_CANNOT_BE_SAVED], + ['SAVE_ORDER_NOT_SUPPORTED', UnprocessableEntityException::SAVE_ORDER_NOT_SUPPORTED], + ['PUI_DUPLICATE_ORDER', UnprocessableEntityException::PUI_DUPLICATE_ORDER], + ]; + } +} diff --git a/tests/Unit/PaymentService/PaymentServiceGetOrderTest.php b/tests/Unit/PaymentService/PaymentServiceGetOrderTest.php new file mode 100644 index 000000000..400cd2d62 --- /dev/null +++ b/tests/Unit/PaymentService/PaymentServiceGetOrderTest.php @@ -0,0 +1,91 @@ +handleErrorsGetOrder(401, $errorName, $errorCode); + } + + /** + * @param int $statusCode + * @param string $errorName + * @param int $errorCode + * + * @throws InvalidRequestException|NotAuthorizedException|UnprocessableEntityException|PsCheckoutException + */ + private function handleErrorsGetOrder($statusCode, $errorName, $errorCode) + { + if ($errorName === 'invalid_token') { + $error = $this->getInvalidTokenError(); + } else { + $error = $this->getNotAuthorizedError($errorName); + } + + $requestMock = $this->createMock(RequestInterface::class); + + $streamMock = $this->createMock(StreamInterface::class); + $streamMock->method('getContents')->willReturn(json_encode($error)); + + $responseMock = $this->createMock(ResponseInterface::class); + $responseMock->method('getStatusCode')->willReturn($statusCode); + $responseMock->method('getBody')->willReturn($streamMock); + + $clientMock = $this->createMock(CheckoutHttpClient::class); + $clientMock->method('fetchOrder')->willThrowException(new HttpException('An error occurred', $requestMock, $responseMock)); + + $this->expectExceptionCode($errorCode); + $paymentService = new PaymentService($clientMock, new ObjectSerializer()); + $paymentService->getOrder('LUX8l091NV'); + } + + private function getNotAuthorizedError($issueError) + { + return [ + 'name' => $issueError, + 'message' => 'Authentication failed due to invalid authentication credentials or a missing Authorization header.', + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/overview/#error', + 'rel' => 'information_link', + ], + ], + ]; + } + + private function getInvalidTokenError() + { + return [ + 'error' => 'invalid_token', + 'error_description' => 'Current version only supports token for response_type', + ]; + } + + public function notAuthorizedErrorsProvider() + { + return [ + ['PERMISSION_DENIED', NotAuthorizedException::PERMISSION_DENIED], + ['invalid_token', NotAuthorizedException::INVALID_TOKEN], + ]; + } +} diff --git a/tests/Unit/PaymentService/PaymentServiceUpdateOrderTest.php b/tests/Unit/PaymentService/PaymentServiceUpdateOrderTest.php new file mode 100644 index 000000000..f6e07f875 --- /dev/null +++ b/tests/Unit/PaymentService/PaymentServiceUpdateOrderTest.php @@ -0,0 +1,199 @@ +handleErrorsUpdateOrder(400, $errorName, $errorCode); + } + + /** + * @dataProvider notAuthorizedErrorsProvider + * + * @throws InvalidRequestException|NotAuthorizedException|UnprocessableEntityException|PsCheckoutException + */ + public function testNotAuthorizedErrorsUpdateOrder($errorName, $errorCode) + { + $this->handleErrorsUpdateOrder(401, $errorName, $errorCode); + } + + /** + * @dataProvider unprocessableEntityErrorsProvider + * + * @throws InvalidRequestException|NotAuthorizedException|UnprocessableEntityException|PsCheckoutException + */ + public function testUnprocessableEntityErrorsUpdateOrder($errorName, $errorCode) + { + $this->handleErrorsUpdateOrder(422, $errorName, $errorCode); + } + + /** + * @param int $statusCode + * @param string $errorName + * @param int $errorCode + * + * @throws InvalidRequestException|NotAuthorizedException|UnprocessableEntityException|PsCheckoutException + */ + private function handleErrorsUpdateOrder($statusCode, $errorName, $errorCode) + { + switch ($statusCode) { + case 400: + $error = $this->getInvalidRequestError($errorName); + break; + case 401: + $error = $this->getNotAuthorizedError($errorName); + break; + case 422: + default: + $error = $this->getUnprocessableEntityError($errorName); + break; + } + + $requestMock = $this->createMock(RequestInterface::class); + $updateRequestMock = $this->createMock(UpdatePayPalOrderRequestInterface::class); + + $streamMock = $this->createMock(StreamInterface::class); + $streamMock->method('getContents')->willReturn(json_encode($error)); + + $responseMock = $this->createMock(ResponseInterface::class); + $responseMock->method('getStatusCode')->willReturn($statusCode); + $responseMock->method('getBody')->willReturn($streamMock); + + $clientMock = $this->createMock(CheckoutHttpClient::class); + $clientMock->method('updateOrder')->willThrowException(new HttpException('An error occurred', $requestMock, $responseMock)); + + $this->expectExceptionCode($errorCode); + $paymentService = new PaymentService($clientMock, new ObjectSerializer()); + $paymentService->updateOrder($updateRequestMock); + } + + private function getInvalidRequestError($issueError) + { + return [ + 'name' => 'INVALID_REQUEST', + 'message' => 'Request is not well-formed, syntactically incorrect, or violates schema.', + 'debug_id' => 'b6b9a374802ea', + 'details' => [ + [ + 'field' => '', + 'value' => '', + 'location' => 'body', + 'issue' => $issueError, + 'description' => '', + ], + ], + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_PARAMETER_VALUE', + 'rel' => 'information_link', + 'encType' => 'application/json', + ], + ], + ]; + } + + private function getNotAuthorizedError($issueError) + { + return [ + 'name' => $issueError, + 'message' => 'Authentication failed due to invalid authentication credentials or a missing Authorization header.', + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/overview/#error', + 'rel' => 'information_link', + ], + ], + ]; + } + + private function getUnprocessableEntityError($issueError) + { + return [ + 'name' => 'UNPROCESSABLE_ENTITY', + 'details' => [ + [ + 'field' => '', + 'value' => '', + 'issue' => $issueError, + 'description' => '', + ], + ], + 'message' => 'The requested action could not be performed, semantically incorrect, or failed business validation.', + 'debug_id' => 'c9a75b43fc807', + 'links' => [ + [ + 'href' => 'https://developer.paypal.com/docs/api/orders/v2/#error-MAX_VALUE_EXCEEDED', + 'rel' => 'information_link', + 'method' => 'GET', + ], + ], + ]; + } + + public function invalidRequestErrorsProvider() + { + return [ + ['FIELD_NOT_PATCHABLE', InvalidRequestException::FIELD_NOT_PATCHABLE], + ['INVALID_ARRAY_MAX_ITEMS', InvalidRequestException::INVALID_ARRAY_MAX_ITEMS], + ['INVALID_PARAMETER_SYNTAX', InvalidRequestException::INVALID_PARAMETER_SYNTAX], + ['INVALID_STRING_LENGTH', InvalidRequestException::INVALID_STRING_LENGTH], + ['INVALID_PARAMETER_VALUE', InvalidRequestException::INVALID_PARAMETER_VALUE], + ['MISSING_REQUIRED_PARAMETER', InvalidRequestException::MISSING_REQUIRED_PARAMETER], + ['AMOUNT_NOT_PATCHABLE', InvalidRequestException::AMOUNT_NOT_PATCHABLE], + ['INVALID_PATCH_OPERATION', InvalidRequestException::INVALID_PATCH_OPERATION], + ['ERROR_CURRENTLY_UNKNOWN', InvalidRequestException::UNKNOWN], + ]; + } + + public function notAuthorizedErrorsProvider() + { + return [ + ['PERMISSION_DENIED', NotAuthorizedException::PERMISSION_DENIED], + ['PAYEE_ACCOUNT_NOT_SUPPORTED', NotAuthorizedException::PAYEE_ACCOUNT_NOT_SUPPORTED], + ['PAYEE_ACCOUNT_NOT_VERIFIED', NotAuthorizedException::PAYEE_ACCOUNT_NOT_VERIFIED], + ['PAYEE_NOT_CONSENTED', NotAuthorizedException::PAYEE_NOT_CONSENTED], + ['ERROR_CURRENTLY_UNKNOWN', NotAuthorizedException::UNKNOWN], + ]; + } + + public function unprocessableEntityErrorsProvider() + { + return [ + ['INVALID_JSON_POINTER_FORMAT', UnprocessableEntityException::INVALID_JSON_POINTER_FORMAT], + ['INVALID_PARAMETER', UnprocessableEntityException::INVALID_PARAMETER], + ['NOT_PATCHABLE', UnprocessableEntityException::NOT_PATCHABLE], + ['UNSUPPORTED_PATCH_PARAMETER_VALUE', UnprocessableEntityException::UNSUPPORTED_PATCH_PARAMETER_VALUE], + ['PATCH_VALUE_REQUIRED', UnprocessableEntityException::PATCH_VALUE_REQUIRED], + ['PATCH_PATH_REQUIRED', UnprocessableEntityException::PATCH_PATH_REQUIRED], + ['REFERENCE_ID_NOT_FOUND', UnprocessableEntityException::REFERENCE_ID_NOT_FOUND], + ['MULTI_CURRENCY_ORDER', UnprocessableEntityException::MULTI_CURRENCY_ORDER], + ['SHIPPING_OPTION_NOT_SELECTED', UnprocessableEntityException::SHIPPING_OPTION_NOT_SELECTED], + ['SHIPPING_OPTIONS_NOT_SUPPORTED', UnprocessableEntityException::SHIPPING_OPTIONS_NOT_SUPPORTED], + ['MULTIPLE_SHIPPING_OPTION_SELECTED', UnprocessableEntityException::MULTIPLE_SHIPPING_OPTION_SELECTED], + ['ORDER_ALREADY_COMPLETED', UnprocessableEntityException::ORDER_ALREADY_COMPLETED], + ['PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH', UnprocessableEntityException::PREFERRED_SHIPPING_OPTION_AMOUNT_MISMATCH], + ['ERROR_CURRENTLY_UNKNOWN', UnprocessableEntityException::UNKNOWN], + ]; + } +} diff --git a/tests/Unit/Serializer/ObjectSerializerTest.php b/tests/Unit/Serializer/ObjectSerializerTest.php new file mode 100644 index 000000000..5099ffc39 --- /dev/null +++ b/tests/Unit/Serializer/ObjectSerializerTest.php @@ -0,0 +1,250 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Serializer; + +use PHPUnit\Framework\TestCase; +use PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceEntity; +use PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO\CardResponse; +use PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO\CreatePayPalOrderResponse; +use PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO\LinkDescription; +use PrestaShop\Module\PrestashopCheckout\PayPal\Order\DTO\PaymentSourceResponse; +use PrestaShop\Module\PrestashopCheckout\Serializer\ObjectSerializer; +use Symfony\Component\Serializer\Encoder\JsonEncoder; + +class ObjectSerializerTest extends TestCase +{ + /** + * @var ObjectSerializer + */ + private $serializer; + + public function __construct($name = null, array $data = [], $dataName = '') + { + parent::__construct($name, $data, $dataName); + $this->serializer = new ObjectSerializer(); + } + + /** + * @dataProvider objectProvider + */ + public function testSerializeWithoutEmptyValues($object, $expectedJson) + { + $json = $this->serializer->serialize($object, JsonEncoder::FORMAT, true); + $this->assertEquals($expectedJson, $json); + } + + /** + * @dataProvider objectWithEmptyValuesProvider + */ + public function testSerializeWithEmptyValues($object, $expectedJson) + { + $json = $this->serializer->serialize($object, JsonEncoder::FORMAT); + $this->assertEquals($expectedJson, $json); + } + + /** + * @dataProvider objectProvider + */ + public function testDeserialize($expectedObject, $json) + { + $newObject = $this->serializer->deserialize($json, FundingSourceEntity::class, JsonEncoder::FORMAT); + $this->assertEquals($expectedObject, $newObject); + } + + /** + * @dataProvider createPayPalOrderResponseSerializeObjectProvider + */ + public function testSerializePayPalOrderResponse($object, $expectedJson) + { + $json = $this->serializer->serialize($object, JsonEncoder::FORMAT, true, true); + $this->assertEquals($expectedJson, $json); + } + + /** + * @dataProvider createPayPalOrderResponseDeserializeObjectProvider + */ + public function testDeserializePayPalOrderResponse($expectedObject, $json) + { + $newObject = $this->serializer->deserialize($json, CreatePayPalOrderResponse::class, JsonEncoder::FORMAT); + $this->assertEquals($expectedObject, $newObject); + } + + /** + * @dataProvider arrayProvider + */ + public function testToArray($object, $expectedArray, $skipNullValues, $convertToSnakeCase) + { + $newArray = $this->serializer->toArray($object, $skipNullValues, $convertToSnakeCase); + $this->assertEquals($expectedArray, $newArray); + } + + public function objectProvider() + { + $fundingSourceEntity = new FundingSourceEntity('paypal'); + $fundingSourceEntity->setCountries(['US', 'FR']); + $fundingSourceEntity->setPosition(0); + + return [ + [ + new FundingSourceEntity('paypal'), + '{"name":"paypal","countries":[],"isEnabled":true,"isToggleable":true}', + ], + [ + $fundingSourceEntity, + '{"name":"paypal","position":0,"countries":["US","FR"],"isEnabled":true,"isToggleable":true}', + ], + ]; + } + + public function objectWithEmptyValuesProvider() + { + $fundingSourceEntity = new FundingSourceEntity('paypal'); + $fundingSourceEntity->setCountries(['US', 'FR']); + $fundingSourceEntity->setPosition(0); + + return [ + [ + new FundingSourceEntity('paypal'), + '{"name":"paypal","position":null,"countries":[],"isEnabled":true,"isToggleable":true}', + ], + [ + $fundingSourceEntity, + '{"name":"paypal","position":0,"countries":["US","FR"],"isEnabled":true,"isToggleable":true}', + ], + ]; + } + + public function createPayPalOrderResponseSerializeObjectProvider() + { + return [ + [ + (new CreatePayPalOrderResponse()) + ->setId('SOME_ID') + ->setLinks([new LinkDescription(['href' => 'HREF', 'rel' => 'REL', 'method' => 'METHOD'])]), + '{"id":"SOME_ID","links":[{"href":"HREF","rel":"REL","method":"METHOD"}]}', + ], + [ + (new CreatePayPalOrderResponse()) + ->setId('SOME_ID') + ->setLinks([new LinkDescription(['href' => 'HREF', 'rel' => 'REL', 'method' => 'METHOD'])]) + ->setPaymentSource(new PaymentSourceResponse(['card' => new CardResponse(['name' => 'AMEX'])])), + '{"id":"SOME_ID","payment_source":{"card":{"name":"AMEX"}},"links":[{"href":"HREF","rel":"REL","method":"METHOD"}]}', + ], + ]; + } + + public function createPayPalOrderResponseDeserializeObjectProvider() + { + return [ + [ + (new CreatePayPalOrderResponse()) + ->setId('SOME_ID') + ->setLinks([new LinkDescription(['href' => 'HREF', 'rel' => 'REL', 'method' => 'METHOD'])]), + '{"id":"SOME_ID","links":[{"href":"HREF","rel":"REL","method":"METHOD"}]}', + ], + [ + (new CreatePayPalOrderResponse()) + ->setId('SOME_ID') + ->setLinks([new LinkDescription(['href' => 'HREF', 'rel' => 'REL', 'method' => 'METHOD'])]) + ->setPaymentSource(new PaymentSourceResponse(['card' => new CardResponse(['name' => 'AMEX'])])), + '{"id":"SOME_ID","payment_source":{"card":{"name":"AMEX"}},"links":[{"href":"HREF","rel":"REL","method":"METHOD"}]}', + ], + [ + (new CreatePayPalOrderResponse()) + ->setId('SOME_ID') + ->setLinks([new LinkDescription(['href' => 'HREF', 'rel' => 'REL', 'method' => 'METHOD'])]) + ->setPaymentSource(new PaymentSourceResponse(['card' => new CardResponse(['name' => 'AMEX'])])), + '{"id": "SOME_ID","cart_id":"RANDOM_CART_ID","payment_source":{"card":{"name":"AMEX"}},"links":[{"href":"HREF","rel":"REL","method":"METHOD"}]}', + ], + ]; + } + + public function arrayProvider() + { + return [ + [ + (new CreatePayPalOrderResponse()) + ->setId('SOME_ID') + ->setLinks([new LinkDescription(['href' => 'HREF', 'rel' => 'REL', 'method' => 'METHOD'])]) + ->setPaymentSource(new PaymentSourceResponse(['card' => new CardResponse(['name' => 'AMEX'])])), + [ + 'id' => 'SOME_ID', + 'create_time' => null, + 'update_time' => null, + 'payment_source' => [ + 'card' => [ + 'name' => 'AMEX', + 'last_digits' => null, + 'brand' => null, + 'available_networks' => null, + 'type' => null, + 'authentication_result' => null, + 'attributes' => null, + 'from_request' => null, + 'expiry' => null, + 'bin_details' => null, + ], + 'paypal' => null, + 'bancontact' => null, + 'blik' => null, + 'eps' => null, + 'giropay' => null, + 'ideal' => null, + 'mybank' => null, + 'p24' => null, + 'sofort' => null, + 'trustly' => null, + 'venmo' => null, + ], + 'intent' => null, + 'processing_instruction' => null, + 'payer' => null, + 'purchase_units' => null, + 'status' => null, + 'links' => [ + ['href' => 'HREF', 'rel' => 'REL', 'method' => 'METHOD'], + ], + ], + false, + true, + ], + [ + (new CreatePayPalOrderResponse()) + ->setId('SOME_ID') + ->setLinks([new LinkDescription(['href' => 'HREF', 'rel' => 'REL', 'method' => 'METHOD'])]) + ->setPaymentSource(new PaymentSourceResponse(['card' => new CardResponse(['name' => 'AMEX'])])), + [ + 'id' => 'SOME_ID', + 'payment_source' => [ + 'card' => [ + 'name' => 'AMEX', + ], + ], + 'links' => [ + ['href' => 'HREF', 'rel' => 'REL', 'method' => 'METHOD'], + ], + ], + true, + true, + ], + ]; + } +} diff --git a/upgrade/upgrade-8.4.0.2.php b/upgrade/upgrade-8.4.0.2.php new file mode 100644 index 000000000..0dd102f77 --- /dev/null +++ b/upgrade/upgrade-8.4.0.2.php @@ -0,0 +1,47 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ +if (!defined('_PS_VERSION_')) { + exit; +} + +/** + * Update main function for module version 8.4.0.2 + * + * @param Ps_checkout $module + * + * @return bool + */ +function upgrade_module_8_4_0_2($module) +{ + try { + $db = Db::getInstance(); + $db->execute('ALTER TABLE `' . _DB_PREFIX_ . 'pscheckout_payment_token` ADD INDEX `pscheckout_payment_token_paypal_customer_id_merchant_id` (`merchant_id`, `paypal_customer_id`)'); + $db->execute('ALTER TABLE `' . _DB_PREFIX_ . 'pscheckout_capture` ADD INDEX `pscheckout_capture_id_order` (`id_order`)'); + $db->execute('ALTER TABLE `' . _DB_PREFIX_ . 'pscheckout_refund` ADD INDEX `pscheckout_refund_id_order` (`id_order`)'); + $db->execute('ALTER TABLE `' . _DB_PREFIX_ . 'pscheckout_authorization` ADD INDEX `pscheckout_authorization_id_order` (`id_order`)'); + $db->execute('ALTER TABLE `' . _DB_PREFIX_ . 'pscheckout_purchase_unit` ADD INDEX `pscheckout_purchase_unit_id_order` (`id_order`)'); + } catch (Exception $exception) { + PrestaShopLogger::addLog($exception->getMessage(), 4, 1, 'Module', $module->id); + + return false; + } + + return true; +}@
sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted@
sign exists.