Changeset 3389591
- Timestamp:
- 11/04/2025 11:13:56 AM (5 months ago)
- Location:
- yoco-payment-gateway
- Files:
-
- 2 added
- 12 edited
- 1 copied
-
tags/3.8.8 (copied) (copied from yoco-payment-gateway/trunk)
-
tags/3.8.8/assets/images/american_express.svg (added)
-
tags/3.8.8/readme.txt (modified) (2 diffs)
-
tags/3.8.8/src/Gateway/BlocksCheckout.php (modified) (1 diff)
-
tags/3.8.8/src/Gateway/Gateway.php (modified) (3 diffs)
-
tags/3.8.8/src/Gateway/Processors/PaymentProcessor.php (modified) (3 diffs)
-
tags/3.8.8/src/Gateway/Processors/RefundProcessor.php (modified) (1 diff)
-
tags/3.8.8/yoco_wc_payment_gateway.php (modified) (1 diff)
-
trunk/assets/images/american_express.svg (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Gateway/BlocksCheckout.php (modified) (1 diff)
-
trunk/src/Gateway/Gateway.php (modified) (3 diffs)
-
trunk/src/Gateway/Processors/PaymentProcessor.php (modified) (3 diffs)
-
trunk/src/Gateway/Processors/RefundProcessor.php (modified) (1 diff)
-
trunk/yoco_wc_payment_gateway.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
yoco-payment-gateway/tags/3.8.8/readme.txt
r3354721 r3389591 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4.0 7 Stable tag: 3.8. 67 Stable tag: 3.8.8 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 137 137 == Changelog == 138 138 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 139 147 = 3.8.6 = 140 148 -
yoco-payment-gateway/tags/3.8.8/src/Gateway/BlocksCheckout.php
r3354721 r3389591 79 79 'MasterCard' => YOCO_ASSETS_URI . '/images/master.svg', 80 80 'MasterPass' => YOCO_ASSETS_URI . '/images/masterpass.svg', 81 'Amex' => YOCO_ASSETS_URI . '/images/american_express.svg', 81 82 ), 82 83 ); -
yoco-payment-gateway/tags/3.8.8/src/Gateway/Gateway.php
r3354721 r3389591 3 3 namespace Yoco\Gateway; 4 4 5 use WC_Order; 5 6 use WC_Payment_Gateway; 7 use WP_Error; 6 8 use Yoco\Gateway\Processors\OptionsProcessor; 7 9 use Yoco\Gateway\Processors\PaymentProcessor; 8 10 use Yoco\Gateway\Processors\RefundProcessor; 9 11 use Yoco\Helpers\Admin\Notices; 12 use Yoco\Helpers\Logger; 10 13 use Yoco\Installations\InstallationsManager; 11 14 … … 31 34 $this->has_fields = false; 32 35 33 $this->icon = trailingslashit( YOCO_ASSETS_URI ) . 'images/yoco-2024.svg';36 $this->icon = YOCO_ASSETS_URI . '/images/yoco-2024.svg'; 34 37 $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', 38 42 ); 39 43 … … 88 92 } 89 93 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 ); 93 103 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 ); 95 119 } 96 120 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 */ 97 129 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 ); 100 131 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 ); 102 144 } 103 145 -
yoco-payment-gateway/tags/3.8.8/src/Gateway/Processors/PaymentProcessor.php
r3067423 r3389591 14 14 class PaymentProcessor { 15 15 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 { 17 24 try { 18 25 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 ); 21 34 } 22 35 23 $checkout Url = yoco( Metadata::class )->getOrderCheckoutUrl( $order );36 $checkout_url = yoco( Metadata::class )->getOrderCheckoutUrl( $order ); 24 37 25 if ( ! empty( $checkout Url ) ) {26 return $this->createSuccessRedirectResponse( $checkoutUrl );38 if ( ! empty( $checkout_url ) ) { 39 return self::create_success_redirect_response( $checkout_url ); 27 40 } 28 41 … … 46 59 do_action( 'yoco_payment_gateway/checkout/created', $order, $response['body'] ); 47 60 48 return $this->createSuccessRedirectResponse( $response['body']['redirectUrl'] );61 return self::create_success_redirect_response( $response['body']['redirectUrl'] ); 49 62 } catch ( \Throwable $th ) { 50 63 yoco( Logger::class )->logError( sprintf( 'Yoco: ERROR: Failed to request for payment: "%s".', $th->getMessage() ) ); … … 52 65 wc_add_notice( __( 'Your order could not be processed by Yoco - please try again later.', 'yoco_wc_payment_gateway' ), 'error' ); 53 66 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 ); 55 71 } 56 72 } 57 73 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 { 59 82 return array( 60 83 'result' => 'success', 61 'redirect' => $ redirectUrl,84 'redirect' => $url, 62 85 ); 63 86 } -
yoco-payment-gateway/tags/3.8.8/src/Gateway/Processors/RefundProcessor.php
r3253194 r3389591 17 17 * Process refund. 18 18 * 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. 22 21 * 23 22 * @return bool|WP_Error 24 23 */ 25 public function process( WC_Order $order, float $amount ) {24 public static function process( WC_Order $order, float $amount ) { 26 25 27 26 try { -
yoco-payment-gateway/tags/3.8.8/yoco_wc_payment_gateway.php
r3354721 r3389591 6 6 * Author: Yoco 7 7 * Author URI: https://www.yoco.com 8 * Version: 3.8. 68 * Version: 3.8.8 9 9 * Requires at least: 5.0.0 10 10 * Tested up to: 6.8 11 11 * WC requires at least: 8.0.0 12 * WC tested up to: 10. 112 * WC tested up to: 10.3 13 13 * Requires Plugins: woocommerce 14 14 * Text Domain: yoco_wc_payment_gateway -
yoco-payment-gateway/trunk/readme.txt
r3354721 r3389591 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4.0 7 Stable tag: 3.8. 67 Stable tag: 3.8.8 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 137 137 == Changelog == 138 138 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 139 147 = 3.8.6 = 140 148 -
yoco-payment-gateway/trunk/src/Gateway/BlocksCheckout.php
r3354721 r3389591 79 79 'MasterCard' => YOCO_ASSETS_URI . '/images/master.svg', 80 80 'MasterPass' => YOCO_ASSETS_URI . '/images/masterpass.svg', 81 'Amex' => YOCO_ASSETS_URI . '/images/american_express.svg', 81 82 ), 82 83 ); -
yoco-payment-gateway/trunk/src/Gateway/Gateway.php
r3354721 r3389591 3 3 namespace Yoco\Gateway; 4 4 5 use WC_Order; 5 6 use WC_Payment_Gateway; 7 use WP_Error; 6 8 use Yoco\Gateway\Processors\OptionsProcessor; 7 9 use Yoco\Gateway\Processors\PaymentProcessor; 8 10 use Yoco\Gateway\Processors\RefundProcessor; 9 11 use Yoco\Helpers\Admin\Notices; 12 use Yoco\Helpers\Logger; 10 13 use Yoco\Installations\InstallationsManager; 11 14 … … 31 34 $this->has_fields = false; 32 35 33 $this->icon = trailingslashit( YOCO_ASSETS_URI ) . 'images/yoco-2024.svg';36 $this->icon = YOCO_ASSETS_URI . '/images/yoco-2024.svg'; 34 37 $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', 38 42 ); 39 43 … … 88 92 } 89 93 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 ); 93 103 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 ); 95 119 } 96 120 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 */ 97 129 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 ); 100 131 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 ); 102 144 } 103 145 -
yoco-payment-gateway/trunk/src/Gateway/Processors/PaymentProcessor.php
r3067423 r3389591 14 14 class PaymentProcessor { 15 15 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 { 17 24 try { 18 25 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 ); 21 34 } 22 35 23 $checkout Url = yoco( Metadata::class )->getOrderCheckoutUrl( $order );36 $checkout_url = yoco( Metadata::class )->getOrderCheckoutUrl( $order ); 24 37 25 if ( ! empty( $checkout Url ) ) {26 return $this->createSuccessRedirectResponse( $checkoutUrl );38 if ( ! empty( $checkout_url ) ) { 39 return self::create_success_redirect_response( $checkout_url ); 27 40 } 28 41 … … 46 59 do_action( 'yoco_payment_gateway/checkout/created', $order, $response['body'] ); 47 60 48 return $this->createSuccessRedirectResponse( $response['body']['redirectUrl'] );61 return self::create_success_redirect_response( $response['body']['redirectUrl'] ); 49 62 } catch ( \Throwable $th ) { 50 63 yoco( Logger::class )->logError( sprintf( 'Yoco: ERROR: Failed to request for payment: "%s".', $th->getMessage() ) ); … … 52 65 wc_add_notice( __( 'Your order could not be processed by Yoco - please try again later.', 'yoco_wc_payment_gateway' ), 'error' ); 53 66 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 ); 55 71 } 56 72 } 57 73 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 { 59 82 return array( 60 83 'result' => 'success', 61 'redirect' => $ redirectUrl,84 'redirect' => $url, 62 85 ); 63 86 } -
yoco-payment-gateway/trunk/src/Gateway/Processors/RefundProcessor.php
r3253194 r3389591 17 17 * Process refund. 18 18 * 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. 22 21 * 23 22 * @return bool|WP_Error 24 23 */ 25 public function process( WC_Order $order, float $amount ) {24 public static function process( WC_Order $order, float $amount ) { 26 25 27 26 try { -
yoco-payment-gateway/trunk/yoco_wc_payment_gateway.php
r3354721 r3389591 6 6 * Author: Yoco 7 7 * Author URI: https://www.yoco.com 8 * Version: 3.8. 68 * Version: 3.8.8 9 9 * Requires at least: 5.0.0 10 10 * Tested up to: 6.8 11 11 * WC requires at least: 8.0.0 12 * WC tested up to: 10. 112 * WC tested up to: 10.3 13 13 * Requires Plugins: woocommerce 14 14 * Text Domain: yoco_wc_payment_gateway
Note: See TracChangeset
for help on using the changeset viewer.