This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Payment): add payment update actions for cart
- Loading branch information
Jens Schulze
committed
Oct 7, 2015
1 parent
c64fad0
commit 13e1860
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |