diff --git a/src/Model/Payment/PaymentReference.php b/src/Model/Payment/PaymentReference.php new file mode 100644 index 0000000000..ea01e3aed5 --- /dev/null +++ b/src/Model/Payment/PaymentReference.php @@ -0,0 +1,32 @@ + + */ + +namespace Commercetools\Core\Model\Payment; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Model\Common\Reference; + +class PaymentReference extends Reference +{ + const TYPE_PAYMENT = 'payment'; + + public function fieldDefinitions() + { + $fields = parent::fieldDefinitions(); + $fields[static::OBJ] = [static::TYPE => '\Commercetools\Core\Model\Payment\Payment']; + + return $fields; + } + + /** + * @param $id + * @param Context|callable $context + * @return PaymentReference + */ + public static function ofId($id, $context = null) + { + return static::ofTypeAndId(static::TYPE_PAYMENT, $id, $context); + } +} diff --git a/src/Request/Carts/Command/CartAddPaymentAction.php b/src/Request/Carts/Command/CartAddPaymentAction.php new file mode 100644 index 0000000000..18ae49bbd2 --- /dev/null +++ b/src/Request/Carts/Command/CartAddPaymentAction.php @@ -0,0 +1,30 @@ + + */ + +namespace Commercetools\Core\Request\Carts\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Request\AbstractAction; + +class CartAddPaymentAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'payment' => [static::TYPE => '\Commercetools\Core\Model\Payment\PaymentReference'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('addPayment'); + } +} diff --git a/src/Request/Carts/Command/CartRemovePaymentAction.php b/src/Request/Carts/Command/CartRemovePaymentAction.php new file mode 100644 index 0000000000..fe31a21980 --- /dev/null +++ b/src/Request/Carts/Command/CartRemovePaymentAction.php @@ -0,0 +1,30 @@ + + */ + +namespace Commercetools\Core\Request\Carts\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Request\AbstractAction; + +class CartRemovePaymentAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'payment' => [static::TYPE => '\Commercetools\Core\Model\Payment\PaymentReference'], + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('removePayment'); + } +}