diff --git a/.github/workflows/artifact.yml b/.github/workflows/artifact.yml new file mode 100644 index 0000000..1c95eee --- /dev/null +++ b/.github/workflows/artifact.yml @@ -0,0 +1,27 @@ +on: [push, pull_request] + +name: Create Artifact + +jobs: + build: + name: Add Artifact + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + tools: composer + + - name: Install Dependencies + run: composer install + + - name: Upload Artifact + id: upload_artifact + uses: actions/upload-artifact@v2 + with: + name: woocommerce-qenta-checkout-seamless + path: woocommerce-qenta-checkout-seamless diff --git a/woocommerce-qenta-checkout-seamless/assets/scripts/payment.js b/woocommerce-qenta-checkout-seamless/assets/scripts/payment.js index 1bd8772..6712c51 100644 --- a/woocommerce-qenta-checkout-seamless/assets/scripts/payment.js +++ b/woocommerce-qenta-checkout-seamless/assets/scripts/payment.js @@ -245,6 +245,20 @@ form.addEventListener('submit', (event) => { var paybox = document.getElementById('payment_method_wcs_PBX'); var giropay = document.getElementById('payment_method_wcs_GIROPAY'); + var pmArray = Array.from(document.querySelectorAll('input.input-radio.qcs_payment_method_list')); + if(pmArray.length == 1) { + pmArray[0].click(); + } + + var pmSelected = !!pmArray.filter(function (pm) { + return pm.checked; + }).length; + + if(pmSelected === false) { + event.preventDefault(); + return false; + } + if (document.woo_wcs_ok) { return true; } diff --git a/woocommerce-qenta-checkout-seamless/classes/class-qenta-admin.php b/woocommerce-qenta-checkout-seamless/classes/class-qenta-admin.php index df2ba7b..18ffd2d 100644 --- a/woocommerce-qenta-checkout-seamless/classes/class-qenta-admin.php +++ b/woocommerce-qenta-checkout-seamless/classes/class-qenta-admin.php @@ -539,7 +539,7 @@ public function print_support_form() { */ public function create_support_request() { global $wp_version; - $postdata = array_map( 'sanitize_text_field', $_POST ); + $postdata = $this->get_post_data(); $message = "WordPress: " . $wp_version . "\n"; $message .= "WooCommerce: " . WC()->version . "\n"; diff --git a/woocommerce-qenta-checkout-seamless/classes/class-qenta-backend-operations.php b/woocommerce-qenta-checkout-seamless/classes/class-qenta-backend-operations.php index 9df58bd..b3ab451 100644 --- a/woocommerce-qenta-checkout-seamless/classes/class-qenta-backend-operations.php +++ b/woocommerce-qenta-checkout-seamless/classes/class-qenta-backend-operations.php @@ -89,7 +89,7 @@ public function __construct( $settings ) { public function refund( $order_id = 0, $amount = 0, $reason = '' ) { global $wpdb; - $params_post = array_map( 'sanitize_text_field', $_POST ); + $params_post = $this->get_post_data(); $order_id = $params_post['order_id']; $refund_amount = $params_post['refund_amount']; if ( $refund_amount <= 0 ) { @@ -507,7 +507,7 @@ public function depositreversal( $orderNumber, $paymentNumber ) { * @return array */ public function approvereversal( $orderNumber ) { - $params_post = array_map( 'sanitize_text_field', $_POST ); + $params_post = $this->get_post_data(); $response = $this->get_client()->approveReversal( $orderNumber ); $transaction = new WC_Gateway_Qenta_Checkout_Seamless_Transaction( $this->_settings ); diff --git a/woocommerce-qenta-checkout-seamless/classes/class-qenta-config.php b/woocommerce-qenta-checkout-seamless/classes/class-qenta-config.php index f1fa248..ddd0440 100644 --- a/woocommerce-qenta-checkout-seamless/classes/class-qenta-config.php +++ b/woocommerce-qenta-checkout-seamless/classes/class-qenta-config.php @@ -31,7 +31,7 @@ */ define( 'WOOCOMMERCE_GATEWAY_QMORE_NAME', 'QentaCheckoutSeamless' ); -define( 'WOOCOMMERCE_GATEWAY_QMORE_VERSION', '2.0.4' ); +define( 'WOOCOMMERCE_GATEWAY_QMORE_VERSION', '2.0.5' ); /** * Config class diff --git a/woocommerce-qenta-checkout-seamless/classes/class-qenta-gateway.php b/woocommerce-qenta-checkout-seamless/classes/class-qenta-gateway.php index ab7cf52..48d61b7 100644 --- a/woocommerce-qenta-checkout-seamless/classes/class-qenta-gateway.php +++ b/woocommerce-qenta-checkout-seamless/classes/class-qenta-gateway.php @@ -396,11 +396,19 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) { * @return array */ public function process_payment( $order_id ) { - $params_post = array_map( 'sanitize_text_field', $_POST ); + $params_post = $this->get_post_data(); $order = wc_get_order( $order_id ); $payment_type = $params_post['wcs_payment_method']; + // payment_type woocommerce_wcs means no input was selected and the default value was sent + // this fails when instantiating $paymentClass + // we abort here and return a message to the consumer + if(strtolower($payment_type) === 'woocommerce_wcs'){ + wc_add_notice( esc_html(__( 'Please select a payment method!', 'woocommerce-qenta-checkout-seamless' )), 'error' ); + return; + } + $paymentClass = 'WC_Gateway_Qenta_Checkout_Seamless_'. str_replace('-', '_', ucfirst(strtolower($payment_type))); $paymentClass = new $paymentClass( $this->settings ); update_post_meta( $order_id, '_payment_method_title', $paymentClass->get_label()); @@ -641,7 +649,7 @@ public function create_return_url( $order, $payment_state ) { * @return string */ public function confirm_request() { - $params_post = array_map( 'sanitize_text_field', $_POST ); + $params_post = $this->get_post_data(); $params_request = array_map( 'sanitize_text_field', $_REQUEST ); $message = null; @@ -819,7 +827,7 @@ public function confirm_request() { */ private function create_payment_data() { $data = ''; - $params_post = array_map( 'sanitize_text_field', $_POST ); + $params_post = $this->get_post_data(); foreach ( $params_post as $key => $value ) { $data .= "$key:$value\n"; } @@ -998,7 +1006,7 @@ public function datastorage_return() { * @since 1.0.0 */ public function qenta_transaction_do_page() { - $params_post = array_map( 'sanitize_text_field', $_POST ); + $params_post = $this->get_post_data(); $params_request = array_map( 'sanitize_text_field', $_REQUEST ); echo "