diff --git a/README.md b/README.md new file mode 100644 index 0000000..2780fd5 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# interface-library +Shopgate Interface PHP Library is deprecated! +Please use our new repository instead: [Shopgate Cart Integration SDK](https://github.com/shopgate/cart-integration-sdk) diff --git a/build_config.php b/build_config.php index a2a2e9a..0b1b14b 100644 --- a/build_config.php +++ b/build_config.php @@ -2,7 +2,7 @@ $buildConfig = array ( 'major' => 2, 'minor' => 9, - 'build' => 60, + 'build' => 64, 'shopgate_library_path' => '', 'plugin_name' => 'library', 'display_name' => 'Shopgate Library 2.9.x', diff --git a/changelog.txt b/changelog.txt index 0f0a3f4..584d456 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,15 @@ +'''Version 2.9.64''' +* Added missing getter for review XML filename in the configuration + +'''Version 2.9.63''' +* Added payment method constants for Merchant Payment + +'''Version 2.9.62''' +* restored compatibility for PHP versions below 5.3 + +'''Version 2.9.61''' +* fixed a bug in stack trace generation that may appear on certain server configurations + '''Version 2.9.60''' * fixed debug logging @@ -27,7 +39,7 @@ * added ShopgateClient to ShopgateCartBase to distinguish between the mobile clients * added error code to remove items silently in the cart validation * replaced "document.write" with asynchronous loading of mobile redirect / mobile header -* added Content-Length header to Response objects for CSV, XML and JSON repsonses +* added Content-Length header to Response objects for CSV, XML and JSON responses '''Version 2.9.55''' * refactored ShopgateLogger to be able to pass a strategy for logging diff --git a/classes/client.php b/classes/client.php index a7ab37b..5759e0e 100644 --- a/classes/client.php +++ b/classes/client.php @@ -53,7 +53,7 @@ public function getType() */ public function isMobileWebsite() { - return $this->type == $this::TYPE_MOBILESITE; + return $this->type == self::TYPE_MOBILESITE; } /** @@ -62,10 +62,10 @@ public function isMobileWebsite() public function isApp() { $appTypes = array( - $this::TYPE_ANDROIDPHONEAPP, - $this::TYPE_ANDROIDTABLETAPP, - $this::TYPE_IPADAPP, - $this::TYPE_IPHONEAPP + self::TYPE_ANDROIDPHONEAPP, + self::TYPE_ANDROIDTABLETAPP, + self::TYPE_IPADAPP, + self::TYPE_IPHONEAPP ); return in_array($this->type, $appTypes); } diff --git a/classes/configuration.php b/classes/configuration.php index bc80653..9eac228 100644 --- a/classes/configuration.php +++ b/classes/configuration.php @@ -1287,6 +1287,10 @@ public function getReviewsCsvFilename() { return $this->reviews_csv_filename; } + public function getReviewsXmlFilename() { + return $this->reviews_xml_filename; + } + public function getAccessLogFilename() { return $this->access_log_filename; } diff --git a/classes/core.php b/classes/core.php index 770fc56..3963ab7 100644 --- a/classes/core.php +++ b/classes/core.php @@ -24,7 +24,7 @@ ################################################################################### # define constants ################################################################################### -define("SHOPGATE_LIBRARY_VERSION", "2.9.60"); +define("SHOPGATE_LIBRARY_VERSION", "2.9.64"); define('SHOPGATE_LIBRARY_ENCODING' , 'UTF-8'); define('SHOPGATE_BASE_DIR', realpath(dirname(__FILE__).'/../')); diff --git a/classes/helper/logging/stack_trace/GeneratorDefault.php b/classes/helper/logging/stack_trace/GeneratorDefault.php index 977d6d5..162d79f 100644 --- a/classes/helper/logging/stack_trace/GeneratorDefault.php +++ b/classes/helper/logging/stack_trace/GeneratorDefault.php @@ -105,7 +105,15 @@ private function generateFormattedTrace(array $traces) if (!isset($trace['file'])) { $trace['file'] = 'unknown file'; - $trace['line'] = 'unknown line'; + $trace['line'] = 'unknown line'; + } + + if (!isset($trace['function'])) { + $trace['function'] = 'unknown function'; + } + + if (!isset($trace['args']) || !is_array($trace['args'])) { + $trace['args'] = array(); } $arguments = $this->namedParameterProvider->get($trace['class'], $trace['function'], $trace['args']); diff --git a/classes/orders.php b/classes/orders.php index 84db21d..1be7149 100644 --- a/classes/orders.php +++ b/classes/orders.php @@ -23,162 +23,167 @@ */ abstract class ShopgateCartBase extends ShopgateContainer { - const SHOPGATE = "SHOPGATE"; + const SHOPGATE = 'SHOPGATE'; // Prepayment - const PREPAY = "PREPAY"; - const PAYONE_PRP = "PAYONE_PRP"; - const SG_PREPAY = "SG_PREPAY"; + const PREPAY = 'PREPAY'; + const PAYONE_PRP = 'PAYONE_PRP'; + const SG_PREPAY = 'SG_PREPAY'; // Debit - const DEBIT = "DEBIT"; - const PAYMRW_DBT = "PAYMRW_DBT"; - const PAYONE_DBT = "PAYONE_DBT"; + const DEBIT = 'DEBIT'; + const PAYMRW_DBT = 'PAYMRW_DBT'; + const PAYONE_DBT = 'PAYONE_DBT'; // Cash On Delivery - const COD = "COD"; - const COLL_STORE = "COLL_STORE"; + const COD = 'COD'; + const COLL_STORE = 'COLL_STORE'; // Installment - const ACCRD_INS = "ACCRD_INS"; - const PAYOL_INS = "PAYOL_INS"; + const ACCRD_INS = 'ACCRD_INS'; + const PAYOL_INS = 'PAYOL_INS'; // Invoice - const INVOICE = "INVOICE"; - const ACCRD_INV = "ACCRD_INV"; - const KLARNA_INV = "KLARNA_INV"; - const BILLSAFE = "BILLSAFE"; - const MSTPAY_INV = "MSTPAY_INV"; - const PAYMRW_INV = "PAYMRW_INV"; - const PAYONE_INV = "PAYONE_INV"; - const SG_INVOICE = "SG_INVOICE"; - const WCARD_INV = "WCARD_INV"; - const PAYONE_KLV = "PAYONE_KLV"; - const PAYOL_INV = "PAYOL_INV"; + const INVOICE = 'INVOICE'; + const ACCRD_INV = 'ACCRD_INV'; + const KLARNA_INV = 'KLARNA_INV'; + const BILLSAFE = 'BILLSAFE'; + const MSTPAY_INV = 'MSTPAY_INV'; + const PAYMRW_INV = 'PAYMRW_INV'; + const PAYONE_INV = 'PAYONE_INV'; + const SG_INVOICE = 'SG_INVOICE'; + const WCARD_INV = 'WCARD_INV'; + const PAYONE_KLV = 'PAYONE_KLV'; + const PAYOL_INV = 'PAYOL_INV'; // Paypal - const PAYPAL = "PAYPAL"; - const PPAL_PLUS = "PPAL_PLUS"; - const CMPTOP_PP = "CMPTOP_PP"; - const MASTPAY_PP = "MASTPAY_PP"; - const PAYONE_PP = "PAYONE_PP"; - const SAGEPAY_PP = "SAGEPAY_PP"; - const SG_PAYPAL = "SG_PAYPAL"; - const SIX_PP = "SIX_PP"; - const WCARD_PP = "WCARD_PP"; + const PAYPAL = 'PAYPAL'; + const PPAL_PLUS = 'PPAL_PLUS'; + const CMPTOP_PP = 'CMPTOP_PP'; + const MASTPAY_PP = 'MASTPAY_PP'; + const PAYONE_PP = 'PAYONE_PP'; + const SAGEPAY_PP = 'SAGEPAY_PP'; + const SG_PAYPAL = 'SG_PAYPAL'; + const SIX_PP = 'SIX_PP'; + const WCARD_PP = 'WCARD_PP'; // Credit Card - const CC = "CC"; - const AUTHN_CC = "AUTHN_CC"; - const BCLEPDQ_CC = "BCLEPDQ_CC"; - const BNSTRM_CC = "BNSTRM_CC"; - const BRAINTR_CC = "BRAINTR_CC"; - const CHASE_CC = "CHASE_CC"; - const CMPTOP_CC = "CMPTOP_CC"; - const CONCAR_CC = "CONCAR_CC"; - const CRDSTRM_CC = "CRDSTRM_CC"; - const CREDITCARD = "CREDITCARD"; - const CYBRSRC_CC = "CYBRSRC_CC"; - const DRCPAY_CC = "DRCPAY_CC"; - const DTCASH_CC = "DTCASH_CC"; - const DT_CC = "DT_CC"; - const EFSNET_CC = "EFSNET_CC"; - const ELAVON_CC = "ELAVON_CC"; - const EPAY_CC = "EPAY_CC"; - const EWAY_CC = "EWAY_CC"; - const EXACT_CC = "EXACT_CC"; - const FRSTDAT_CC = "FRSTDAT_CC"; - const GAMEDAY_CC = "GAMEDAY_CC"; - const GARANTI_CC = "GARANTI_CC"; - const GESTPAY_CC = "GESTPAY_CC"; - const HDLPAY_CC = "HDLPAY_CC"; - const HIPAY = "HIPAY"; - const HITRUST_CC = "HITRUST_CC"; - const INSPIRE_CC = "INSPIRE_CC"; - const INSTAP_CC = "INSTAP_CC"; - const INTUIT_CC = "INTUIT_CC"; - const IRIDIUM_CC = "IRIDIUM_CC"; - const LITLE_CC = "LITLE_CC"; - const MASTPAY_CC = "MASTPAY_CC"; - const MERESOL_CC = "MERESOL_CC"; - const MERWARE_CC = "MERWARE_CC"; - const MODRPAY_CC = "MODRPAY_CC"; - const MONERIS_CC = "MONERIS_CC"; - const MSTPAY_CC = "MSTPAY_CC"; - const NELTRAX_CC = "NELTRAX_CC"; - const NETBILL_CC = "NETBILL_CC"; - const NETREGS_CC = "NETREGS_CC"; - const NOCHEX_CC = "NOCHEX_CC"; - const OGONE_CC = "OGONE_CC"; - const OPTIMAL_CC = "OPTIMAL_CC"; - const PAY4ONE_CC = "PAY4ONE_CC"; - const PAYBOX_CC = "PAYBOX_CC"; - const PAYEXPR_CC = "PAYEXPR_CC"; - const PAYFAST_CC = "PAYFAST_CC"; - const PAYFLOW_CC = "PAYFLOW_CC"; - const PAYJUNC_CC = "PAYJUNC_CC"; - const PAYONE_CC = "PAYONE_CC"; - const PAYZEN_CC = "PAYZEN_CC"; - const PLUGNPL_CC = "PLUGNPL_CC"; - const PP_WSPP_CC = "PP_WSPP_CC"; - const PSIGATE_CC = "PSIGATE_CC"; - const PSL_CC = "PSL_CC"; - const PXPAY_CC = "PXPAY_CC"; - const QUIKPAY_CC = "QUIKPAY_CC"; - const REALEX_CC = "REALEX_CC"; - const SAGEPAY_CC = "SAGEPAY_CC"; - const SAGE_CC = "SAGE_CC"; - const SAMURAI_CC = "SAMURAI_CC"; - const SCPTECH_CC = "SCPTECH_CC"; - const SCP_AU_CC = "SCP_AU_CC"; - const SECPAY_CC = "SECPAY_CC"; - const SG_CC = "SG_CC"; - const SIX_CC = "SIX_CC"; - const SKIPJCK_CC = "SKIPJCK_CC"; - const SKRILL_CC = "SKRILL_CC"; - const STRIPE_CC = "STRIPE_CC"; - const TELECSH_CC = "TELECSH_CC"; - const TRNSFST_CC = "TRNSFST_CC"; - const TRUSTCM_CC = "TRUSTCM_CC"; - const USAEPAY_CC = "USAEPAY_CC"; - const VALITOR_CC = "VALITOR_CC"; - const VERIFI_CC = "VERIFI_CC"; - const VIAKLIX_CC = "VIAKLIX_CC"; - const WCARDS_CC = "WCARDS_CC"; - const WIRECRD_CC = "WIRECRD_CC"; - const WLDPDIR_CC = "WLDPDIR_CC"; - const WLDPOFF_CC = "WLDPOFF_CC"; + const CC = 'CC'; + const AUTHN_CC = 'AUTHN_CC'; + const BCLEPDQ_CC = 'BCLEPDQ_CC'; + const BNSTRM_CC = 'BNSTRM_CC'; + const BRAINTR_CC = 'BRAINTR_CC'; + const CHASE_CC = 'CHASE_CC'; + const CMPTOP_CC = 'CMPTOP_CC'; + const CONCAR_CC = 'CONCAR_CC'; + const CRDSTRM_CC = 'CRDSTRM_CC'; + const CREDITCARD = 'CREDITCARD'; + const CYBRSRC_CC = 'CYBRSRC_CC'; + const DRCPAY_CC = 'DRCPAY_CC'; + const DTCASH_CC = 'DTCASH_CC'; + const DT_CC = 'DT_CC'; + const EFSNET_CC = 'EFSNET_CC'; + const ELAVON_CC = 'ELAVON_CC'; + const EPAY_CC = 'EPAY_CC'; + const EWAY_CC = 'EWAY_CC'; + const EXACT_CC = 'EXACT_CC'; + const FRSTDAT_CC = 'FRSTDAT_CC'; + const GAMEDAY_CC = 'GAMEDAY_CC'; + const GARANTI_CC = 'GARANTI_CC'; + const GESTPAY_CC = 'GESTPAY_CC'; + const HDLPAY_CC = 'HDLPAY_CC'; + const HIPAY = 'HIPAY'; + const HITRUST_CC = 'HITRUST_CC'; + const INSPIRE_CC = 'INSPIRE_CC'; + const INSTAP_CC = 'INSTAP_CC'; + const INTUIT_CC = 'INTUIT_CC'; + const IRIDIUM_CC = 'IRIDIUM_CC'; + const LITLE_CC = 'LITLE_CC'; + const MASTPAY_CC = 'MASTPAY_CC'; + const MERESOL_CC = 'MERESOL_CC'; + const MERWARE_CC = 'MERWARE_CC'; + const MODRPAY_CC = 'MODRPAY_CC'; + const MONERIS_CC = 'MONERIS_CC'; + const MSTPAY_CC = 'MSTPAY_CC'; + const NELTRAX_CC = 'NELTRAX_CC'; + const NETBILL_CC = 'NETBILL_CC'; + const NETREGS_CC = 'NETREGS_CC'; + const NOCHEX_CC = 'NOCHEX_CC'; + const OGONE_CC = 'OGONE_CC'; + const OPTIMAL_CC = 'OPTIMAL_CC'; + const PAY4ONE_CC = 'PAY4ONE_CC'; + const PAYBOX_CC = 'PAYBOX_CC'; + const PAYEXPR_CC = 'PAYEXPR_CC'; + const PAYFAST_CC = 'PAYFAST_CC'; + const PAYFLOW_CC = 'PAYFLOW_CC'; + const PAYJUNC_CC = 'PAYJUNC_CC'; + const PAYONE_CC = 'PAYONE_CC'; + const PAYZEN_CC = 'PAYZEN_CC'; + const PLUGNPL_CC = 'PLUGNPL_CC'; + const PP_WSPP_CC = 'PP_WSPP_CC'; + const PSIGATE_CC = 'PSIGATE_CC'; + const PSL_CC = 'PSL_CC'; + const PXPAY_CC = 'PXPAY_CC'; + const QUIKPAY_CC = 'QUIKPAY_CC'; + const REALEX_CC = 'REALEX_CC'; + const SAGEPAY_CC = 'SAGEPAY_CC'; + const SAGE_CC = 'SAGE_CC'; + const SAMURAI_CC = 'SAMURAI_CC'; + const SCPTECH_CC = 'SCPTECH_CC'; + const SCP_AU_CC = 'SCP_AU_CC'; + const SECPAY_CC = 'SECPAY_CC'; + const SG_CC = 'SG_CC'; + const SIX_CC = 'SIX_CC'; + const SKIPJCK_CC = 'SKIPJCK_CC'; + const SKRILL_CC = 'SKRILL_CC'; + const STRIPE_CC = 'STRIPE_CC'; + const TELECSH_CC = 'TELECSH_CC'; + const TRNSFST_CC = 'TRNSFST_CC'; + const TRUSTCM_CC = 'TRUSTCM_CC'; + const USAEPAY_CC = 'USAEPAY_CC'; + const VALITOR_CC = 'VALITOR_CC'; + const VERIFI_CC = 'VERIFI_CC'; + const VIAKLIX_CC = 'VIAKLIX_CC'; + const WCARDS_CC = 'WCARDS_CC'; + const WIRECRD_CC = 'WIRECRD_CC'; + const WLDPDIR_CC = 'WLDPDIR_CC'; + const WLDPOFF_CC = 'WLDPOFF_CC'; // ClickandBuy - const CNB = "CNB"; - const SG_CNB = "SG_CNB"; + const CNB = 'CNB'; + const SG_CNB = 'SG_CNB'; - const MCM = "MCM"; - const UPAID_MCM = "UPAID_MCM"; + const MCM = 'MCM'; + const UPAID_MCM = 'UPAID_MCM'; - const PAYU = "PAYU"; + const PAYU = 'PAYU'; - const REDIRECTCC = "REDIRECTCC"; - const WORLDLINE = "WORLDLINE"; + const REDIRECTCC = 'REDIRECTCC'; + const WORLDLINE = 'WORLDLINE'; // SOFORT Überweisung - const SUE = "SUE"; - const HDLPAY_SUE = "HDLPAY_SUE"; - const MSTPAY_SUE = "MSTPAY_SUE"; - const PAYONE_SUE = "PAYONE_SUE"; - const SG_SUE = "SG_SUE"; - const SKRILL_SUE = "SKRILL_SUE"; - const WCARD_SUE = "WCARD_SUE"; + const SUE = 'SUE'; + const HDLPAY_SUE = 'HDLPAY_SUE'; + const MSTPAY_SUE = 'MSTPAY_SUE'; + const PAYONE_SUE = 'PAYONE_SUE'; + const SG_SUE = 'SG_SUE'; + const SKRILL_SUE = 'SKRILL_SUE'; + const WCARD_SUE = 'WCARD_SUE'; // Giropay - const PAYONE_GP = "PAYONE_GP"; + const PAYONE_GP = 'PAYONE_GP'; // iDEAL - const PAYONE_IDL = "PAYONE_IDL"; - const SIX_IDEAL = "SIX_IDEAL"; - const SKRILL_IDL = "SKRILL_IDL"; + const PAYONE_IDL = 'PAYONE_IDL'; + const SIX_IDEAL = 'SIX_IDEAL'; + const SKRILL_IDL = 'SKRILL_IDL'; - const AMAZON_PAYMENT = "MWS"; + const AMAZON_PAYMENT = 'MWS'; + + // MERCHANT_PAYMENT + const MERCH_PM = 'MERCH_PM'; + const MERCH_PM_2 = 'MERCH_PM_2'; + const MERCH_PM_3 = 'MERCH_PM_3'; protected $customer_number; protected $customer_ip; diff --git a/tests/classes/helper/logging/stack_trace/GeneratorDefaultTest.php b/tests/classes/helper/logging/stack_trace/GeneratorDefaultTest.php index 9680c4b..86ddcc7 100644 --- a/tests/classes/helper/logging/stack_trace/GeneratorDefaultTest.php +++ b/tests/classes/helper/logging/stack_trace/GeneratorDefaultTest.php @@ -127,6 +127,40 @@ public function testStackTraceGenerationWithMissingClassAndType() ); } + public function testStackTraceGenerationWithFunction() + { + $this->obfuscator + ->expects($this->any()) + ->method('cleanParamsForLog') + ->withAnyParameters() + ->willReturnArgument(0) + ; + + $this->namedParameterProvider->expects($this->any())->method('get')->willReturnArgument(2); + + $this->assertEquals( + $this->fixtureProvider->getExceptionWithMissingFunctionExpected(), + $this->subjectUnderTest->generate($this->fixtureProvider->getExceptionWithMissingFunctionFixture()) + ); + } + + public function testStackTraceGenerationWithArgs() + { + $this->obfuscator + ->expects($this->any()) + ->method('cleanParamsForLog') + ->withAnyParameters() + ->willReturnArgument(0) + ; + + $this->namedParameterProvider->expects($this->any())->method('get')->willReturnArgument(2); + + $this->assertEquals( + $this->fixtureProvider->getExceptionWithMissingArgsExpected(), + $this->subjectUnderTest->generate($this->fixtureProvider->getExceptionWithMissingArgsFixture()) + ); + } + public function testDepthLimitIsHonoured() { $this->obfuscator diff --git a/tests/fixtures/helper/logging/stack_trace/GeneratorDefaultTestFixtureBuilder.php b/tests/fixtures/helper/logging/stack_trace/GeneratorDefaultTestFixtureBuilder.php index 10f7e1d..1ec2632 100644 --- a/tests/fixtures/helper/logging/stack_trace/GeneratorDefaultTestFixtureBuilder.php +++ b/tests/fixtures/helper/logging/stack_trace/GeneratorDefaultTestFixtureBuilder.php @@ -139,6 +139,48 @@ public function getExceptionWithMissingClassAndTypeFixture() ); } + /** + * @return PHPUnit_Framework_MockObject_MockObject|ThrowableStub|Throwable + */ + public function getExceptionWithMissingFunctionFixture() + { + $trace = $this->getTraceFixture('DumboLandingException'); + unset($trace[0]['function']); + + return $this->buildMockFromFixture( + array( + 'exception_class' => 'DumboLandingException', + 'message' => 'Landing failed.', + 'code' => 99, + 'file' => '/Animals/Mammals/Elephants/Dumbo.php', + 'line' => 34, + 'trace' => $trace, + 'previous' => null, + ) + ); + } + + /** + * @return PHPUnit_Framework_MockObject_MockObject|ThrowableStub|Throwable + */ + public function getExceptionWithMissingArgsFixture() + { + $trace = $this->getTraceFixture('DumboLandingException'); + unset($trace[0]['args']); + + return $this->buildMockFromFixture( + array( + 'exception_class' => 'DumboLandingException', + 'message' => 'Landing failed.', + 'code' => 99, + 'file' => '/Animals/Mammals/Elephants/Dumbo.php', + 'line' => 34, + 'trace' => $trace, + 'previous' => null, + ) + ); + } + /** * @return string */ @@ -276,6 +318,34 @@ public function getExceptionWithMissingClassAndTypeExpected() STACK_TRACE; } + /** + * @return string + */ + public function getExceptionWithMissingFunctionExpected() + { + return <<checkHealth() called in /Animals/Mammals/Elephants/Dumbo.php:23 +at \Animals\Mammals\Elephants\Dumbo->unknown function(90, 30) called in /Animals/Mammals/Elephants/Dumbo.php:12 +STACK_TRACE; + } + + /** + * @return string + */ + public function getExceptionWithMissingArgsExpected() + { + return <<checkHealth() called in /Animals/Mammals/Elephants/Dumbo.php:23 +at \Animals\Mammals\Elephants\Dumbo->land() called in /Animals/Mammals/Elephants/Dumbo.php:12 +STACK_TRACE; + } + /** * @param string $index *