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 update actions for cart
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Schulze committed Oct 7, 2015
1 parent c64fad0 commit 13e1860
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/Model/Payment/PaymentReference.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* @author @ct-jensschulze <jens.schulze@commercetools.de>
*/

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);
}
}
30 changes: 30 additions & 0 deletions src/Request/Carts/Command/CartAddPaymentAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* @author @ct-jensschulze <jens.schulze@commercetools.de>
*/

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

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

0 comments on commit 13e1860

Please # to comment.