From c8b8e1a5b89d30c0edbba8c7378ec01b08591dec Mon Sep 17 00:00:00 2001 From: tomazpu <32056440+tomazpu@users.noreply.github.com> Date: Tue, 27 Feb 2018 08:38:35 +0100 Subject: [PATCH 1/3] #56 Check for payment provider on validation --- .../class-wirecard-installment.php | 16 +++++++++++++++- .../payment-methods/class-wirecard-invoice.php | 16 +++++++++++++++- .../class-wirecard-invoiceb2b.php | 16 +++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-installment.php b/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-installment.php index 9db0ea2..c16af43 100644 --- a/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-installment.php +++ b/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-installment.php @@ -343,7 +343,7 @@ public function validate_payment_fields( $data ) { $errors = [ ]; - if ( $this->_settings['woo_wcs_payolutionterms'] && $data['wcs_installment_consent'] != 'on' ) { + if ( $this->_settings['woo_wcs_payolutionterms'] && $data['wcs_installment_consent'] != 'on' && $this->check_terms( $data['wcs_payment_method'] ) ) { $errors[] = "• " . __( 'Please accept the consent terms!', 'woocommerce-wirecard-checkout-seamless' ); } @@ -359,4 +359,18 @@ public function validate_payment_fields( $data ) { return count( $errors ) == 0 ? true : join( "
", $errors ); } + + /** + * Check if the provider is payolution if so agb check is needed + * + * @since 1.0.11 + * @param $payment_method + * @return bool + */ + private function check_terms( $payment_method ) { + if ( ( $payment_method == 'INSTALLMENT' && $this->_settings['woo_wcs_installmentprovider'] == 'payolution' ) ) { + return true; + } + return false; + } } diff --git a/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-invoice.php b/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-invoice.php index f29c4bb..5923e0a 100644 --- a/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-invoice.php +++ b/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-invoice.php @@ -318,7 +318,7 @@ public function validate_payment_fields( $data ) { $errors = [ ]; - if ( $this->_settings['woo_wcs_payolutionterms'] && $data['consent'] != 'on' ) { + if ( $this->_settings['woo_wcs_payolutionterms'] && $data['consent'] != 'on' && $this->check_terms( $data['wcs_payment_method'] ) ) { $errors[] = "• " . __( 'Please accept the consent terms!', 'woocommerce-wirecard-checkout-seamless' ); } @@ -354,4 +354,18 @@ private function address_empty( $address ) { return true; } + + /** + * Check if the provider is payolution if so agb check is needed + * + * @since 1.0.11 + * @param $payment_method + * @return bool + */ + private function check_terms( $payment_method ) { + if ( ( $payment_method == 'INVOICE' && $this->_settings['woo_wcs_invoiceprovider'] == 'payolution' ) ) { + return true; + } + return false; + } } diff --git a/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-invoiceb2b.php b/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-invoiceb2b.php index 855dedc..99977a7 100644 --- a/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-invoiceb2b.php +++ b/woocommerce-wirecard-checkout-seamless/classes/payment-methods/class-wirecard-invoiceb2b.php @@ -315,7 +315,7 @@ public function validate_payment_fields( $data ) { $errors = [ ]; - if ( $this->_settings['woo_wcs_payolutionterms'] && $data['b2b_consent'] != 'on' ) { + if ( $this->_settings['woo_wcs_payolutionterms'] && $data['b2b_consent'] != 'on' && $this->check_terms( $data['wcs_payment_method'] ) ) { $errors[] = "• " . __( 'Please accept the consent terms!', 'woocommerce-wirecard-checkout-seamless' ); } @@ -324,4 +324,18 @@ public function validate_payment_fields( $data ) { return count( $errors ) == 0 ? true : join( "
", $errors ); } + + /** + * Check if the provider is payolution if so agb check is needed + * + * @since 1.0.11 + * @param $payment_method + * @return bool + */ + private function check_terms( $payment_method ) { + if ( ( $payment_method == 'INVOICE' && $this->_settings['woo_wcs_invoiceprovider'] == 'payolution' ) ) { + return true; + } + return false; + } } From 84b9749567c09ab7b070bc833f07e8122b157e9e Mon Sep 17 00:00:00 2001 From: tomazpu <32056440+tomazpu@users.noreply.github.com> Date: Tue, 27 Feb 2018 08:38:51 +0100 Subject: [PATCH 2/3] #56 Update plugin version --- .../classes/class-wirecard-config.php | 2 +- .../woocommerce-wirecard-checkout-seamless.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-config.php b/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-config.php index d1f6105..78b79a7 100644 --- a/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-config.php +++ b/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-config.php @@ -31,7 +31,7 @@ */ define( 'WOOCOMMERCE_GATEWAY_WCS_NAME', 'WirecardCheckoutSeamless' ); -define( 'WOOCOMMERCE_GATEWAY_WCS_VERSION', '1.0.10' ); +define( 'WOOCOMMERCE_GATEWAY_WCS_VERSION', '1.0.11' ); /** * Config class diff --git a/woocommerce-wirecard-checkout-seamless/woocommerce-wirecard-checkout-seamless.php b/woocommerce-wirecard-checkout-seamless/woocommerce-wirecard-checkout-seamless.php index 39fa3b6..f2e8fb6 100644 --- a/woocommerce-wirecard-checkout-seamless/woocommerce-wirecard-checkout-seamless.php +++ b/woocommerce-wirecard-checkout-seamless/woocommerce-wirecard-checkout-seamless.php @@ -3,7 +3,7 @@ * Plugin Name: Wirecard Checkout Seamless * Plugin URI: https://github.com/wirecard/woocommerce-wcs * Description: Wirecard Checkout Seamless plugin for WooCommerce - * Version: 1.0.10 + * Version: 1.0.11 * Author: Wirecard * Author URI: https://www.wirecard.at/ * License: GPL2 From b04432e52f64c4fe7b861dd97bfd2817d634696f Mon Sep 17 00:00:00 2001 From: tomazpu <32056440+tomazpu@users.noreply.github.com> Date: Thu, 1 Mar 2018 09:49:02 +0100 Subject: [PATCH 3/3] #56 Sending birth date in consumer data --- .../classes/class-wirecard-config.php | 7 ++++++- .../classes/class-wirecard-gateway.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-config.php b/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-config.php index 78b79a7..e3d24ec 100644 --- a/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-config.php +++ b/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-config.php @@ -231,7 +231,7 @@ public function get_order_reference( $order ) { * @since 1.0.0 * @return WirecardCEE_Stdlib_ConsumerData */ - public function get_consumer_data( $order, $gateway ) { + public function get_consumer_data( $order, $gateway, $checkout_data ) { $consumerData = new WirecardCEE_Stdlib_ConsumerData(); $consumerData->setIpAddress( $order->get_customer_ip_address() ); @@ -248,6 +248,11 @@ public function get_consumer_data( $order, $gateway ) { $shipping_address = $this->get_address_data( $order, 'shipping' ); $consumerData->addAddressInformation( $shipping_address ); } + if ($checkout_data['wcs_payment_method'] == WirecardCEE_Stdlib_PaymentTypeAbstract::INVOICE || + $checkout_data['wcs_payment_method'] == WirecardCEE_Stdlib_PaymentTypeAbstract::INSTALLMENT) { + $birth_date = new DateTime( $checkout_data['dob_year'] . '-' . $checkout_data['dob_month'] . '-' . $checkout_data['dob_day'] ); + $consumerData->setBirthDate($birth_date); + } return $consumerData; } diff --git a/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-gateway.php b/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-gateway.php index a6c9e0f..2a4e738 100644 --- a/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-gateway.php +++ b/woocommerce-wirecard-checkout-seamless/classes/class-wirecard-gateway.php @@ -482,7 +482,7 @@ public function initiate_payment( $order ) { $return_url = add_query_arg( 'wc-api', 'WC_Gateway_Wirecard_Checkout_Seamless', site_url( '/', is_ssl() ? 'https' : 'http' ) ); - $consumer_data = $this->_config->get_consumer_data( $order, $this ); + $consumer_data = $this->_config->get_consumer_data( $order, $this, $checkout_data ); $auto_deposit = $this->get_option( 'woo_wcs_automateddeposit' ); $service_url = $this->get_option( 'woo_wcs_serviceurl' );