Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Model/Fields/Collect/Account.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Collect;

use Tpay\OpenApi\Model\Fields\Field;

class Account extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
protected $minLength = 1;
protected $maxLength = 255;
}
14 changes: 14 additions & 0 deletions src/Model/Fields/Collect/Receiver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tpay\OpenApi\Model\Fields\Collect;

use Tpay\OpenApi\Model\Fields\Field;

class Receiver extends Field
{
protected $name = __CLASS__;
protected $type = self::STRING;
protected $minLength = 28;
protected $maxLength = 28;
protected $pattern = '^PL\d{26}$';
}
5 changes: 5 additions & 0 deletions src/Model/Objects/RequestBody/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Tpay\OpenApi\Model\Fields\Transaction\Lang;
use Tpay\OpenApi\Model\Objects\Objects;
use Tpay\OpenApi\Model\Objects\Transactions\Callbacks;
use Tpay\OpenApi\Model\Objects\Transactions\Collect;
use Tpay\OpenApi\Model\Objects\Transactions\Payer;

class Transaction extends Objects
Expand All @@ -20,6 +21,7 @@ class Transaction extends Objects
'pay' => Pay::class,
'payer' => Payer::class,
'callbacks' => Callbacks::class,
'collect' => Collect::class,
];

/** @var Amount */
Expand All @@ -43,6 +45,9 @@ class Transaction extends Objects
/** @var Callbacks */
public $callbacks;

/** @var Collect */
public $collect;

public function getRequiredFields()
{
return [
Expand Down
29 changes: 29 additions & 0 deletions src/Model/Objects/Transactions/Collect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Tpay\OpenApi\Model\Objects\Transactions;

use Tpay\OpenApi\Model\Fields\Collect\Account;
use Tpay\OpenApi\Model\Fields\Collect\Receiver;
use Tpay\OpenApi\Model\Objects\Objects;

class Collect extends Objects
{
const OBJECT_FIELDS = [
'account' => Account::class,
'receiver' => Receiver::class,
];

/** @var Account */
public $account;

/** @var Receiver */
public $receiver;

public function getRequiredFields()
{
return [
$this->account,
$this->receiver,
];
}
}
9 changes: 9 additions & 0 deletions tests/Api/Transactions/TransactionsApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,14 @@ public static function dataCreatingTransaction()
];

yield 'with pay (applePay)' => [$transactionData];

unset($transactionData['pay']);

$transactionData['collect'] = [
'account' => 'CHANGE_THIS_TO_VALID_ACCOUNT_NUMBER',
'receiver' => 'CHANGE_THIS_TO_VALID_RECEIVER_NAME',
Comment on lines +184 to +185
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to put valid values here to let the tests pass

];

yield 'with collect' => [$transactionData];
}
}
Loading