Skip to content

Commit

Permalink
Merge pull request #57 from wirecard/TPWDCEE-830
Browse files Browse the repository at this point in the history
Tpwdcee 830
  • Loading branch information
jpy authored Mar 1, 2018
2 parents 6ca50fe + b04432e commit 59d4af1
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() );
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}

Expand All @@ -359,4 +359,18 @@ public function validate_payment_fields( $data ) {

return count( $errors ) == 0 ? true : join( "<br>", $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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = "&bull; " . __( 'Please accept the consent terms!', 'woocommerce-wirecard-checkout-seamless' );
}

Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = "&bull; " . __( 'Please accept the consent terms!', 'woocommerce-wirecard-checkout-seamless' );
}

Expand All @@ -324,4 +324,18 @@ public function validate_payment_fields( $data ) {

return count( $errors ) == 0 ? true : join( "<br>", $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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 59d4af1

Please sign in to comment.