Plugin Directory

Changeset 3253194


Ignore:
Timestamp:
03/10/2025 09:27:10 AM (13 months ago)
Author:
yocoadmin
Message:

Update to version 3.8.4 from Gitlab

Location:
yoco-payment-gateway
Files:
2 deleted
30 edited
1 copied

Legend:

Unmodified
Added
Removed
  • yoco-payment-gateway/assets/banner-1544x500.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • yoco-payment-gateway/assets/banner-772x250.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • yoco-payment-gateway/assets/icon-128x128.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • yoco-payment-gateway/assets/icon-256x256.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • yoco-payment-gateway/assets/screenshot-1.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • yoco-payment-gateway/assets/screenshot-2.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • yoco-payment-gateway/assets/screenshot-3.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • yoco-payment-gateway/assets/screenshot-4.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • yoco-payment-gateway/tags/3.8.4/readme.txt

    r3239360 r3253194  
    55Tested up to: 6.7
    66Requires PHP: 7.4.0
    7 Stable tag: 3.8.3
     7Stable tag: 3.8.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    137137== Changelog ==
    138138
     139= 3.8.4 =
     140
     141* Fix relative checkout url.
     142
    139143= 3.8.3 =
    140144
  • yoco-payment-gateway/tags/3.8.4/src/Gateway/Gateway.php

    r3177082 r3253194  
    2929        $this->icon       = trailingslashit( YOCO_ASSETS_URI ) . 'images/yoco-2024.svg';
    3030        $this->has_fields = false;
    31         $this->supports   = array( 'products', 'refunds' );
    3231
    3332        $this->title       = $this->get_option( 'title', __( 'Yoco', 'yoco_wc_payment_gateway' ) );
  • yoco-payment-gateway/tags/3.8.4/src/Gateway/Notes.php

    r3206321 r3253194  
    7171        }
    7272
     73        $order_notes = wc_get_order_notes( array( 'order_id' => $order_id ) );
     74        foreach ( $order_notes as $note ) {
     75            if ( strpos( $note->content, 'refund session ID (' . $refund_id ) !== false ) {
     76                return;
     77            }
     78        }
     79
    7380        // translators: Refund ID.
    7481        $this->addNote( $order, sprintf( esc_html__( 'Yoco: Received refund session ID (%s).', 'yoco_wc_payment_gateway' ), esc_html( $refund_id ) ) );
  • yoco-payment-gateway/tags/3.8.4/src/Gateway/Processors/OptionsProcessor.php

    r3102357 r3253194  
    3535            $response = $installationRequest->send();
    3636
    37             // If we get 500 error, reset Idempotence Key and retry the request.
    38             if ( 500 === (int) $response['code'] ) {
     37            // Retry the request for 408, 409, 425, 429, 502, 503, 504 response codes.
     38            if ( in_array( $response['code'], array( 408, 409, 425, 429, 502, 503, 504 ) ) ) {
     39                $response = $installationRequest->send();
     40            }
     41
     42            // If we get 500 response code, reset Idempotence Key and retry the request.
     43            if ( in_array( $response['code'], array( 500 ) ) ) {
    3944                add_filter( 'yoco_payment_gateway/installation/request/headers', array( $this, 'resetIdempotenceKey' ) );
    4045
  • yoco-payment-gateway/tags/3.8.4/src/Gateway/Processors/RefundProcessor.php

    r3177082 r3253194  
    66use WP_Error;
    77use Yoco\Gateway\Metadata;
     8use Yoco\Gateway\Refunds\Actions as Refunds_Actions;
    89use Yoco\Gateway\Refund\Request;
    910use Yoco\Helpers\Logger;
     
    2526
    2627        try {
     28            Refunds_Actions::sync_refunds( $order );
    2729            $request  = new Request( $order );
    2830            $response = $request->send( $amount );
  • yoco-payment-gateway/tags/3.8.4/src/Gateway/Refund/Request.php

    r3177082 r3253194  
    6161        $headers = array(
    6262            'Content-Type'  => 'application/json',
    63             'Authorization' => $this->installation->getApiBearer(),
     63            'Authorization' => $this->installation->getApiBearer( $this->order->get_meta( 'yoco_order_payment_mode', true ) ),
    6464            'X-Product'     => 'woocommerce',
    6565        );
    6666
     67        $idempotency_key = $this->getIdempotencyKey();
     68
     69        if ( null !== $idempotency_key ) {
     70            $headers['Idempotency-Key'] = $idempotency_key;
     71        }
     72
    6773        return apply_filters( 'yoco_payment_gateway/refund/request/headers', $headers );
    6874    }
     75
     76    private function getIdempotencyKey(): ?string {
     77        if ( ! isset( $_POST['security'] ) || wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['security'] ) ), 'woocommerce-order-items' ) ) {
     78            return null;
     79        }
     80
     81        if ( ! isset( $_POST['refund_amount'] ) || ! isset( $_POST['refunded_amount'] ) ) {
     82            return null;
     83        }
     84
     85        $refund_amount   = sanitize_text_field( wp_unslash( $_POST['refund_amount'] ) );
     86        $refunded_amount = sanitize_text_field( wp_unslash( $_POST['refunded_amount'] ) );
     87
     88        return hash( 'SHA256', yoco( Metadata::class )->getOrderPaymentId( $this->order ) . $refund_amount . $refunded_amount );
     89    }
    6990}
  • yoco-payment-gateway/tags/3.8.4/src/Gateway/Refunds/Actions.php

    r3206321 r3253194  
    109109                ),
    110110                'order_id'       => $order->get_id(),
    111                 'refund_payment' => true,
     111                'refund_payment' => false,
    112112            );
    113113
     
    116116            if ( is_wp_error( $new_refund ) ) {
    117117                yoco( Logger::class )->logError( 'Refund creation failed: ' . $new_refund->get_error_message() . ' code: ' . $new_refund->get_error_code() );
     118                return;
    118119            }
    119120
  • yoco-payment-gateway/tags/3.8.4/src/Gateway/Refunds/Request.php

    r3177082 r3253194  
    5656        $headers = array(
    5757            'Content-Type'  => 'application/json',
    58             'Authorization' => $this->installation->getApiBearer(),
     58            'Authorization' => $this->installation->getApiBearer( $this->order->get_meta( 'yoco_order_payment_mode', true ) ),
    5959            'X-Product'     => 'woocommerce',
    6060        );
  • yoco-payment-gateway/tags/3.8.4/src/Integrations/Yoco/Requests/Checkout.php

    r3177082 r3253194  
    2525            ->setAmount( $this->getOrderTotal() )
    2626            ->setCurrency( $this->order->get_currency() )
    27             ->setSuccessUrl( $this->order->get_checkout_order_received_url() )
    28             ->setCancelUrl( $this->order->get_checkout_payment_url() )
    29             ->setFailureUrl( $this->getOrderCheckoutPaymentUrl( 'failed' ) )
     27            ->setSuccessUrl( $this->absoluteUrl( $this->order->get_checkout_order_received_url() ) )
     28            ->setCancelUrl( $this->absoluteUrl( $this->order->get_checkout_payment_url() ) )
     29            ->setFailureUrl( $this->absoluteUrl( $this->getOrderCheckoutPaymentUrl( 'failed' ) ) )
    3030            ->setMetadata( $this->buildMetadata( $this->order ) )
    3131            ->setLineItems( $this->buildLineItems( $this->order ) )
     
    110110        );
    111111    }
     112
     113    private function absoluteUrl( string $url ): string {
     114        if ( ! preg_match( '/^https?:\/\//', $url ) ) {
     115            $url = home_url( $url );
     116        }
     117
     118        return $url;
     119    }
    112120}
  • yoco-payment-gateway/tags/3.8.4/src/Integrations/Yoco/Requests/Refund.php

    r3206321 r3253194  
    5151            ),
    5252            'order_id'       => $order->get_id(),
    53             'refund_payment' => true,
     53            'refund_payment' => false,
    5454        );
    5555
  • yoco-payment-gateway/tags/3.8.4/yoco_wc_payment_gateway.php

    r3206321 r3253194  
    66 * Author: Yoco
    77 * Author URI: https://www.yoco.com
    8  * Version: 3.8.1
     8 * Version: 3.8.4
    99 * Requires at least: 5.0.0
    10  * Tested up to: 6.6
     10 * Tested up to: 6.7
    1111 * WC requires at least: 8.0.0
    12  * WC tested up to: 9.3
     12 * WC tested up to: 9.7
    1313 * Requires Plugins: woocommerce
    1414 * Text Domain: yoco_wc_payment_gateway
  • yoco-payment-gateway/trunk/readme.txt

    r3239360 r3253194  
    55Tested up to: 6.7
    66Requires PHP: 7.4.0
    7 Stable tag: 3.8.3
     7Stable tag: 3.8.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    137137== Changelog ==
    138138
     139= 3.8.4 =
     140
     141* Fix relative checkout url.
     142
    139143= 3.8.3 =
    140144
  • yoco-payment-gateway/trunk/src/Gateway/Gateway.php

    r3177082 r3253194  
    2929        $this->icon       = trailingslashit( YOCO_ASSETS_URI ) . 'images/yoco-2024.svg';
    3030        $this->has_fields = false;
    31         $this->supports   = array( 'products', 'refunds' );
    3231
    3332        $this->title       = $this->get_option( 'title', __( 'Yoco', 'yoco_wc_payment_gateway' ) );
  • yoco-payment-gateway/trunk/src/Gateway/Notes.php

    r3206321 r3253194  
    7171        }
    7272
     73        $order_notes = wc_get_order_notes( array( 'order_id' => $order_id ) );
     74        foreach ( $order_notes as $note ) {
     75            if ( strpos( $note->content, 'refund session ID (' . $refund_id ) !== false ) {
     76                return;
     77            }
     78        }
     79
    7380        // translators: Refund ID.
    7481        $this->addNote( $order, sprintf( esc_html__( 'Yoco: Received refund session ID (%s).', 'yoco_wc_payment_gateway' ), esc_html( $refund_id ) ) );
  • yoco-payment-gateway/trunk/src/Gateway/Processors/OptionsProcessor.php

    r3102357 r3253194  
    3535            $response = $installationRequest->send();
    3636
    37             // If we get 500 error, reset Idempotence Key and retry the request.
    38             if ( 500 === (int) $response['code'] ) {
     37            // Retry the request for 408, 409, 425, 429, 502, 503, 504 response codes.
     38            if ( in_array( $response['code'], array( 408, 409, 425, 429, 502, 503, 504 ) ) ) {
     39                $response = $installationRequest->send();
     40            }
     41
     42            // If we get 500 response code, reset Idempotence Key and retry the request.
     43            if ( in_array( $response['code'], array( 500 ) ) ) {
    3944                add_filter( 'yoco_payment_gateway/installation/request/headers', array( $this, 'resetIdempotenceKey' ) );
    4045
  • yoco-payment-gateway/trunk/src/Gateway/Processors/RefundProcessor.php

    r3177082 r3253194  
    66use WP_Error;
    77use Yoco\Gateway\Metadata;
     8use Yoco\Gateway\Refunds\Actions as Refunds_Actions;
    89use Yoco\Gateway\Refund\Request;
    910use Yoco\Helpers\Logger;
     
    2526
    2627        try {
     28            Refunds_Actions::sync_refunds( $order );
    2729            $request  = new Request( $order );
    2830            $response = $request->send( $amount );
  • yoco-payment-gateway/trunk/src/Gateway/Refund/Request.php

    r3177082 r3253194  
    6161        $headers = array(
    6262            'Content-Type'  => 'application/json',
    63             'Authorization' => $this->installation->getApiBearer(),
     63            'Authorization' => $this->installation->getApiBearer( $this->order->get_meta( 'yoco_order_payment_mode', true ) ),
    6464            'X-Product'     => 'woocommerce',
    6565        );
    6666
     67        $idempotency_key = $this->getIdempotencyKey();
     68
     69        if ( null !== $idempotency_key ) {
     70            $headers['Idempotency-Key'] = $idempotency_key;
     71        }
     72
    6773        return apply_filters( 'yoco_payment_gateway/refund/request/headers', $headers );
    6874    }
     75
     76    private function getIdempotencyKey(): ?string {
     77        if ( ! isset( $_POST['security'] ) || wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['security'] ) ), 'woocommerce-order-items' ) ) {
     78            return null;
     79        }
     80
     81        if ( ! isset( $_POST['refund_amount'] ) || ! isset( $_POST['refunded_amount'] ) ) {
     82            return null;
     83        }
     84
     85        $refund_amount   = sanitize_text_field( wp_unslash( $_POST['refund_amount'] ) );
     86        $refunded_amount = sanitize_text_field( wp_unslash( $_POST['refunded_amount'] ) );
     87
     88        return hash( 'SHA256', yoco( Metadata::class )->getOrderPaymentId( $this->order ) . $refund_amount . $refunded_amount );
     89    }
    6990}
  • yoco-payment-gateway/trunk/src/Gateway/Refunds/Actions.php

    r3206321 r3253194  
    109109                ),
    110110                'order_id'       => $order->get_id(),
    111                 'refund_payment' => true,
     111                'refund_payment' => false,
    112112            );
    113113
     
    116116            if ( is_wp_error( $new_refund ) ) {
    117117                yoco( Logger::class )->logError( 'Refund creation failed: ' . $new_refund->get_error_message() . ' code: ' . $new_refund->get_error_code() );
     118                return;
    118119            }
    119120
  • yoco-payment-gateway/trunk/src/Gateway/Refunds/Request.php

    r3177082 r3253194  
    5656        $headers = array(
    5757            'Content-Type'  => 'application/json',
    58             'Authorization' => $this->installation->getApiBearer(),
     58            'Authorization' => $this->installation->getApiBearer( $this->order->get_meta( 'yoco_order_payment_mode', true ) ),
    5959            'X-Product'     => 'woocommerce',
    6060        );
  • yoco-payment-gateway/trunk/src/Integrations/Yoco/Requests/Checkout.php

    r3177082 r3253194  
    2525            ->setAmount( $this->getOrderTotal() )
    2626            ->setCurrency( $this->order->get_currency() )
    27             ->setSuccessUrl( $this->order->get_checkout_order_received_url() )
    28             ->setCancelUrl( $this->order->get_checkout_payment_url() )
    29             ->setFailureUrl( $this->getOrderCheckoutPaymentUrl( 'failed' ) )
     27            ->setSuccessUrl( $this->absoluteUrl( $this->order->get_checkout_order_received_url() ) )
     28            ->setCancelUrl( $this->absoluteUrl( $this->order->get_checkout_payment_url() ) )
     29            ->setFailureUrl( $this->absoluteUrl( $this->getOrderCheckoutPaymentUrl( 'failed' ) ) )
    3030            ->setMetadata( $this->buildMetadata( $this->order ) )
    3131            ->setLineItems( $this->buildLineItems( $this->order ) )
     
    110110        );
    111111    }
     112
     113    private function absoluteUrl( string $url ): string {
     114        if ( ! preg_match( '/^https?:\/\//', $url ) ) {
     115            $url = home_url( $url );
     116        }
     117
     118        return $url;
     119    }
    112120}
  • yoco-payment-gateway/trunk/src/Integrations/Yoco/Requests/Refund.php

    r3206321 r3253194  
    5151            ),
    5252            'order_id'       => $order->get_id(),
    53             'refund_payment' => true,
     53            'refund_payment' => false,
    5454        );
    5555
  • yoco-payment-gateway/trunk/yoco_wc_payment_gateway.php

    r3206321 r3253194  
    66 * Author: Yoco
    77 * Author URI: https://www.yoco.com
    8  * Version: 3.8.1
     8 * Version: 3.8.4
    99 * Requires at least: 5.0.0
    10  * Tested up to: 6.6
     10 * Tested up to: 6.7
    1111 * WC requires at least: 8.0.0
    12  * WC tested up to: 9.3
     12 * WC tested up to: 9.7
    1313 * Requires Plugins: woocommerce
    1414 * Text Domain: yoco_wc_payment_gateway
Note: See TracChangeset for help on using the changeset viewer.