Skip to content

Commit

Permalink
Merge pull request #353 from reepay/pre-1.7.11
Browse files Browse the repository at this point in the history
v 1.7.11
  • Loading branch information
ponddeja authored Nov 27, 2024
2 parents f08a7b9 + 16fd88f commit 4368714
Show file tree
Hide file tree
Showing 28 changed files with 959 additions and 386 deletions.
10 changes: 8 additions & 2 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Contributors: reepaydenmark,aaitse
Tags: billwerk+, visa, mastercard, dankort, mobilepay
Requires at least: 4.0
Tested up to: 6.6.1
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.7.10
Stable tag: 1.7.11
License: GPL
License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html

Expand All @@ -18,6 +18,12 @@ The Billwerk+ Pay plugin extends WooCommerce allowing you to take payments on yo
See installation guide right here: https://docu.billwerk.plus/help/en/apps/woocommerce/setup-woocommerce-plugin.html

== Changelog ==
v 1.7.11
- [Fix] - VAT added as compound rate got computed twice.
- [Fix] - Shows no Payment logos when none are selected in settings.
- [Improvement] - Payment method logo height defaults to 20px.
- [Improvement] - Support WordPress version 6.7

v 1.7.10
- [Fix] - Discount coupons for regular products couldn't be used if a Billwerk subscription product was also in the cart.
- [Fix] - The order confirmation page now shows a list of split orders (for regular and subscription products) with correct total amounts.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Get a plug-n-play payment solution for WooCommerce, that is easy to use, highly secure and is built to maximize the potential of your e-commerce.",
"type": "wordpress-plugin",
"license": "GPL",
"version": "1.7.10",
"version": "1.7.11",
"autoload": {
"psr-4": {
"Reepay\\Checkout\\": "includes/",
Expand Down
8 changes: 4 additions & 4 deletions includes/Admin/Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function capture() {
$this->verify_nonce();

if ( empty( $_REQUEST['order_id'] ) ) {
wp_send_json_error( __( 'Order id not specified' ) );
wp_send_json_error( __( 'Order id not specified', 'reepay-checkout-gateway' ) );
}

$order_id = (int) wc_clean( $_REQUEST['order_id'] );
Expand All @@ -93,7 +93,7 @@ public function cancel() {
$this->verify_nonce();

if ( empty( $_REQUEST['order_id'] ) ) {
wp_send_json_error( __( 'Order id not specified' ) );
wp_send_json_error( __( 'Order id not specified', 'reepay-checkout-gateway' ) );
}

$order_id = (int) wc_clean( $_REQUEST['order_id'] );
Expand Down Expand Up @@ -129,7 +129,7 @@ public function refund() {
$this->verify_nonce();

if ( empty( $_REQUEST['order_id'] ) ) {
wp_send_json_error( __( 'Order id not specified' ) );
wp_send_json_error( __( 'Order id not specified', 'reepay-checkout-gateway' ) );
}

$order_id = (int) wc_clean( $_REQUEST['order_id'] );
Expand Down Expand Up @@ -216,7 +216,7 @@ public function set_complete_settle_transient() {
$this->verify_nonce( 'reepay' );

if ( empty( $_POST['order_id'] ) || empty( $_POST['settle_order'] ) ) {
wp_send_json_error( __( 'Order id or settle order not specified' ) );
wp_send_json_error( __( 'Order id or settle order not specified', 'reepay-checkout-gateway' ) );
}

$order_id = wc_clean( $_POST['order_id'] );
Expand Down
2 changes: 1 addition & 1 deletion includes/Api/Controller/DebugController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function run_debug( WP_REST_Request $request ) {
*/
public function get_items_permissions_check( $request ) {
if ( ! current_user_can( 'manage_options' ) ) {
return new WP_Error( 'rest_forbidden', esc_html__( 'You cannot view the post resource.' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'rest_forbidden', esc_html__( 'You cannot view the post resource.', 'reepay-checkout-gateway' ), array( 'status' => rest_authorization_required_code() ) );
}

return true;
Expand Down
8 changes: 4 additions & 4 deletions includes/Api/Controller/MetaFieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public function get_order_meta_fields( WP_REST_Request $request ) {
$order = wc_get_order( $id );

if ( ! $order ) {
return new WP_Error( 'not_found', esc_html__( 'Not found order.' ) );
return new WP_Error( 'not_found', esc_html__( 'Not found order.', 'reepay-checkout-gateway' ) );
}

$meta_data = $order->get_meta_data();
Expand Down Expand Up @@ -427,7 +427,7 @@ public function get_user_meta_fields( WP_REST_Request $request ) {
$user = get_user_by( 'id', $id );

if ( ! $user ) {
return new WP_Error( 'not_found', esc_html__( 'Not found user.' ) );
return new WP_Error( 'not_found', esc_html__( 'Not found user.', 'reepay-checkout-gateway' ) );
}

$meta_data = get_user_meta( $id );
Expand Down Expand Up @@ -472,7 +472,7 @@ public function add_user_meta_field( WP_REST_Request $request ) {
$user = get_user_by( 'id', $id );

if ( ! $user ) {
return new WP_Error( 'not_found', esc_html__( 'Not found user.' ) );
return new WP_Error( 'not_found', esc_html__( 'Not found user.', 'reepay-checkout-gateway' ) );
}

$decoded_value = json_decode( $value, true );
Expand Down Expand Up @@ -560,7 +560,7 @@ public function edit_user_meta_field( WP_REST_Request $request ) {
*/
public function get_items_permissions_check( $request ) {
if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'delete_posts' ) ) {
return new WP_Error( 'rest_forbidden', esc_html__( 'You cannot view the post resource.' ), array( 'status' => rest_authorization_required_code() ) );
return new WP_Error( 'rest_forbidden', esc_html__( 'You cannot view the post resource.', 'reepay-checkout-gateway' ), array( 'status' => rest_authorization_required_code() ) );
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion includes/Gateways/Mobilepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function warning_message() {
?>
<div class="woo-connect-notice notice notice-error">
<p>
<?php _e( 'The new Vipps MobilePay payment method, which utilizes bank transfers instead of card payments, will replace the old MobilePay Online payment method. Please refer to Vipps MobilePay for more efficient transactions and a better conversion rate.', 'reepay-checkout-gateway' ); ?>
<?php esc_html_e( 'The new Vipps MobilePay payment method, which utilizes bank transfers instead of card payments, will replace the old MobilePay Online payment method. Please refer to Vipps MobilePay for more efficient transactions and a better conversion rate.', 'reepay-checkout-gateway' ); ?>
</p>
</div>
<?php
Expand Down
2 changes: 1 addition & 1 deletion includes/Gateways/MobilepaySubscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function admin_notice_message() {
?>
<div class="woo-connect-notice notice notice-error">
<p>
<?php echo $this->warning_message(); ?>
<?php echo esc_html( $this->warning_message() ); ?>
</p>
</div>
<?php
Expand Down
16 changes: 8 additions & 8 deletions includes/Gateways/ReepayCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public function init_form_fields() {
'sanitize_callback' => function ( $value ) {
if ( ! empty( $value ) ) {
if ( ! is_email( $value ) ) {
throw new Exception( __( 'Email address is invalid.', 'reepay-checkout-gateway' ) );
throw new Exception( esc_html__( 'Email address is invalid.', 'reepay-checkout-gateway' ) );
}
}

Expand Down Expand Up @@ -375,7 +375,7 @@ public function init_form_fields() {
'title' => __( 'Logo Height', 'reepay-checkout-gateway' ),
'type' => 'text',
'description' => __( 'Set the Logo height in pixels', 'reepay-checkout-gateway' ),
'default' => '',
'default' => 20,
),
'hr7' => array(
'type' => 'separator',
Expand Down Expand Up @@ -472,7 +472,7 @@ public function generate_account_info_html( string $key, array $data ): string {
<fieldset>
<?php if ( ! is_wp_error( $info ) && ! empty( $info[ $data['info_type'] ] ) ) : ?>
<span>
<?php echo $info[ $data['info_type'] ]; ?>
<?php echo esc_attr( $info[ $data['info_type'] ] ); ?>
</span>
<?php endif; ?>
</fieldset>
Expand Down Expand Up @@ -513,7 +513,7 @@ public function generate_verify_key_html( string $key, array $data ): string {
<td class="forminp">
<fieldset>
<button name="save" class="button-primary woocommerce-save-button" type="submit" value="Save changes">
<?php _e( 'Save and verify', 'reepay-checkout-gateway' ); ?>
<?php esc_html_e( 'Save and verify', 'reepay-checkout-gateway' ); ?>
</button>
</fieldset>
</td>
Expand Down Expand Up @@ -555,7 +555,7 @@ public function generate_webhook_status_html( string $key, array $data ): string
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label><?php _e( 'Webhook', 'reepay-checkout-gateway' ); ?></label>
<label><?php esc_html_e( 'Webhook', 'reepay-checkout-gateway' ); ?></label>
</th>
<td class="forminp">
<fieldset>
Expand Down Expand Up @@ -799,7 +799,7 @@ public function notice_message_live_key_changed() {
$notice_message = sprintf( __( 'The Api key identifies the Billwerk account. Only subscription plan handles that exist under the account of the API key can be used to submit subscription orders. <a href="%s" target="_blank">Read more about this here.</a>', 'reepay-checkout-gateway' ), 'https://optimize-docs.billwerk.com/reference/account' );
?>
<div class="notice notice-info">
<p><?php echo $notice_message; ?></p>
<p><?php echo wp_kses_post( $notice_message ); ?></p>
</div>
<?php
}
Expand All @@ -812,7 +812,7 @@ public function notice_message_test_mode_enabled() {
$notice_message = sprintf( __( 'You just enabled test mode, meaning your test API key will now be used. Please note that all subscription products previously linked to plans on your live account are no longer linked. If you try to purchase a subscription product now, an error will occur. Disabling test mode will restore all connections. <a href="%s" target="_blank">Read more about this here.</a>', 'reepay-checkout-gateway' ), 'https://optimize-docs.billwerk.com/reference/account' );
?>
<div class="notice notice-info">
<p><?php echo $notice_message; ?></p>
<p><?php echo wp_kses_post( $notice_message ); ?></p>
</div>
<?php
}
Expand All @@ -825,7 +825,7 @@ public function notice_message_test_mode_disabled() {
$notice_message = sprintf( __( 'You just disabled test mode, meaning your live API key will now be used. Please note that all subscription products previously linked to plans on your live account are now restored. If you haven\'t linked your subscription products with your test account, they will remain unlinked. <a href="%s" target="_blank">Read more about this here.</a>', 'reepay-checkout-gateway' ), 'https://optimize-docs.billwerk.com/reference/account' );
?>
<div class="notice notice-info">
<p><?php echo $notice_message; ?></p>
<p><?php echo wp_kses_post( $notice_message ); ?></p>
</div>
<?php
}
Expand Down
45 changes: 16 additions & 29 deletions includes/Gateways/ReepayGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,7 @@ abstract class ReepayGateway extends WC_Payment_Gateway {
*
* @var array
*/
public array $logos = array(
'dankort',
'visa',
'mastercard',
'visa-electron',
'maestro',
'mobilepay',
'viabill',
'applepay',
'paypal_logo',
'klarna-pay-later',
'klarna-pay-now',
'klarna',
);
public array $logos = array();

/**
* Current payment type
Expand Down Expand Up @@ -647,13 +634,13 @@ public function capture_payment( $order, $amount = null ) {
$order = wc_get_order( $order );

if ( '1' === $order->get_meta( '_reepay_order_cancelled' ) ) {
throw new Exception( __( 'Order is canceled', 'reepay-checkout-gateway' ) );
throw new Exception( esc_html__( 'Order is canceled', 'reepay-checkout-gateway' ) );
}

$result = reepay()->api( $this )->capture_payment( $order, $amount );

if ( is_wp_error( $result ) ) {
throw new Exception( $result->get_error_message() );
throw new Exception( esc_html( $result->get_error_message() ) );
}
}

Expand All @@ -668,13 +655,13 @@ public function cancel_payment( $order ) {
$order = wc_get_order( $order );

if ( '1' === $order->get_meta( '_reepay_order_cancelled' ) ) {
throw new Exception( 'Order is already canceled' );
throw new Exception( esc_html__( 'Order is already canceled', 'reepay-checkout-gateway' ) );
}

$result = reepay()->api( $this )->cancel_payment( $order );

if ( is_wp_error( $result ) ) {
throw new Exception( $result->get_error_message() );
throw new Exception( esc_html( $result->get_error_message() ) );
}
}

Expand All @@ -692,21 +679,21 @@ public function refund_payment( $order, $amount = null, $reason = '' ) {
$order = wc_get_order( $order );

if ( '1' === $order->get_meta( '_reepay_order_cancelled' ) ) {
throw new Exception( 'Order is already canceled' );
throw new Exception( esc_html__( 'Order is already canceled', 'reepay-checkout-gateway' ) );
}

if ( ! $this->can_refund( $order ) ) {
throw new Exception( 'Payment can\'t be refunded.' );
throw new Exception( esc_html__( 'Payment can\'t be refunded.', 'reepay-checkout-gateway' ) );
}

if ( ! is_null( $amount ) && $amount <= 0 ) {
throw new Exception( 'Refund amount must be greater than 0.' );
throw new Exception( esc_html__( 'Refund amount must be greater than 0.', 'reepay-checkout-gateway' ) );
}

$result = reepay()->api( $this )->refund( $order, $amount, $reason );

if ( is_wp_error( $result ) ) {
throw new Exception( $result->get_error_message() );
throw new Exception( esc_html( $result->get_error_message() ) );
}
}

Expand Down Expand Up @@ -749,7 +736,7 @@ public function payment_fields() {
$description = $this->get_description();

if ( $description ) {
echo wpautop( wptexturize( $description ) );
echo wp_kses_post( wpautop( wptexturize( $description ) ) );
}
}

Expand Down Expand Up @@ -934,7 +921,7 @@ public function process_payment( $order_id ) {
$result = reepay()->api( $this )->recurring( $this->payment_methods, $order, $data, $token->get_token(), $params['button_text'] );

if ( is_wp_error( $result ) ) {
throw new Exception( $result->get_error_message(), $result->get_error_code() );
throw new Exception( esc_html( $result->get_error_message() ), esc_html( $result->get_error_code() ) );
}

if ( ! empty( $result['id'] ) ) {
Expand All @@ -943,7 +930,7 @@ public function process_payment( $order_id ) {
}

if ( is_wp_error( $result ) ) {
throw new Exception( $result->get_error_message(), $result->get_error_code() );
throw new Exception( esc_html( $result->get_error_message() ), esc_html( $result->get_error_code() ) );
}

try {
Expand Down Expand Up @@ -980,7 +967,7 @@ public function process_payment( $order_id ) {
return false;
} elseif ( ! empty( $method ) ) {
if ( 'active' !== $method['state'] ) {
wc_add_notice( __( 'You payment method has failed, please choose another or add new', 'error' ), 'error' );
wc_add_notice( __( 'You payment method has failed, please choose another or add new', 'reepay-checkout-gateway' ), 'error' );

return false;
}
Expand Down Expand Up @@ -1068,7 +1055,7 @@ public function process_payment( $order_id ) {
$result = reepay()->api( $this )->recurring( $this->payment_methods, $order, $data, false, $params['button_text'] );

if ( is_wp_error( $result ) ) {
throw new Exception( $result->get_error_message(), $result->get_error_code() );
throw new Exception( esc_html( $result->get_error_message() ), esc_html( $result->get_error_code() ) );
}

if ( ! empty( $result['id'] ) ) {
Expand Down Expand Up @@ -1301,7 +1288,7 @@ public function process_session_charge( array $params, WC_Order $order ): array
}

if ( is_wp_error( $result ) ) {
throw new Exception( $result->get_error_message(), $result->get_error_code() );
throw new Exception( esc_html( $result->get_error_message() ), esc_html( $result->get_error_code() ) );
} else {
return array(
'result' => 'success',
Expand Down Expand Up @@ -1342,7 +1329,7 @@ public function reepay_cancel() {
$message = $result['transactions'][0]['card_transaction']['acquirer_message'];

$order->add_order_note( 'Payment failed. Error from acquire: ' . $message );
wc_add_notice( __( 'Payment error: ', 'error' ) . $message, 'error' );
wc_add_notice( __( 'Payment error: ', 'reepay-checkout-gateway' ) . $message, 'error' );
}

wp_redirect( wc_get_cart_url() );
Expand Down
3 changes: 2 additions & 1 deletion includes/Integrations/WooBlocks/WooBlocksPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public function __construct( string $name ) {
$this->gateway = reepay()->gateways()->get_gateway( $this->name );

if ( is_null( $this->gateway ) ) {
throw new Exception( "Gateway '$this->name' not found" );
// translators: %s is the name of the gateway.
throw new Exception( sprintf( esc_html__( "Gateway '%s' not found", 'reepay-checkout-gateway' ), esc_html( $this->name ) ) );
}
}

Expand Down
7 changes: 3 additions & 4 deletions includes/OrderFlow/OrderCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,10 @@ public function multi_settle( WC_Order $order ): bool {
$fees_item->set_tax_class( 'zero-rate' );
$fees_item->add_meta_data( '_is_card_fee', true );
$order->add_item( $fees_item );
}

$order->calculate_totals();
$order->save();
$order->calculate_totals();
$order->calculate_totals( false );
$order->save();
}
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions includes/OrderFlow/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,10 @@ public function process( array $data ) {
$fees_item->set_tax_class( 'zero-rate' );
$fees_item->add_meta_data( '_is_card_fee', true );
$order->add_item( $fees_item );
}

$order->calculate_totals();
$order->save();
$order->calculate_totals();
$order->calculate_totals( false );
$order->save();
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion includes/Plugin/UpdateDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct() {
*/
public function add_admin_menu() {
add_submenu_page(
null,
' ',
'Reepay update db',
'Reepay update db',
self::USER_CAPABILITY,
Expand Down
Loading

0 comments on commit 4368714

Please sign in to comment.