Skip to content

Commit

Permalink
Merge pull request #44 from Vantiv/upgrade12_31
Browse files Browse the repository at this point in the history
Upgrade v12.31.0
  • Loading branch information
isunnapud authored Jul 6, 2023
2 parents 865ae53 + 75c84fe commit 4ebb1ce
Show file tree
Hide file tree
Showing 19 changed files with 417 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
= CnpOnline CHANGELOG

==Version 12.31.0 (Jul 08, 2023)
* Feature: [cnpAPI v12.31] New element foreignRetailerIndicator of type enum added in capture, captureGivenAuth, forceCapture, sale request.
* Change: [cnpAPI v12.31] phpseclib is upgraded to phpseclib3 to support modern ciphers during sftp sessions.

==Version 12.30.0 (Mar 14, 2023)
Note: It contains changes from cnpAPI v12.30 . In case you need any feature supported by cnpAPI v12.30, please use SDK version 12.30.0.

Expand Down
2 changes: 1 addition & 1 deletion cnp/sdk/Checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Checker
public static function validateXML($request){
$xml = new DOMDocument();
$xml->loadXML($request);
$filepath = __DIR__ . "/schema/SchemaCombined_v12.30.xsd";
$filepath = __DIR__ . "/schema/SchemaCombined_v12.31.xsd";
$result = $xml->schemaValidate( $filepath);

if(!$result)
Expand Down
4 changes: 2 additions & 2 deletions cnp/sdk/CnpOnline.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
namespace cnp\sdk;
define('CURRENT_XML_VERSION', '12.30');
define('CURRENT_SDK_VERSION', 'PHP;12.30.0');
define('CURRENT_XML_VERSION', '12.31');
define('CURRENT_SDK_VERSION', 'PHP;12.31.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');
Expand Down
12 changes: 8 additions & 4 deletions cnp/sdk/CnpOnlineRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ public function saleRequest($hash_in)
'productEnrolled' => XmlFields::returnArrayValue($hash_in, 'productEnrolled'),
'decisionPurpose' => XmlFields::returnArrayValue($hash_in, 'decisionPurpose'),
'fraudSwitchIndicator' => XmlFields::returnArrayValue($hash_in, 'fraudSwitchIndicator'),
'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData'))
'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData')),
'foreignRetailerIndicator' => XmlFields::returnArrayValue($hash_in, 'foreignRetailerIndicator')
);

$choice_hash = array($hash_out['card'], $hash_out['paypal'], $hash_out['token'], $hash_out['paypage'], $hash_out['applepay'], $hash_out['mpos']);
Expand Down Expand Up @@ -430,7 +431,8 @@ public function forceCaptureRequest($hash_in)
'processingType' => XmlFields::returnArrayValue($hash_in, 'processingType'),
'merchantCategoryCode' => XmlFields::returnArrayValue($hash_in, 'merchantCategoryCode'),
'businessIndicator' => XmlFields::returnArrayValue($hash_in, 'businessIndicator'),
'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData'))
'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData')),
'foreignRetailerIndicator' => XmlFields::returnArrayValue($hash_in, 'foreignRetailerIndicator')
);

$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, 'mpos'));
Expand Down Expand Up @@ -459,7 +461,8 @@ public function captureRequest($hash_in)
'payPalNotes' => XmlFields::returnArrayValue($hash_in, 'payPalNotes'),
'lodgingInfo' => XmlFields::lodgingInfo(XmlFields::returnArrayValue($hash_in, 'lodgingInfo')),
'pin' => XmlFields::returnArrayValue($hash_in, 'pin'),
'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData'))
'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData')),
'foreignRetailerIndicator' => XmlFields::returnArrayValue($hash_in, 'foreignRetailerIndicator')
);
$captureResponse = $this->processRequest($hash_out, $hash_in, 'capture');

Expand Down Expand Up @@ -505,7 +508,8 @@ public function captureGivenAuthRequest($hash_in)
'merchantCategoryCode' => XmlFields::returnArrayValue($hash_in, 'merchantCategoryCode'),
'businessIndicator' => XmlFields::returnArrayValue($hash_in, 'businessIndicator'),
'crypto' => XmlFields::returnArrayValue($hash_in, 'crypto'),
'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData'))
'passengerTransportData' => XmlFields::passengerTransportData(XmlFields::returnArrayValue($hash_in, 'passengerTransportData')),
'foreignRetailerIndicator' => XmlFields::returnArrayValue($hash_in, 'foreignRetailerIndicator')
);

$choice_hash = array($hash_out['card'], $hash_out['token'], $hash_out['paypage'], $hash_out['mpos']);
Expand Down
4 changes: 2 additions & 2 deletions cnp/sdk/CnpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function sendToCnpSFTP()

$session = $this->createSFTPSession();
# with extension .prg
$session->put('/inbound/' . basename($this->request_file) . '.prg', $requestFilename, \phpseclib\Net\SFTP::SOURCE_LOCAL_FILE);
$session->put('/inbound/' . basename($this->request_file) . '.prg', $requestFilename, \phpseclib3\Net\SFTP::SOURCE_LOCAL_FILE);
# rename when the file upload is complete
$session->rename('/inbound/' . basename($this->request_file) . '.prg', '/inbound/' . basename($this->request_file) . '.asc');

Expand Down Expand Up @@ -245,7 +245,7 @@ public function createSFTPSession()
$sftp_url = $this->config['batch_url'];
$sftp_username = $this->config['sftp_username'];
$sftp_password = $this->config['sftp_password'];
$session = new \phpseclib\Net\SFTP($sftp_url);
$session = new \phpseclib3\Net\SFTP($sftp_url);
if (!$session->login($sftp_username, $sftp_password)) {
throw new \RuntimeException("Failed to SFTP with the username $sftp_username and the password $sftp_password to the host $sftp_url. Check your credentials!");
}
Expand Down
7 changes: 2 additions & 5 deletions cnp/sdk/Test/functional/AuthFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ public function test_simple_auth_with_amount()
$this->assertEquals('sandbox', $location);
}

public function test_simple_auth_with_authIndicatorenum_estimated()
public function test_simple_auth_with_authIndicatorEnum_estimated()
{
$hash_in = array(
'id' => 'id',
Expand Down Expand Up @@ -1259,7 +1259,7 @@ public function test_simple_auth_with_authIndicatorenum_estimated()
$this->assertEquals('sandbox', $location);
}

public function test_simple_auth_with_authIndicator_increamental()
public function test_simple_auth_with_authIndicator_incremental()
{
$hash_in = array(
'id' => 'id',
Expand Down Expand Up @@ -1290,7 +1290,4 @@ public function test_simple_auth_with_authIndicator_increamental()
$location = XmlParser::getNode($authorizationResponse, 'location');
$this->assertEquals('sandbox', $location);
}



}
6 changes: 3 additions & 3 deletions cnp/sdk/Test/functional/BatchRequestFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ public function test_mechaBatchSFTP()
'orderId'=> '2111',
'orderSource'=>'ecommerce',
'id'=>'654',
'amount'=>'123');
'amount'=>'1123');
$batch->addAuth($hash_in);

$hash_in = array(
Expand All @@ -1822,7 +1822,7 @@ public function test_mechaBatchSFTP()
'id'=>'654',
'orderId'=> '2111',
'orderSource'=>'ecommerce',
'amount'=>'123');
'amount'=>'1123');
$batch->addSale($hash_in);
$request->addBatchRequest($batch);

Expand Down Expand Up @@ -2010,7 +2010,7 @@ public function test_auth_with_additionalCOFData_batch()
$hash_in = array(
'id'=>'0001',
'orderId' => '82364_cnpApiAuth',
'amount' => '2870',
'amount' => '1870',
'orderSource' => 'telephone',
'billToAddress' => array(
'name' => 'David Berman A',
Expand Down
41 changes: 41 additions & 0 deletions cnp/sdk/Test/functional/CaptureFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,45 @@ public function test_simple_capture_passengerTransportData()
$location = XmlParser::getNode($captureResponse, 'location');
$this->assertEquals('sandbox', $location);
}

public function test_simple_capture_foreignRetailerIndicator()
{
$hash_in = array('id' => 'id',
'cnpTxnId' => '1234567891234567891',
'passengerTransportData' => array(
'passengerName' => 'Mrs. Huxley234567890123456789',
'ticketNumber' => 'ATL456789012345',
'issuingCarrier' => 'AMTK',
'carrierName' => 'AMTK',
'restrictedTicketIndicator' => '99999',
'numberOfAdults' => '2',
'numberOfChildren' => '0',
'customerCode' => 'Railway',
'arrivalDate' => '2022-09-20',
'issueDate' => '2022-09-10',
'travelAgencyCode' => '12345678',
'travelAgencyName' => 'Travel R Us23456789012345',
'computerizedReservationSystem' => 'STRT',
'creditReasonIndicator' => 'P',
'ticketChangeIndicator' => 'C',
'ticketIssuerAddress' => '99 Second St',
'exchangeTicketNumber' => '123456789012346',
'exchangeAmount' => '500046',
'exchangeFeeAmount' => '5046',
'tripLegData' => array(
'tripLegNumber' => '10',
'serviceClass' => 'First',
'departureDate' => '2022-09-20',
'originCity' => 'BOS')),
'foreignRetailerIndicator' => 'F'
);

$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);
}

}
50 changes: 50 additions & 0 deletions cnp/sdk/Test/functional/CaptureGivenAuthFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,5 +536,55 @@ public function test_captureGivenAuth_with_passengerTransportData()
$this->assertEquals('sandbox', $location);
}

public function test_captureGivenAuth_with_foreignRetailerIndicator()
{
$hash_in = array('id' => 'id',
'orderId' => '12344',
'amount' => '106',
'businessIndicator' => 'consumerBillPayment',
'authInformation' => array(
'authDate' => '2002-10-09', 'authCode' => '543216',
'authAmount' => '12345'),
'orderSource' => 'ecommerce',
'card' => array(
'type' => 'VI',
'number' => '4100000000000000',
'expDate' => '1210'),
'passengerTransportData' =>array(
'passengerName' =>'Mrs. Huxley234567890123456789',
'ticketNumber' =>'ATL456789012345' ,
'issuingCarrier' =>'AMTK',
'carrierName' =>'AMTK',
'restrictedTicketIndicator' =>'99999',
'numberOfAdults' =>'2',
'numberOfChildren' =>'0',
'customerCode' =>'Railway',
'arrivalDate' =>'2022-09-20',
'issueDate' =>'2022-09-10',
'travelAgencyCode' =>'12345678',
'travelAgencyName' =>'Travel R Us23456789012345',
'computerizedReservationSystem' =>'STRT',
'creditReasonIndicator' =>'P',
'ticketChangeIndicator' =>'C',
'ticketIssuerAddress' =>'99 Second St',
'exchangeTicketNumber' =>'123456789012346',
'exchangeAmount' =>'500046',
'exchangeFeeAmount' =>'5046',
'tripLegData' =>array(
'tripLegNumber' =>'10' ,
'serviceClass' =>'First',
'departureDate' =>'2022-09-20',
'originCity' =>'BOS')
),
'foreignRetailerIndicator' => 'F'
);


$initialize = new CnpOnlineRequest();
$authorizationResponse = $initialize->captureGivenAuthRequest($hash_in);
$response = XmlParser::getNode($authorizationResponse, 'response');
$this->assertEquals('000', $response);
$location = XmlParser::getNode($authorizationResponse, 'location');
$this->assertEquals('sandbox', $location);
}
}
Loading

0 comments on commit 4ebb1ce

Please sign in to comment.