Skip to content

Cleaning up code style & indentation.#182

Merged
guzzilar merged 3 commits intomasterfrom
code-cleanup
Jul 31, 2020
Merged

Cleaning up code style & indentation.#182
guzzilar merged 3 commits intomasterfrom
code-cleanup

Conversation

@guzzilar
Copy link
Copy Markdown
Contributor

@guzzilar guzzilar commented Jul 23, 2020

1. Objective

Mainly to cleanup code after a long work of adding in and removing out partial of code here and there.

2. Description of change

  1. For those /includes/gateway/class-omise-payment-*.php classes.
    Only removing 1 indent.

Back to the PR #153: "Code cleaning for payment method classes", the outer function layer has been removed. However, because I don't want to create an unnecessary LOC at that time, so I leave all the code as it is without moving its indent up 1 layer.

So for this time, just to remove the remaining indentation for the following files:

• includes/gateway/class-omise-payment-alipay.php
• includes/gateway/class-omise-payment-billpayment-tesco.php
• includes/gateway/class-omise-payment-creditcard.php
• includes/gateway/class-omise-payment-installment.php
• includes/gateway/class-omise-payment-internetbanking.php
• includes/gateway/class-omise-payment-truemoney.php
  1. Update code style at /includes/gateway/class-omise-payment.php
    Removing unnecessary long pyramid layer of indent. Grouping it to make it easier to read
    Before
protected function invalid_order( $order_id ) {
    wc_add_notice(
        sprintf(
            wp_kses(
                __( 'We have been unable to process your payment.<br/>Please note that you\'ve done nothing wrong - this is likely an issue with our store.<br/><br/>Feel free to try submitting your order again, or report this problem to our support team (Your temporary order id is \'%s\')', 'omise' ),
                array(
                    'br' => array()
                )
            ),
            $order_id
        ),
        'error'
    );
}

to

protected function invalid_order( $order_id ) {
    $message = wp_kses( __(
        'We have been unable to process your payment.<br/>
         Please note that you\'ve done nothing wrong - this is likely an issue with our store.<br/>
         <br/>
         Feel free to try submitting your order again, or report this problem to our support team (Your temporary order id is \'%s\')',
        'omise'
    ), array( 'br' => array() ) );

    wc_add_notice( sprintf( $message, $order_id ), 'error' );
}
  1. Removing a local $order variable, accessing Order object from a class's property instead (make sure that the entire of payment processing is using and manipulating the same Order Object).

3. Quality assurance

🔧 Environments:

  • WooCommerce: v4.3.1
  • WordPress: v5.4.2
  • PHP version: 7.3.3

✏️ Details:

  1. To test invalid_order error message (https://github.com/omise/omise-woocommerce/pull/182/files#diff-b2a67ad6a97418df7dddcefcfc2a5319R401), you will need to modify Omise_Payment::load_order( $order ); code.
    Right at the first line after an order id has been passed through the method's argument:
public function load_order( $order ) {
    $order = 'x';
    // ...
}

Screen Shot 2563-07-23 at 16 29 25

  1. To test payment_failed error message (https://github.com/omise/omise-woocommerce/pull/182/files#diff-b2a67ad6a97418df7dddcefcfc2a5319R407), you may place an order with Credit Card payment method using a failed-test-card. (Insufficient fund error card: 4111 1111 1114 0011)

Screen Shot 2563-07-23 at 16 34 22

Screen Shot 2563-07-23 at 17 27 21

  1. To test successful payment, you may place order with different payment methods to make sure that the change will not effect its function.
    Alipay

Screen Shot 2563-07-23 at 17 39 14

Bill Payment
Screen Shot 2563-07-23 at 17 40 24

Credit Card
Screen Shot 2563-07-23 at 17 29 47

Installment
Screen Shot 2563-07-23 at 17 45 46

Internet Banking
Screen Shot 2563-07-23 at 17 41 54

PayNow
Screen Shot 2563-07-23 at 17 31 39

TrueMoney Wallet
Screen Shot 2563-07-23 at 17 37 08

4. Impact of the change

None

5. Priority of change

Normal

6. Additional Notes

None

…Also adding those missing 'manual sync' action (Installment, PayNow).
'title' => array(
'title' => __( 'Title', 'omise' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'omise' ),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need 'which' here

'description' => array(
'title' => __( 'Description', 'omise' ),
'type' => 'textarea',
'description' => __( 'This controls the description which the user sees during checkout.', 'omise' )
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

'title' => array(
'title' => __( 'Title', 'omise' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'omise' ),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove 'which'

'description' => array(
'title' => __( 'Description', 'omise' ),
'type' => 'textarea',
'description' => __( 'This controls the description which the user sees during checkout.', 'omise' )
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more

Copy link
Copy Markdown

@jonrandy jonrandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small English issues

@guzzilar
Copy link
Copy Markdown
Contributor Author

@jonrandy done, I have just pushed a new commit to remove which out from the sentences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants