Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions assets/js/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ const UnzerManager = {
UnzerManager.error( unzer_i18n.errorCompanyType || 'Please enter your company type' );
return false;
}
if (!UnzerManager.isB2B() || (UnzerManager.isB2B() && document.getElementById( 'unzer-invoice-company-type' ).value === 'sole')) {
if ( ! UnzerManager.isB2B() || (UnzerManager.isB2B() && document.getElementById( 'unzer-invoice-company-type' ).value === 'sole')) {
if ( ! document.getElementById( 'unzer-invoice-dob' ).value) {
UnzerManager.error( unzer_i18n.errorDob || 'Please enter your date of birth' );
return false;
Expand Down Expand Up @@ -991,32 +991,29 @@ jQuery(
UnzerManager.checkCountry();

const companyTypeInputContainer = document.getElementById( 'unzer-invoice-company-type-container' );
const birthdate_form = document.getElementById('unzer-checkout-dob-row');
const birthdate = document.getElementById('unzer-invoice-dob');
if (companyTypeInputContainer) {
companyTypeInputContainer.style.display = UnzerManager.isB2B() ? 'block' : 'none';
if (UnzerManager.isB2B()) {
if (document.getElementById('unzer-invoice-company-type').value === "sole") {
const birthdate_form = document.getElementById( 'unzer-checkout-dob-row' );
const birthdate = document.getElementById( 'unzer-invoice-dob' );
if (birthdate_form && birthdate) {
if (companyTypeInputContainer) {
companyTypeInputContainer.style.display = UnzerManager.isB2B() ? 'block' : 'none';
if (UnzerManager.isB2B()) {
if (document.getElementById( 'unzer-invoice-company-type' ).value === "sole") {
birthdate_form.style.display = "block";
birthdate.setAttribute( "required", "required" );
birthdate.name = "unzer-invoice-dob";
} else {
birthdate_form.style.display = "none";
birthdate.removeAttribute( "required" );
birthdate.name = "";
}
} else {
birthdate_form.style.display = "block";
birthdate.setAttribute("required", "required");
birthdate.setAttribute( "required", "required" );
birthdate.name = "unzer-invoice-dob";
} else {
birthdate_form.style.display = "none";
birthdate.removeAttribute("required");
birthdate.name = "";
}
} else {
birthdate_form.style.display = "block";
birthdate.setAttribute("required", "required");
birthdate.name = "unzer-invoice-dob";
}
} else {
if(birthdate_form) {
birthdate_form.style.display = "block";
}

if(birthdate) {
birthdate.setAttribute("required", "required");
birthdate.setAttribute( "required", "required" );
birthdate.name = "unzer-invoice-dob";
}
}
Expand Down
10 changes: 10 additions & 0 deletions includes/gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ public function payment_scripts() {
$this->addCheckoutAssets();
}

protected function get_amount() {
global $wp;
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
$order = wc_get_order( $wp->query_vars['order-pay'] );
return $order->get_total();
} else {
return WC()->cart->get_total( 'plain' );
}
}

public function get_private_key() {
return get_option( 'unzer_private_key' );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/gateways/ApplePay.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function payment_fields() {
?>
<input type="hidden" id="unzer-apple-pay-id" name="unzer-apple-pay-id" value=""/>
<input type="hidden" id="unzer-apple-pay-nonce" name="unzer-apple-pay-nonce" value="<?php echo esc_attr( Util::getNonce() ); ?>"/>
<input type="hidden" id="unzer-apple-pay-amount" name="unzer-apple-pay-amount" value="<?php echo esc_attr( WC()->cart->get_total( 'plain' ) ); ?>"/>
<input type="hidden" id="unzer-apple-pay-amount" name="unzer-apple-pay-amount" value="<?php echo esc_attr( $this->get_amount() ); ?>"/>
<?php
}

Expand Down
2 changes: 1 addition & 1 deletion includes/gateways/ApplePayV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function payment_fields() {
?>
<input type="hidden" id="unzer-apple-pay-v2-id" name="unzer-apple-pay-v2-id" value=""/>
<input type="hidden" id="unzer-apple-pay-v2-nonce" name="unzer-apple-pay-v2-nonce" value="<?php echo esc_attr( Util::getNonce() ); ?>"/>
<input type="hidden" id="unzer-apple-pay-v2-amount" name="unzer-apple-pay-v2-amount" value="<?php echo esc_attr( WC()->cart->get_total( 'plain' ) ); ?>"/>
<input type="hidden" id="unzer-apple-pay-v2-amount" name="unzer-apple-pay-v2-amount" value="<?php echo esc_attr( $this->get_amount() ); ?>"/>
<?php
}

Expand Down
2 changes: 1 addition & 1 deletion includes/gateways/GooglePay.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function payment_fields() {
}
?>
<input type="hidden" id="unzer-google-pay-id" name="unzer-google-pay-id" value=""/>
<input type="hidden" id="unzer-google-pay-amount" name="unzer-google-pay-amount" value="<?php echo esc_attr( WC()->cart->get_total( 'plain' ) ); ?>"/>
<input type="hidden" id="unzer-google-pay-amount" name="unzer-google-pay-amount" value="<?php echo esc_attr( $this->get_amount() ); ?>"/>
<?php
}

Expand Down
2 changes: 1 addition & 1 deletion includes/gateways/Installment.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function payment_fields() {
</div>
<div id="unzer-installment-form" class="unzerUI form">
<input type="hidden" id="unzer-installment-id" name="unzer-installment-id" value=""/>
<input type="hidden" id="unzer-installment-amount" name="unzer-installment-amount" value="<?php echo esc_attr( WC()->cart->get_total( 'plain' ) ); ?>"/>
<input type="hidden" id="unzer-installment-amount" name="unzer-installment-amount" value="<?php echo esc_attr( $this->get_amount() ); ?>"/>
<div class="field">
<div id="unzer-installment-fields">
</div>
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: Unzer
Tags: payments, woocommerce
Requires at least: 4.5
Tested up to: 6.8
Stable tag: 1.8.3
Stable tag: 1.8.4
License: Apache-2.0
License URI: http://www.apache.org/licenses/LICENSE-2.0
Author URI: https://unzer.com
Expand Down Expand Up @@ -61,6 +61,9 @@ Unzer is one of the leading payment companies in Europe. Over 70,000 retailers t

## Changelog ##

# 1.8.4 #
* Fix correct amount for order pay page

# 1.8.3 #
* Adaption Invoice as commerical customer

Expand Down
6 changes: 3 additions & 3 deletions unzer-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* Description: Official Unzer Plugin
* Author: Unzer
* Author URI: https://www.unzer.com
* Version: 1.8.3
* Version: 1.8.4
* License: Apache-2.0
* Requires at least: 4.5
* Tested up to: 6.8
* WC requires at least: 6.0
* WC tested up to: 9.7
* WC tested up to: 10.2
* Text Domain: unzer-payments
*/

Expand All @@ -21,7 +21,7 @@
/**
* Required minimums and constants
*/
define( 'UNZER_VERSION', '1.8.3' );
define( 'UNZER_VERSION', '1.8.4' );
define( 'UNZER_PLUGIN_TYPE_STRING', 'Unzer Payments' );
define( 'UNZER_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
define( 'UNZER_PLUGIN_PATH', __DIR__ . '/' );
Expand Down