profile
viewpoint
Flavius Aspra flavius Austria http://flavius-as.com Clean, testable architectures. Language doesn't matter (PHP/C/Rust/Golang/Typescript/Python/Java). I eat two technology stacks and a Linux meal a day

flavius/phpmeta 27

A PHP module for generating the AST tree of a PHP source code, useful for userland tools for static code analysis, a preprocessor, eventually meta programming (a prototype, open for suggestions)

flavius/apacheparser 1

Parse and manipulate programmatically apache configurations

flavius/batchify 1

A small tool which can run jobs concurrently or in parallel

flavius/patterns 1

A catalogue of Rust design patterns

flavius/php-multiver 1

Infrastructure for compiling and using multipe PHP versions on the same machine

flavius/businesslib 0

A library for organizing your business logic needs and algorithms

flavius/calculator 0

calculates + - / * ! operands and () from a string input

flavius/compiler-team 0

A home for compiler team planning documents, meeting minutes, and other such things.

Pull request review commentwirecard/woocommerce-ee

Tpwdcee 5739 my favorite payment

  * Helper functions  */ -var token                = null;-var tabContent           = ".wd-tab-content";-var nonce                = jQuery( "#wc_payment_method_wirecard_creditcard_response_form input[name='cc_nonce']" );-var togglers             = jQuery( ".wd-toggle-tab" );-var contentAreas         = jQuery( tabContent );-var newCardContentArea   = jQuery( "#wc_payment_method_wirecard_new_credit_card" );-var vaultContentArea     = jQuery( "#wc_payment_method_wirecard_creditcard_vault" );-var seamlessSubmitButton = jQuery( "#seamless-submit" );-var vaultSubmitButton    = jQuery( "#vault-submit" );+/**+ * @external WPP - External WPP library+ * @param {string} phpVars.vault_url - endpoint to save token to vault+ * @param {string} phpVars.vault_delete_url - endpoint to delete token from vault+ * @param {string} phpVars.submit_url - endpoint to submit wpp response and process payment+ * @param {string} phpVars.ajax_url - endpoint to get response from payment engine+ * @param {string} phpVars.vault_get_url - endpoint to get tokens from vault+ */ +let Actions = {+	GET_CREDIT_CARD_FROM_VAULT: "get_cc_from_vault",+	SUBMIT_CREDIT_CARD_RESPONSE: "submit_creditcard_response",+	SAVE_CREDIT_CARD_TO_VAULT: "save_cc_to_vault",+	GET_CREDIT_CARD_REQUEST_DATA: "get_credit_card_request_data",+	REMOVE_CREDIT_CARD_FROM_VAULT: "remove_cc_from_vault",+};++let Url = {+	SAVE_TOKEN_TO_VAULT: phpVars.vault_url,+	DELETE_TOKEN_FROM_VAULT: phpVars.vault_delete_url,+	GET_TOKEN_FORMATTED_VIEW: phpVars.vault_get_url,+	PROCESS_PAYMENT: phpVars.submit_url,+	GET_CREDIT_CARD_REQUEST_DATA: phpVars.ajax_url,+};++let Spinner = {+	FORM_SPINNER: ".show-spinner",+	PAY_BUTTON_SPINNER: "#wd-cc-submit-spinner",+	STATE_ON: "display",+	STATE_OFF: "none",+	DELETE_TOKEN_SPINNER: phpVars.spinner+};++let DELETE_BUTTON = { +	FROM_VAULT: "delete-from-vault",+	FROM_VAULT_DISABLED: "delete-from-vault-disabled",+	WD_BUTTON: "wd-card-delete",+	WD_BUTTON_DISABLED: "wd-card-delete-disabled",+};++let Constants = {+	IFRAME_HEIGHT: "270px",+	USE_CARD_ID: "input[data-token]",+	DELETE_CARD_BUTTON_ID: ".wd-card-delete",+	SAVE_CARD_CHECKMARK_ID: "#wirecard-store-card",+	VAULT_CONTENT_CONTAINER: "#wc_payment_method_wirecard_creditcard_vault .cards",+	VAULT_TABLE_ID: "vault-table",+	NEW_CARD_CONTENT_AREA: "#wc_payment_method_wirecard_new_credit_card",+	NEW_CARD_CONTENT_AREA_IFRAME: "#wc_payment_method_wirecard_new_credit_card iframe",+	SEAMLESS_SUBMIT_BUTTON: "seamless-submit",+	SEAMLESS_FORM_CONTAINER: "wc_payment_method_wirecard_creditcard_form",+	NONCE_SELECTOR: "#wc_payment_method_wirecard_creditcard_response_form input[name='cc_nonce']",+	MESSAGE_CONTAINER: "#wd-creditcard-messagecontainer",+	WD_TOKEN_ID_PREFIX: "wd-token-",+	+};

Call Object.freeze(obj); on these 5 objects to make them read-only.

rinnhofer

comment created time in 2 days

Pull request review commentwirecard/woocommerce-ee

Tpwdcee 5739 my favorite payment

  * Helper functions  */ -var token                = null;-var tabContent           = ".wd-tab-content";-var nonce                = jQuery( "#wc_payment_method_wirecard_creditcard_response_form input[name='cc_nonce']" );-var togglers             = jQuery( ".wd-toggle-tab" );-var contentAreas         = jQuery( tabContent );-var newCardContentArea   = jQuery( "#wc_payment_method_wirecard_new_credit_card" );-var vaultContentArea     = jQuery( "#wc_payment_method_wirecard_creditcard_vault" );-var seamlessSubmitButton = jQuery( "#seamless-submit" );-var vaultSubmitButton    = jQuery( "#vault-submit" );+/**+ * @external WPP - External WPP library+ * @param {string} phpVars.vault_url - endpoint to save token to vault+ * @param {string} phpVars.vault_delete_url - endpoint to delete token from vault+ * @param {string} phpVars.submit_url - endpoint to submit wpp response and process payment+ * @param {string} phpVars.ajax_url - endpoint to get response from payment engine+ * @param {string} phpVars.vault_get_url - endpoint to get tokens from vault+ */ +let Actions = {+	GET_CREDIT_CARD_FROM_VAULT: "get_cc_from_vault",+	SUBMIT_CREDIT_CARD_RESPONSE: "submit_creditcard_response",+	SAVE_CREDIT_CARD_TO_VAULT: "save_cc_to_vault",+	GET_CREDIT_CARD_REQUEST_DATA: "get_credit_card_request_data",+	REMOVE_CREDIT_CARD_FROM_VAULT: "remove_cc_from_vault",+};++let Url = {+	SAVE_TOKEN_TO_VAULT: phpVars.vault_url,+	DELETE_TOKEN_FROM_VAULT: phpVars.vault_delete_url,+	GET_TOKEN_FORMATTED_VIEW: phpVars.vault_get_url,+	PROCESS_PAYMENT: phpVars.submit_url,+	GET_CREDIT_CARD_REQUEST_DATA: phpVars.ajax_url,+};++let Spinner = {+	FORM_SPINNER: ".show-spinner",+	PAY_BUTTON_SPINNER: "#wd-cc-submit-spinner",+	STATE_ON: "display",+	STATE_OFF: "none",+	DELETE_TOKEN_SPINNER: phpVars.spinner+};++let DELETE_BUTTON = { +	FROM_VAULT: "delete-from-vault",+	FROM_VAULT_DISABLED: "delete-from-vault-disabled",+	WD_BUTTON: "wd-card-delete",+	WD_BUTTON_DISABLED: "wd-card-delete-disabled",+};++let Constants = {+	IFRAME_HEIGHT: "270px",+	USE_CARD_ID: "input[data-token]",+	DELETE_CARD_BUTTON_ID: ".wd-card-delete",+	SAVE_CARD_CHECKMARK_ID: "#wirecard-store-card",+	VAULT_CONTENT_CONTAINER: "#wc_payment_method_wirecard_creditcard_vault .cards",+	VAULT_TABLE_ID: "vault-table",+	NEW_CARD_CONTENT_AREA: "#wc_payment_method_wirecard_new_credit_card",+	NEW_CARD_CONTENT_AREA_IFRAME: "#wc_payment_method_wirecard_new_credit_card iframe",+	SEAMLESS_SUBMIT_BUTTON: "seamless-submit",+	SEAMLESS_FORM_CONTAINER: "wc_payment_method_wirecard_creditcard_form",+	NONCE_SELECTOR: "#wc_payment_method_wirecard_creditcard_response_form input[name='cc_nonce']",+	MESSAGE_CONTAINER: "#wd-creditcard-messagecontainer",+	WD_TOKEN_ID_PREFIX: "wd-token-",+	+};  /**  * Log any error that has occurred.  *- * @param data+ * @param {*} data  * @since 1.7.0  */ function logError( data ) { 	console.error( "An error occurred: ", data ); }  /**- * Gets the request data from the server.+ * jQuery ajax wrapper  *- * @returns mixed- * @since 1.7.0+ * @param {string} request_url+ * @param {string} method+ * @param {*} request_data+ * @returns {jQuery}+ * @since 3.1.0  */-function getCreditCardData() {+function callAjax(request_url, method, request_data) { 	return jQuery.ajax( 		{-			type: "POST",-			url: phpVars.ajax_url,-			cache: false,-			data: {"action": "get_credit_card_request_data"},+			type: method,+			url: request_url,+			data: request_data, 			dataType: "json", 		} 	); }  /**- * Resize the credit card form when loaded+ * Set states for spinner object+ * + * @param {string} state+ * @param {jQuery} selector+ * @since 3.1.0+ */+function setSpinnerState(state, selector) {+	switch (state) {+		case Spinner.STATE_OFF:+			document.querySelector( selector ).style.display = "none";+			break;+		case Spinner.STATE_ON:+			document.querySelector( selector ).style.display = "block";+			break;+	}+}++/**+ * Get saved token from vault  *- * @since 1.0.0+ * @since 3.1.0  */-function onFormRendered() {-	seamlessSubmitButton.removeAttr( "disabled" );-	newCardContentArea.find( "iframe" ).height( 270 );+function getFormattedTokenViewFromVault() {+	return callAjax(+		Url.GET_TOKEN_FORMATTED_VIEW,+		"GET",+		{ action : Actions.GET_CREDIT_CARD_FROM_VAULT }+	); }  /**- * Renders the actual seamless form+ * Load token table+ * @param {*} response  *- * @since 1.7.0+ * @since 3.1.0  */-function renderForm( response ) {-	WPP.seamlessRender(+function loadTokenTable( response ) {+	jQuery( Constants.VAULT_CONTENT_CONTAINER )+		.html( response.data );+}++/**+ * Delete a saved credit card from the vault+ *+ * @param {number} id+ * @since 3.1.0+ */+function deleteTokenFromVault( id ) {+	return callAjax(+		Url.DELETE_TOKEN_FROM_VAULT,+		"POST", 		{-			requestData: JSON.parse( response.data ),-			wrappingDivId: "wc_payment_method_wirecard_creditcard_form",-			onSuccess: onFormRendered,-			onError: logError,+			action : Actions.REMOVE_CREDIT_CARD_FROM_VAULT,+			vault_id: id 		} 	); }  /**- * Display error message after failure submit and hide processing spinner+ * Deleting token from view and vault  *- * @param data- * @since 2.0.3+ * @since 3.1.0  */-function onSubmitError( data ) {-	jQuery( "#wd-cc-submit-spinner" ).css( "display","none" );-	if ("transaction_state" in data) {-		getCreditCardData()-			.then( renderForm )-			.fail( logError )-			.always(-				function() {-					jQuery( ".show-spinner" ).hide();+function onTokenDeleted() {+	let self = this;+	jQuery( self ).append( Spinner.DELETE_TOKEN_SPINNER );+	let vault_id = jQuery( self ) .data( "vault-id" );++	if ( vault_id ) {+		deleteTokenFromVault( vault_id )+			.done(+				function () {+					self.closest( "tr" ).remove(); 				} 			)-		jQuery( "#wd-creditcard-messagecontainer" ).css( "display","block" );+			.fail( logError ); 	}-	logError( data ); } --/*- * AJAX-based functions- */- /**- * Save a new credit card token to our vault.+ * Replace class for chosen selector  *- * @param response- * @returns mixed- * @since 1.7.0+ * @param {jQuery} selector+ * @param {string} needle+ * @param {string} replacement+ * @since 3.1.0  */-function saveCreditCardToVault( response ) {-	var deferred      = jQuery.Deferred();-	var vaultCheckbox = jQuery( "#wirecard-store-card" );-	var request       = {-		"action": "save_cc_to_vault",-		"token": response.token_id,-		"mask_pan": response.masked_account_number-	};--	if ( "success" !== response.transaction_state ) {-		return deferred.resolve();-	}--	if ( ! vaultCheckbox.is( ":checked" ) ) {-		return deferred.resolve();-	}--	return jQuery.ajax(-		{-			type: "POST",-			url: phpVars.vault_url,-			data: request,-			dataType: "json"-		}-	);+function replaceClassForSelector( selector, needle, replacement ) {+	selector.removeClass( needle ).addClass( replacement );

Use $ for variable names holding jQuery objects. This makes it obvious that the variables have methods which you can call.

rinnhofer

comment created time in 2 days

Pull request review commentwirecard/woocommerce-ee

Tpwdcee 5739 my favorite payment

 public function load_variables() { 	 * @since 1.1.8 	 */ 	public function load_cc_template() {+		// @TODO: Change heading according to mock

fix this.

rinnhofer

comment created time in 2 days

Pull request review commentwirecard/woocommerce-ee

Tpwdcee 5739 my favorite payment

+<?php+/**+ * Shop System Plugins - Terms of Use+ *+ * The plugins offered are provided free of charge by Wirecard AG and are explicitly not part+ * of the Wirecard AG range of products and services.+ *+ * They have been tested and approved for full functionality in the standard configuration+ * (status on delivery) of the corresponding shop system. They are under General Public+ * License version 3 (GPLv3) and can be used, developed and passed on to third parties under+ * the same terms.+ *+ * However, Wirecard AG does not provide any guarantee or accept any liability for any errors+ * occurring when used in an enhanced, customized shop system configuration.+ *+ * Operation in an enhanced, customized configuration is at your own risk and requires a+ * comprehensive test phase by the user of the plugin.+ *+ * Customers use the plugins at their own risk. Wirecard AG does not guarantee their full+ * functionality neither does Wirecard AG assume liability for any disadvantages related to+ * the use of the plugins. Additionally, Wirecard AG does not guarantee the full functionality+ * for customized shop systems or installed plugins of other vendors of plugins within the same+ * shop system.+ *+ * Customers are responsible for testing the plugin's functionality before starting productive+ * operation.+ *+ * By installing the plugin into the shop system the customer agrees to these terms of use.+ * Please do not use the plugin if you do not agree to these terms of use!+ */++if ( ! defined( 'ABSPATH' ) ) {+	exit;+}++require_once( WIRECARD_EXTENSION_HELPER_DIR . 'class-method-helper.php' );++use Wirecard\PaymentSdk\Entity\Amount;+use Wirecard\PaymentSdk\Entity\Item;++/**+ * Class Basket_Item_Helper+ * Builds SDK Basket Items+ *+ * Handles basket+ *+ * @since   1.0.0+ */+class Basket_Item_Helper {++	/**+	 * @param string $name+	 * @param float $amount+	 * @param int $quantity+	 * @param string $description+	 * @param string $article_number+	 * @param float $tax_rate+	 * @param null|float $tax_amount+	 * @param null|string $currency+	 *+	 * @return Item+	 *+	 * @since 3.1.0+	 */+	public function build_basket_item( $name, $amount, $quantity, $description, $article_number, $tax_rate, $tax_amount = null, $currency = null ) {+		return $this->populate_basket_item(+			$this->create_basket_item( $name, $amount, $quantity ),+			$description,+			$article_number,+			$tax_rate,+			$tax_amount,+			$currency+		);+	}++	/**+	 * @param Item $item+	 * @param string $description+	 * @param string $article_nr+	 * @param float $tax_rate+	 * @param null|float $tax_amount+	 * @param null|string $currency+	 *+	 * @return Item+	 *+	 * @since 3.1.0+	 */+	private function populate_basket_item( $item, $description, $article_nr, $tax_rate, $tax_amount = null, $currency = null ) {+		$item->setDescription( Method_Helper::string_format_wc( $description ) );+		$item->setArticleNumber( $article_nr );+		$item->setTaxRate( Method_Helper::number_format_wc( $tax_rate ) );++		if ( $this->is_tax_amount( $tax_amount ) ) {+			$item->setTaxAmount(+				$this->create_formatted_amount( $tax_amount, $currency )+			);+		}++		return $item;+	}++	/**+	 * @param string $name+	 * @param float $amount+	 * @param int $quantity+	 * @param null|string $currency+	 *+	 * @return Item+	 *+	 * @since 3.1.0+	 */+	private function create_basket_item( $name, $amount, $quantity, $currency = null ) {+		return new Item(+			Method_Helper::string_format_wc( $name ),+			$this->create_formatted_amount( $amount, $currency ),+			$quantity+		);+	}++	/**+	 * @param float $amount+	 * @param null|string $currency+	 *+	 * @return Amount+	 *+	 * @since 3.1.0+	 */+	private function create_formatted_amount( $amount, $currency = null ) {+		if ( null === $currency ) {+			$currency = get_woocommerce_currency();+		}++		return new Amount(+			Method_Helper::number_format_wc( $amount ),+			$currency+		);+	}++	/**+	 * Check if tax amount is set+	 *+	 * @param $tax_amount+	 * @return bool+	 *+	 * @since 3.1.0+	 */+	private function is_tax_amount( $tax_amount ) {

I think a better name would be has_tax_amount.

rinnhofer

comment created time in 2 days

push eventwirecard/magento2-ee

Flavius Aspra

commit sha 5ea51f083258169edaaadc045b7c1ca269731b4b

Test factoring php-enum out of the SDK

view details

push time in 2 days

push eventwirecard/paymentSDK-php

Flavius Aspra

commit sha 49c365ebfe2e6516d6734a370c97d11e83d3052f

Vendor enum class

view details

Flavius Aspra

commit sha fbcf90e1c08f610b23116be11f6418a5e4e9a970

Add MacOS file to gitignore

view details

push time in 2 days

create barnchwirecard/paymentSDK-php

branch : TPWDCEE-5860

created branch time in 2 days

push eventwirecard/magento2-ee

Flavius Aspra

commit sha 23f55254c99d27b0076ade029638800f6f0cfcc4

Pin version of php-enum

view details

push time in 3 days

create barnchwirecard/magento2-ee

branch : TPWDCEE-5860

created branch time in 3 days

Pull request review commentwirecard/magento2-ee

Add QuoteAddress object to addressfactory and accountholderfactory

 class AddressFactory {     /**-     * @param AddressAdapterInterface $magentoAddressObj+     * @param AddressAdapterInterface|QuoteAddress $magentoAddressObj      * @return Address-     * @throws \InvalidArgumentException      */     public function create($magentoAddressObj)     {-        $address = null;-        if (!$magentoAddressObj instanceof AddressAdapterInterface) {-            throw new \InvalidArgumentException('Address data object should be provided.');-        }-         $address = new Address(             $magentoAddressObj->getCountryId(),             $magentoAddressObj->getCity(),-            $magentoAddressObj->getStreetLine1()+            $this->getStreetLine1($magentoAddressObj)         );         $address->setPostalCode($magentoAddressObj->getPostcode());          if (strlen($magentoAddressObj->getRegionCode())) {             $address->setState($magentoAddressObj->getRegionCode());         } -        if (strlen($magentoAddressObj->getStreetLine2())) {-            $address->setStreet2($magentoAddressObj->getStreetLine2());+        if (strlen($this->getStreetLine2($magentoAddressObj))) {

It's probably a good idea to also call trim() before calculating strlen, particularly also because we're in a public method.

rinnhofer

comment created time in 10 days

delete branch wirecard/prestashop-ee

delete branch : TPWDCEE-5595

delete time in 16 days

push eventwirecard/prestashop-ee

Sebastijan Sakac

commit sha a67c4819b8b589a1726d3fd91532bd69fe812070

Add mobile phone number only to account holder data

view details

Sebastijan Sakac

commit sha 084c3f0531b0e6046bff79cda84176eeb633befa

Trim whitespaces on phone and mobile phone number

view details

Flavius Aspra

commit sha f2a9cc05f0dd4ceea082ae1e8b10d2c4127a7813

Merge pull request #258 from wirecard/TPWDCEE-5595 Add mobile phone number only to account holder data

view details

push time in 16 days

delete branch wirecard/magento-ee

delete branch : TPWDCEE-5662-test

delete time in 16 days

push eventwirecard/magento-ee

brkicadis

commit sha f4422e73361bba81b44d8ec3d94783a49747e692

Update Payolution to accept the terms of paying

view details

Adis Brkic

commit sha 48428736ebb0e6dbba66b4285b0dd81ae5c075de

Merge branch 'master' into TPWDCEE-5662-test

view details

Flavius Aspra

commit sha 5d54ef7b36ddcb6040d25b642bebe847e0955204

Merge pull request #116 from wirecard/TPWDCEE-5662-test Update test for Payolution to accept the terms of paying

view details

push time in 16 days

delete branch wirecard/prestashop-ee

delete branch : TPWDCEE-4808

delete time in 17 days

push eventwirecard/prestashop-ee

Sebastijan Sakac

commit sha 3669983540f21d9259ea2496575ed7c02f3f4ca6

Submit if checkbox is selected

view details

Sebastijan Sakac

commit sha bca71eb05caca13f4ebfad0b7b7b31ac3627a834

Uncheck confirm checkbox on hiding popup

view details

Flavius Aspra

commit sha 8ce3b3499079745a27fa19e18851099674089c7e

Merge pull request #257 from wirecard/TPWDCEE-4808 Submit if checkbox is selected

view details

push time in 17 days

Pull request review commentwirecard/magento-ee

Update Payolution to accept the terms of paying

 describe('payolution invoice test', () => {       });     });     await driver.findElement(By.id('wirecardee-payolution--consent')).click();+    await driver.findElement(By.id('wirecardee-payolution--consent')).click();

Just a learning/understanding question for myself: why is the solution to the problem duplicating the line?

brkicadis

comment created time in 17 days

issue commentwirecard/shop-systems-coding-guidelines

Establish a common meta-language for these very guidelines

Establish a workflow for these items.

Possible ideas:

  • categorize tickets in tiers; tier 0 could be this ticket and other tickets about processes
  • split tickets such that one ticket belongs to exactly one tier
  • split and merge tickets as necessary, based on the subject matter
flavius

comment created time in 24 days

issue commentwirecard/shop-systems-coding-guidelines

Programming and OOP principles

My ideas about how to proceed:

  • define them
  • give examples of good code wrt the problem
  • give examples of bad code wrt the problem
  • outline connections between them
  • ???
flavius

comment created time in 24 days

issue openedwirecard/shop-systems-coding-guidelines

Programming and OOP principles

We need to establish a common ground regarding existing principles.

The purpose is not to decide what and when to follow which principle, but to define them and inspect connections between them.

Possibly incomplete list of principles, metrics, things to watch out for, "anti"-principles:

  • SRP
  • OCP
  • LSP
  • ISP
  • DIP
  • law of demeter
  • separation of concerns
  • cohesion / coupling
  • tell, don't ask
  • temporal coupling
  • uniform access (=uniform notation - storage vs calculation)
  • single source of truth
  • CQS
  • YAGNI
  • DRY
  • OOP polymorphism
  • OOP encapsulation
  • OOP inheritance
  • accidental vs inherent complexity

Some of these are synonyms to each other, or partly overlapping, or some enforce others.

created time in 24 days

startedr2dbc/r2dbc-postgresql

started time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha d0975e7a18c923365c5d5655c1fa3ce96a57e648

Pass the full amount in Hook/BeforeOrderStatusUpdateHandler as delta

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 53460a58df8da90af310f3a71bfa6803778e8029

CS fixes

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 575f5114cbd70b267ffea08d87dd248b1c542d6f

CS fixes

view details

Flavius Aspra

commit sha 9247ffcac05358921d60b43a0f881c97a96c8702

Remove unused: creating order payment

view details

Flavius Aspra

commit sha e09f4825e668df42a797d42287375f6b69a9285f

Call postProcessingService with a delta of 0 from Hook/BeforeOrderStatusUpdateHandler

view details

push time in a month

Pull request review commentwirecard/prestashop-ee

Partial capture/refund

 public function postProcess()             return;         } +        $parentTransaction = new Transaction($transaction_id);+        $delta_amount = Tools::getValue('partial-delta-amount', $parentTransaction->getAmount());+         $transactionPostProcessingService = new TransactionPostProcessingService($operation, $transaction_id);-        $transactionPostProcessingService->process();+        $transactionPostProcessingService->process($delta_amount);         $this->errors = $transactionPostProcessingService->getErrors(); -        parent::postProcess();+        return parent::postProcess();

Yes, it's intentional. Simply ignoring the return value of the parent violates LSP.

flavius

comment created time in a month

Pull request review commentwirecard/prestashop-ee

Partial capture/refund

 public function __construct($order, $notification)     public function getPaymentProcessing()

Not the author of the code, but the naming feels consistent with the rest of the code - e.g. Notification\Initial\PostProcessing. I would have named it "Processor" instead of "Processing".

The nesting would probably be avoidable by making $processType an actual object - not a string. Since the type knows what it is, it could return the correct type of "Processor", when given the order and the notification.

Furthermore, $notification itself knows what kind of object it is, so it could provide the object (or delegate further down). All in all, I guess too much of a change at once.

flavius

comment created time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 41688d79a88756c11c316a792d5d526f2017e891

Update payment in order when full amount paid

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha d53ddcd0716766f09ceef030f2b1d81b4fa4378f

Fix order state for purchase

view details

Flavius Aspra

commit sha bf82e9b0e0262c7ce3e8e68c7ca76f8771968e6b

Do more research about missing constant

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha fbfdbf26bc6643d8e7f6de232ed669a6daed9d2a

Make more methods private

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 3ed02a5e015cd72e7e22be8693ff6fefa68c3bb6

Fix test

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha aaffea699af4d7150eca9d3432b5d3d0f21101df

CS fixes

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha c1056288cc47ce798679b87870ac5052bdef9948

Reference new constant from ProcessType

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha aaecfed4b2bb90eae0b960b5175ef1867f09f6fc

Improve DBManager documentation

view details

Flavius Aspra

commit sha d7b05ee414ed2e5c18615c0c1501aaab7518fbd5

Attempt to reduce cyclomatic complexity

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha d5679cd7038647f9b1698c3025c8aee6395348ca

Make static analysis happier

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha f5d954742870c288895024d8c48f517280065aab

Make static analysis happier

view details

Flavius Aspra

commit sha 04f4f57321ffaa4ad768aeb786b1af36719aa73e

License header

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha c1786350d059f4dc20d0b993a28f15c76f6fe0a5

Make static analysis happier

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 58051532d99395d0f4827dac7e27d844b4c542b2

Make static analysis happier

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 756d676424417d1797f890b3af2518571782f1b3

Remove TODOs

view details

Flavius Aspra

commit sha c0ef6a46ea8aacc6485b88814d0ef2c91f11180a

Remove TODOs

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 153f7ca68b679ea7ad837792168d8512258f89e1

CS fixes

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 53586e0e6200d8eb460560fc896b6be8b61614ef

Cancellation is available only for the whole amount

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha c3dc5c44f7fd89d0ac4a55c7cbeeed1947cc5798

Introduce transitive calculation of sums for children, both for deducting operations and for capturing operations

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha dbfd9c7ca85a5cd3221b6b4b25232cae7ca87d0c

Make amount always an object

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 56a51968e953b4173368c8dbf8a784d8fd3c7862

Inspect bug in presta

view details

Flavius Aspra

commit sha 23108a13eebc67be821dfccfe974bf9e01ebe063

Merge branch 'TPWDCEE-4113' of https://github.com/wirecard/prestashop-ee into TPWDCEE-4113

view details

Flavius Aspra

commit sha c3963661707f6864af3b1cd1d5f0566a98c9469c

[WIP] separate refunds from captures

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha c0b6e6e7777d7cf6c66657f813c92b165b6bc83e

Use ProcessType constant and error message

view details

Flavius Aspra

commit sha 3daaaaca4e96eae0f511d95d52a4b2e6d41bd89e

Temp work

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha cc80928f1247859726661bc0da8911d5455885ab

Fix LSP violations

view details

Flavius Aspra

commit sha 89e2a59de5c6ed91a597aec2f68bfb0e9a6e39da

Drop unused variables

view details

Flavius Aspra

commit sha 3c1d88116bff6b658c91574a679fe64605577f69

Document property

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha d02ef948ba202604f4b69032fdf6510efde15718

Add license headers

view details

push time in a month

Pull request review commentwirecard/prestashop-ee

Partial capture/refund

+<?php++namespace WirecardEE\Prestashop\Classes\Notification\PostProcessing;++use WirecardEE\Prestashop\Classes\Notification\ProcessablePaymentNotification;+use \WirecardEE\Prestashop\Classes\Notification\Success as AbstractSuccess;

I guess it's a misfeature of the IDE.

flavius

comment created time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 02cd624591bee53dec64fc831d1a013f253a4217

Remove unused variables

view details

push time in a month

push eventwirecard/prestashop-ee

Your Name

commit sha b985435851e45dea3a213e798f59fb20c4bc7dd8

CS fixes

view details

push time in a month

PR opened wirecard/prestashop-ee

Partial capture/refund
+734 -90

0 comment

21 changed files

pr created time in a month

create barnchwirecard/prestashop-ee

branch : RC-2.6.0-minor

created branch time in a month

push eventwirecard/prestashop-ee

Richard Blechinger

commit sha 4df8f1b6ac6bff668b3335e0f69bacdb2c1f8449

Sync Phraseapp

view details

Richard Blechinger

commit sha 50cc83673f53283a74454578a0ae193287d8fddb

Fix translation lookup

view details

Richard Blechinger

commit sha a4765a4977dd0378e94fc57dc9c1635fec635c5f

Address Codacy issues

view details

Richard Blechinger

commit sha cb441bd395c20a4e49096e88cd5f8ebab1b72e45

Code style

view details

Richard Blechinger

commit sha 85a7181c9eb87f31fc25b32d95b6cc2762563127

Add missing translations

view details

Flavius Aspra

commit sha cde1a7e589b977b44f1985e8d4d93a5ac42fe0e1

Extract functionality and reduce complexity

view details

Flavius Aspra

commit sha ea0949f123643e918a11d4f734c2d03d687e14d7

Merge remote-tracking branch 'origin/RC-2.5.0' into TPWDCEE-4113

view details

push time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 23747a37c84685cc4b39e1e2e25867b2a70fcccb

Mark order as refunded only when the full amount has been refunded

view details

push time in a month

issue openedwirecard/shop-systems-coding-guidelines

Class hierarchy

Set rules for class hierarchies, based on the context.

My ideas:

  • flat and shallow hierarchy
  • only the leaves are concrete classes, the rest are abstract classes
  • all concrete classes are final (TODO: identify extension points)
  • respect liskov: #5

created time in a month

issue commentwirecard/shop-systems-coding-guidelines

Establish a common meta-language for these very guidelines

Many, if not all issues, are worth separating based on "context":

  • shop plugin itself
  • sdk at large
  • the core domain model within the sdk
flavius

comment created time in a month

issue openedwirecard/shop-systems-coding-guidelines

Open-Closed principle

This principle means that the code should be structured such that if a new requirement arises, we don't need to change existing methods, just add new methods or add new classes and hook them up.

It's worth talking about how we deal with this principle based on the context:

  • shop system plugin
  • sdk at large
  • core domain

created time in a month

push eventwirecard/prestashop-ee

ozada

commit sha 2dfc41f954c23e314425ab2cd64d024f168ed488

Capture on order state change.

view details

ozada

commit sha 676a79a77c0712e039a5dea11fd91022319fb981

Capture on order state change. Refactoring. Preparation.

view details

ozada

commit sha 7bdfb331543719f61d71cceb3d0b2dc9e46badbe

Form helper and elements refactoring.

view details

ozada

commit sha 65ce334717c51d0f146cb3730a84ff05bc3514c5

Capture on order state change. Refactoring. Unit tests.

view details

Huseyn Zada

commit sha a1d0eea7aff5c81a02b5a6e5e99b586196ccfb70

Merge remote-tracking branch 'origin/TPWDCEE-5325' into TPWDCEE-5170

view details

ozada

commit sha d8f51bdf455602f56ffb4a9291e407d9d21c33a6

Merge remote-tracking branch 'origin/TPWDCEE-4383' into TPWDCEE-5170

view details

ozada

commit sha d311a31abda03050162f0e3960f445c5a92b95cd

Automatic capture preparation.

view details

ozada

commit sha 16a5eb2bdf4a38337f68823d1dcb209b21cbe626

Automatic capture preparation.

view details

ozada

commit sha fc6a18db37e29b02ec3c8e6511b83ab2ce85f73c

Automatic capture.

view details

ozada

commit sha 675778f507a5cdd13db566f64fdb6a31ec3068af

Merge remote-tracking branch 'origin/TPWDCEE-4383' into TPWDCEE-5170 # Conflicts: # wirecardpaymentgateway/controllers/admin/WirecardTransactions.php # wirecardpaymentgateway/helper/StringHelper.php

view details

ozada

commit sha a0fe65ca2a2dd4d4301264efa09a8219ccc510dd

Merge remote-tracking branch 'origin/TPWDCEE-4383' into TPWDCEE-5170

view details

ozada

commit sha 81b312e2428df166b57541adb1369f11e30367c1

Composer test namespace fix.

view details

ozada

commit sha e2fbbe8f562e92156774e0a43f77dd11bd5b9e7c

Unit tests.

view details

ozada

commit sha b25bfed088e1378712d4b91594b762aae0d36be8

Unit tests. Refactoring.

view details

ozada

commit sha 689d6dac469d1b7b68c52f17c14af5e0fb6ee20b

Merge remote-tracking branch 'origin/TPWDCEE-4383' into TPWDCEE-5170

view details

ozada

commit sha bb32f07c74ac0d24270ec790f55d0f2db263eff9

Automatic capture refactoring & and unit tests.

view details

ozada

commit sha 6c01b71005ed8b4654536c1f16641e5e1ea82f52

Unit tests. cs-fix. Refactoring.

view details

Your Name

commit sha b164623ecfda39e42e6abb58260e8802bba64a77

php cs fix issues.

view details

ozada

commit sha 2b4fc7d5d8d7fa0784c52c0eb0273ded4d59cf14

Refactoring. @since tags.

view details

ozada

commit sha 280debd7218d57854a24e8dfa852a01d47d3cffa

Refactoring. Move array function to helper.

view details

push time in a month

issue openedwirecard/shop-systems-coding-guidelines

Usage of repositories

A repository is a class which mediates the fetching and the storage/updating of DB entities.

A repository is a collection mapping unique IDs to objects.

If they implement an interface, then we can use the interfaces in the SDK, without actually requiring a database. The repositories are then injected by the shop plugin.

Each repository uses internally the abstractions provided by plugins.

Repositories are sitting in the application layer, but the SDK depends on the interfaces.

The repository keeps track of objects and their IDs, their states. Since it stores internally the state of all entities before returning them to the caller, it can also decide if something has changed, and it can decide which fields to update.

autoincrement IDs are unique identifiers identifing the position of entities within the repository.

A repository does not need to deal with only one table, as it's not specific to a database technology or strategy (like "relational"), but it serves as purely an "object storage".

Inside the repository, SQL and "relational" are implementation details.


Possible interface for repositories:

  • add($object): Identifier returns the new ID of the entity, as a value object specific to the type
  • store($object): bool - figures out the ID of the object and inserts or updates the object
  • flush() - updates any object which has changed and not been stored explicitly
  • delete($object) - removes the object from the entity

Discussion: how much we want to tie ourselves to the database type or database vendor?

Open-ended discussion should follow.

created time in a month

issue openedwirecard/shop-systems-coding-guidelines

Git configuration

  • git config name: a nickname vs full name, and if full name, first name first?

created time in a month

issue commentwirecard/shop-systems-coding-guidelines

How to name things

Do we want to have a fixed variable name for the return value of a method, e.g. always call it $result, or do we want to give it a more meaningful name semantically, based on the method we're currently in?

Advantage of something like $result: during refactorings, we don't have to worry about the name, since it's always the same

Disadvantage: it goes against the principle mentioned in the first comment. https://github.com/wirecard/shop-systems-coding-guidelines/issues/7#issue-533819922

flavius

comment created time in a month

issue openedwirecard/shop-systems-coding-guidelines

Establish a common meta-language for these very guidelines

In this repository, we attempt to establish rules, indications and guidelines for developing shop system plugins, PHP development, and software development in general.

What we need is a common language to use while defining all these artifacts.

For example, RFC 2119 defines words like "MUST", "SHOULD", etc.

created time in a month

issue openedwirecard/shop-systems-coding-guidelines

Building new bridges in the architecture

When refactoring something, e.g. extracting some functionality into a new component / class, the newly introduced component should be used throughout the code, and the old way of doing things should be removed throughout the code.

created time in a month

issue commentwirecard/shop-systems-coding-guidelines

LogMethod calls vs direct calls

Consistency is king, but I would split the discussion based on the context: shop system plugin and sdk.

serucee

comment created time in a month

issue commentwirecard/shop-systems-coding-guidelines

Json decode assoc vs no assoc

Either way, it should be symmetrical to what was encoded to begin with.

serucee

comment created time in a month

issue commentwirecard/shop-systems-coding-guidelines

How to name things

Naming classes and namespaces might be worth discussing based on the context. Some contexts:

  • shop system plugin
  • sdk at large
  • core domain (within the sdk)
flavius

comment created time in a month

issue commentwirecard/shop-systems-coding-guidelines

Purpose and return values of specific classes

Related: #7 "how to name things".

serucee

comment created time in a month

issue commentwirecard/shop-systems-coding-guidelines

Purpose and return values of specific classes

There are heated debates whether there should be technical names in classes or not.

The way I see things, it might be worth talking about this first, also split between domain model and the other layers.

Personally, I have a strong opinion about not using technical names in the core domain model because it's the place where the business can be understood without technicalities.

Outside of the core model, I don't have a strong opinion, just some thoughts:

  • what the thing is is many times enforced by the shop system, e.g. XController or YModel
  • if the name itself is not enforced, then the location (on disk or in namespace) is
  • Acme\Controller\FooController - the second mention of Controller is redundant and according to the improvement day, disliked by some
  • "wrapper" is an umbrella term for a decorator or an adapter. I would use those terms explicitly, if at all, instead of wrapper, because they highlight the intent better
  • many times, what a thing is, is encoded in where it comes from; e.g. an object stored in the controller which I call ad-hoc is most likely a service
  • for helpers, I would use traits. The reason is that an additional helper class means an additional contract that client code depends on. If instead helper methods are hidden in private methods, they become almost invisible. This point might be discussed differently depending on the component where the helper would be: in an extension, or in the sdk. I would be more strict about it in the sdk, and more lax in shop extensions
  • model is not a class, except in shop systems where the idea of "mvc" screwed up the minds of the makers of shop systems. Again, I would have a different discussion based on context: in the shop system vs. sdk vs core model. The "core model" for example is not a specific class, it's a whole directory/namespace
  • DTOs are supposed to be used at system boundaries, not within systems, so again it's clear from the context whether it's a DTO or not
serucee

comment created time in a month

issue closedwirecard/shop-systems-coding-guidelines

Definitions of patterns

  • factory - there are two valid types of factories: factory methods and factory classes
  • service - a service is a stateless class which is injected at the top-most level into the application (shop plugin); it gets via its constructor its dependencies (e.g. another service like the database), and it implements public stateless methods for various operations; each operation receives the necessary values as parameters; a service is shared among parties, e.g. all controllers and other services have the same service instance

closed time in a month

flavius

issue commentwirecard/shop-systems-coding-guidelines

Definitions of patterns

Closed because it's covered by #12

flavius

comment created time in a month

issue commentwirecard/shop-systems-coding-guidelines

Define rules for a class constructor

Regarding this

  • All data that is needed to operate the class is passed over the constructor

We should respect the Law of Demeter in that we pass in strictly just what the class needs, not more than that.

It might feel restrictive at times, but interface seggregation (from SOLID) is employed, then we can isolate the dependencies further. Read: we're working at the contract level, even if we pass in an object which in theory offers more methods.

tomazpu

comment created time in a month

issue commentwirecard/shop-systems-coding-guidelines

Handling TODOs

We're not allowed to use internal tickets in code, but we could instead:

  • create tickets in the internal system and reference code
  • create issues on github and reference code

In both cases, the referenced code has to be done via a tree sha id, not via a symbolic branch name.

In both cases, the disadvantage is that we make it harder for a boy-scout. Why? Because the boy-scout scouts the code, not the tickets. Moreover, a boy-scout might fix an issue without being aware of it (because there is no indication in the code), which means the ticket stays in the backlog untouched, and at some point, someone will have to dig through it, just to figure out that there's nothing to be done => wasted time.

flavius

comment created time in a month

issue commentwirecard/shop-systems-coding-guidelines

Define rules for a class constructor

This discussion goes hand in hand with the discussion in #4

tomazpu

comment created time in a month

issue openedwirecard/shop-systems-coding-guidelines

Usage of marker interfaces

Marker interfaces are empty interfaces with meaningful names. Their goal is to mark classes as implementing concepts and make it easy to find those classes in the whole project.

One disadvantage though is that they can be used in function signatures (the language allows it), but the implementation of the function cannot use it because the marker interface doesn't provide any contracts.

Decide how to go about marker interfaces.

created time in a month

issue openedwirecard/shop-systems-coding-guidelines

Definitions of patterns

  • factory - there are two valid types of factories: factory methods and factory classes
  • service - a service is a stateless class which is injected at the top-most level into the application (shop plugin); it gets via its constructor its dependencies (e.g. another service like the database), and it implements public stateless methods for various operations; each operation receives the necessary values as parameters; a service is shared among parties, e.g. all controllers and other services have the same service instance

created time in a month

delete branch wirecard/magento-ee

delete branch : Update-release-configuration

delete time in a month

push eventwirecard/magento-ee

Tatjana Starcenko

commit sha d1758dda6f561db6edab39db6f6bc14f9664a051

Update create_release.yml

view details

Flavius Aspra

commit sha a89080a09efab48bab8b194d111c94313d8a27ef

Merge pull request #114 from wirecard/Update-release-configuration Update create_release.yml

view details

push time in a month

PR merged wirecard/magento-ee

Update create_release.yml no-release
+1 -1

0 comment

1 changed file

tatsta

pr closed time in a month

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha f47224f5cc6b818710d961228c280c8557326398

Implement: cannot cancel after making partial refunds; no partial payment for ratepay-invoice

view details

push time in 2 months

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 915c8fce6c35c3be98dae78b807a629ddc6a0c83

Transaction can be hydrated via a transaction id, instead of requiring tx_id

view details

push time in 2 months

push eventwirecard/prestashop-ee

Flavius Aspra

commit sha 3713f9d911c29f0607ee4d3625c4e2abf7683fb8

Lock mechanism for concurrent response/notification; transactions work

view details

push time in 2 months

IssuesEvent

issue closedwirecard/shop-systems-coding-guidelines

How to do code reviews

A tutorial on how to do them, how to navigate code, what to watch out for, where to draw a line, etc.

A list of "trigger patterns", sections of code that you might see while reviewing which make you look closer. Links to other, corresponding articles elaborating on those patterns or anti-patterns.

closed time in 2 months

flavius

Pull request review commentwirecard/woocommerce-ee

Refactor additional information

 private function get_correct_country_for_tax_rate() { 		$tax_setting = get_option( 'woocommerce_tax_based_on' );  		switch ( $tax_setting ) {-			case 'billing':+			case self::BILLING: 				return WC()->customer->get_billing_country();-			case 'shipping':+			case self::SHIPPING: 				return WC()->customer->get_shipping_country(); 			case 'base':

Introduce symbolic constant.

serucee

comment created time in 2 months

Pull request review commentwirecard/woocommerce-ee

Refactor additional information

 public function create_address_data( $order, $type ) { 		return $address; 	} +	/**+	 * @param Item $item+	 * @param string $description+	 * @param string $article_nr+	 * @param float $tax_rate+	 * @param null|float $tax_amount+	 * @param null|string $currency+	 *+	 * @return Item+	 *+	 * @since 3.1.0+	 */+	protected function populate_basket_item( $item, $description, $article_nr, $tax_rate, $tax_amount = null, $currency = null ) {+		$item->setDescription( Method_Helper::string_format_wc( $description ) );+		$item->setArticleNumber( $article_nr );+		$item->setTaxRate( Method_Helper::number_format_wc( $tax_rate ) );++		if ( null !== $tax_amount ) {+			$item->setTaxAmount(+				$this->create_formatted_amount( $tax_amount, $currency )+			);+		}++		return $item;+	}++	/**+	 * @param string $name+	 * @param float $amount+	 * @param int $quantity+	 * @param null|string $currency+	 *+	 * @return Item+	 *+	 * @since 3.1.0+	 */+	protected function create_basket_item( $name, $amount, $quantity, $currency = null ) {+		return new Item(+			Method_Helper::string_format_wc( $name ),+			$this->create_formatted_amount( $amount, $currency ),+			$quantity+		);+	}++	/**+	 * @param float $amount+	 * @param null|string $currency+	 *+	 * @return Amount+	 *+	 * @since 3.1.0+	 */+	protected function create_formatted_amount( $amount, $currency = null ) {+		if ( null === $currency ) {+			$currency = get_woocommerce_currency();+		}+		return new Amount(+			Method_Helper::number_format_wc( $amount ),+			$currency+		);+	}++	/**+	 * @param string $name+	 * @param float $amount+	 * @param int $quantity+	 * @param string $description+	 * @param string $article_number+	 * @param float $tax_rate+	 * @param null|float $tax_amount+	 * @param null|string $currency+	 *+	 * @return Item+	 *+	 * @since 3.1.0+	 */+	protected function build_basket_item( $name, $amount, $quantity, $description, $article_number, $tax_rate, $tax_amount = null, $currency = null ) {+		// TODO: move basket logic into separate class

Write a ticket for this and reference it here.

serucee

comment created time in 2 months

Pull request review commentwirecard/woocommerce-ee

Refactor additional information

 public function map_state_to_iso_code( $country, $state ) { 	 * @return Basket|WP_Error 	 * @since 1.3.2 	 */-	public function create_basket_from_parent_transaction( $order, $config, $payment_method, $refund_basket = [], $refunding_amount = 0 ) {+	public function create_basket_from_parent_transaction( $order, $config, $payment_method, $refund_basket = array(), $refunding_amount = 0 ) { 		$basket              = new Basket(); 		$transaction_service = new \Wirecard\PaymentSdk\TransactionService( $config ); 		$parent_transaction  = $transaction_service->getTransactionByTransactionId( $order->get_transaction_id(), $payment_method ); 		$items_total         = 0; 		$shipping            = 0; +		// TODO: only call build_basket_item_from_array once, always use $item, remove calc logic from method call

Create a ticket for this TODO and add it to the TODO or resolve it.

serucee

comment created time in 2 months

Pull request review commentwirecard/woocommerce-ee

Refactor additional information

 public function __construct() { 	 * @since 2.2.0 	 */ 	public function init_form_fields() {-		$this->form_fields = [-			'enabled'             => [+		$this->form_fields = array(

Why did we change from [ to array(? There's probably no right or wrong, just curious about the reasoning.

serucee

comment created time in 2 months

issue openedwirecard/shop-systems-coding-guidelines

Collection of misconceptions

A very incomplete list:

  • an object encapsulates data; better: it encapsulates behaviour, and it just uses data

created time in 2 months

issue openedwirecard/shop-systems-coding-guidelines

How to do code reviews

A tutorial on how to do them, how to navigate code, what to watch out for, where to draw a line, etc.

created time in 2 months

issue openedwirecard/shop-systems-coding-guidelines

Tutorial: how to recognize a good architecture

  • principle: a good architecture is one allowing for change, not a "perfect" one; design for flexibility, but don't overdo it; sometimes, it's enough to "open doors" by naming things differently, without actually implementing big things
  • principle: a good architecture forces you to write good code; while it's still possible to make a mess, a good architecture makes it hard for you to go against the flow; for the remaining problems we have code reviews

This is not the whole story. A more involved discussion should follow.

created time in 2 months

issue openedwirecard/shop-systems-coding-guidelines

How to name things

naming: qualify the thing that you're naming with some business-relevant information, or at least give it more context. Don't: "$amount", do: "$remainingAmount", don't: "$transaction", do: "$parentTransaction", even for non-domain areas, don't: "$coefficient", do: "$fractionalCoefficient"

created time in 2 months

issue openedwirecard/shop-systems-coding-guidelines

Use the type system of the language

use the type system of the language, even if it's "weak", it's better than nothing; implication: one anti-pattern is having methods akin to "getType"; instead of "getType", you'd have "getSomething", returning an instance of some type.

This is not the whole story. A more involved discussion should follow.

created time in 2 months

issue openedwirecard/shop-systems-coding-guidelines

Liskov substitution principle

Liskov substitution principle (from SOLID): one aspect of respecting it is returning the value from the parent implementation when overriding a method, or at least not disregard it, e.g. no-go: "parent::foo()", instead do: "return parent::foo()"

This is not the whole story. A more involved discussion should follow.

created time in 2 months

issue openedwirecard/shop-systems-coding-guidelines

An object is valid at all times

  • Pattern: C++ has the notion of "friend", PHP doesn't, but still it is possible to achieve something similar by using Closure::bind & co; related to this: see next point
  • Principle: an object is valid at all times; things to watch out for (keywords): constructor, setters, "friend" (see previous point), temporal coupling (anti-pattern); public methods like "init" (anti-pattern, should be done by constructor)

This is not the whole story. A more involved discussion should follow.

created time in 2 months

issue openedwirecard/shop-systems-coding-guidelines

Exhaustive matching over closed sets

Pattern: "exhaustive matcher/executor". Code will be provided for this, but the idea is that we can ensure (at runtime) that all switch-case branches over a closed set are covered. Not a perfect solution, but a good thing we can do in case we add new possible values to the set, without support from the language.

Useful when we have an "enum", and switch-cases of this enum sprinkled all over the code.

The pattern can ensure at runtime that, as long as any branch of the switch is executed, all branches are actually covered. Meaning: we test for one thing (e.g. "payment method"), and we throw an exception if any case statement is missing.

created time in 2 months

issue openedwirecard/shop-systems-coding-guidelines

Protect sections which can be executed in parallel due to the asynchronicity of HTTP

Processes like "response" and "notification" for transactions can run in parallel. The handling code needs to be protected via a lock, so that the lines of code from both sections are not intertwined.

As a locking ID, a common value like the transaction id has to be used - depending on the business case.

Possible locking mechanisms are:

  • GET_LOCK() & co in mysql; beware of compatibility requirements. At least mysql 5.0+ support this
  • advisory file locking; in this case you'll probably create a temporary file containing in its name the locking ID; see http://php.net/flock

created time in 2 months

issue openedwirecard/shop-systems-coding-guidelines

Handling TODOs

  • TODO must always be accompanied by ticket number; e.g. you find a bug/issue/improvement, you take a shortcut in the code, but you know how a cleaner approach would look like; naturally, you write a TODO in the code; as part of writing a TODO, you have to create a separate ticket and use that ticket number in your newly written TODO, as a reference to keep things in check
  • related to previous, boyscout rule: when you see a TODO with a ticket number in it, check if the referenced ticket has already been tackled, and implement it if so
  • related to previous, boyscout rule: when you see a TODO without a ticket number in it, create a ticket for it and update the TODO
  • TODOs without ticket numbers are fine during development, as long as they don't reach the code review; useful when you want to get a prototype working without bothering with details, but you need a reminder to address those details before starting a code review

created time in 2 months

create barnchwirecard/prestashop-ee

branch : TPWDCEE-4113

created branch time in 2 months

more