Skip to content

Commit

Permalink
Merge branch 'RemoveDataValidation' into 'master'
Browse files Browse the repository at this point in the history
Remove Data validation from SDK

See merge request kount/third_party/kount-ris-php-sdk!11
  • Loading branch information
Sanjeev Kumar committed Feb 5, 2021
2 parents 0547aec + 7a04799 commit 18e9f00
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 789 deletions.
2 changes: 1 addition & 1 deletion composer.json
@@ -1,5 +1,5 @@
{
"name": "sanjeev.kumar/phpcicduat",
"name": "kount/kount-ris-php-sdk",
"description": "PHP client for Kount Risk Inquiry Service.",
"keywords": ["test", "payments", "sdk"],
"homepage": "https://github.com/Kount/kount-ris-php-sdk",
Expand Down
12 changes: 2 additions & 10 deletions src/Kount/Ris/ArraySettings.php
Expand Up @@ -45,11 +45,7 @@ public function __construct ($settings) {
* @return int Kount Merchant ID (MERC)
*/
public function getMerchantId () {
if(!$this->settings['MERCHANT_ID']) {
throw new Exception(
"Unable to get configuration setting 'MERCHANT_ID'. " .
"Check that the MERCHANT_ID setting exists and is not set to null or empty string. ");
}

return $this->settings['MERCHANT_ID'];
}

Expand All @@ -60,11 +56,7 @@ public function getMerchantId () {
* @return string RIS server URL
*/
public function getRisUrl () {
if(!$this->settings['URL']) {
throw new Exception(
"Unable to get configuration setting 'URL'. " .
"Check that the URL setting exists and is not set to null or empty string. ");
}

return $this->settings['URL'];
}

Expand Down
60 changes: 23 additions & 37 deletions src/Kount/Ris/Request.php
Expand Up @@ -247,10 +247,8 @@ public function __construct($settings = null)
$this->settings = new Kount_Ris_ArraySettings($configReader->getSettings());
Kount_Util_Khash::createKhash($this->settings);
}
if ($this->settings->getConfigKey()) {
Kount_Util_Khash::setConfigKey($this->settings->getConfigKey());
}

Kount_Util_Khash::setConfigKey($this->settings->getConfigKey());
$this->setMerchantId($this->settings->getMerchantId());
$this->setVersion(self::VERSION);
$this->setUrl($this->settings->getRisUrl());
Expand Down Expand Up @@ -294,7 +292,6 @@ public function getResponse()
"due to empty payment token. Request mode [" . $this->data['MODE'] .
"]");
}

//start RIS call timer
$startTimer = microtime(true);

Expand Down Expand Up @@ -366,7 +363,6 @@ public function getResponse()
$result = curl_error($ch);
$this->logger->error(__METHOD__ . " An error occurred posting to RIS. " .
"Curl error [$result]");
throw new Kount_Ris_Exception($result);
}
curl_close($ch);

Expand Down Expand Up @@ -470,10 +466,7 @@ public function setConnectionTimeout($timeout)
*/
public function setVersion($version)
{
if (is_int($version)) {
$this->logger->error(__METHOD__ . " Invalid version number [{$version}]");
throw new Kount_Ris_IllegalArgumentException("Version must be a string");
}

$this->data['VERS'] = $version;
return $this;
}
Expand Down Expand Up @@ -911,22 +904,16 @@ protected function isSetKhashPaymentEncoding()
*/
protected function setPaymentToken($token)
{
if (!empty($token) && empty($this->data['LAST4'])) {
if (mb_strlen($token) >= 4) {
$this->data['LAST4'] = mb_substr($token, mb_strlen($token) - 4);
} else {

if (mb_strlen($token) >= 4) {
$this->data['LAST4'] = mb_substr($token, mb_strlen($token) - 4);
} else {
$this->data['LAST4'] = $token;
}
}

if ($this->isSetKhashPaymentEncoding()) {
if ($this->settings->getConfigKey()) {
Kount_Util_Khash::setConfigKey($this->settings->getConfigKey());
}
$token = (self::GIFT_CARD_TYPE == $this->data['PTYP']) ?
Kount_Util_Khash::setConfigKey($this->settings->getConfigKey());
$token = (self::GIFT_CARD_TYPE == $this->data['PTYP']) ?
Kount_Util_Khash::hashGiftCard($this->data['MERC'], $token) :
Kount_Util_Khash::hashPaymentToken($token);
}
$this->data['PTOK'] = $token;
return $this;
}
Expand All @@ -942,13 +929,13 @@ protected function setPaymentToken($token)
public function setPaymentMasked($cardNumber)
{
$this->logger->debug(__METHOD__);
if (!empty($cardNumber) && empty($this->data['LAST4'])) {
if (mb_strlen($cardNumber) >= 4) {
$this->data['LAST4'] = mb_substr($cardNumber, mb_strlen($cardNumber) - 4);
} else {
$this->data['LAST4'] = $cardNumber;
}

if (mb_strlen($cardNumber) >= 4) {
$this->data['LAST4'] = mb_substr($cardNumber, mb_strlen($cardNumber) - 4);
} else {
$this->data['LAST4'] = $cardNumber;
}

$result = $this->maskPaymentToken($cardNumber);

$this->data['PTOK'] = $result;
Expand Down Expand Up @@ -1000,18 +987,17 @@ public function setPaymentTokenLast4($last4)
public function setPayment($paymentType, $paymentToken)
{
$this->logger->debug(__METHOD__);
if (!empty($paymentToken) && empty($this->data['LAST4'])) {
if (mb_strlen($paymentToken) >= 4) {
$this->data['LAST4'] =
mb_substr($paymentToken, mb_strlen($paymentToken) - 4);
} else {
$this->data['LAST4'] = $paymentToken;
}
}

if ($this->settings->getConfigKey()) {
Kount_Util_Khash::setConfigKey($this->settings->getConfigKey());

if (mb_strlen($paymentToken) >= 4) {
$this->data['LAST4'] =
mb_substr($paymentToken, mb_strlen($paymentToken) - 4);
} else {
$this->data['LAST4'] = $paymentToken;
}

Kount_Util_Khash::setConfigKey($this->settings->getConfigKey());

$token = (self::GIFT_CARD_TYPE == $paymentType) ?
Kount_Util_Khash::hashGiftCard($this->data['MERC'], $paymentToken) :
Kount_Util_Khash::hashPaymentToken($paymentToken);
Expand Down
15 changes: 2 additions & 13 deletions src/Kount/Ris/Request/Inquiry.php
Expand Up @@ -160,11 +160,6 @@ public function setUserDefinedField($label, $value)
*/
public function setMode($mode)
{
if ((self::MODE_Q != $mode) && (self::MODE_P != $mode) &&
(self::MODE_W != $mode) && (self::MODE_J != $mode)) {
throw new Kount_Ris_IllegalArgumentException(
"Invalid RIS inquiry mode [{$mode}]. Must be 'Q', 'P', 'W' or 'J'");
}
$this->data['MODE'] = $mode;
return $this;
}
Expand Down Expand Up @@ -450,15 +445,9 @@ public function setWebsite($site)
*/
public function setCart($cart)
{
if (!is_array($cart)) {
throw new Kount_Ris_IllegalArgumentException("Cart must be an array");
}

for ($i = 0; $i < count($cart); $i++) {
if ('Kount_Ris_Data_CartItem' != get_class($cart[$i])) {
throw new Kount_Ris_IllegalArgumentException("Cart item #{$i} " .
print_r($cart[$i], true) . " must be of type " .
"Kount_Ris_Data_CartItem");
}

$this->data["PROD_TYPE[{$i}]"] = $cart[$i]->getProductType();
$this->data["PROD_ITEM[{$i}]"] = $cart[$i]->getItemName();
$this->data["PROD_DESC[{$i}]"] = $cart[$i]->getDescription();
Expand Down
11 changes: 2 additions & 9 deletions src/Kount/Ris/Request/Update.php
Expand Up @@ -91,10 +91,7 @@ public function __construct ($settings = null) {
* @return this
*/
public function setMode ($mode) {
if ((self::MODE_U != $mode) && (self::MODE_X != $mode)) {
throw new Kount_Ris_IllegalArgumentException(
"Invalid RIS update mode [{$mode}]. Must be 'U' or 'X'.");
}

$this->data['MODE'] = $mode;
return $this;
}
Expand All @@ -118,11 +115,7 @@ public function setTransactionId ($transactionId) {
* @return this
*/
public function setRefundChargeback ($rfcb) {
if ((self::RFCB_R != $rfcb) && (self::RFCB_C != $rfcb)) {
throw new Kount_Ris_IllegalArgumentException(
"Invalid RIS update RFCB [{$rfcb}], Must be '" .
self::RFCB_R . "' or '" . self::RFCB_C . "'");
}

$this->data['RFCB'] = $rfcb;
return $this;
}
Expand Down
158 changes: 0 additions & 158 deletions src/Kount/Ris/Validate.php

This file was deleted.

0 comments on commit 18e9f00

Please sign in to comment.