Plugin Directory

Changeset 3389591


Ignore:
Timestamp:
11/04/2025 11:13:56 AM (5 months ago)
Author:
yocoadmin
Message:

Update to version 3.8.8 from Gitlab

Location:
yoco-payment-gateway
Files:
2 added
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • yoco-payment-gateway/tags/3.8.8/readme.txt

    r3354721 r3389591  
    55Tested up to: 6.8
    66Requires PHP: 7.4.0
    7 Stable tag: 3.8.6
     7Stable tag: 3.8.8
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    137137== Changelog ==
    138138
     139= 3.8.8 =
     140
     141* Fix Payment error when using legacy theme with block checkout.
     142
     143= 3.8.7 =
     144
     145* Add AMEX Payment Method logo.
     146
    139147= 3.8.6 =
    140148
  • yoco-payment-gateway/tags/3.8.8/src/Gateway/BlocksCheckout.php

    r3354721 r3389591  
    7979                'MasterCard' => YOCO_ASSETS_URI . '/images/master.svg',
    8080                'MasterPass' => YOCO_ASSETS_URI . '/images/masterpass.svg',
     81                'Amex'       => YOCO_ASSETS_URI . '/images/american_express.svg',
    8182            ),
    8283        );
  • yoco-payment-gateway/tags/3.8.8/src/Gateway/Gateway.php

    r3354721 r3389591  
    33namespace Yoco\Gateway;
    44
     5use WC_Order;
    56use WC_Payment_Gateway;
     7use WP_Error;
    68use Yoco\Gateway\Processors\OptionsProcessor;
    79use Yoco\Gateway\Processors\PaymentProcessor;
    810use Yoco\Gateway\Processors\RefundProcessor;
    911use Yoco\Helpers\Admin\Notices;
     12use Yoco\Helpers\Logger;
    1013use Yoco\Installations\InstallationsManager;
    1114
     
    3134        $this->has_fields = false;
    3235
    33         $this->icon            = trailingslashit( YOCO_ASSETS_URI ) . 'images/yoco-2024.svg';
     36        $this->icon            = YOCO_ASSETS_URI . '/images/yoco-2024.svg';
    3437        $this->providers_icons = array(
    35             'Visa'       => trailingslashit( YOCO_ASSETS_URI ) . 'images/visa.svg',
    36             'MasterCard' => trailingslashit( YOCO_ASSETS_URI ) . 'images/master.svg',
    37             'MasterPass' => trailingslashit( YOCO_ASSETS_URI ) . 'images/masterpass.svg',
     38            'Visa'       => YOCO_ASSETS_URI . '/images/visa.svg',
     39            'MasterCard' => YOCO_ASSETS_URI . '/images/master.svg',
     40            'MasterPass' => YOCO_ASSETS_URI . '/images/masterpass.svg',
     41            'Amex'       => YOCO_ASSETS_URI . '/images/american_express.svg',
    3842        );
    3943
     
    8892    }
    8993
    90     public function process_payment( $order_id ): ?array {
    91         $order     = wc_get_order( $order_id );
    92         $processor = new PaymentProcessor();
     94    /**
     95     * Process payment.
     96     *
     97     * @param  int $order_id WC_Order ID.
     98     *
     99     * @return array
     100     */
     101    public function process_payment( $order_id ): array {
     102        $order = wc_get_order( $order_id );
    93103
    94         return $processor->process( $order );
     104        if ( ! $order instanceof WC_Order ) {
     105            yoco( Logger::class )->logError(
     106                sprintf(
     107                    'Can\'t perform payment. Invalid order. Order id: %s',
     108                    $order_id
     109                )
     110            );
     111
     112            return array(
     113                'result'  => 'failure',
     114                'message' => __( 'Can\'t perform payment. Invalid order.', 'yoco_wc_payment_gateway' ),
     115            );
     116        }
     117
     118        return PaymentProcessor::process( $order );
    95119    }
    96120
     121    /**
     122     * Process refund.
     123     *
     124     * @param  int        $order_id Order ID.
     125     * @param  float|null $amount Refund amount.
     126     * @param  string     $reason Refund reason.
     127     * @return bool|\WP_Error True or false based on success, or a WP_Error object.
     128     */
    97129    public function process_refund( $order_id, $amount = null, $reason = '' ) {
    98         $order     = wc_get_order( $order_id );
    99         $processor = new RefundProcessor();
     130        $order = wc_get_order( $order_id );
    100131
    101         return $processor->process( $order, $amount );
     132        if ( ! $order instanceof WC_Order ) {
     133            yoco( Logger::class )->logError(
     134                sprintf(
     135                    'Can\'t perform refund. Invalid order. Order id: %s',
     136                    $order_id
     137                )
     138            );
     139
     140            return new WP_Error( 'refund_failure', 'Can\'t perform refund. Invalid order.' );
     141        }
     142
     143        return RefundProcessor::process( $order, $amount );
    102144    }
    103145
  • yoco-payment-gateway/tags/3.8.8/src/Gateway/Processors/PaymentProcessor.php

    r3067423 r3389591  
    1414class PaymentProcessor {
    1515
    16     public function process( WC_Order $order ): ?array {
     16    /**
     17     * Process payment.
     18     *
     19     * @param  WC_Order $order Woo Order.
     20     *
     21     * @return array
     22     */
     23    public static function process( WC_Order $order ): array {
    1724        try {
    1825            if ( 200 > yoco( Money::class )->format( $order->get_total() ) ) {
    19                 wc_add_notice( __( 'You must have an order with a minimum of R2,00 to place your order.', 'yoco_wc_payment_gateway' ), 'error' );
    20                 return null;
     26                // translators: order total.
     27                wc_add_notice( sprintf( __( 'A minimum order of R2.00 is required to proceed. Your order total is %s.', 'yoco_wc_payment_gateway' ), $order->get_formatted_order_total() ), 'error' );
     28
     29                return array(
     30                    'result'  => 'failure',
     31                    // translators: order total.
     32                    'message' => sprintf( __( 'A minimum order of R2.00 is required to proceed. Your order total is %s.', 'yoco_wc_payment_gateway' ), $order->get_formatted_order_total() ),
     33                );
    2134            }
    2235
    23             $checkoutUrl = yoco( Metadata::class )->getOrderCheckoutUrl( $order );
     36            $checkout_url = yoco( Metadata::class )->getOrderCheckoutUrl( $order );
    2437
    25             if ( ! empty( $checkoutUrl ) ) {
    26                 return $this->createSuccessRedirectResponse( $checkoutUrl );
     38            if ( ! empty( $checkout_url ) ) {
     39                return self::create_success_redirect_response( $checkout_url );
    2740            }
    2841
     
    4659            do_action( 'yoco_payment_gateway/checkout/created', $order, $response['body'] );
    4760
    48             return $this->createSuccessRedirectResponse( $response['body']['redirectUrl'] );
     61            return self::create_success_redirect_response( $response['body']['redirectUrl'] );
    4962        } catch ( \Throwable $th ) {
    5063            yoco( Logger::class )->logError( sprintf( 'Yoco: ERROR: Failed to request for payment: "%s".', $th->getMessage() ) );
     
    5265            wc_add_notice( __( 'Your order could not be processed by Yoco - please try again later.', 'yoco_wc_payment_gateway' ), 'error' );
    5366
    54             return null;
     67            return array(
     68                'result'  => 'failure',
     69                'message' => __( 'Your order could not be processed by Yoco - please try again later.', 'yoco_wc_payment_gateway' ),
     70            );
    5571        }
    5672    }
    5773
    58     private function createSuccessRedirectResponse( string $redirectUrl ): array {
     74    /**
     75     * Return success result.
     76     *
     77     * @param  string $url Redirect url.
     78     *
     79     * @return array
     80     */
     81    private static function create_success_redirect_response( string $url ): array {
    5982        return array(
    6083            'result'   => 'success',
    61             'redirect' => $redirectUrl,
     84            'redirect' => $url,
    6285        );
    6386    }
  • yoco-payment-gateway/tags/3.8.8/src/Gateway/Processors/RefundProcessor.php

    r3253194 r3389591  
    1717     * Process refund.
    1818     *
    19      * @param  WC_Order   $order
    20      * @param  float|null $amount
    21      * @param  string     $reason
     19     * @param  WC_Order   $order Woo Order.
     20     * @param  float|null $amount Amount.
    2221     *
    2322     * @return bool|WP_Error
    2423     */
    25     public function process( WC_Order $order, float $amount ) {
     24    public static function process( WC_Order $order, float $amount ) {
    2625
    2726        try {
  • yoco-payment-gateway/tags/3.8.8/yoco_wc_payment_gateway.php

    r3354721 r3389591  
    66 * Author: Yoco
    77 * Author URI: https://www.yoco.com
    8  * Version: 3.8.6
     8 * Version: 3.8.8
    99 * Requires at least: 5.0.0
    1010 * Tested up to: 6.8
    1111 * WC requires at least: 8.0.0
    12  * WC tested up to: 10.1
     12 * WC tested up to: 10.3
    1313 * Requires Plugins: woocommerce
    1414 * Text Domain: yoco_wc_payment_gateway
  • yoco-payment-gateway/trunk/readme.txt

    r3354721 r3389591  
    55Tested up to: 6.8
    66Requires PHP: 7.4.0
    7 Stable tag: 3.8.6
     7Stable tag: 3.8.8
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    137137== Changelog ==
    138138
     139= 3.8.8 =
     140
     141* Fix Payment error when using legacy theme with block checkout.
     142
     143= 3.8.7 =
     144
     145* Add AMEX Payment Method logo.
     146
    139147= 3.8.6 =
    140148
  • yoco-payment-gateway/trunk/src/Gateway/BlocksCheckout.php

    r3354721 r3389591  
    7979                'MasterCard' => YOCO_ASSETS_URI . '/images/master.svg',
    8080                'MasterPass' => YOCO_ASSETS_URI . '/images/masterpass.svg',
     81                'Amex'       => YOCO_ASSETS_URI . '/images/american_express.svg',
    8182            ),
    8283        );
  • yoco-payment-gateway/trunk/src/Gateway/Gateway.php

    r3354721 r3389591  
    33namespace Yoco\Gateway;
    44
     5use WC_Order;
    56use WC_Payment_Gateway;
     7use WP_Error;
    68use Yoco\Gateway\Processors\OptionsProcessor;
    79use Yoco\Gateway\Processors\PaymentProcessor;
    810use Yoco\Gateway\Processors\RefundProcessor;
    911use Yoco\Helpers\Admin\Notices;
     12use Yoco\Helpers\Logger;
    1013use Yoco\Installations\InstallationsManager;
    1114
     
    3134        $this->has_fields = false;
    3235
    33         $this->icon            = trailingslashit( YOCO_ASSETS_URI ) . 'images/yoco-2024.svg';
     36        $this->icon            = YOCO_ASSETS_URI . '/images/yoco-2024.svg';
    3437        $this->providers_icons = array(
    35             'Visa'       => trailingslashit( YOCO_ASSETS_URI ) . 'images/visa.svg',
    36             'MasterCard' => trailingslashit( YOCO_ASSETS_URI ) . 'images/master.svg',
    37             'MasterPass' => trailingslashit( YOCO_ASSETS_URI ) . 'images/masterpass.svg',
     38            'Visa'       => YOCO_ASSETS_URI . '/images/visa.svg',
     39            'MasterCard' => YOCO_ASSETS_URI . '/images/master.svg',
     40            'MasterPass' => YOCO_ASSETS_URI . '/images/masterpass.svg',
     41            'Amex'       => YOCO_ASSETS_URI . '/images/american_express.svg',
    3842        );
    3943
     
    8892    }
    8993
    90     public function process_payment( $order_id ): ?array {
    91         $order     = wc_get_order( $order_id );
    92         $processor = new PaymentProcessor();
     94    /**
     95     * Process payment.
     96     *
     97     * @param  int $order_id WC_Order ID.
     98     *
     99     * @return array
     100     */
     101    public function process_payment( $order_id ): array {
     102        $order = wc_get_order( $order_id );
    93103
    94         return $processor->process( $order );
     104        if ( ! $order instanceof WC_Order ) {
     105            yoco( Logger::class )->logError(
     106                sprintf(
     107                    'Can\'t perform payment. Invalid order. Order id: %s',
     108                    $order_id
     109                )
     110            );
     111
     112            return array(
     113                'result'  => 'failure',
     114                'message' => __( 'Can\'t perform payment. Invalid order.', 'yoco_wc_payment_gateway' ),
     115            );
     116        }
     117
     118        return PaymentProcessor::process( $order );
    95119    }
    96120
     121    /**
     122     * Process refund.
     123     *
     124     * @param  int        $order_id Order ID.
     125     * @param  float|null $amount Refund amount.
     126     * @param  string     $reason Refund reason.
     127     * @return bool|\WP_Error True or false based on success, or a WP_Error object.
     128     */
    97129    public function process_refund( $order_id, $amount = null, $reason = '' ) {
    98         $order     = wc_get_order( $order_id );
    99         $processor = new RefundProcessor();
     130        $order = wc_get_order( $order_id );
    100131
    101         return $processor->process( $order, $amount );
     132        if ( ! $order instanceof WC_Order ) {
     133            yoco( Logger::class )->logError(
     134                sprintf(
     135                    'Can\'t perform refund. Invalid order. Order id: %s',
     136                    $order_id
     137                )
     138            );
     139
     140            return new WP_Error( 'refund_failure', 'Can\'t perform refund. Invalid order.' );
     141        }
     142
     143        return RefundProcessor::process( $order, $amount );
    102144    }
    103145
  • yoco-payment-gateway/trunk/src/Gateway/Processors/PaymentProcessor.php

    r3067423 r3389591  
    1414class PaymentProcessor {
    1515
    16     public function process( WC_Order $order ): ?array {
     16    /**
     17     * Process payment.
     18     *
     19     * @param  WC_Order $order Woo Order.
     20     *
     21     * @return array
     22     */
     23    public static function process( WC_Order $order ): array {
    1724        try {
    1825            if ( 200 > yoco( Money::class )->format( $order->get_total() ) ) {
    19                 wc_add_notice( __( 'You must have an order with a minimum of R2,00 to place your order.', 'yoco_wc_payment_gateway' ), 'error' );
    20                 return null;
     26                // translators: order total.
     27                wc_add_notice( sprintf( __( 'A minimum order of R2.00 is required to proceed. Your order total is %s.', 'yoco_wc_payment_gateway' ), $order->get_formatted_order_total() ), 'error' );
     28
     29                return array(
     30                    'result'  => 'failure',
     31                    // translators: order total.
     32                    'message' => sprintf( __( 'A minimum order of R2.00 is required to proceed. Your order total is %s.', 'yoco_wc_payment_gateway' ), $order->get_formatted_order_total() ),
     33                );
    2134            }
    2235
    23             $checkoutUrl = yoco( Metadata::class )->getOrderCheckoutUrl( $order );
     36            $checkout_url = yoco( Metadata::class )->getOrderCheckoutUrl( $order );
    2437
    25             if ( ! empty( $checkoutUrl ) ) {
    26                 return $this->createSuccessRedirectResponse( $checkoutUrl );
     38            if ( ! empty( $checkout_url ) ) {
     39                return self::create_success_redirect_response( $checkout_url );
    2740            }
    2841
     
    4659            do_action( 'yoco_payment_gateway/checkout/created', $order, $response['body'] );
    4760
    48             return $this->createSuccessRedirectResponse( $response['body']['redirectUrl'] );
     61            return self::create_success_redirect_response( $response['body']['redirectUrl'] );
    4962        } catch ( \Throwable $th ) {
    5063            yoco( Logger::class )->logError( sprintf( 'Yoco: ERROR: Failed to request for payment: "%s".', $th->getMessage() ) );
     
    5265            wc_add_notice( __( 'Your order could not be processed by Yoco - please try again later.', 'yoco_wc_payment_gateway' ), 'error' );
    5366
    54             return null;
     67            return array(
     68                'result'  => 'failure',
     69                'message' => __( 'Your order could not be processed by Yoco - please try again later.', 'yoco_wc_payment_gateway' ),
     70            );
    5571        }
    5672    }
    5773
    58     private function createSuccessRedirectResponse( string $redirectUrl ): array {
     74    /**
     75     * Return success result.
     76     *
     77     * @param  string $url Redirect url.
     78     *
     79     * @return array
     80     */
     81    private static function create_success_redirect_response( string $url ): array {
    5982        return array(
    6083            'result'   => 'success',
    61             'redirect' => $redirectUrl,
     84            'redirect' => $url,
    6285        );
    6386    }
  • yoco-payment-gateway/trunk/src/Gateway/Processors/RefundProcessor.php

    r3253194 r3389591  
    1717     * Process refund.
    1818     *
    19      * @param  WC_Order   $order
    20      * @param  float|null $amount
    21      * @param  string     $reason
     19     * @param  WC_Order   $order Woo Order.
     20     * @param  float|null $amount Amount.
    2221     *
    2322     * @return bool|WP_Error
    2423     */
    25     public function process( WC_Order $order, float $amount ) {
     24    public static function process( WC_Order $order, float $amount ) {
    2625
    2726        try {
  • yoco-payment-gateway/trunk/yoco_wc_payment_gateway.php

    r3354721 r3389591  
    66 * Author: Yoco
    77 * Author URI: https://www.yoco.com
    8  * Version: 3.8.6
     8 * Version: 3.8.8
    99 * Requires at least: 5.0.0
    1010 * Tested up to: 6.8
    1111 * WC requires at least: 8.0.0
    12  * WC tested up to: 10.1
     12 * WC tested up to: 10.3
    1313 * Requires Plugins: woocommerce
    1414 * Text Domain: yoco_wc_payment_gateway
Note: See TracChangeset for help on using the changeset viewer.