Changeset 3635057
- Timestamp:
- 08/05/2026 08:38:34 AM (3 months ago)
- Location:
- pensopay-payments-v2
- Files:
-
- 12 edited
- 1 copied
-
tags/2.1.5 (copied) (copied from pensopay-payments-v2/trunk )
-
tags/2.1.5/README.txt (modified) (2 diffs)
-
tags/2.1.5/includes/admin/order-table/order-table-transaction-data.php (modified) (2 diffs)
-
tags/2.1.5/includes/helpers/media.php (modified) (1 diff)
-
tags/2.1.5/includes/methods/abstract.php (modified) (1 diff)
-
tags/2.1.5/pensopay.php (modified) (2 diffs)
-
tags/2.1.5/views/html-order-table-transaction-data.php (modified) (1 diff)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/includes/admin/order-table/order-table-transaction-data.php (modified) (2 diffs)
-
trunk/includes/helpers/media.php (modified) (1 diff)
-
trunk/includes/methods/abstract.php (modified) (1 diff)
-
trunk/pensopay.php (modified) (2 diffs)
-
trunk/views/html-order-table-transaction-data.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pensopay-payments-v2/tags/2.1.5/README.txt
r3632642 r3635057 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.4 7 Stable tag: 2.1. 47 Stable tag: 2.1.5 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 40 40 41 41 == Changelog == 42 = 2.1.5 = 43 * Fix: payment methods without a card brand (Anyday, ViaBill and every other alternative method) now show their own logo in the order overview instead of no logo 44 * Fix: a reported card brand is only used when the matching logo file exists, so brands whose logo ships only as a PNG no longer render a broken image 45 * Fix: the Finnish store language is now sent to the gateway as fi_FI, which the API accepts, instead of WordPress's bare fi 46 * Change: updated development dependencies 47 42 48 = 2.1.4 = 43 49 * Fix: renewal orders no longer reuse the subscription's already-consumed payment link -
pensopay-payments-v2/tags/2.1.5/includes/admin/order-table/order-table-transaction-data.php
r3394059 r3635057 84 84 'transaction_order_id' => $transaction->get_order_id() ?? $order->get_order_number(), 85 85 'transaction_brand' => $transaction->get_brand(), 86 'transaction_brand_logo_url' => plugin_dir_url( PENSOPAY_PAYMENTS_V2_PLUGIN_FILE ) . 'assets/images/cards/' . $transaction->get_brand() . '.svg',86 'transaction_brand_logo_url' => Pensopay_Payments_V2_Helpers_Media::get_transaction_logo_url( $transaction->get_brand(), $order->get_payment_method() ), 87 87 'transaction_status' => $transaction->get_state(), 88 88 'transaction_is_test' => $transaction->is_test(), … … 99 99 'transaction_order_id' => $transaction->get_order_id() ?? $order->get_order_number(), 100 100 'transaction_brand' => $transaction->get_brand(), 101 'transaction_brand_logo_url' => plugin_dir_url( PENSOPAY_PAYMENTS_V2_PLUGIN_FILE ) . 'assets/images/cards/' . $transaction->get_brand() . '.svg',101 'transaction_brand_logo_url' => Pensopay_Payments_V2_Helpers_Media::get_transaction_logo_url( $transaction->get_brand(), $order->get_payment_method() ), 102 102 'transaction_status' => $transaction->get_current_type(), 103 103 'transaction_is_test' => $transaction->is_test(), -
pensopay-payments-v2/tags/2.1.5/includes/helpers/media.php
r3494543 r3635057 4 4 5 5 class Pensopay_Payments_V2_Helpers_Media { 6 /** 7 * Logo URL for a payment method, for payments that carry no card brand. 8 * 9 * Rather than keep a second copy of the method-to-asset mapping, ask the gateway for 10 * the icon it already renders at checkout: every method declares its own asset in 11 * apply_gateway_icons() via create_gateway_icon(), which also owns the SVG-then-PNG 12 * fallback and the `pensopay_payments_checkout_gateway_icon_url` filter. So a method 13 * that gets a logo at checkout gets the same one in the order overview, and a new 14 * method needs no change here at all. 15 * 16 * Only an unambiguous single icon is used. The card gateway appends one icon per 17 * configured card brand (see Pensopay_Payments_V2_Methods_Abstract::apply_gateway_icons()), 18 * and picking an arbitrary one of those would claim the order was paid with a brand 19 * we do not actually know, so those resolve to nothing instead. 20 * 21 * @param string $facilitator WooCommerce payment method id. 22 * 23 * @return string Logo URL, or an empty string when the method has no single logo. 24 */ 6 25 public static function get_facilitator_logo( $facilitator ) { 7 return 'none.png'; 26 if ( empty( $facilitator ) || ! function_exists( 'WC' ) || ! WC()->payment_gateways() ) { 27 return ''; 28 } 29 30 $gateways = WC()->payment_gateways()->payment_gateways(); 31 32 if ( ! isset( $gateways[ $facilitator ] ) ) { 33 return ''; 34 } 35 36 return self::extract_single_icon_url( $gateways[ $facilitator ]->get_icon() ); 37 } 38 39 /** 40 * Pull the asset URL out of rendered gateway icon markup, but only when it names 41 * exactly one asset. 42 * 43 * @param string $icon_html Markup returned by WC_Payment_Gateway::get_icon(). 44 * 45 * @return string The single icon URL, or an empty string for none or several. 46 */ 47 public static function extract_single_icon_url( $icon_html ) { 48 if ( empty( $icon_html ) || ! is_string( $icon_html ) ) { 49 return ''; 50 } 51 52 if ( ! preg_match_all( '/<img[^>]+src=["\']([^"\']+)["\']/i', $icon_html, $matches ) ) { 53 return ''; 54 } 55 56 $urls = array_values( array_unique( $matches[1] ) ); 57 58 return count( $urls ) === 1 ? $urls[0] : ''; 59 } 60 61 /** 62 * Resolve the logo for an order row: the brand the payment reports, or failing that 63 * the payment method it was paid with. 64 * 65 * Anyday and ViaBill are authorized and captured by their own providers, so their 66 * payments never get a `payment_details.brand` the way card payments do, and the 67 * overview was left building `assets/images/cards/.svg` and showing nothing. 68 * 69 * A brand still wins, but only when it names an asset that is actually on disk: the 70 * brand slug is not the asset slug, so e.g. a brand of `anyday` used to build 71 * `cards/anyday.svg` and 404 (the only Anyday asset is `anyday-split.svg`), which is 72 * worse than showing the method's own logo. When the brand resolves to no file we fall 73 * through to the same fallback a brandless payment gets. Every brand that does have an 74 * asset keeps the URL the overview has always built. 75 * 76 * @param string $brand `payment_details.brand` from the payment object. 77 * @param string $facilitator WooCommerce payment method id. 78 * 79 * @return string Logo URL, or an empty string when nothing resolves. 80 */ 81 public static function get_transaction_logo_url( $brand, $facilitator ) { 82 if ( ! empty( $brand ) ) { 83 $brand_logo = self::get_card_asset_url( $brand ); 84 85 if ( ! empty( $brand_logo ) ) { 86 return $brand_logo; 87 } 88 } 89 90 return self::get_facilitator_logo( $facilitator ); 91 } 92 93 /** 94 * URL of a `assets/images/cards/` asset, or an empty string when there is no such file. 95 * 96 * SVG is preferred and PNG accepted, the same order and the same directory 97 * Pensopay_Payments_V2_Methods_Abstract::create_gateway_icon() uses for checkout icons, 98 * so a brand whose asset only ships as a PNG (visaelectron, discovercard, apple-pay) 99 * resolves instead of asking for a `.svg` that was never there. 100 * 101 * @param string $slug Asset base name. 102 * 103 * @return string Asset URL, or an empty string when nothing is on disk. 104 */ 105 public static function get_card_asset_url( $slug ) { 106 if ( empty( $slug ) || ! is_string( $slug ) ) { 107 return ''; 108 } 109 110 $directory = 'assets/images/cards/'; 111 112 foreach ( array( 'svg', 'png' ) as $extension ) { 113 $file = $directory . $slug . '.' . $extension; 114 115 if ( file_exists( plugin_dir_path( PENSOPAY_PAYMENTS_V2_PLUGIN_FILE ) . $file ) ) { 116 return plugin_dir_url( PENSOPAY_PAYMENTS_V2_PLUGIN_FILE ) . $file; 117 } 118 } 119 120 return ''; 8 121 } 9 122 -
pensopay-payments-v2/tags/2.1.5/includes/methods/abstract.php
r3632642 r3635057 1128 1128 protected function get_wp_locale() { 1129 1129 $lang_iso = get_locale(); 1130 if ( $lang_iso === 'fo' ) { //Wordpress does not use the right format for Faroese which is relevant for us. 1131 $lang_iso = 'fo_FO'; 1130 1131 // WordPress returns a bare 2-letter code for some languages, but the payment API 1132 // validates `locale` as exactly 5 characters (da_DK, en_US, nb_NO, ...) and rejects 1133 // the entire request with a validation error otherwise. Expand the ones we support. 1134 $short_locales = array( 1135 'fo' => 'fo_FO', // Faroese. 1136 'fi' => 'fi_FI', // Finnish. 1137 ); 1138 1139 if ( isset( $short_locales[ $lang_iso ] ) ) { 1140 $lang_iso = $short_locales[ $lang_iso ]; 1132 1141 } 1133 1142 -
pensopay-payments-v2/tags/2.1.5/pensopay.php
r3632642 r3635057 5 5 * Plugin URI: http://wordpress.org/plugins/pensopay/ 6 6 * Description: Integrates your pensopay v2 payment gateway into your WooCommerce installation. 7 * Version: 2.1. 47 * Version: 2.1.5 8 8 * Author: pensopay 9 9 * Text Domain: pensopay-payments-v2 … … 24 24 defined( 'ABSPATH' ) || exit; 25 25 26 define( 'PENSOPAY_PAYMENTS_V2_VERSION', '2.1. 4' );26 define( 'PENSOPAY_PAYMENTS_V2_VERSION', '2.1.5' ); 27 27 define( 'PENSOPAY_PAYMENTS_V2_WC_MIN_VER', '8.2' ); 28 28 define( 'PENSOPAY_PAYMENTS_V2_PLUGIN_FILE', __FILE__ ); -
pensopay-payments-v2/tags/2.1.5/views/html-order-table-transaction-data.php
r3394059 r3635057 16 16 <td> 17 17 <span class="transaction-brand"> 18 <?php if ( $transaction_brand_logo_url ) : ?> 18 19 <img src="<?= esc_attr( $transaction_brand_logo_url ) ?>" 19 20 alt="<?= esc_attr( $transaction_brand ) ?>" title="<?= esc_attr( $transaction_brand ) ?>" 20 21 style="max-width:20px"/> 22 <?php endif; ?> 21 23 </span> 22 24 </td> -
pensopay-payments-v2/trunk/README.txt
r3632642 r3635057 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.4 7 Stable tag: 2.1. 47 Stable tag: 2.1.5 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 40 40 41 41 == Changelog == 42 = 2.1.5 = 43 * Fix: payment methods without a card brand (Anyday, ViaBill and every other alternative method) now show their own logo in the order overview instead of no logo 44 * Fix: a reported card brand is only used when the matching logo file exists, so brands whose logo ships only as a PNG no longer render a broken image 45 * Fix: the Finnish store language is now sent to the gateway as fi_FI, which the API accepts, instead of WordPress's bare fi 46 * Change: updated development dependencies 47 42 48 = 2.1.4 = 43 49 * Fix: renewal orders no longer reuse the subscription's already-consumed payment link -
pensopay-payments-v2/trunk/includes/admin/order-table/order-table-transaction-data.php
r3394059 r3635057 84 84 'transaction_order_id' => $transaction->get_order_id() ?? $order->get_order_number(), 85 85 'transaction_brand' => $transaction->get_brand(), 86 'transaction_brand_logo_url' => plugin_dir_url( PENSOPAY_PAYMENTS_V2_PLUGIN_FILE ) . 'assets/images/cards/' . $transaction->get_brand() . '.svg',86 'transaction_brand_logo_url' => Pensopay_Payments_V2_Helpers_Media::get_transaction_logo_url( $transaction->get_brand(), $order->get_payment_method() ), 87 87 'transaction_status' => $transaction->get_state(), 88 88 'transaction_is_test' => $transaction->is_test(), … … 99 99 'transaction_order_id' => $transaction->get_order_id() ?? $order->get_order_number(), 100 100 'transaction_brand' => $transaction->get_brand(), 101 'transaction_brand_logo_url' => plugin_dir_url( PENSOPAY_PAYMENTS_V2_PLUGIN_FILE ) . 'assets/images/cards/' . $transaction->get_brand() . '.svg',101 'transaction_brand_logo_url' => Pensopay_Payments_V2_Helpers_Media::get_transaction_logo_url( $transaction->get_brand(), $order->get_payment_method() ), 102 102 'transaction_status' => $transaction->get_current_type(), 103 103 'transaction_is_test' => $transaction->is_test(), -
pensopay-payments-v2/trunk/includes/helpers/media.php
r3494543 r3635057 4 4 5 5 class Pensopay_Payments_V2_Helpers_Media { 6 /** 7 * Logo URL for a payment method, for payments that carry no card brand. 8 * 9 * Rather than keep a second copy of the method-to-asset mapping, ask the gateway for 10 * the icon it already renders at checkout: every method declares its own asset in 11 * apply_gateway_icons() via create_gateway_icon(), which also owns the SVG-then-PNG 12 * fallback and the `pensopay_payments_checkout_gateway_icon_url` filter. So a method 13 * that gets a logo at checkout gets the same one in the order overview, and a new 14 * method needs no change here at all. 15 * 16 * Only an unambiguous single icon is used. The card gateway appends one icon per 17 * configured card brand (see Pensopay_Payments_V2_Methods_Abstract::apply_gateway_icons()), 18 * and picking an arbitrary one of those would claim the order was paid with a brand 19 * we do not actually know, so those resolve to nothing instead. 20 * 21 * @param string $facilitator WooCommerce payment method id. 22 * 23 * @return string Logo URL, or an empty string when the method has no single logo. 24 */ 6 25 public static function get_facilitator_logo( $facilitator ) { 7 return 'none.png'; 26 if ( empty( $facilitator ) || ! function_exists( 'WC' ) || ! WC()->payment_gateways() ) { 27 return ''; 28 } 29 30 $gateways = WC()->payment_gateways()->payment_gateways(); 31 32 if ( ! isset( $gateways[ $facilitator ] ) ) { 33 return ''; 34 } 35 36 return self::extract_single_icon_url( $gateways[ $facilitator ]->get_icon() ); 37 } 38 39 /** 40 * Pull the asset URL out of rendered gateway icon markup, but only when it names 41 * exactly one asset. 42 * 43 * @param string $icon_html Markup returned by WC_Payment_Gateway::get_icon(). 44 * 45 * @return string The single icon URL, or an empty string for none or several. 46 */ 47 public static function extract_single_icon_url( $icon_html ) { 48 if ( empty( $icon_html ) || ! is_string( $icon_html ) ) { 49 return ''; 50 } 51 52 if ( ! preg_match_all( '/<img[^>]+src=["\']([^"\']+)["\']/i', $icon_html, $matches ) ) { 53 return ''; 54 } 55 56 $urls = array_values( array_unique( $matches[1] ) ); 57 58 return count( $urls ) === 1 ? $urls[0] : ''; 59 } 60 61 /** 62 * Resolve the logo for an order row: the brand the payment reports, or failing that 63 * the payment method it was paid with. 64 * 65 * Anyday and ViaBill are authorized and captured by their own providers, so their 66 * payments never get a `payment_details.brand` the way card payments do, and the 67 * overview was left building `assets/images/cards/.svg` and showing nothing. 68 * 69 * A brand still wins, but only when it names an asset that is actually on disk: the 70 * brand slug is not the asset slug, so e.g. a brand of `anyday` used to build 71 * `cards/anyday.svg` and 404 (the only Anyday asset is `anyday-split.svg`), which is 72 * worse than showing the method's own logo. When the brand resolves to no file we fall 73 * through to the same fallback a brandless payment gets. Every brand that does have an 74 * asset keeps the URL the overview has always built. 75 * 76 * @param string $brand `payment_details.brand` from the payment object. 77 * @param string $facilitator WooCommerce payment method id. 78 * 79 * @return string Logo URL, or an empty string when nothing resolves. 80 */ 81 public static function get_transaction_logo_url( $brand, $facilitator ) { 82 if ( ! empty( $brand ) ) { 83 $brand_logo = self::get_card_asset_url( $brand ); 84 85 if ( ! empty( $brand_logo ) ) { 86 return $brand_logo; 87 } 88 } 89 90 return self::get_facilitator_logo( $facilitator ); 91 } 92 93 /** 94 * URL of a `assets/images/cards/` asset, or an empty string when there is no such file. 95 * 96 * SVG is preferred and PNG accepted, the same order and the same directory 97 * Pensopay_Payments_V2_Methods_Abstract::create_gateway_icon() uses for checkout icons, 98 * so a brand whose asset only ships as a PNG (visaelectron, discovercard, apple-pay) 99 * resolves instead of asking for a `.svg` that was never there. 100 * 101 * @param string $slug Asset base name. 102 * 103 * @return string Asset URL, or an empty string when nothing is on disk. 104 */ 105 public static function get_card_asset_url( $slug ) { 106 if ( empty( $slug ) || ! is_string( $slug ) ) { 107 return ''; 108 } 109 110 $directory = 'assets/images/cards/'; 111 112 foreach ( array( 'svg', 'png' ) as $extension ) { 113 $file = $directory . $slug . '.' . $extension; 114 115 if ( file_exists( plugin_dir_path( PENSOPAY_PAYMENTS_V2_PLUGIN_FILE ) . $file ) ) { 116 return plugin_dir_url( PENSOPAY_PAYMENTS_V2_PLUGIN_FILE ) . $file; 117 } 118 } 119 120 return ''; 8 121 } 9 122 -
pensopay-payments-v2/trunk/includes/methods/abstract.php
r3632642 r3635057 1128 1128 protected function get_wp_locale() { 1129 1129 $lang_iso = get_locale(); 1130 if ( $lang_iso === 'fo' ) { //Wordpress does not use the right format for Faroese which is relevant for us. 1131 $lang_iso = 'fo_FO'; 1130 1131 // WordPress returns a bare 2-letter code for some languages, but the payment API 1132 // validates `locale` as exactly 5 characters (da_DK, en_US, nb_NO, ...) and rejects 1133 // the entire request with a validation error otherwise. Expand the ones we support. 1134 $short_locales = array( 1135 'fo' => 'fo_FO', // Faroese. 1136 'fi' => 'fi_FI', // Finnish. 1137 ); 1138 1139 if ( isset( $short_locales[ $lang_iso ] ) ) { 1140 $lang_iso = $short_locales[ $lang_iso ]; 1132 1141 } 1133 1142 -
pensopay-payments-v2/trunk/pensopay.php
r3632642 r3635057 5 5 * Plugin URI: http://wordpress.org/plugins/pensopay/ 6 6 * Description: Integrates your pensopay v2 payment gateway into your WooCommerce installation. 7 * Version: 2.1. 47 * Version: 2.1.5 8 8 * Author: pensopay 9 9 * Text Domain: pensopay-payments-v2 … … 24 24 defined( 'ABSPATH' ) || exit; 25 25 26 define( 'PENSOPAY_PAYMENTS_V2_VERSION', '2.1. 4' );26 define( 'PENSOPAY_PAYMENTS_V2_VERSION', '2.1.5' ); 27 27 define( 'PENSOPAY_PAYMENTS_V2_WC_MIN_VER', '8.2' ); 28 28 define( 'PENSOPAY_PAYMENTS_V2_PLUGIN_FILE', __FILE__ ); -
pensopay-payments-v2/trunk/views/html-order-table-transaction-data.php
r3394059 r3635057 16 16 <td> 17 17 <span class="transaction-brand"> 18 <?php if ( $transaction_brand_logo_url ) : ?> 18 19 <img src="<?= esc_attr( $transaction_brand_logo_url ) ?>" 19 20 alt="<?= esc_attr( $transaction_brand ) ?>" title="<?= esc_attr( $transaction_brand ) ?>" 20 21 style="max-width:20px"/> 22 <?php endif; ?> 21 23 </span> 22 24 </td>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)