Skip to content

Commit

Permalink
API create fields validation
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrjozwiak committed Oct 9, 2017
1 parent c55e00a commit f4024a5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tpayLibs/examples/BlikExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct()

/**
* pass blikcode to created transaction
* channel for create method must be 64
* channel for create method must be 150
*/

public function blikTransaction()
Expand Down
1 change: 1 addition & 0 deletions tpayLibs/src/Dictionaries/FieldsConfigDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ class FieldsConfigDictionary
const CURRENCY = 'currency';
const LANGUAGE = 'language';
const CODE = 'code';
const NAME = 'nazwisko';

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use tpayLibs\src\_class_tpay\Utilities\ObjectsHelper;
use tpayLibs\src\_class_tpay\Utilities\TException;
use tpayLibs\src\_class_tpay\Validators\PaymentTypes\PaymentTypeBasic;
use tpayLibs\src\_class_tpay\Validators\PaymentTypes\PaymentTypeBasicApi;

/**
* Class BasicPaymentOptions
Expand Down Expand Up @@ -48,13 +49,13 @@ public function setTransactionID($transactionID)
*
* @param array $config transaction config
*
* @param bool $isApi set to get config fields for transaction API
* @return array
*
* @throws TException
*/
public function prepareConfig($config)
public function prepareConfig($config, $isApi = false)
{
$ready = $this->validateConfig(new PaymentTypeBasic(), $config);
$ready = $isApi ? $this->validateConfig(new PaymentTypeBasicApi(), $config) :
$this->validateConfig(new PaymentTypeBasic(), $config);

$ready['md5sum'] = md5($this->merchantId . $ready['kwota'] . $ready['crc'] . $this->merchantSecret);
$ready['id'] = $this->merchantId;
Expand Down
2 changes: 1 addition & 1 deletion tpayLibs/src/_class_tpay/TransactionApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function create($config)
{
$url = $this->apiURL . $this->trApiKey . '/transaction/create';

$config = $this->prepareConfig($config);
$config = $this->prepareConfig($config, true);
Util::log('Transaction create request params', print_r($config, true));
$response = $this->requests($url, $config);
Util::log('Transaction create response', print_r($response, true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function getRequestFields()
{
$fields = StandardFieldsDictionary::REQUEST_FIELDS;
$fields[FieldsConfigDictionary::GROUP][FieldsConfigDictionary::REQUIRED] = true;
$fields[FieldsConfigDictionary::NAME][FieldsConfigDictionary::REQUIRED] = true;
return $fields;
}

Expand Down

0 comments on commit f4024a5

Please sign in to comment.