Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
feat(Payment): add payment messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Schulze committed Sep 25, 2015
1 parent c720eed commit b9308c1
Showing 21 changed files with 232 additions and 33 deletions.
41 changes: 41 additions & 0 deletions src/Model/Message/PaymentCreatedMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* @author @ct-jensschulze <jens.schulze@commercetools.de>
*/

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;
}
}
41 changes: 41 additions & 0 deletions src/Model/Message/PaymentInteractionAddedMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* @author @ct-jensschulze <jens.schulze@commercetools.de>
*/

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;
}
}
33 changes: 33 additions & 0 deletions src/Model/Message/PaymentStatusStateTransitionMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* @author @ct-jensschulze <jens.schulze@commercetools.de>
*/

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';
}
41 changes: 41 additions & 0 deletions src/Model/Message/PaymentTransactionAddedMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* @author @ct-jensschulze <jens.schulze@commercetools.de>
*/

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;
}
}
Original file line number Diff line number Diff line change
@@ -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
{
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion src/Request/Payments/Command/PaymentSetCustomerAction.php
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 3 additions & 18 deletions src/Request/Payments/Command/PaymentTransitionStateAction.php
Original file line number Diff line number Diff line change
@@ -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');
}
}
49 changes: 49 additions & 0 deletions src/Request/States/Command/TransitionStateAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* @author @ct-jensschulze <jens.schulze@commercetools.de>
*/

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);
}
}

0 comments on commit b9308c1

Please # to comment.