From b9308c1323f4769b6573a275c5e4698f64276b61 Mon Sep 17 00:00:00 2001 From: Jens Schulze Date: Fri, 25 Sep 2015 15:10:09 +0200 Subject: [PATCH] feat(Payment): add payment messages --- src/Model/Message/PaymentCreatedMessage.php | 41 ++++++++++++++++ .../PaymentInteractionAddedMessage.php | 41 ++++++++++++++++ .../PaymentStatusStateTransitionMessage.php | 33 +++++++++++++ .../PaymentTransactionAddedMessage.php | 41 ++++++++++++++++ .../PaymentAddInterfaceInteractionAction.php | 11 ++++- .../Command/PaymentAddTransactionAction.php | 2 +- .../Command/PaymentSetAmountPaidAction.php | 2 +- .../PaymentSetAmountRefundedAction.php | 2 +- .../Command/PaymentSetAuthorizationAction.php | 2 +- .../Command/PaymentSetCustomFieldAction.php | 2 +- .../Command/PaymentSetCustomTypeAction.php | 2 +- .../Command/PaymentSetCustomerAction.php | 2 +- .../Command/PaymentSetExternalIdAction.php | 2 +- .../Command/PaymentSetInterfaceIdAction.php | 2 +- .../PaymentSetMethodInfoInterfaceAction.php | 2 +- .../PaymentSetMethodInfoMethodAction.php | 2 +- .../PaymentSetMethodInfoNameAction.php | 2 +- .../PaymentSetStatusInterfaceCodeAction.php | 2 +- .../PaymentSetStatusInterfaceTextAction.php | 2 +- .../Command/PaymentTransitionStateAction.php | 21 ++------ .../States/Command/TransitionStateAction.php | 49 +++++++++++++++++++ 21 files changed, 232 insertions(+), 33 deletions(-) create mode 100644 src/Model/Message/PaymentCreatedMessage.php create mode 100644 src/Model/Message/PaymentInteractionAddedMessage.php create mode 100644 src/Model/Message/PaymentStatusStateTransitionMessage.php create mode 100644 src/Model/Message/PaymentTransactionAddedMessage.php create mode 100644 src/Request/States/Command/TransitionStateAction.php diff --git a/src/Model/Message/PaymentCreatedMessage.php b/src/Model/Message/PaymentCreatedMessage.php new file mode 100644 index 0000000000..b84855fcb0 --- /dev/null +++ b/src/Model/Message/PaymentCreatedMessage.php @@ -0,0 +1,41 @@ + + */ + +namespace Commercetools\Core\Model\Message; + +use Commercetools\Core\Model\Common\DateTimeDecorator; +use Commercetools\Core\Model\Common\Reference; +use Commercetools\Core\Model\Payment\Payment; + +/** + * @package Commercetools\Core\Model\Message + * + * @method string getId() + * @method PaymentCreatedMessage setId(string $id = null) + * @method DateTimeDecorator getCreatedAt() + * @method PaymentCreatedMessage setCreatedAt(\DateTime $createdAt = null) + * @method int getSequenceNumber() + * @method PaymentCreatedMessage setSequenceNumber(int $sequenceNumber = null) + * @method Reference getResource() + * @method PaymentCreatedMessage setResource(Reference $resource = null) + * @method int getResourceVersion() + * @method PaymentCreatedMessage setResourceVersion(int $resourceVersion = null) + * @method string getType() + * @method PaymentCreatedMessage setType(string $type = null) + * @method Payment getPayment() + * @method PaymentCreatedMessage setPayment(Payment $payment = null) + */ +class PaymentCreatedMessage extends Message +{ + const MESSAGE_TYPE = 'PaymentCreated'; + + public function fieldDefinitions() + { + $definitions = parent::fieldDefinitions(); + $definitions['payment'] = [static::TYPE => '\Commercetools\Core\Model\Payment\Payment']; + + return $definitions; + } +} diff --git a/src/Model/Message/PaymentInteractionAddedMessage.php b/src/Model/Message/PaymentInteractionAddedMessage.php new file mode 100644 index 0000000000..28ab975d7a --- /dev/null +++ b/src/Model/Message/PaymentInteractionAddedMessage.php @@ -0,0 +1,41 @@ + + */ + +namespace Commercetools\Core\Model\Message; + +use Commercetools\Core\Model\Common\DateTimeDecorator; +use Commercetools\Core\Model\Common\Reference; +use Commercetools\Core\Model\CustomField\CustomFieldObject; + +/** + * @package Commercetools\Core\Model\Message + * + * @method string getId() + * @method PaymentInteractionAddedMessage setId(string $id = null) + * @method DateTimeDecorator getCreatedAt() + * @method PaymentInteractionAddedMessage setCreatedAt(\DateTime $createdAt = null) + * @method int getSequenceNumber() + * @method PaymentInteractionAddedMessage setSequenceNumber(int $sequenceNumber = null) + * @method Reference getResource() + * @method PaymentInteractionAddedMessage setResource(Reference $resource = null) + * @method int getResourceVersion() + * @method PaymentInteractionAddedMessage setResourceVersion(int $resourceVersion = null) + * @method string getType() + * @method PaymentInteractionAddedMessage setType(string $type = null) + * @method CustomFieldObject getInteraction() + * @method PaymentInteractionAddedMessage setInteraction(CustomFieldObject $interaction = null) + */ +class PaymentInteractionAddedMessage extends Message +{ + const MESSAGE_TYPE = 'PaymentInteractionAdded'; + + public function fieldDefinitions() + { + $definitions = parent::fieldDefinitions(); + $definitions['interaction'] = [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObject']; + + return $definitions; + } +} diff --git a/src/Model/Message/PaymentStatusStateTransitionMessage.php b/src/Model/Message/PaymentStatusStateTransitionMessage.php new file mode 100644 index 0000000000..a4e65a24b7 --- /dev/null +++ b/src/Model/Message/PaymentStatusStateTransitionMessage.php @@ -0,0 +1,33 @@ + + */ + +namespace Commercetools\Core\Model\Message; + +use Commercetools\Core\Model\Common\DateTimeDecorator; +use Commercetools\Core\Model\Common\Reference; +use Commercetools\Core\Model\State\StateReference; + +/** + * @package Commercetools\Core\Model\Message + * + * @method string getId() + * @method PaymentStatusStateTransitionMessage setId(string $id = null) + * @method DateTimeDecorator getCreatedAt() + * @method PaymentStatusStateTransitionMessage setCreatedAt(\DateTime $createdAt = null) + * @method int getSequenceNumber() + * @method PaymentStatusStateTransitionMessage setSequenceNumber(int $sequenceNumber = null) + * @method Reference getResource() + * @method PaymentStatusStateTransitionMessage setResource(Reference $resource = null) + * @method int getResourceVersion() + * @method PaymentStatusStateTransitionMessage setResourceVersion(int $resourceVersion = null) + * @method string getType() + * @method PaymentStatusStateTransitionMessage setType(string $type = null) + * @method StateReference getState() + * @method PaymentStatusStateTransitionMessage setState(StateReference $state = null) + */ +class PaymentStatusStateTransitionMessage extends StateTransitionMessage +{ + const MESSAGE_TYPE = 'PaymentStatusStateTransition'; +} diff --git a/src/Model/Message/PaymentTransactionAddedMessage.php b/src/Model/Message/PaymentTransactionAddedMessage.php new file mode 100644 index 0000000000..0d72a89365 --- /dev/null +++ b/src/Model/Message/PaymentTransactionAddedMessage.php @@ -0,0 +1,41 @@ + + */ + +namespace Commercetools\Core\Model\Message; + +use Commercetools\Core\Model\Common\DateTimeDecorator; +use Commercetools\Core\Model\Common\Reference; +use Commercetools\Core\Model\Payment\Transaction; + +/** + * @package Commercetools\Core\Model\Message + * + * @method string getId() + * @method PaymentTransactionAddedMessage setId(string $id = null) + * @method DateTimeDecorator getCreatedAt() + * @method PaymentTransactionAddedMessage setCreatedAt(\DateTime $createdAt = null) + * @method int getSequenceNumber() + * @method PaymentTransactionAddedMessage setSequenceNumber(int $sequenceNumber = null) + * @method Reference getResource() + * @method PaymentTransactionAddedMessage setResource(Reference $resource = null) + * @method int getResourceVersion() + * @method PaymentTransactionAddedMessage setResourceVersion(int $resourceVersion = null) + * @method string getType() + * @method PaymentTransactionAddedMessage setType(string $type = null) + * @method Transaction getTransaction() + * @method PaymentTransactionAddedMessage setTransaction(Transaction $transaction = null) + */ +class PaymentTransactionAddedMessage extends Message +{ + const MESSAGE_TYPE = 'PaymentTransactionAdded'; + + public function fieldDefinitions() + { + $definitions = parent::fieldDefinitions(); + $definitions['transaction'] = [static::TYPE => '\Commercetools\Core\Model\Payment\Transaction']; + + return $definitions; + } +} diff --git a/src/Request/Payments/Command/PaymentAddInterfaceInteractionAction.php b/src/Request/Payments/Command/PaymentAddInterfaceInteractionAction.php index 5ad29a1a27..bf25229cc3 100644 --- a/src/Request/Payments/Command/PaymentAddInterfaceInteractionAction.php +++ b/src/Request/Payments/Command/PaymentAddInterfaceInteractionAction.php @@ -7,10 +7,19 @@ use Commercetools\Core\Model\Common\Context; use Commercetools\Core\Request\CustomField\Command\SetCustomTypeAction; +use Commercetools\Core\Model\CustomField\FieldContainer; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * + * @method string getAction() + * @method PaymentAddInterfaceInteractionAction setAction(string $action = null) + * @method string getTypeId() + * @method PaymentAddInterfaceInteractionAction setTypeId(string $typeId = null) + * @method string getTypeKey() + * @method PaymentAddInterfaceInteractionAction setTypeKey(string $typeKey = null) + * @method FieldContainer getFields() + * @method PaymentAddInterfaceInteractionAction setFields(FieldContainer $fields = null) */ class PaymentAddInterfaceInteractionAction extends SetCustomTypeAction { diff --git a/src/Request/Payments/Command/PaymentAddTransactionAction.php b/src/Request/Payments/Command/PaymentAddTransactionAction.php index ddd5c30e8f..6201438e0a 100644 --- a/src/Request/Payments/Command/PaymentAddTransactionAction.php +++ b/src/Request/Payments/Command/PaymentAddTransactionAction.php @@ -12,7 +12,7 @@ use Commercetools\Core\Model\State\StateReference; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentAddTransactionAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetAmountPaidAction.php b/src/Request/Payments/Command/PaymentSetAmountPaidAction.php index ef0ef6239e..3b6b9e081e 100644 --- a/src/Request/Payments/Command/PaymentSetAmountPaidAction.php +++ b/src/Request/Payments/Command/PaymentSetAmountPaidAction.php @@ -10,7 +10,7 @@ use Commercetools\Core\Model\Common\Money; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetAmountPaidAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetAmountRefundedAction.php b/src/Request/Payments/Command/PaymentSetAmountRefundedAction.php index 512eefa3ac..fba8649058 100644 --- a/src/Request/Payments/Command/PaymentSetAmountRefundedAction.php +++ b/src/Request/Payments/Command/PaymentSetAmountRefundedAction.php @@ -10,7 +10,7 @@ use Commercetools\Core\Model\Common\Money; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetAmountRefundedAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetAuthorizationAction.php b/src/Request/Payments/Command/PaymentSetAuthorizationAction.php index d5f6bd341f..3531783b08 100644 --- a/src/Request/Payments/Command/PaymentSetAuthorizationAction.php +++ b/src/Request/Payments/Command/PaymentSetAuthorizationAction.php @@ -11,7 +11,7 @@ use Commercetools\Core\Model\Common\DateTimeDecorator; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetAuthorizationAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetCustomFieldAction.php b/src/Request/Payments/Command/PaymentSetCustomFieldAction.php index 188b5d247a..5ae35f66bf 100644 --- a/src/Request/Payments/Command/PaymentSetCustomFieldAction.php +++ b/src/Request/Payments/Command/PaymentSetCustomFieldAction.php @@ -8,7 +8,7 @@ use Commercetools\Core\Request\CustomField\Command\SetCustomFieldAction; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetCustomFieldAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetCustomTypeAction.php b/src/Request/Payments/Command/PaymentSetCustomTypeAction.php index 9710f53cb6..db29c16b88 100644 --- a/src/Request/Payments/Command/PaymentSetCustomTypeAction.php +++ b/src/Request/Payments/Command/PaymentSetCustomTypeAction.php @@ -10,7 +10,7 @@ use Commercetools\Core\Model\CustomField\FieldContainer; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetCustomTypeAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetCustomerAction.php b/src/Request/Payments/Command/PaymentSetCustomerAction.php index b0bf27dcb1..d56822d5e5 100644 --- a/src/Request/Payments/Command/PaymentSetCustomerAction.php +++ b/src/Request/Payments/Command/PaymentSetCustomerAction.php @@ -10,7 +10,7 @@ use Commercetools\Core\Model\Customer\CustomerReference; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetCustomerAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetExternalIdAction.php b/src/Request/Payments/Command/PaymentSetExternalIdAction.php index 1a2060ae6f..63b405c10b 100644 --- a/src/Request/Payments/Command/PaymentSetExternalIdAction.php +++ b/src/Request/Payments/Command/PaymentSetExternalIdAction.php @@ -10,7 +10,7 @@ use Commercetools\Core\Model\Customer\CustomerReference; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetExternalIdAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetInterfaceIdAction.php b/src/Request/Payments/Command/PaymentSetInterfaceIdAction.php index 40d4f2ff46..c43a133092 100644 --- a/src/Request/Payments/Command/PaymentSetInterfaceIdAction.php +++ b/src/Request/Payments/Command/PaymentSetInterfaceIdAction.php @@ -10,7 +10,7 @@ use Commercetools\Core\Model\Customer\CustomerReference; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetInterfaceIdAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetMethodInfoInterfaceAction.php b/src/Request/Payments/Command/PaymentSetMethodInfoInterfaceAction.php index 65f529bb13..a2b1dcc957 100644 --- a/src/Request/Payments/Command/PaymentSetMethodInfoInterfaceAction.php +++ b/src/Request/Payments/Command/PaymentSetMethodInfoInterfaceAction.php @@ -9,7 +9,7 @@ use Commercetools\Core\Request\AbstractAction; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetMethodInfoInterfaceAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetMethodInfoMethodAction.php b/src/Request/Payments/Command/PaymentSetMethodInfoMethodAction.php index c3b615e2ba..13ffe080a1 100644 --- a/src/Request/Payments/Command/PaymentSetMethodInfoMethodAction.php +++ b/src/Request/Payments/Command/PaymentSetMethodInfoMethodAction.php @@ -9,7 +9,7 @@ use Commercetools\Core\Request\AbstractAction; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetMethodInfoMethodAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetMethodInfoNameAction.php b/src/Request/Payments/Command/PaymentSetMethodInfoNameAction.php index b3191338c6..f7ed16cb6e 100644 --- a/src/Request/Payments/Command/PaymentSetMethodInfoNameAction.php +++ b/src/Request/Payments/Command/PaymentSetMethodInfoNameAction.php @@ -10,7 +10,7 @@ use Commercetools\Core\Model\Common\LocalizedString; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetMethodInfoNameAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetStatusInterfaceCodeAction.php b/src/Request/Payments/Command/PaymentSetStatusInterfaceCodeAction.php index c937983e4a..5926e6665e 100644 --- a/src/Request/Payments/Command/PaymentSetStatusInterfaceCodeAction.php +++ b/src/Request/Payments/Command/PaymentSetStatusInterfaceCodeAction.php @@ -10,7 +10,7 @@ use Commercetools\Core\Model\Customer\CustomerReference; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetStatusInterfaceCodeAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentSetStatusInterfaceTextAction.php b/src/Request/Payments/Command/PaymentSetStatusInterfaceTextAction.php index a509adbcd4..19232c6cc4 100644 --- a/src/Request/Payments/Command/PaymentSetStatusInterfaceTextAction.php +++ b/src/Request/Payments/Command/PaymentSetStatusInterfaceTextAction.php @@ -10,7 +10,7 @@ use Commercetools\Core\Model\Customer\CustomerReference; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentSetStatusInterfaceTextAction setAction(string $action = null) diff --git a/src/Request/Payments/Command/PaymentTransitionStateAction.php b/src/Request/Payments/Command/PaymentTransitionStateAction.php index 2a4862753f..b9da63485a 100644 --- a/src/Request/Payments/Command/PaymentTransitionStateAction.php +++ b/src/Request/Payments/Command/PaymentTransitionStateAction.php @@ -9,32 +9,17 @@ use Commercetools\Core\Request\AbstractAction; use Commercetools\Core\Model\Customer\CustomerReference; use Commercetools\Core\Model\State\StateReference; +use Commercetools\Core\Request\States\Command\TransitionStateAction; /** - * @package Commercetools\Core\Request\Payments\Commands + * @package Commercetools\Core\Request\Payments\Command * * @method string getAction() * @method PaymentTransitionStateAction setAction(string $action = null) * @method StateReference getState() * @method PaymentTransitionStateAction setState(StateReference $state = null) */ -class PaymentTransitionStateAction extends AbstractAction +class PaymentTransitionStateAction extends TransitionStateAction { - public function fieldDefinitions() - { - return [ - 'action' => [static::TYPE => 'string'], - 'state' => [static::TYPE => '\Commercetools\Core\Model\State\StateReference'], - ]; - } - /** - * @param array $data - * @param Context|callable $context - */ - public function __construct(array $data = [], $context = null) - { - parent::__construct($data, $context); - $this->setAction('transitionState'); - } } diff --git a/src/Request/States/Command/TransitionStateAction.php b/src/Request/States/Command/TransitionStateAction.php new file mode 100644 index 0000000000..9755f737ad --- /dev/null +++ b/src/Request/States/Command/TransitionStateAction.php @@ -0,0 +1,49 @@ + + */ + +namespace Commercetools\Core\Request\States\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Model\State\StateReference; +use Commercetools\Core\Request\AbstractAction; + +/** + * @package Commercetools\Core\Request\States\Command + * + * @method string getAction() + * @method TransitionStateAction setAction(string $action = null) + * @method StateReference getState() + * @method TransitionStateAction setState(StateReference $state = null) + */ +class TransitionStateAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'state' => [static::TYPE => '\Commercetools\Core\Model\State\StateReference'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('transitionState'); + } + + /** + * @param StateReference $state + * @param Context|callable $context + * @return static + */ + public static function ofState(StateReference $state, $context = null) + { + return static::of($context)->setState($state); + } +}