diff --git a/CHANGELOG.md b/CHANGELOG.md index 610d371..2d96202 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ = CnpOnline CHANGELOG +==Version 12.40.0 (v12.40.0)(October 25, 2024) +* Change: [cnpAPI v12.40] In authorization,sale and captureGivenAuth request new elements added-> 'typeOfDigitalCurrency' and 'conversionAffiliateId'. +* Change: [cnpAPI v12.40] In existing simple type transactionAmountType range added between minInclusive value -999999999999 and maxInclusive value 999999999999 +* Change: [cnpAPI v12.40] In existing type authenticationProtocolVersionType new values '3','4','5','6','7','8' and '9' are added + +==Version 12.39.0 (v12.39.0) (October 25, 2024) +* Change: [cnpAPI v12.39] In 'subMerchantCredit' 'payFacCredit','reserveCredit', 'payoutOrgCreditRequest' base changed from 'transactionTypeWithReportGroup' to 'transactionTypeWithReportGroupAndRtp'. +* Change: [cnpAPI v12.39] To support new changed extension base for above txns ,New Complextype 'transactionTypeWithReportGroupAndRtp' added. +* Change: [cnpAPI v12.39] New element 'fundingTransactionReferenceNumber' in authorization and sale response. + +==Version 12.38.0 (v12.38.0) (October 25, 2024) +* Change: [cnpAPI v12.38] In existing Enum 'ActionTypeEnum' new value 'FIVD' added +* Change: [cnpAPI v12.38] In existing complex element 'baseRequest' two more choices are added 'encryptionKeyRequest' and 'encryptedPayload' +* Change: [cnpAPI v12.38] In existing complex element 'cnpOnlineResponse' one more choice is added 'encryptionKeyResponse' +* Change: [cnpAPI v12.38] New element 'encryptionKeyRequest' is added of type 'encryptionKeyRequestEnum' +* Change: [cnpAPI v12.38] To support 'encryptionKeyRequest' new Enum 'encryptionKeyRequestEnum' added with values 'CURRENT' and 'PREVIOUS' +* Change: [cnpAPI v12.38] New complex element 'encryptionKeyResponse' is added with simple elements ->'encryptionKeySequence' of type 'encryptionKeySequenceType' and 'encryptionKey' of type 'encryptionKeyType' +* Change: [cnpAPI v12.38] To support 'encryptionKeySequence' new simple type 'encryptionKeySequenceType' added with total Digits 19 +* Change: [cnpAPI v12.38] To support 'encryptionKey' new simple type 'encryptionKeyType' of type string with maxLength 15000 +* Change: [cnpAPI v12.38] New complex element 'encryptedPayload' is added with simple elements ->'encryptionKeySequence' of type 'encryptionKeySequenceType' and 'payload' of type 'payloadType' +* Change: [cnpAPI v12.38] To support 'payload' new simple type 'payloadType' of type string with maxLength 15000 +* Change: [cnpAPI v12.38] In capture Request new complex element 'partialCapture' is added with elements-> 'partialCaptureSequenceNumber' of type 'integer' and 'partialCaptureTotalCount' of type 'partialCaptureCount' + ==Version 12.37.1 (v12.37.1)(July 29, 2024) Fix: [cnpAPI v12.37.1] Fix for Ordering issue for Fast Access Funding diff --git a/cnp/sdk/Checker.php b/cnp/sdk/Checker.php index 2381ac3..b56467f 100644 --- a/cnp/sdk/Checker.php +++ b/cnp/sdk/Checker.php @@ -36,7 +36,7 @@ class Checker public static function validateXML($request){ $xml = new DOMDocument(); $xml->loadXML($request); - $filepath = __DIR__ . "/schema/SchemaCombined_v12.37.xsd"; + $filepath = __DIR__ . "/schema/SchemaCombined_v12.40.xsd"; $result = $xml->schemaValidate( $filepath); if(!$result) diff --git a/cnp/sdk/CnpOnline.php b/cnp/sdk/CnpOnline.php index 191ec36..e561b3b 100644 --- a/cnp/sdk/CnpOnline.php +++ b/cnp/sdk/CnpOnline.php @@ -24,9 +24,9 @@ * OTHER DEALINGS IN THE SOFTWARE. */ namespace cnp\sdk; -define('CURRENT_XML_VERSION', '12.37'); -define('CURRENT_SDK_VERSION', 'PHP;12.37.1'); +define('CURRENT_XML_VERSION', '12.40'); +define('CURRENT_SDK_VERSION', 'PHP;12.40.0'); define('MAX_TXNS_PER_BATCH', 100000); define('MAX_TXNS_PER_REQUEST', 500000); -define('CNP_CONFIG_LIST', 'user,password,merchantId,timeout,proxy,reportGroup,version,url,cnp_requests_path,batch_requests_path,sftp_username,sftp_password,batch_url,tcp_port,tcp_ssl,tcp_timeout,print_xml,vantivPublicKeyID,gpgPassphrase,useEncryption,deleteBatchFiles,multiSite,multiSiteErrorThreshold,maxHoursWithoutSwitch,printMultiSiteDebug,multiSiteUrl1,multiSiteUrl2,sftp_timeout'); +define('CNP_CONFIG_LIST', 'user,password,merchantId,timeout,proxy,reportGroup,version,url,cnp_requests_path,batch_requests_path,sftp_username,sftp_password,batch_url,tcp_port,tcp_ssl,tcp_timeout,print_xml,neuter_xml,vantivPublicKeyID,gpgPassphrase,useEncryption,deleteBatchFiles,multiSite,multiSiteErrorThreshold,maxHoursWithoutSwitch,printMultiSiteDebug,multiSiteUrl1,multiSiteUrl2,sftp_timeout,oltpEncryptionKeySequence,oltpEncryptionPayload,oltpEncryptionKeyPath'); diff --git a/cnp/sdk/CnpOnlineRequest.php b/cnp/sdk/CnpOnlineRequest.php index 18ff197..4af99cb 100644 --- a/cnp/sdk/CnpOnlineRequest.php +++ b/cnp/sdk/CnpOnlineRequest.php @@ -25,6 +25,11 @@ */ namespace cnp\sdk; +use DOMDocument; +use XSLTProcessor; +use SimpleXMLElement; +use SplFileInfo; +use Exception; require_once realpath(dirname(__FILE__)) . '/CnpOnline.php'; class CnpOnlineRequest @@ -148,7 +153,10 @@ public function authorizationRequest($hash_in) 'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData')), 'authIndicator' => XmlFields::returnArrayValue($hash_in, 'authIndicator'), 'accountFundingTransactionData' => XmlFields::accountFundingTransactionData(XmlFields::returnArrayValue($hash_in, 'accountFundingTransactionData')), - 'fraudCheckAction' => XmlFields::returnArrayValue($hash_in, 'fraudCheckAction') + 'fraudCheckAction' => XmlFields::returnArrayValue($hash_in, 'fraudCheckAction'), + 'typeOfDigitalCurrency' => XmlFields::returnArrayValue($hash_in, 'typeOfDigitalCurrency'), + 'conversionAffiliateId' => XmlFields::returnArrayValue($hash_in, 'conversionAffiliateId'), + ); } $choice_hash = array(XmlFields::returnArrayValue($hash_out, 'card'), XmlFields::returnArrayValue($hash_out, 'paypal'), XmlFields::returnArrayValue($hash_out, 'token'), XmlFields::returnArrayValue($hash_out, 'paypage'), XmlFields::returnArrayValue($hash_out, 'applepay'), XmlFields::returnArrayValue($hash_out, 'mpos')); @@ -230,7 +238,10 @@ public function saleRequest($hash_in) 'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData')), 'foreignRetailerIndicator' => XmlFields::returnArrayValue($hash_in, 'foreignRetailerIndicator'), 'accountFundingTransactionData' => XmlFields::accountFundingTransactionData(XmlFields::returnArrayValue($hash_in, 'accountFundingTransactionData')), - 'fraudCheckAction' => XmlFields::returnArrayValue($hash_in, 'fraudCheckAction') + 'fraudCheckAction' => XmlFields::returnArrayValue($hash_in, 'fraudCheckAction'), + 'typeOfDigitalCurrency' => XmlFields::returnArrayValue($hash_in, 'typeOfDigitalCurrency'), + 'conversionAffiliateId' => XmlFields::returnArrayValue($hash_in, 'conversionAffiliateId'), + ); $choice_hash = array($hash_out['card'], $hash_out['paypal'], $hash_out['token'], $hash_out['paypage'], $hash_out['applepay'], $hash_out['mpos']); @@ -468,7 +479,9 @@ public function captureRequest($hash_in) 'lodgingInfo' => XmlFields::lodgingInfo(XmlFields::returnArrayValue($hash_in, 'lodgingInfo')), 'pin' => XmlFields::returnArrayValue($hash_in, 'pin'), 'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData')), - 'foreignRetailerIndicator' => XmlFields::returnArrayValue($hash_in, 'foreignRetailerIndicator') + 'foreignRetailerIndicator' => XmlFields::returnArrayValue($hash_in, 'foreignRetailerIndicator'), + 'partialCapture' => XmlFields::partialCapture(XmlFields::returnArrayValue($hash_in, 'partialCapture')), + ); $captureResponse = $this->processRequest($hash_out, $hash_in, 'capture'); @@ -516,7 +529,10 @@ public function captureGivenAuthRequest($hash_in) 'crypto' => XmlFields::returnArrayValue($hash_in, 'crypto'), 'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData')), 'foreignRetailerIndicator' => XmlFields::returnArrayValue($hash_in, 'foreignRetailerIndicator'), - 'accountFundingTransactionData' => XmlFields::accountFundingTransactionData(XmlFields::returnArrayValue($hash_in, 'accountFundingTransactionData')) + 'accountFundingTransactionData' => XmlFields::accountFundingTransactionData(XmlFields::returnArrayValue($hash_in, 'accountFundingTransactionData')), + 'typeOfDigitalCurrency' => XmlFields::returnArrayValue($hash_in, 'typeOfDigitalCurrency'), + 'conversionAffiliateId' => XmlFields::returnArrayValue($hash_in, 'conversionAffiliateId'), + ); $choice_hash = array($hash_out['card'], $hash_out['token'], $hash_out['paypage'], $hash_out['mpos']); @@ -1473,6 +1489,35 @@ public function finicityAccountRequest($hash_in) return $finicityAccountResponse; } + /** + * @param $hash_in + * @return \DOMDocument|\SimpleXMLElement + * @throws exceptions\cnpSDKException + */ + public function encryptionKeyRequest($hash_in) + { + $hash_out = array(XmlFields::returnArrayValue($hash_in,'encryptionKeyRequest')); + $encryptionKeyResponse = $this->processRequest($hash_out, $hash_in, 'encryptionKeyRequest'); + + return $encryptionKeyResponse; + } + + /** + * @param $hash_in + * @return \DOMDocument|\SimpleXMLElement + * @throws exceptions\cnpSDKException + */ + public function encryptedPayload($hash_in) + { + $hash_out = array( + 'encryptionKeySequence' => (XmlFields::returnArrayValue($hash_in, 'encryptionKeySequence')), + 'payload' => (XmlFields::returnArrayValue($hash_in, 'payload')), + ); + $encryptionKeyResponse = $this->processRequest($hash_out, $hash_in, 'encryptedPayload'); + + return $encryptionKeyResponse; + } + /** * @param $hash_in * @return array @@ -1528,20 +1573,88 @@ private static function getOptionalAttributes($hash_in, $hash_out) private function processRequest($hash_out, $hash_in, $type, $choice1 = null, $choice2 = null) { $hash_config = CnpOnlineRequest::overrideConfig($hash_in); + $hash_config= Obj2xml::getConfig($hash_config); $hash = CnpOnlineRequest::getOptionalAttributes($hash_in, $hash_out); $request = Obj2xml::toXml($hash, $hash_config, $type); - if (Checker::validateXML($request)) { $request = str_replace("submerchantDebitCtx", "submerchantDebit", $request); $request = str_replace("submerchantCreditCtx", "submerchantCredit", $request); $request = str_replace("vendorCreditCtx", "vendorCredit", $request); $request = str_replace("vendorDebitCtx", "vendorDebit", $request); + // If oltpEncryptionPayload enabled then send reuqest for encryption. + if (isset($hash_config['oltpEncryptionPayload']) and (int)$hash_config['oltpEncryptionPayload'] == 1){ + $request = CnpOnlineRequest::getEncryptedPayload($request,$hash_config); + } $cnpOnlineResponse = $this->newXML->request($request, $hash_config, $this->useSimpleXml); } return $cnpOnlineResponse; } + public function getEncryptedPayload($request, $hash_config) + { + try { + $doc = new DOMDocument('1.0', 'UTF-8'); + $doc->loadXML($request); + $root = $doc->documentElement; + + // Find the second child element + $secondChild = $root->childNodes->item(1); + + if ($secondChild !== null) { + + // Skip the encrypt payload part for encryptionKeyRequest + if ($secondChild->nodeName == 'encryptionKeyRequest') { + return $request; + + } else { + $path = null; + if(isset($hash_config['oltpEncryptionKeyPath'])){ + $path = $hash_config['oltpEncryptionKeyPath']; + } + if ($path == null) { + throw new Exception('Problem in reading the Encryption Key path. Provide the Encryption key path.'); + } else { + $path = new SplFileInfo($path); + if (!$path->isFile()) { + throw new Exception("The provided path is not a valid file path or the file does not exist."); + } + } + + $output = $doc->saveXML($secondChild); + + // removing the child element which needs to be encrypted. + $root->removeChild($secondChild); + + //Send payload for encryption + $payload = PgpHelper::encryptPayload($output, $path); + + $encryptedPayloadElement = $doc->createElement('encryptedPayload'); + + // Create and append the encryptionKeySequence element + $encryptionKeySequenceElement = $doc->createElement('encryptionKeySequence'); + if(isset($hash_config['oltpEncryptionKeySequence']) and $hash_config['oltpEncryptionKeySequence'] != null ) { + $encryptionKeySequenceElement->nodeValue = (int)$hash_config['oltpEncryptionKeySequence']; + $encryptedPayloadElement->appendChild($encryptionKeySequenceElement); + } else{ + throw new Exception('Problem in reading the Encryption Key Sequence ...Provide the Encryption key Sequence'); + } + // Create and append the payload element + $payloadElement = $doc->createElement('payload'); + $payloadElement->nodeValue = $payload; + $encryptedPayloadElement->appendChild($payloadElement); + + // adding new element after encryption + $root->appendChild($encryptedPayloadElement); + $xmlRequest = $doc->saveHTML(); + return $xmlRequest; + } + } + } catch (Exception $e) { + throw new Exception('Error processing XML request. Please reach out to SDK Support team.', 0, $e); + } + } } + diff --git a/cnp/sdk/Communication.php b/cnp/sdk/Communication.php index ee6a6aa..428f381 100644 --- a/cnp/sdk/Communication.php +++ b/cnp/sdk/Communication.php @@ -30,8 +30,9 @@ public static function httpRequest($req,$hash_config=NULL) $config = Obj2xml::getConfig($hash_config); - if ((int) $config['print_xml']) { - echo $req; + if ((int)$config['print_xml']) { + Communication::print_xml($req, $config); + #echo $req; } $ch = curl_init(); @@ -55,7 +56,6 @@ public static function httpRequest($req,$hash_config=NULL) $output = curl_exec($ch); - $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if (! $output) { if ($responseCode == 'CURLE_OPERATION_TIMEDOUT'){ @@ -75,4 +75,33 @@ public static function httpRequest($req,$hash_config=NULL) } } + + public static function neuter_xml($xml) + { + $neuter_str = "NEUTERED"; + if ($xml === null) { + return $xml; + } + $xml = preg_replace("/.*?<\/accNum>/", "$neuter_str", $xml); + $xml = preg_replace("/.*?<\/user>/", "$neuter_str", $xml); + $xml = preg_replace("/.*?<\/password>/", "$neuter_str", $xml); + $xml = preg_replace("/.*?<\/track>/", "$neuter_str", $xml); + $xml = preg_replace("/.*?<\/number>/", "$neuter_str", $xml); + $xml = preg_replace("/.*?<\/cardValidationNum>/", "$neuter_str", $xml); + + return $xml; + } + + //If neuter_xml flag enabled then neuter the sensitive data from the request xml + public static function print_xml($xml_request, $config) + { + $xml_to_log = $xml_request; + if (isset($config['neuter_xml']) and (int)$config['neuter_xml'] == 1) { + $xml_to_log = Communication::neuter_xml($xml_to_log); + } + echo "Request XML: $xml_to_log\n"; + + return $xml_to_log; + } + } diff --git a/cnp/sdk/Obj2xml.php b/cnp/sdk/Obj2xml.php index 5f01725..2be093a 100644 --- a/cnp/sdk/Obj2xml.php +++ b/cnp/sdk/Obj2xml.php @@ -43,7 +43,11 @@ public static function toXml($data, $hash_config, $type, $rootNodeName = 'cnpOnl $authentication->addChild('user',$config["user"]); $authentication->addChild('password',$config["password"]); - + // If request type is encryptionKeyRequest then return xml with encryptionKeyRequest value. + if ($type == "encryptionKeyRequest"){ + $xml->addChild($type,$data[0]); + return $xml->asXML(); + } $transacType = $xml->addChild($type); @@ -335,10 +339,13 @@ public static function getConfig($data, $type=NULL) } elseif ($name == 'sftp_timeout') { $config['sftp_timeout'] = isset($config_array['sftp_timeout'])? $config_array['sftp_timeout']:'720'; } else { - if ((!isset($config_array[$name])) and ($name != 'proxy')) { + if ((!isset($config_array[$name])) and ($name != 'proxy') and ($name != 'oltpEncryptionPayload') and ($name != 'oltpEncryptionKeySequence') and ($name != 'oltpEncryptionKeyPath') and ($name != 'neuter_xml')) { throw new \InvalidArgumentException("Missing Field /$name/"); } - $config[$name] = $config_array[$name]; + // If encryptionPayload properties are not available in config file then add other properties. + if(isset($config_array[$name])){ + $config[$name] = $config_array[$name]; + } } } } diff --git a/cnp/sdk/PgpHelper.php b/cnp/sdk/PgpHelper.php index f3e96b9..648a8f8 100644 --- a/cnp/sdk/PgpHelper.php +++ b/cnp/sdk/PgpHelper.php @@ -1,6 +1,7 @@ ["pipe", "r"], // stdin is a pipe that the child will read from + 1 => ["pipe", "w"], // stdout is a pipe that the child will write to + 2 => ["pipe", "w"] // stderr is a pipe that the child will write to + ]; + + $process = proc_open("gpg --batch --yes --quiet --no-secmem-warning --armor --trust-model always --recipient-file $publicKey --encrypt", $descriptorspec, $pipes); + + if (is_resource($process)) { + // Write the input string to the stdin of the process + fwrite($pipes[0], $encryptInput); + fclose($pipes[0]); + + // Read the encrypted content from the stdout of the process + $encryptedString = stream_get_contents($pipes[1]); + fclose($pipes[1]); + + // Read any errors from the stderr of the process + $errors = stream_get_contents($pipes[2]); + fclose($pipes[2]); + + // Close the process + $return_value = proc_close($process); + + if ($return_value != 0) { + throw new \RuntimeException("Encrypting the payload has failed" . $errors); + } + return $encryptedString; + } else { + throw new \RuntimeException("Encrypting the payload has failed. Please check the Encryption key or key path, is correct!\n"); + } + } } diff --git a/cnp/sdk/Setup.php b/cnp/sdk/Setup.php index 1a0e7f9..b5585f6 100755 --- a/cnp/sdk/Setup.php +++ b/cnp/sdk/Setup.php @@ -99,6 +99,7 @@ function initialize() # ssl should be usd by default $line['tcp_ssl'] = '1'; $line['print_xml'] = '0'; + $line['neuter_xml'] = '1'; print "Use PGP encryption for batch files? (y/n) (No encryption by default): "; $useEncryption = formatConfigValue(STDIN); if(("y" == $useEncryption) || ("true" == $useEncryption) || ("yes" == $useEncryption)){ @@ -130,6 +131,22 @@ function initialize() $line['multiSiteErrorThreshold'] = '5'; $line['maxHoursWithoutSwitch'] = '48'; $line['deleteBatchFiles'] = ""; + + print "Please input your oltpEncryptionPayload (true/false) (No encryption by default): "; + $oltpEncryptionPayload = trim(fgets(STDIN)); + $line['oltpEncryptionPayload'] = $oltpEncryptionPayload; + $booleanValue = filter_var(strtolower($oltpEncryptionPayload), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); + if ($booleanValue){ + print "Please input your oltpEncryptionKeySequence: "; + $line['oltpEncryptionKeySequence'] = formatConfigValue(STDIN); + print "Please input your oltpEncryptionKeyPath: "; + $line['oltpEncryptionKeyPath '] = formatConfigValue(STDIN); + }else{ + $line['oltpEncryptionPayload'] = "false"; + $line['oltpEncryptionKeySequence'] = ""; + $line['oltpEncryptionKeyPath '] = ""; + } + writeConfig($line,$handle); #default http timeout set to 500 ms fwrite($handle, "timeout = 500". PHP_EOL); diff --git a/cnp/sdk/Test/functional/AuthFunctionalTest.php b/cnp/sdk/Test/functional/AuthFunctionalTest.php index dc75dc5..c45cb4a 100644 --- a/cnp/sdk/Test/functional/AuthFunctionalTest.php +++ b/cnp/sdk/Test/functional/AuthFunctionalTest.php @@ -1320,4 +1320,113 @@ public function test_simple_auth_with_authIndicator_incremental() $location = XmlParser::getNode($authorizationResponse, 'location'); $this->assertEquals('sandbox', $location); } + + public function test_simple_auth_with_DigitalCurrency() + { + $hash_in = array('id' => 'id', + 'card' => array('type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1213', + 'cardValidationNum' => '1213'), + 'id' => '1211', + 'accountFundingTransactionData' => array( + 'receiverLastName' =>'Smith', + 'receiverState' => 'AZ', + 'receiverCountry' => 'USA', + 'receiverAccountNumber' => '1234567890', + 'accountFundingTransactionType' => 'walletTransfer', + 'receiverAccountNumberType' => 'socialNetworkID' + ), + 'typeOfDigitalCurrency' => '1', + 'conversionAffiliateId' => 'Test', + 'orderId' => '22@33', + 'reportGroup' => 'Planets', + 'orderSource' => 'ecommerce', + 'orderChannel' => 'SCAN_AND_GO', + 'fraudCheckAction' => 'DECLINED_NEED_FRAUD_CHECK', + 'amount' => '0', + 'enhancedData' => array( + 'detailTax0' => array( + 'taxAmount' => '200', + 'taxRate' => '0.06', + 'taxIncludedInTotal' => true + ), + 'detailTax1' => array( + 'taxAmount' => '300', + 'taxRate' => '0.10', + 'taxIncludedInTotal' => true + ),'lineItemData0' => array( + 'itemSequenceNumber' => '1', + 'itemDescription' => 'product 1', + 'productCode' => '123', + 'quantity' => 3, + 'unitOfMeasure' => 'unit', + 'taxAmount' => 200, + 'detailTax' => array( + 'taxIncludedInTotal' => true, + 'taxAmount' => 200 + ), + 'itemCategory' => 'Aparel', + 'itemSubCategory' => 'Clothing', + 'productId' => '1001', + 'productName' => 'N1', + ), + 'lineItemData1' => array( + 'itemSequenceNumber' => '2', + 'itemDescription' => 'product 2', + 'productCode' => '456', + 'quantity' => 1, + 'unitOfMeasure' => 'unit', + 'taxAmount' => 300, + 'detailTax' => array( + 'taxIncludedInTotal' => true, + 'taxAmount' => 300 + ) + ), + 'salesTax' => '500', + 'taxExempt' => false, + 'fulfilmentMethodType' => 'STANDARD_SHIPPING' + ), + ); + + $initialize = new CnpOnlineRequest(); + $authorizationResponse = $initialize->authorizationRequest($hash_in); + $response = XmlParser::getNode($authorizationResponse, 'response'); + $this->assertEquals('000', $response); + $location = XmlParser::getNode($authorizationResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + + public function test_encrypted_auth() + { + $hash_in = array('id' => 'id', + 'card' => array('type' => 'MC', + 'number' => '5112000900000005', + 'expDate' => '1213', + 'cardValidationNum' => '1213'), + 'id' => '1211', + 'orderId' => '22@33', + 'reportGroup' => 'Planets', + 'orderSource' => 'ecommerce', + 'businessIndicator'=>'agentCashOut', + 'accountFundingTransactionData' => array( + 'receiverLastName' =>'Smith', + 'receiverState' => 'AZ', + 'receiverCountry' => 'USA', + 'receiverAccountNumber' => '1234567890', + 'accountFundingTransactionType' => 'walletTransfer', + 'receiverAccountNumberType' => 'cardAccount' + ), + 'amount' => '1512', + 'oltpEncryptionPayload' => true + ); + + $initialize = new CnpOnlineRequest(); + $authorizationResponse = $initialize->authorizationRequest($hash_in); + $response = XmlParser::getNode($authorizationResponse, 'response'); + $this->assertEquals('000', $response); + $location = XmlParser::getNode($authorizationResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + } diff --git a/cnp/sdk/Test/functional/BNPLAuthorizationRequestTest.php b/cnp/sdk/Test/functional/BNPLAuthorizationRequestTest.php index 3ce8208..a239846 100644 --- a/cnp/sdk/Test/functional/BNPLAuthorizationRequestTest.php +++ b/cnp/sdk/Test/functional/BNPLAuthorizationRequestTest.php @@ -97,4 +97,35 @@ public function test_simple_BNPL_Authorization_Request() } + public function test_encrypted_BNPL_Authorization_Request() + { + $hash_in = array( + 'id' => '1211', + 'orderId' => '2111', + 'reportGroup' => 'Planets', + 'amount' => '1000', + 'provider' => 'AFFIRM', + 'postCheckoutRedirectUrl' => 'www.abc.com', + 'customerInfo' => array( + 'accountUsername' => 'username123', + 'userAccountNumber' => '7647326235897', + 'userAccountEmail' => 'dummtemail@abc.com', + 'membershipId' => '23874682304', + 'membershipPhone' => '16818807607551094758', + 'membershipEmail' => 'email@abc.com', + 'membershipName' => 'member123', + 'accountCreatedDate' => '2050-07-17', + 'userAccountPhone' => '1392345678', + ), + 'oltpEncryptionPayload' => true + ); + $initialize = new CnpOnlineRequest(); + $BNPLAuthorizationResponse = $initialize->BNPLAuthorizationRequest($hash_in); + $response = XmlParser::getNode($BNPLAuthorizationResponse, 'response'); + $this->assertEquals('000', $response); + $location = XmlParser::getNode($BNPLAuthorizationResponse, 'location'); + $this->assertEquals('sandbox', $location); + + } + } \ No newline at end of file diff --git a/cnp/sdk/Test/functional/BatchRequestFunctionalTest.php b/cnp/sdk/Test/functional/BatchRequestFunctionalTest.php index 64e2144..25bb795 100644 --- a/cnp/sdk/Test/functional/BatchRequestFunctionalTest.php +++ b/cnp/sdk/Test/functional/BatchRequestFunctionalTest.php @@ -3390,6 +3390,140 @@ public function test_batch_with_accountFundingTransactionData_fraudCheckAction() } + public function test_batch_12_40() + { + if(strtolower($this->preliveStatus) == 'down'){ + $this->markTestSkipped('Prelive is not available'); + } + + $request = new CnpRequest(); + + $batch = new BatchRequest(); + $hash_in = array('id' => '123', + 'card' => array('type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1210'), + 'cardholderAuthentication' => array( + 'authenticationProtocolVersion' => 9), + 'orderId' => '22@33', + 'reportGroup' => 'Planets', + 'orderSource' => 'ecommerce', + 'amount' => '1000', + 'orderChannel' => 'SCAN_AND_GO', + 'businessIndicator'=>'agentCashOut', + 'passengerTransportData' =>array( + 'passengerName' =>'Mrs. Abc', + 'ticketNumber' =>'ATL456789010000' , + 'issuingCarrier' =>'AMTK', + 'carrierName' =>'AMTK', + 'restrictedTicketIndicator' =>'99999', + 'numberOfAdults' =>'3', + 'numberOfChildren' =>'0', + 'customerCode' =>'Railway', + 'arrivalDate' =>'2023-09-20', + 'issueDate' =>'2023-09-10', + 'travelAgencyCode' =>'12345678', + 'travelAgencyName' =>'Travel R Us23456789054321', + 'computerizedReservationSystem' =>'STRT', + 'creditReasonIndicator' =>'P', + 'ticketChangeIndicator' =>'C', + 'ticketIssuerAddress' =>'99 Second St', + 'exchangeTicketNumber' =>'123456789012346', + 'exchangeAmount' =>'500006', + 'exchangeFeeAmount' =>'5006', + 'tripLegData' =>array( + 'tripLegNumber' =>'12' , + 'serviceClass' =>'First', + 'departureDate' =>'2023-09-20', + 'originCity' =>'BOS') + ), + 'fraudCheckAction' => 'APPROVED_SKIP_FRAUD_CHECK', + 'typeOfDigitalCurrency' => 'BCoin', + 'conversionAffiliateId' => 'DC12345' + ); + $batch->addAuth($hash_in); + + $hash_in = array( + 'card' => array( + 'type' => 'VI', + 'number' => '4100000000000001', + 'expDate' => '1213', + 'cardValidationNum' => '1213' + ), + 'id' => '1211', + 'orderId' => '2111', + 'reportGroup' => 'Planets', + 'orderSource' => 'ecommerce', + 'orderChannel' => 'SCAN_AND_GO', + 'fraudCheckAction' => 'APPROVED_SKIP_FRAUD_CHECK', + 'amount' => '123', + 'businessIndicator'=>'businessToBusinessTransfer', + 'accountFundingTransactionData' => array( + 'receiverLastName' =>'Jon', + 'receiverState' => 'CA', + 'receiverCountry' => 'USA', + 'receiverAccountNumber' => '4356872257i', + 'accountFundingTransactionType' => 'businessDisbursement', + 'receiverAccountNumberType' => 'RTNAndBAN' + ), + 'overridePolicy' => 'merchantPolicyToDecline', + 'fsErrorCode' => 'error123', + 'merchantAccountStatus' => 'activeAccount', + 'productEnrolled' => 'GUARPAY2', + 'decisionPurpose' => 'INFORMATION_ONLY', + 'fraudSwitchIndicator' => 'PRE', + 'typeOfDigitalCurrency' => 'DCoin', + 'conversionAffiliateId' => 'DC15345' + ); + $batch->addSale($hash_in); + + $hash_in = array( + 'card' => array( + 'type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1213', + 'cardValidationNum' => '1213' + ), + 'id' => '1211', + 'orderId' => '2111', + 'cnpTxnId' => '12345678000', + 'reportGroup' => 'Planets', + 'orderSource' => 'ecommerce', + 'amount' => '123' + ); + $batch->addCapture($hash_in); + + $hash_in = array('id' => 'id', + 'reportGroup' => 'Planets', + 'rtp' => 'true', + 'fundingSubmerchantId' => '2111', + 'submerchantName' => '001', + 'fundsTransferId' => '12345678', + 'amount' => '13', + 'accountInfo' => array( + 'accType' => 'Checking', + 'accNum' => '12345657890', + 'routingNum' => '123456789', + 'checkNum' => '123455' + ), + 'partialCapture' => array( + 'partialCaptureSequenceNumber' => '3', + 'partialCaptureTotalCount' => '5' + ) + ); + $batch->addSubmerchantCredit($hash_in); + + $request->addBatchRequest($batch); + + $resp = new CnpResponseProcessor($request->sendToCnp()); + + $message = $resp->getXmlReader()->getAttribute("message"); + $response = $resp->getXmlReader()->getAttribute("response"); + $this->assertEquals("Valid Format", $message); + $this->assertEquals(0, $response); + + } + public function tearDown() { $files = glob($this->direct . '/*'); // get all file names diff --git a/cnp/sdk/Test/functional/CaptureFunctionalTest.php b/cnp/sdk/Test/functional/CaptureFunctionalTest.php index 2035c9b..b5ce920 100644 --- a/cnp/sdk/Test/functional/CaptureFunctionalTest.php +++ b/cnp/sdk/Test/functional/CaptureFunctionalTest.php @@ -257,4 +257,43 @@ public function test_simple_capture_with_subscription() $location = XmlParser::getNode($captureResponse, 'location'); $this->assertEquals('sandbox', $location); } + + public function test_capture_digitalCurrency() + { + $hash_in = array('id' => 'id', + 'cnpTxnId' => '1234567891234567891', + 'amount' => '123', 'enhancedData' => array( + 'customerReference' => 'Litle', + 'salesTax' => '50', + 'deliveryType' => 'TBD'), + 'payPalOrderComplete' => 'true', + 'partialCapture' => array( + 'partialCaptureSequenceNumber' => '1', + 'partialCaptureTotalCount' => '7' + ) + ); + + $initialize = new CnpOnlineRequest(); + $captureResponse = $initialize->captureRequest($hash_in); + $message = XmlParser::getAttribute($captureResponse, 'cnpOnlineResponse', 'response'); + $this->assertEquals('0', $message); + $location = XmlParser::getNode($captureResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + + public function test_encrypted_capture() + { + $hash_in = array('id' => 'id', + 'cnpTxnId' => '1234567891234567891', + 'amount' => '123', + 'oltpEncryptionPayload' => true); + + $initialize = new CnpOnlineRequest(); + $captureResponse = $initialize->captureRequest($hash_in); + $message = XmlParser::getAttribute($captureResponse, 'cnpOnlineResponse', 'response'); + $this->assertEquals('0', $message); + $location = XmlParser::getNode($captureResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + } diff --git a/cnp/sdk/Test/functional/CaptureGivenAuthFunctionalTest.php b/cnp/sdk/Test/functional/CaptureGivenAuthFunctionalTest.php index 5cbfaeb..21585c6 100644 --- a/cnp/sdk/Test/functional/CaptureGivenAuthFunctionalTest.php +++ b/cnp/sdk/Test/functional/CaptureGivenAuthFunctionalTest.php @@ -654,4 +654,71 @@ public function test_captureGivenAuth_with_subscription() $location = XmlParser::getNode($authorizationResponse, 'location'); $this->assertEquals('sandbox', $location); } + + public function test_simple_captureGivenAuth_with_DigitalCurrency() + { + $hash_in = array('id' => 'id', + 'orderId' => '12344', + 'amount' => '106', + 'authInformation' => array( + 'authDate' => '2002-10-09', 'authCode' => '543216', + 'authAmount' => '12345'), + 'orderSource' => 'ecommerce', + 'businessIndicator'=>'agentCashOut', + 'card' => array( + 'type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1210'), + 'accountFundingTransactionData' => array( + 'receiverLastName' =>'Harry', + 'receiverState' => 'NU', + 'receiverCountry' => 'USA', + 'receiverAccountNumber' => '1234567890', + 'accountFundingTransactionType' => 'personToPerson', + 'receiverAccountNumberType' => 'email' + ), + 'typeOfDigitalCurrency' => '1', + 'conversionAffiliateId' => 'Test', + ); + + $initialize = new CnpOnlineRequest(); + $captureGivenAuthResponse = $initialize->captureGivenAuthRequest($hash_in); + $message = XmlParser::getNode($captureGivenAuthResponse, 'message'); + $this->assertEquals('Approved', $message); + $location = XmlParser::getNode($captureGivenAuthResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + + public function test_encrypted_captureGivenAuth() + { + $hash_in = array('id' => 'id', + 'orderId' => '12344', + 'amount' => '106', + 'authInformation' => array( + 'authDate' => '2002-10-09', 'authCode' => '543216', + 'authAmount' => '12345'), + 'orderSource' => 'ecommerce', + 'businessIndicator'=>'agentCashOut', + 'card' => array( + 'type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1210'), + 'accountFundingTransactionData' => array( + 'receiverLastName' =>'Harry', + 'receiverState' => 'NU', + 'receiverCountry' => 'USA', + 'receiverAccountNumber' => '1234567890', + 'accountFundingTransactionType' => 'personToPerson', + 'receiverAccountNumberType' => 'email' + ), + 'oltpEncryptionPayload' => true); + + $initialize = new CnpOnlineRequest(); + $captureGivenAuthResponse = $initialize->captureGivenAuthRequest($hash_in); + $message = XmlParser::getNode($captureGivenAuthResponse, 'message'); + $this->assertEquals('Approved', $message); + $location = XmlParser::getNode($captureGivenAuthResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + } diff --git a/cnp/sdk/Test/functional/CreditFunctionalTest.php b/cnp/sdk/Test/functional/CreditFunctionalTest.php index 85915a3..e1f942c 100644 --- a/cnp/sdk/Test/functional/CreditFunctionalTest.php +++ b/cnp/sdk/Test/functional/CreditFunctionalTest.php @@ -403,4 +403,39 @@ public function test_simple_credit_with_subscription() $this->assertEquals('sandbox', $location); } + public function test_encrypted_credit() + { + $hash_in = array( + 'card' => array('type' => 'VI', 'id' => 'id', + 'number' => '4100000000000000', + 'expDate' => '1213', + 'cardValidationNum' => '1213'), + 'id' => '1211', + 'orderId' => '2111', + 'reportGroup' => 'Planets', + 'orderSource' => 'ecommerce', + 'amount' => '123', + 'businessIndicator'=>'rapidMerchantSettlement', + 'card' => array( + 'type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1210'), + 'accountFundingTransactionData' => array( + 'receiverLastName' =>'Jon', + 'receiverState' => 'AZ', + 'receiverCountry' => 'USA', + 'receiverAccountNumber' => '4356872257i', + 'accountFundingTransactionType' => 'paymentOfOwnCreditCardBill', + 'receiverAccountNumberType' => 'cardAccount' + ), + 'oltpEncryptionPayload' => true); + + $initialize = new CnpOnlineRequest(); + $creditResponse = $initialize->creditRequest($hash_in); + $response = XmlParser::getNode($creditResponse, 'response'); + $this->assertEquals('000', $response); + $location = XmlParser::getNode($creditResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + } diff --git a/cnp/sdk/Test/functional/EcheckSaleFunctionalTest.php b/cnp/sdk/Test/functional/EcheckSaleFunctionalTest.php index 8f3eed8..4c369a3 100644 --- a/cnp/sdk/Test/functional/EcheckSaleFunctionalTest.php +++ b/cnp/sdk/Test/functional/EcheckSaleFunctionalTest.php @@ -180,4 +180,23 @@ public function test_simple_echeckSale_with_merchantData_customIdentifier() $this->assertEquals('sandbox', $location); } + public function test_encrypted_echeckSale_with_echeck() + { + $hash_in = array('id' => 'id', + 'amount' => '123456', + 'verify' => 'true', + 'orderId' => '12345', + 'orderSource' => 'ecommerce', + 'echeck' => array('accType' => 'Checking', 'accNum' => '12345657890', 'routingNum' => '123456789', 'checkNum' => '123455','echeckCustomerId' => 'customer_v12.34','accountId' => 'account'), + 'billToAddress' => array('name' => 'Bob', 'city' => 'lowell', 'state' => 'MA', 'email' => 'vantiv.com'), + 'oltpEncryptionPayload' => true); + + $initialize = new CnpOnlineRequest(); + $echeckSaleResponse = $initialize->echeckSaleRequest($hash_in); + $response = XmlParser::getNode($echeckSaleResponse, 'response'); + $this->assertEquals('000', $response); + $location = XmlParser::getNode($echeckSaleResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + } diff --git a/cnp/sdk/Test/functional/EncryptionRequestFunctionalTest.php b/cnp/sdk/Test/functional/EncryptionRequestFunctionalTest.php new file mode 100644 index 0000000..64bfff5 --- /dev/null +++ b/cnp/sdk/Test/functional/EncryptionRequestFunctionalTest.php @@ -0,0 +1,32 @@ + 'CURRENT'); + + $initialize = new CnpOnlineRequest(); + $encryptionKeyResponse = $initialize->encryptionKeyRequest($hash_in); + $response = XmlParser::getNode($encryptionKeyResponse, 'encryptionKeySequence'); + $this->assertEquals('10000', $response); + + } +} \ No newline at end of file diff --git a/cnp/sdk/Test/functional/FastAccessFundingFunctionalTest.php b/cnp/sdk/Test/functional/FastAccessFundingFunctionalTest.php index 5d981dd..667b02d 100644 --- a/cnp/sdk/Test/functional/FastAccessFundingFunctionalTest.php +++ b/cnp/sdk/Test/functional/FastAccessFundingFunctionalTest.php @@ -91,4 +91,26 @@ public function test_fastAccessFunding_Direct_Merchant() $location = XmlParser::getNode($fastAccessFundingResponse, 'location'); $this->assertEquals('sandbox', $location); } + + public function test_encrypted_fastAccessFunding() + { + $hash_in = array('id' => 'id', + 'fundingSubmerchantId' => '2111', + 'submerchantName' => '001', + 'fundsTransferId' => '1234567891111111', + 'amount' => '13', + 'card' => array( + 'type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1210' + ), + 'oltpEncryptionPayload' => true + ); + $initialize = new CnpOnlineRequest(); + $fastAccessFundingResponse = $initialize->fastAccessFunding($hash_in); + $response = XmlParser::getNode($fastAccessFundingResponse, 'response'); + $this->assertEquals('000', $response); + $location = XmlParser::getNode($fastAccessFundingResponse, 'location'); + $this->assertEquals('sandbox', $location); + } } \ No newline at end of file diff --git a/cnp/sdk/Test/functional/FinicityUrlRequestTest.php b/cnp/sdk/Test/functional/FinicityUrlRequestTest.php index 3bb5547..97e26a1 100644 --- a/cnp/sdk/Test/functional/FinicityUrlRequestTest.php +++ b/cnp/sdk/Test/functional/FinicityUrlRequestTest.php @@ -32,4 +32,23 @@ public function test_simple_finicity_Url_Request() $this->assertEquals('sandbox', $location); } + + public function test_encrypted_finicity_Url_Request() + { + $hash_in = array( + 'id' => '1211', + 'firstName' => 'abc', + 'lastName' => 'xyz', + 'phoneNumber' => '123456789', + 'email' => 'abc@gmail.com', + 'oltpEncryptionPayload' => true + ); + $initialize = new CnpOnlineRequest(); + $finicityUrlResponse = $initialize->finicityUrlRequest($hash_in); + $response = XmlParser::getNode($finicityUrlResponse, 'response'); + $this->assertEquals('000', $response); + $location = XmlParser::getNode($finicityUrlResponse, 'location'); + $this->assertEquals('sandbox', $location); + + } } \ No newline at end of file diff --git a/cnp/sdk/Test/functional/RefundTransactionReversalFunctionalTest.php b/cnp/sdk/Test/functional/RefundTransactionReversalFunctionalTest.php index 591783e..347f177 100644 --- a/cnp/sdk/Test/functional/RefundTransactionReversalFunctionalTest.php +++ b/cnp/sdk/Test/functional/RefundTransactionReversalFunctionalTest.php @@ -128,4 +128,52 @@ public function test_simple_refundTransactionReversal_with_passengerTransportDat $this->assertEquals('sandbox', $location); } + public function test_encrypted_refundTransactionReversal() + { + $hash_in = array( + 'id' => 'id', + 'cnpTxnId' => '12345678000', + 'amount' => '123', + 'pin' => '1234', + 'surchargeAmount' => '4321', + 'enhancedData' => array( + 'customerReference' => 'cust ref sale1', + 'salesTax' => '1000', + 'discountAmount' => '0', + 'shippingAmount' => '0', + 'dutyAmount' => '0', + 'lineItemData' => array( + 'itemSequenceNumber' => '1', + 'itemDescription' => 'Clothes', + 'productCode' => 'TB123', + 'quantity' => '1', + 'unitOfMeasure' => 'EACH', + 'lineItemTotal' => '9900', + 'lineItemTotalWithTax' => '10000', + 'itemDiscountAmount' => '0', + 'commodityCode' => '301', + 'unitCost' => '31.02', + 'itemCategory' => 'Aparel', + 'itemSubCategory' => 'Clothing', + ), + 'discountCode' => 'OneTimeDiscount11', + 'discountPercent' => '11', + 'fulfilmentMethodType' => 'EXPEDITED_SHIPPING', + ), + 'oltpEncryptionPayload' => true + ); + + $initilaize = new CnpOnlineRequest(); + $refundTransactionReversalResponse = $initilaize->refundTransactionReversal($hash_in); + + $response = XmlParser::getNode($refundTransactionReversalResponse, 'response'); + $this->assertEquals('000', $response); + + $response = XmlParser::getNode($refundTransactionReversalResponse, 'message'); + $this->assertEquals('Approved', $response); + + $location = XmlParser::getNode($refundTransactionReversalResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + } diff --git a/cnp/sdk/Test/functional/SaleFunctionalTest.php b/cnp/sdk/Test/functional/SaleFunctionalTest.php index 76de95c..badc557 100644 --- a/cnp/sdk/Test/functional/SaleFunctionalTest.php +++ b/cnp/sdk/Test/functional/SaleFunctionalTest.php @@ -1474,5 +1474,81 @@ public function test_sale_with_subscription() $message = XmlParser::getNode($authorizationResponse, 'message'); $this->assertEquals('Approved', $message); } - + + public function test_simple_sale_with_digitalCurrency() + { + $hash_in = array( + 'card' => array('type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1213', + 'cardValidationNum' => '1213'), + 'id' => '1211', + 'orderId' => '2111', + 'reportGroup' => 'Planets', + 'orderSource' => 'ecommerce', + 'orderChannel' => 'SCAN_AND_GO', + 'fraudCheckAction' => 'APPROVED_SKIP_FRAUD_CHECK', + 'amount' => '123', + 'businessIndicator'=>'businessToBusinessTransfer', + 'card' => array( + 'type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1210'), + 'accountFundingTransactionData' => array( + 'receiverLastName' =>'Jon', + 'receiverState' => 'CA', + 'receiverCountry' => 'USA', + 'receiverAccountNumber' => '4356872257i', + 'accountFundingTransactionType' => 'businessDisbursement', + 'receiverAccountNumberType' => 'RTNAndBAN' + ), + 'typeOfDigitalCurrency' => '1', + 'conversionAffiliateId' => 'Test', + ); + + $initialize = new CnpOnlineRequest(); + $saleResponse = $initialize->saleRequest($hash_in); + $response = XmlParser::getNode($saleResponse, 'response'); + $this->assertEquals('000', $response); + $location = XmlParser::getNode($saleResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + + public function test_encrypted_sale() + { + $hash_in = array( + 'card' => array('type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1213', + 'cardValidationNum' => '1213'), + 'id' => '1211', + 'orderId' => '2111', + 'reportGroup' => 'Planets', + 'orderSource' => 'ecommerce', + 'orderChannel' => 'SCAN_AND_GO', + 'fraudCheckAction' => 'APPROVED_SKIP_FRAUD_CHECK', + 'amount' => '123', + 'businessIndicator'=>'businessToBusinessTransfer', + 'card' => array( + 'type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1210'), + 'accountFundingTransactionData' => array( + 'receiverLastName' =>'Jon', + 'receiverState' => 'CA', + 'receiverCountry' => 'USA', + 'receiverAccountNumber' => '4356872257i', + 'accountFundingTransactionType' => 'businessDisbursement', + 'receiverAccountNumberType' => 'RTNAndBAN'), + 'oltpEncryptionPayload' => true); + + $initialize = new CnpOnlineRequest(); + $saleResponse = $initialize->saleRequest($hash_in); + $response = XmlParser::getNode($saleResponse, 'response'); + $this->assertEquals('000', $response); + $location = XmlParser::getNode($saleResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + + } diff --git a/cnp/sdk/Test/functional/TokenFunctionalTest.php b/cnp/sdk/Test/functional/TokenFunctionalTest.php index 43c9f34..1df8062 100644 --- a/cnp/sdk/Test/functional/TokenFunctionalTest.php +++ b/cnp/sdk/Test/functional/TokenFunctionalTest.php @@ -145,4 +145,22 @@ public function test_simple_token_with_androidpay() $this->assertEquals('sandbox', $location); } + public function test_encrypted_token() + { + $hash_in = array('id' => '1211', + 'merchantId' => '101', + 'version' => '8.8', + 'reportGroup' => 'Planets', + 'orderId' => '12344', + 'accountNumber' => '1233456789103801', + 'oltpEncryptionPayload' => true); + + $initialize = new CnpOnlineRequest(); + $registerTokenResponse = $initialize->registerTokenRequest($hash_in); + $message = XmlParser::getAttribute($registerTokenResponse, 'cnpOnlineResponse', 'message'); + $this->assertEquals('Valid Format', $message); + $location = XmlParser::getNode($registerTokenResponse, 'location'); + $this->assertEquals('sandbox', $location); + } + } diff --git a/cnp/sdk/Test/unit/AuthUnitTest.php b/cnp/sdk/Test/unit/AuthUnitTest.php index af85382..605ce00 100644 --- a/cnp/sdk/Test/unit/AuthUnitTest.php +++ b/cnp/sdk/Test/unit/AuthUnitTest.php @@ -664,4 +664,103 @@ public function test_simple_auth_with_accountFundingTransactionData_fraudCheckAc $cnpTest->authorizationRequest($hash_in); } + public function test_simple_auth_with_DigitalCurrency() + { + $hash_in = array('id' => 'id', + 'card' => array('type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1213', + 'cardValidationNum' => '1213'), + 'orderId' => '22833', + 'reportGroup' => 'Planets', + 'orderSource' => 'ecommerce', + 'amount' => '1000', + 'orderChannel' => 'SCAN_AND_GO', + 'enhancedData' => array( + 'detailTax0' => array( + 'taxAmount' => '200', + 'taxRate' => '0.06', + 'taxIncludedInTotal' => true + ), + 'detailTax1' => array( + 'taxAmount' => '300', + 'taxRate' => '0.10', + 'taxIncludedInTotal' => true + ), + 'fulfilmentMethodType' => 'STANDARD_SHIPPING', + ), + + 'accountFundingTransactionData' => array( + 'receiverFirstName' => 'abc', + 'receiverLastName' => 'xyz', + 'receiverState' => 'AK', + 'receiverCountry' => 'AD', + 'receiverAccountNumberType' => 'BANAndBIC', + 'receiverAccountNumber' => '12345', + 'accountFundingTransactionType' => 'accountToAccount' + ), + 'typeOfDigitalCurrency' => '1', + 'conversionAffiliateId' => 'Test', + ); + + $mock = $this->getMock('cnp\sdk\CnpXmlMapper'); + $mock ->expects($this->once()) + ->method('request') + ->with($this->matchesRegularExpression('/.*STANDARD_SHIPPING.*.*abc.*xyz.*AK.*AD.*BANAndBIC.*123.*accountToAccount.*1.*Test.*/')); + + $cnpTest = new CnpOnlineRequest(); + $cnpTest->newXML = $mock; + $cnpTest->authorizationRequest($hash_in); + } + + public function test_encrypted_auth_with_lineItemData0() + { + $hash_in = array('id' => 'id', + 'card' => array('type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1213', + 'cardValidationNum' => '1213'), + 'id' => '1211', + 'orderId' => '22@33', + 'reportGroup' => 'Planets', + 'orderSource' => 'ecommerce', + 'amount' => '0', + 'enhancedData' => array( + 'detailTax0' => array( + 'taxAmount' => '200', + 'taxRate' => '0.06', + 'taxIncludedInTotal' => true + ), + 'detailTax1' => array( + 'taxAmount' => '300', + 'taxRate' => '0.10', + 'taxIncludedInTotal' => true + ),'lineItemData0' => array( + 'itemSequenceNumber' => '1', + 'itemDescription' => 'product 1', + 'productCode' => '123', + 'quantity' => 3, + 'unitOfMeasure' => 'unit', + 'taxAmount' => 200, + 'detailTax' => array( + 'taxIncludedInTotal' => true, + 'taxAmount' => 200 + ), + 'itemCategory' => 'Aparel', + 'itemSubCategory' => 'Clothing', + 'productId' => '1001', + 'productName' => 'N1', + )), + 'oltpEncryptionPayload' => true); + $mock = $this->getMock('cnp\sdk\CnpXmlMapper'); + $mock ->expects($this->once()) + ->method('request') #.*.* + ->with($this->matchesRegularExpression('/.*.*/')); + + $cnpTest = new CnpOnlineRequest(); + $cnpTest->newXML = $mock; + $cnpTest->authorizationRequest($hash_in); + } + + } diff --git a/cnp/sdk/Test/unit/CaptureGivenAuthUnitTest.php b/cnp/sdk/Test/unit/CaptureGivenAuthUnitTest.php index 0e2be8e..d3720e5 100644 --- a/cnp/sdk/Test/unit/CaptureGivenAuthUnitTest.php +++ b/cnp/sdk/Test/unit/CaptureGivenAuthUnitTest.php @@ -651,4 +651,41 @@ public function test_capture_given_auth_with_accountFundingTransactionData() $cnpTest->newXML = $mock; $cnpTest->captureGivenAuthRequest($hash_in); } + + public function test_capture_given_auth_with_digitalCurrency() + { + $hash_in = array('id' => 'id', + 'orderId' => '12344', + 'amount' => '106', + 'authInformation' => array( + 'authDate' => '2002-10-09', 'authCode' => '543216', + 'authAmount' => '12345'), + 'orderSource' => 'ecommerce', + 'card' => array( + 'type' => 'VI', + 'number' => '4100000000000000', + 'expDate' => '1210'), + 'businessIndicator' => 'consumerBillPayment', + 'accountFundingTransactionData' => array( + 'receiverFirstName' => 'abc', + 'receiverLastName' => 'xyz', + 'receiverState' => 'NY', + 'receiverCountry' => 'US', + 'receiverAccountNumberType' => 'email', + 'receiverAccountNumber' => '12345', + 'accountFundingTransactionType' => 'topUp' + ), + 'typeOfDigitalCurrency' => '1', + 'conversionAffiliateId' => 'Test', + ); + $mock = $this->getMock('cnp\sdk\CnpXmlMapper'); + $mock ->expects($this->once()) + ->method('request') + ->with($this->matchesRegularExpression('/.*.*abc.*xyz.*NY.*US.*email.*12345.*topUp.*/')); + + $cnpTest = new CnpOnlineRequest(); + $cnpTest->newXML = $mock; + $cnpTest->captureGivenAuthRequest($hash_in); + } + } diff --git a/cnp/sdk/Test/unit/CaptureUnitTest.php b/cnp/sdk/Test/unit/CaptureUnitTest.php index afa0da5..191bd8f 100644 --- a/cnp/sdk/Test/unit/CaptureUnitTest.php +++ b/cnp/sdk/Test/unit/CaptureUnitTest.php @@ -263,4 +263,21 @@ public function test_capture_with_subscription() $cnpTest->newXML = $mock; $cnpTest->captureRequest($hash_in); } + + public function test_encrypted_capture() + { + $hash_in = array('cnpTxnId'=> '12312312', + 'id' => 'id', + 'merchantSdk'=>'PHP;10.1.0', + 'amount'=>'123', + 'oltpEncryptionPayload' => true); + $mock = $this->getMock('cnp\sdk\CnpXmlMapper'); + $mock->expects($this->once()) + ->method('request') + ->with($this->matchesRegularExpression('/.*.*/')); + + $cnpTest = new CnpOnlineRequest(); + $cnpTest->newXML = $mock; + $cnpTest->captureRequest($hash_in); + } } diff --git a/cnp/sdk/Test/unit/CreditUnitTest.php b/cnp/sdk/Test/unit/CreditUnitTest.php index 2811883..118ecd7 100644 --- a/cnp/sdk/Test/unit/CreditUnitTest.php +++ b/cnp/sdk/Test/unit/CreditUnitTest.php @@ -591,4 +591,31 @@ public function test_credit_with_accountFundingTransactionData() $cnpTest->creditRequest($hash_in);; } + public function test_encrypted_credit() + { + + $hash_in = array( + 'reportGroup'=>'Planets', + 'orderId'=>'12344', + 'id' => 'id', + 'amount'=>'106', + 'orderSource'=>'ecommerce', + 'merchantCategoryCode' => '3535', + 'card'=>array( + 'type'=>'VI', + 'number' =>'4100000000000001', + 'expDate' =>'1210' + ), + 'oltpEncryptionPayload' => true); + + $mock = $this->getMock('cnp\sdk\CnpXmlMapper'); + $mock->expects($this->once()) + ->method('request') + ->with($this->matchesRegularExpression('/.*.*/')); + + $cnpTest = new CnpOnlineRequest(); + $cnpTest->newXML = $mock; + $cnpTest->creditRequest($hash_in); + } + } diff --git a/cnp/sdk/Test/unit/SaleUnitTest.php b/cnp/sdk/Test/unit/SaleUnitTest.php index f612880..4ff39db 100644 --- a/cnp/sdk/Test/unit/SaleUnitTest.php +++ b/cnp/sdk/Test/unit/SaleUnitTest.php @@ -1298,4 +1298,89 @@ public function test_sale_with_accountFundingTransactionData_fraudCheckAction() $cnpTest->newXML = $mock; $cnpTest->saleRequest($hash_in); } + public function test_sale_with_digitalCurrency() + { + $hash_in = array( + 'id' => 'id', + 'orderId' => '82364_cnpApiAuth', + 'amount' => '1001', + 'orderSource' => 'telephone', + 'customerInfo' => array( + 'accountUsername' => 'username123', + 'userAccountNumber' => '7647326235897', + 'userAccountEmail' => 'dummtemail@abc.com', + 'membershipId' => '23874682304', + 'membershipPhone' => '16818807607551094758', + 'membershipEmail' => 'email@abc.com', + 'membershipName' => 'member123', + 'accountCreatedDate' => '2050-07-17', + 'userAccountPhone' => '1392345678', + ), + 'card' => array( + 'type' => 'VI', + 'number' => '4005518220000002', + 'expDate' => '0150', + 'cardValidationNum' => '987', + ), + 'orderChannel' => 'SMART_TV', + 'enhancedData' => array( + 'detailTax0' => array( + 'taxAmount' => '200', + 'taxRate' => '0.06', + 'taxIncludedInTotal' => true + ), + 'detailTax1' => array( + 'taxAmount' => '300', + 'taxRate' => '0.10', + 'taxIncludedInTotal' => true + ), + 'fulfilmentMethodType' => 'EXPEDITED_SHIPPING', + ), + 'accountFundingTransactionData' => array( + 'receiverFirstName' => 'abc', + 'receiverLastName' => 'xyz', + 'receiverState' => 'AK', + 'receiverCountry' => 'AD', + 'receiverAccountNumberType' => 'cardAccount', + 'receiverAccountNumber' => '12345', + 'accountFundingTransactionType' => 'bankInitiated' + ), + 'fraudCheckAction' => 'DECLINED_NEED_FRAUD_CHECK', + 'typeOfDigitalCurrency' => '1', + 'conversionAffiliateId' => 'Test', + + ); + + $mock = $this->getMock('cnp\sdk\CnpXmlMapper'); + $mock ->expects($this->once()) + ->method('request') + ->with($this->matchesRegularExpression('/.*EXPEDITED_SHIPPING.*.*abc.*xyz.*AK.*AD.*cardAccount.*12345.*bankInitiated.*DECLINED_NEED_FRAUD_CHECK.*/')); + + $cnpTest = new CnpOnlineRequest(); + $cnpTest->newXML = $mock; + $cnpTest->saleRequest($hash_in); + } + + public function test_encrypted_sale() + { + $hash_in = array( + 'card'=>array('type'=>'VI', + 'number'=>'4100000000000001', + 'expDate'=>'1213', + 'cardValidationNum' => '1213'), + 'id'=>'654', + 'orderId'=> '2111', + 'orderSource'=>'ecommerce', + 'amount'=>'123', + 'oltpEncryptionPayload' => true); + $mock = $this->getMock('cnp\sdk\CnpXmlMapper'); + $mock->expects($this->once()) + ->method('request') + ->with($this->matchesRegularExpression('/.*.*/')); + + $cnpTest = new CnpOnlineRequest(); + $cnpTest->newXML = $mock; + $cnpTest->saleRequest($hash_in); + } + } diff --git a/cnp/sdk/XmlFields.php b/cnp/sdk/XmlFields.php index 162ca1f..7a962f4 100644 --- a/cnp/sdk/XmlFields.php +++ b/cnp/sdk/XmlFields.php @@ -1037,6 +1037,19 @@ public static function sellerAddress($hash_in) } } + public static function partialCapture($hash_in) + { + if (isset($hash_in)) { + $hash_out = array( + "partialCaptureSequenceNumber"=>XmlFields::returnArrayValue($hash_in, "partialCaptureSequenceNumber", 100), + "partialCaptureTotalCount"=>XmlFields::returnArrayValue($hash_in, "partialCaptureTotalCount", 100), + ); + + return $hash_out; + } + } + + public static function sellerTagsType($hash_in) { if (isset($hash_in)) { @@ -1121,4 +1134,6 @@ public static function inquiryResultType($hash_in) } } + + } diff --git a/cnp/sdk/schema/SchemaCombined_v12.37.xsd b/cnp/sdk/schema/SchemaCombined_v12.40.xsd similarity index 96% rename from cnp/sdk/schema/SchemaCombined_v12.37.xsd rename to cnp/sdk/schema/SchemaCombined_v12.40.xsd index 486314d..3e7bd2e 100644 --- a/cnp/sdk/schema/SchemaCombined_v12.37.xsd +++ b/cnp/sdk/schema/SchemaCombined_v12.40.xsd @@ -275,6 +275,7 @@ + @@ -362,6 +363,8 @@ + + @@ -1391,6 +1394,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1653,9 +1688,6 @@ - - - @@ -1675,6 +1707,15 @@ + + + + + + + + + @@ -1848,6 +1889,9 @@ + + + @@ -1908,6 +1952,7 @@ + @@ -2006,6 +2051,9 @@ + + + @@ -2088,6 +2136,9 @@ + + + @@ -2565,6 +2616,7 @@ + @@ -3030,6 +3082,7 @@ + @@ -3603,6 +3656,13 @@ + + + + + + + @@ -4163,7 +4223,7 @@ - + @@ -4219,7 +4279,7 @@ - + @@ -4574,7 +4634,7 @@ - + @@ -4993,6 +5053,15 @@ + + + + + + + + + @@ -5326,7 +5395,7 @@ - + @@ -5399,7 +5468,6 @@ - @@ -5410,6 +5478,8 @@ + + @@ -5433,6 +5503,7 @@ + @@ -5707,126 +5778,126 @@ - + @@ -6045,5 +6116,24 @@ + + + + + + + + + + + + + + + + + + +