omise / omise-woocommerce

Omise WooCommerce Plugin
https://docs.opn.ooo/woocommerce-plugin
MIT License
47 stars 27 forks source link

Cleaning up code style & indentation. #182

Closed guzzilar closed 4 years ago

guzzilar commented 4 years ago

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' );
    }
  2. 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:

✏️ 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
  2. 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

guzzilar commented 4 years ago

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