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

Commit 13e1860

Browse files
author
Jens Schulze
committed
feat(Payment): add payment update actions for cart
1 parent c64fad0 commit 13e1860

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* @author @ct-jensschulze <[email protected]>
4+
*/
5+
6+
namespace Commercetools\Core\Model\Payment;
7+
8+
use Commercetools\Core\Model\Common\Context;
9+
use Commercetools\Core\Model\Common\Reference;
10+
11+
class PaymentReference extends Reference
12+
{
13+
const TYPE_PAYMENT = 'payment';
14+
15+
public function fieldDefinitions()
16+
{
17+
$fields = parent::fieldDefinitions();
18+
$fields[static::OBJ] = [static::TYPE => '\Commercetools\Core\Model\Payment\Payment'];
19+
20+
return $fields;
21+
}
22+
23+
/**
24+
* @param $id
25+
* @param Context|callable $context
26+
* @return PaymentReference
27+
*/
28+
public static function ofId($id, $context = null)
29+
{
30+
return static::ofTypeAndId(static::TYPE_PAYMENT, $id, $context);
31+
}
32+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* @author @ct-jensschulze <[email protected]>
4+
*/
5+
6+
namespace Commercetools\Core\Request\Carts\Command;
7+
8+
use Commercetools\Core\Model\Common\Context;
9+
use Commercetools\Core\Request\AbstractAction;
10+
11+
class CartAddPaymentAction extends AbstractAction
12+
{
13+
public function fieldDefinitions()
14+
{
15+
return [
16+
'action' => [static::TYPE => 'string'],
17+
'payment' => [static::TYPE => '\Commercetools\Core\Model\Payment\PaymentReference'],
18+
];
19+
}
20+
21+
/**
22+
* @param array $data
23+
* @param Context|callable $context
24+
*/
25+
public function __construct(array $data = [], $context = null)
26+
{
27+
parent::__construct($data, $context);
28+
$this->setAction('addPayment');
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* @author @ct-jensschulze <[email protected]>
4+
*/
5+
6+
namespace Commercetools\Core\Request\Carts\Command;
7+
8+
use Commercetools\Core\Model\Common\Context;
9+
use Commercetools\Core\Request\AbstractAction;
10+
11+
class CartRemovePaymentAction extends AbstractAction
12+
{
13+
public function fieldDefinitions()
14+
{
15+
return [
16+
'action' => [static::TYPE => 'string'],
17+
'payment' => [static::TYPE => '\Commercetools\Core\Model\Payment\PaymentReference'],
18+
];
19+
}
20+
21+
/**
22+
* @param array $data
23+
* @param Context|callable $context
24+
*/
25+
public function __construct(array $data = [], $context = null)
26+
{
27+
parent::__construct($data, $context);
28+
$this->setAction('removePayment');
29+
}
30+
}

0 commit comments

Comments
 (0)