Changeset 3114383
- Timestamp:
- 07/08/2024 02:27:45 PM (21 months ago)
- Location:
- multisafepay
- Files:
-
- 6 added
- 50 edited
- 1 copied
-
tags/6.6.0 (copied) (copied from multisafepay/trunk)
-
tags/6.6.0/multisafepay.php (modified) (3 diffs)
-
tags/6.6.0/readme.txt (modified) (3 diffs)
-
tags/6.6.0/src/Client/MultiSafepayClient.php (modified) (2 diffs)
-
tags/6.6.0/src/PaymentMethods/Base/BaseBrandedPaymentMethod.php (added)
-
tags/6.6.0/src/PaymentMethods/Base/BasePaymentMethod.php (modified) (3 diffs)
-
tags/6.6.0/src/PaymentMethods/Base/BasePaymentMethodBlocks.php (modified) (1 diff)
-
tags/6.6.0/src/PaymentMethods/Base/BaseRefunds.php (modified) (4 diffs)
-
tags/6.6.0/src/PaymentMethods/PaymentMethodCallback.php (modified) (12 diffs)
-
tags/6.6.0/src/PaymentMethods/PaymentMethodsController.php (modified) (17 diffs)
-
tags/6.6.0/src/Services/ApiTokenService.php (modified) (2 diffs)
-
tags/6.6.0/src/Services/OrderService.php (modified) (1 diff)
-
tags/6.6.0/src/Services/PaymentMethodService.php (modified) (7 diffs)
-
tags/6.6.0/src/Services/SdkService.php (modified) (10 diffs)
-
tags/6.6.0/src/Services/ShoppingCartService.php (modified) (3 diffs)
-
tags/6.6.0/src/Utils/Logger.php (modified) (11 diffs)
-
tags/6.6.0/src/Utils/Order.php (added)
-
tags/6.6.0/vendor/autoload.php (modified) (1 diff)
-
tags/6.6.0/vendor/composer/autoload_real.php (modified) (2 diffs)
-
tags/6.6.0/vendor/composer/autoload_static.php (modified) (2 diffs)
-
tags/6.6.0/vendor/composer/installed.json (modified) (3 diffs)
-
tags/6.6.0/vendor/composer/installed.php (modified) (3 diffs)
-
tags/6.6.0/vendor/multisafepay/php-sdk/CHANGELOG.md (modified) (2 diffs)
-
tags/6.6.0/vendor/multisafepay/php-sdk/composer.json (modified) (1 diff)
-
tags/6.6.0/vendor/multisafepay/php-sdk/src/Api/Base/Response.php (modified) (5 diffs)
-
tags/6.6.0/vendor/multisafepay/php-sdk/src/Api/Transactions/TransactionResponse.php (modified) (2 diffs)
-
tags/6.6.0/vendor/multisafepay/php-sdk/src/Client/Client.php (modified) (11 diffs)
-
tags/6.6.0/vendor/multisafepay/php-sdk/src/Exception/ApiUnavailableException.php (added)
-
tags/6.6.0/vendor/multisafepay/php-sdk/src/Util/Version.php (modified) (1 diff)
-
trunk/multisafepay.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/src/Client/MultiSafepayClient.php (modified) (2 diffs)
-
trunk/src/PaymentMethods/Base/BaseBrandedPaymentMethod.php (added)
-
trunk/src/PaymentMethods/Base/BasePaymentMethod.php (modified) (3 diffs)
-
trunk/src/PaymentMethods/Base/BasePaymentMethodBlocks.php (modified) (1 diff)
-
trunk/src/PaymentMethods/Base/BaseRefunds.php (modified) (4 diffs)
-
trunk/src/PaymentMethods/PaymentMethodCallback.php (modified) (12 diffs)
-
trunk/src/PaymentMethods/PaymentMethodsController.php (modified) (17 diffs)
-
trunk/src/Services/ApiTokenService.php (modified) (2 diffs)
-
trunk/src/Services/OrderService.php (modified) (1 diff)
-
trunk/src/Services/PaymentMethodService.php (modified) (7 diffs)
-
trunk/src/Services/SdkService.php (modified) (10 diffs)
-
trunk/src/Services/ShoppingCartService.php (modified) (3 diffs)
-
trunk/src/Utils/Logger.php (modified) (11 diffs)
-
trunk/src/Utils/Order.php (added)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (2 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.json (modified) (3 diffs)
-
trunk/vendor/composer/installed.php (modified) (3 diffs)
-
trunk/vendor/multisafepay/php-sdk/CHANGELOG.md (modified) (2 diffs)
-
trunk/vendor/multisafepay/php-sdk/composer.json (modified) (1 diff)
-
trunk/vendor/multisafepay/php-sdk/src/Api/Base/Response.php (modified) (5 diffs)
-
trunk/vendor/multisafepay/php-sdk/src/Api/Transactions/TransactionResponse.php (modified) (2 diffs)
-
trunk/vendor/multisafepay/php-sdk/src/Client/Client.php (modified) (11 diffs)
-
trunk/vendor/multisafepay/php-sdk/src/Exception/ApiUnavailableException.php (added)
-
trunk/vendor/multisafepay/php-sdk/src/Util/Version.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
multisafepay/tags/6.6.0/multisafepay.php
r3099249 r3114383 5 5 * Plugin URI: https://docs.multisafepay.com/docs/woocommerce 6 6 * Description: MultiSafepay Payment Plugin 7 * Version: 6. 5.17 * Version: 6.6.0 8 8 * Author: MultiSafepay 9 9 * Author URI: https://www.multisafepay.com … … 12 12 * License URI: http://www.gnu.org/licenses/gpl-3.0.html 13 13 * Requires at least: 6.0 14 * Tested up to: 6.5. 414 * Tested up to: 6.5.5 15 15 * WC requires at least: 6.0.0 16 * WC tested up to: 8.8.316 * WC tested up to: 9.0.2 17 17 * Requires PHP: 7.3 18 18 * Text Domain: multisafepay … … 27 27 * Plugin version 28 28 */ 29 define( 'MULTISAFEPAY_PLUGIN_VERSION', '6. 5.1' );29 define( 'MULTISAFEPAY_PLUGIN_VERSION', '6.6.0' ); 30 30 31 31 /** -
multisafepay/tags/6.6.0/readme.txt
r3099249 r3114383 3 3 Tags: multisafepay, payment gateway, credit cards, ideal, bnpl 4 4 Requires at least: 6.0 5 Tested up to: 6.5. 45 Tested up to: 6.5.5 6 6 Requires PHP: 7.3 7 Stable tag: 6. 5.17 Stable tag: 6.6.0 8 8 License: MIT 9 9 … … 128 128 == Upgrade Notice == 129 129 130 = 6. 5.1=130 = 6.6.0 = 131 131 6.x.x is a major upgrade in which the MultiSafepay payment methods are registered dynamically via an API request to MultiSafepay. If you are upgrading from 5.X.X version, after the upgrade, please navigate to the MultiSafepay settings page, and to each one of the payment methods enabled in your account, and confirm the settings in each section are set up according to your preferences. 132 132 … … 144 144 145 145 == Changelog == 146 = Release Notes - WooCommerce 6.6.0 (Jul 8th, 2024) = 147 148 ### Added 149 + PLGWOOS-946: Add support for branded credit and debit cards 150 151 ### Changed 152 + PLGWOOS-943: Refactor PaymentMethodCallback class (#574) 153 + PLGWOOS-948: General improvements to increase unit test coverage 154 146 155 = Release Notes - WooCommerce 6.5.1 (Jun 7th, 2024) = 147 156 -
multisafepay/tags/6.6.0/src/Client/MultiSafepayClient.php
r3090804 r3114383 14 14 */ 15 15 class MultiSafepayClient implements ClientInterface { 16 17 /** 18 * @var Logger 19 */ 20 private $logger; 21 22 /** 23 * @param Logger|null $logger 24 */ 25 public function __construct( ?Logger $logger = null ) { 26 $this->logger = $logger ?? new Logger(); 27 } 16 28 17 29 /** … … 33 45 } 34 46 } catch ( Exception $exception ) { 35 Logger::log_error( 'Error when process request via MultiSafepayClient: ' . $exception->getMessage() );47 $this->logger->log_error( 'Error when process request via MultiSafepayClient: ' . $exception->getMessage() ); 36 48 throw new Exception( $exception->getMessage() ); 37 49 } -
multisafepay/tags/6.6.0/src/PaymentMethods/Base/BasePaymentMethod.php
r3099249 r3114383 109 109 110 110 /** 111 * Defines if the payment method is tokenizable 111 * @var Logger 112 */ 113 private $logger; 114 115 /** 116 * BasePaymentMethod constructor. 112 117 * 113 118 * @param PaymentMethod $payment_method 114 */ 115 public function __construct( PaymentMethod $payment_method ) { 119 * @param Logger|null $logger 120 */ 121 public function __construct( PaymentMethod $payment_method, ?Logger $logger = null ) { 122 $this->logger = $logger ?? new Logger(); 116 123 $this->payment_method = $payment_method; 117 124 $this->supports = array( 'products', 'refunds' ); … … 636 643 $transaction = $transaction_manager->create( $order_request ); 637 644 } catch ( ApiException | ClientExceptionInterface $exception ) { 638 Logger::log_error( $exception->getMessage() );645 $this->logger->log_error( $exception->getMessage() ); 639 646 wc_add_notice( __( 'There was a problem processing your payment. Please try again later or contact with us.', 'multisafepay' ), 'error' ); 640 647 return; … … 642 649 643 650 if ( get_option( 'multisafepay_debugmode', false ) ) { 644 Logger::log_info( 'Start MultiSafepay transaction for the order ID ' . $order_id . ' on ' . date( 'd/m/Y H:i:s' ) . ' with payment URL ' . $transaction->getPaymentUrl() );651 $this->logger->log_info( 'Start MultiSafepay transaction for the order ID ' . $order_id . ' on ' . date( 'd/m/Y H:i:s' ) . ' with payment URL ' . $transaction->getPaymentUrl() ); 645 652 } 646 653 -
multisafepay/tags/6.6.0/src/PaymentMethods/Base/BasePaymentMethodBlocks.php
r3090804 r3114383 42 42 $multisafepay_payment_methods = $payment_method_service->get_multisafepay_payment_methods_from_api(); 43 43 foreach ( $multisafepay_payment_methods as $multisafepay_payment_method ) { 44 $woocommerce_payment_gateway = null; 44 $woocommerce_payment_gateways = array(); 45 45 46 if ( isset( $multisafepay_payment_method['type'] ) && ( 'coupon' === $multisafepay_payment_method['type'] ) ) { 46 $woocommerce_payment_gateway = new BaseGiftCardPaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 47 } 48 if ( isset( $multisafepay_payment_method['type'] ) && ( 'payment-method' === $multisafepay_payment_method['type'] ) ) { 49 $woocommerce_payment_gateway = new BasePaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 47 $woocommerce_payment_gateways[] = new BaseGiftCardPaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 50 48 } 51 49 52 // Include direct payment methods without components just in the checkout page of the frontend context 53 if ( 54 $woocommerce_payment_gateway->check_direct_payment_methods_without_components() && 55 ! $woocommerce_payment_gateway->admin_editing_checkout_page() 56 ) { 57 $this->gateways[] = $woocommerce_payment_gateway; 50 if ( isset( $multisafepay_payment_method['type'] ) && ( 'payment-method' === $multisafepay_payment_method['type'] ) ) { 51 $woocommerce_payment_gateways[] = new BasePaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 52 foreach ( $multisafepay_payment_method['brands'] as $brand ) { 53 if ( ! empty( $brand['allowed_countries'] ) ) { 54 $woocommerce_payment_gateways[] = new BaseBrandedPaymentMethod( new PaymentMethod( $multisafepay_payment_method ), $brand ); 55 } 56 } 58 57 } 59 58 60 if ( ( 'redirect' === $woocommerce_payment_gateway->get_payment_method_type() ) && $woocommerce_payment_gateway->is_available() ) { 61 $this->gateways[] = $woocommerce_payment_gateway; 59 foreach ( $woocommerce_payment_gateways as $woocommerce_payment_gateway ) { 60 // Include direct payment methods without components just in the checkout page of the frontend context 61 if ( 62 $woocommerce_payment_gateway->check_direct_payment_methods_without_components() && 63 ! $woocommerce_payment_gateway->admin_editing_checkout_page() 64 ) { 65 $this->gateways[] = $woocommerce_payment_gateway; 66 } 67 68 if ( ( 'redirect' === $woocommerce_payment_gateway->get_payment_method_type() ) && $woocommerce_payment_gateway->is_available() ) { 69 $this->gateways[] = $woocommerce_payment_gateway; 70 } 62 71 } 63 72 } -
multisafepay/tags/6.6.0/src/PaymentMethods/Base/BaseRefunds.php
r3048898 r3114383 10 10 use MultiSafepay\ValueObject\CartItem; 11 11 use MultiSafepay\WooCommerce\Services\SdkService; 12 use MultiSafepay\WooCommerce\Utils\Logger;13 12 use MultiSafepay\WooCommerce\Utils\MoneyUtil; 14 13 use Psr\Http\Client\ClientExceptionInterface; … … 76 75 } catch ( Exception | ClientExceptionInterface | ApiException $exception ) { 77 76 $error = __( 'Error:', 'multisafepay' ) . htmlspecialchars( $exception->getMessage() ); 78 Logger::log_error( $error );77 $this->logger->log_error( $error ); 79 78 wc_add_notice( $error, 'error' ); 80 79 } … … 83 82 /* translators: %1$: The currency code. %2$ The transaction amount */ 84 83 $note = sprintf( __( 'Refund of %1$s%2$s has been processed successfully.', 'multisafepay' ), get_woocommerce_currency_symbol( $order->get_currency() ), $amount ); 85 Logger::log_info( $note );84 $this->logger->log_info( $note ); 86 85 $order->add_order_note( $note ); 87 86 return true; … … 91 90 /* translators: %1$: The order ID. %2$ The PSP transaction ID */ 92 91 $message = sprintf( __( 'Refund for Order ID: %1$s with transactionId: %2$s gives message: %3$s.', 'multisafepay' ), $order_id, $multisafepay_transaction->getTransactionId(), $error ); 93 Logger::log_warning( $message );92 $this->logger->log_warning( $message ); 94 93 } 95 94 -
multisafepay/tags/6.6.0/src/PaymentMethods/PaymentMethodCallback.php
r3048898 r3114383 10 10 use MultiSafepay\WooCommerce\Settings\SettingsFields; 11 11 use MultiSafepay\WooCommerce\Utils\Logger; 12 use MultiSafepay\WooCommerce\Utils\Order as OrderUtil; 12 13 use Psr\Http\Client\ClientExceptionInterface; 13 14 use WC_Data_Exception; … … 57 58 58 59 /** 59 * PaymentMethodCallback constructor 60 * 61 * @param string $multisafepay_order_id 62 * @param ?TransactionResponse $multisafepay_transaction 63 */ 64 public function __construct( string $multisafepay_order_id, $multisafepay_transaction = null ) { 65 $this->multisafepay_order_id = $multisafepay_order_id; 66 67 if ( ! isset( $multisafepay_transaction ) ) { 68 $multisafepay_transaction = $this->get_transaction(); 69 } 70 71 $this->multisafepay_transaction = $multisafepay_transaction; 72 73 // For most transactions, var2 contains the order id since the order request is being register using order number 74 if ( ! empty( $this->multisafepay_transaction->getVar2() ) ) { 75 $this->woocommerce_order_id = (int) $this->multisafepay_transaction->getVar2(); 76 } 77 78 // In case we need it, a filter to set the right order id, based on order number 79 if ( empty( $this->multisafepay_transaction->getVar2() ) ) { 80 $this->woocommerce_order_id = apply_filters( 'multisafepay_transaction_order_id', $this->multisafepay_order_id ); 81 } 82 83 $this->time_stamp = date( 'd/m/Y H:i:s' ); 84 $this->order = wc_get_order( $this->woocommerce_order_id ); 60 * @var Logger 61 */ 62 private $logger; 63 64 /** 65 * @param string $multisafepay_order_id 66 * @param TransactionResponse|null $multisafepay_transaction 67 * @param Logger|null $logger 68 */ 69 public function __construct( string $multisafepay_order_id, ?TransactionResponse $multisafepay_transaction = null, ?Logger $logger = null ) { 70 $this->logger = $logger ?? new Logger(); 71 $this->multisafepay_order_id = $multisafepay_order_id; 72 $this->multisafepay_transaction = $multisafepay_transaction ?? $this->get_transaction(); 73 $this->woocommerce_order_id = $this->get_woocommerce_order_id(); 74 $this->time_stamp = date( 'd/m/Y H:i:s' ); 75 $this->order = wc_get_order( $this->woocommerce_order_id ); 85 76 } 86 77 … … 95 86 $transaction = $transaction_manager->get( $this->multisafepay_order_id ); 96 87 } catch ( ClientExceptionInterface $client_exception ) { 97 Logger::log_error( $client_exception->getMessage() );88 $this->logger->log_error( $client_exception->getMessage() ); 98 89 wp_die( esc_html__( 'Invalid request', 'multisafepay' ), esc_html__( 'Invalid request', 'multisafepay' ), 400 ); 99 90 } catch ( ApiException $api_exception ) { 100 Logger::log_error( $api_exception->getMessage() );91 $this->logger->log_error( $api_exception->getMessage() ); 101 92 wp_die( esc_html__( 'Invalid request', 'multisafepay' ), esc_html__( 'Invalid request', 'multisafepay' ), 400 ); 102 93 } … … 105 96 106 97 /** 98 * Return the WooCommerce order id 99 * 100 * @return int 101 */ 102 private function get_woocommerce_order_id(): int { 103 // For most transactions, var2 contains the order id since the order request is being registered using order number 104 if ( ! empty( $this->multisafepay_transaction->getVar2() ) ) { 105 return (int) $this->multisafepay_transaction->getVar2(); 106 } 107 return apply_filters( 'multisafepay_transaction_order_id', $this->multisafepay_order_id ); 108 } 109 110 /** 107 111 * Return the WooCommerce order status 108 112 * 109 113 * @return string 110 114 */ 111 private function get_w c_order_status(): string {115 private function get_woocommerce_order_status(): string { 112 116 return $this->order->get_status(); 113 117 } … … 164 168 165 169 /** 170 * Return the initial order status configured in the payment method settings 171 * 172 * @return string|null 173 */ 174 private function get_initial_order_status(): ?string { 175 $registered_payment_method = ( new PaymentMethodService() )->get_woocommerce_payment_gateway_by_id( $this->order->get_payment_method() ); 176 return $registered_payment_method ? $registered_payment_method->initial_order_status : null; 177 } 178 179 /** 166 180 * Check if the order status should be updated or not 167 181 * … … 170 184 private function should_status_be_updated(): bool { 171 185 // Check if the WooCommerce completed order status is considered as the final one 172 if ( $this->is_completed_the_final_status( $this->get_w c_order_status() ) ) {186 if ( $this->is_completed_the_final_status( $this->get_woocommerce_order_status() ) ) { 173 187 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 174 188 $message = 'It seems a notification is trying to process an order which already has defined completed as the final order status. For this reason notification is being ignored. Transaction ID received is ' . sanitize_text_field( (string) wp_unslash( $this->get_multisafepay_transaction_id() ) ) . ' with status ' . $this->get_multisafepay_transaction_status(); 175 Logger::log_warning( $message );189 $this->logger->log_warning( $message ); 176 190 $this->order->add_order_note( $message ); 177 191 return false; … … 191 205 // On pre-transactions notification, and using sequential order numbers plugins, var 2 is not received in the notification, then order doesn't exist 192 206 if ( ! $this->order ) { 193 if ( get_option( 'multisafepay_debugmode', false ) ) { 194 Logger::log_info( 'Notification has been received for the transaction ID ' . $this->multisafepay_order_id . ' but WooCommerce order object has not been found' ); 195 } 207 $this->logger->log_info( 'Notification has been received for the transaction ID ' . $this->multisafepay_order_id . ' but WooCommerce order object has not been found' ); 196 208 header( 'Content-type: text/plain' ); 197 209 die( 'OK' ); … … 199 211 200 212 // If payment method of the order does not belong to MultiSafepay 201 if ( strpos( $this->order->get_payment_method(), 'multisafepay_' ) === false ) { 202 if ( get_option( 'multisafepay_debugmode', false ) ) { 203 $message = 'It seems a notification is trying to process an order processed by another payment method. Transaction ID received is ' . $this->order->get_id(); 204 Logger::log_info( $message ); 205 } 206 header( 'Content-type: text/plain' ); 207 die( 'OK' ); 208 } 209 210 if ( $this->get_wc_order_status() === 'trash' ) { 211 if ( get_option( 'multisafepay_debugmode', false ) ) { 212 $message = 'It seems a notification is trying to change the order status, but the order has been moved to the trash. Transaction ID received is ' . $this->order->get_id() . ' and transaction status is ' . $this->get_multisafepay_transaction_status(); 213 Logger::log_info( $message ); 214 $this->order->add_order_note( $message ); 215 } 213 if ( ! OrderUtil::is_multisafepay_order( $this->order ) ) { 214 $message = 'It seems a notification is trying to process an order processed by another payment method. Transaction ID received is ' . $this->order->get_id(); 215 $this->logger->log_info( $message ); 216 header( 'Content-type: text/plain' ); 217 die( 'OK' ); 218 } 219 220 if ( $this->get_woocommerce_order_status() === 'trash' ) { 221 $message = 'It seems a notification is trying to change the order status, but the order has been moved to the trash. Transaction ID received is ' . $this->order->get_id() . ' and transaction status is ' . $this->get_multisafepay_transaction_status(); 222 $this->logger->log_info( $message ); 223 OrderUtil::add_order_note( $this->order, $message, true ); 216 224 header( 'Content-type: text/plain' ); 217 225 die( 'OK' ); … … 221 229 if ( $this->get_multisafepay_transaction_status() === Transaction::PARTIAL_REFUNDED ) { 222 230 $message = 'A partial refund has been registered within MultiSafepay Control for Order ID: ' . $this->woocommerce_order_id . ' and Order Number: ' . $this->multisafepay_order_id; 223 $this->order->add_order_note($message );231 OrderUtil::add_order_note( $this->order, $message ); 224 232 header( 'Content-type: text/plain' ); 225 233 die( 'OK' ); … … 231 239 $payment_method_id_registered_by_wc = $this->order->get_payment_method(); 232 240 $payment_method_title_registered_by_wc = $this->order->get_payment_method_title(); 233 $registered_by_woocommerce_payment_method_object = ( new PaymentMethodService() )->get_woocommerce_payment_gateway_by_id( $payment_method_id_registered_by_wc ); 234 $initial_order_status = $registered_by_woocommerce_payment_method_object ? $registered_by_woocommerce_payment_method_object->initial_order_status : false; 241 $initial_order_status = $this->get_initial_order_status(); 235 242 $default_order_status = SettingsFields::get_multisafepay_order_statuses(); 236 243 … … 238 245 // Or if the custom initial order status of the gateway is different than the general one, and the MultiSafepay transaction status is initialized, and custom initial order status is different than the current WooCommerce order status 239 246 if ( 240 $this->get_w c_order_status() !== str_replace( 'wc-', '', get_option( 'multisafepay_' . $this->get_multisafepay_transaction_status() . '_status', $default_order_status[ $this->get_multisafepay_transaction_status() . '_status' ]['default'] ) ) ||241 get_option( 'multisafepay_' . $this->get_multisafepay_transaction_status() . '_status', $default_order_status[ $this->get_multisafepay_transaction_status() . '_status' ]['default'] ) !== $initial_order_status && $this->get_multisafepay_transaction_status() === Transaction::INITIALIZED && $this->get_w c_order_status() !== $initial_order_status247 $this->get_woocommerce_order_status() !== str_replace( 'wc-', '', get_option( 'multisafepay_' . $this->get_multisafepay_transaction_status() . '_status', $default_order_status[ $this->get_multisafepay_transaction_status() . '_status' ]['default'] ) ) || 248 get_option( 'multisafepay_' . $this->get_multisafepay_transaction_status() . '_status', $default_order_status[ $this->get_multisafepay_transaction_status() . '_status' ]['default'] ) !== $initial_order_status && $this->get_multisafepay_transaction_status() === Transaction::INITIALIZED && $this->get_woocommerce_order_status() !== $initial_order_status 242 249 ) { 243 244 250 // If MultiSafepay transaction status is initialized, check if there is a custom initial order status for this payment method. 245 251 if ( $this->get_multisafepay_transaction_status() === Transaction::INITIALIZED ) { 246 if ( $initial_order_status && 'wc-default' !== $initial_order_status && $this->get_w c_order_status() !== $initial_order_status ) {252 if ( $initial_order_status && 'wc-default' !== $initial_order_status && $this->get_woocommerce_order_status() !== $initial_order_status ) { 247 253 $this->order->update_status( str_replace( 'wc-', '', $initial_order_status ), __( 'Transaction has been initialized.', 'multisafepay' ) ); 248 254 } … … 266 272 } 267 273 268 if ( get_option( 'multisafepay_debugmode', false ) ) { 269 $message = 'Callback received for Order ID: ' . $this->woocommerce_order_id . ' and Order Number: ' . $this->multisafepay_order_id . ' on ' . $this->time_stamp . ' with status: ' . $this->get_multisafepay_transaction_status() . ' and PSP ID: ' . $this->get_multisafepay_transaction_id() . '.'; 270 Logger::log_info( $message ); 271 $this->order->add_order_note( $message ); 272 } 274 $message = 'Callback received for Order ID: ' . $this->woocommerce_order_id . ' and Order Number: ' . $this->multisafepay_order_id . ' on ' . $this->time_stamp . ' with status: ' . $this->get_multisafepay_transaction_status() . ' and PSP ID: ' . $this->get_multisafepay_transaction_id() . '.'; 275 $this->logger->log_info( $message ); 276 OrderUtil::add_order_note( $this->order, $message, true ); 273 277 } 274 278 275 279 // If the payment method changed in MultiSafepay payment page, after leave WooCommerce checkout page 276 280 if ( $payment_method_id_registered_by_multisafepay && $payment_method_id_registered_by_wc !== $payment_method_id_registered_by_multisafepay ) { 277 if ( get_option( 'multisafepay_debugmode', false ) ) { 278 $message = 'Callback received with a different payment method for Order ID: ' . $this->woocommerce_order_id . ' and Order Number: ' . $this->multisafepay_order_id . ' on ' . $this->time_stamp . '. Payment method changed from ' . $payment_method_title_registered_by_wc . ' to ' . $payment_method_title_registered_by_multisafepay . '.'; 279 Logger::log_info( $message ); 280 $this->order->add_order_note( $message ); 281 } 282 281 $message = 'Callback received with a different payment method for Order ID: ' . $this->woocommerce_order_id . ' and Order Number: ' . $this->multisafepay_order_id . ' on ' . $this->time_stamp . '. Payment method changed from ' . $payment_method_title_registered_by_wc . ' to ' . $payment_method_title_registered_by_multisafepay . '.'; 282 $this->logger->log_info( $message ); 283 OrderUtil::add_order_note( $this->order, $message, true ); 283 284 $this->order = wc_get_order( $this->woocommerce_order_id ); 284 285 $this->order->set_payment_method( $registered_by_multisafepay_payment_method_object ); -
multisafepay/tags/6.6.0/src/PaymentMethods/PaymentMethodsController.php
r3050467 r3114383 6 6 use MultiSafepay\Api\Transactions\TransactionResponse; 7 7 use MultiSafepay\Api\Transactions\UpdateRequest; 8 use MultiSafepay\Api\Wallets\ApplePay\MerchantSessionRequest; 8 9 use MultiSafepay\Exception\ApiException; 9 use MultiSafepay\Api\Wallets\ApplePay\MerchantSessionRequest;10 10 use MultiSafepay\Util\Notification; 11 11 use MultiSafepay\WooCommerce\Services\OrderService; … … 14 14 use MultiSafepay\WooCommerce\Utils\Hpos; 15 15 use MultiSafepay\WooCommerce\Utils\Logger; 16 use MultiSafepay\WooCommerce\Utils\Order as OrderUtil; 16 17 use Psr\Http\Client\ClientExceptionInterface; 17 18 use WC_Data_Exception; … … 26 27 public const VALIDATION_URL_KEY = 'validation_url'; 27 28 public const ORIGIN_DOMAIN_KEY = 'origin_domain'; 29 30 /** 31 * @var Logger 32 */ 33 private $logger; 34 35 /** 36 * @param Logger|null $logger 37 */ 38 public function __construct( ?Logger $logger = null ) { 39 $this->logger = $logger ?? new Logger(); 40 } 28 41 29 42 /** … … 104 117 public function set_multisafepay_transaction_as_shipped( int $order_id ): void { 105 118 $order = wc_get_order( $order_id ); 106 if ( strpos( $order->get_payment_method(), 'multisafepay_' ) !== false) {119 if ( OrderUtil::is_multisafepay_order( $order ) ) { 107 120 $sdk = new SdkService(); 108 121 $transaction_manager = $sdk->get_transaction_manager(); … … 112 125 $transaction_manager->update( (string) $order->get_order_number(), $update_order ); 113 126 } catch ( ApiException $api_exception ) { 114 Logger::log_error( $api_exception->getMessage() );127 $this->logger->log_error( $api_exception->getMessage() ); 115 128 return; 116 129 } … … 128 141 public function set_multisafepay_transaction_as_invoiced( int $order_id ): void { 129 142 $order = wc_get_order( $order_id ); 130 if ( strpos( $order->get_payment_method(), 'multisafepay_' ) !== false) {143 if ( OrderUtil::is_multisafepay_order( $order ) ) { 131 144 $sdk = new SdkService(); 132 145 $transaction_manager = $sdk->get_transaction_manager(); … … 136 149 $transaction_manager->update( (string) $order->get_order_number(), $update_order ); 137 150 } catch ( ApiException $api_exception ) { 138 Logger::log_error( $api_exception->getMessage() );151 $this->logger->log_error( $api_exception->getMessage() ); 139 152 return; 140 153 } … … 178 191 179 192 if ( ! $request->sanitize_params() ) { 180 Logger::log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but could not be sanitized' );193 $this->logger->log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but could not be sanitized' ); 181 194 header( 'Content-type: text/plain' ); 182 195 die( 'OK' ); … … 185 198 $payload_type = $request->get_param( 'payload_type' ) ?? ''; 186 199 if ( 'pretransaction' === $payload_type ) { 187 Logger::log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but is going to be ignored, because is pretransaction type' );200 $this->logger->log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but is going to be ignored, because is pretransaction type' ); 188 201 header( 'Content-type: text/plain' ); 189 202 die( 'OK' ); … … 196 209 197 210 if ( ! $verify_notification ) { 198 Logger::log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but is not validated' );211 $this->logger->log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but is not validated' ); 199 212 header( 'Content-type: text/plain' ); 200 213 die( 'OK' ); … … 202 215 203 216 if ( get_option( 'multisafepay_debugmode', false ) ) { 204 Logger::log_info( 'Notification has been received and validated for transaction id ' . $transactionid );217 $this->logger->log_info( 'Notification has been received and validated for transaction id ' . $transactionid ); 205 218 206 219 if ( ! empty( $body ) ) { 207 Logger::log_info( 'Body of the POST notification: ' . wc_print_r( $body, true ) );220 $this->logger->log_info( 'Body of the POST notification: ' . wc_print_r( $body, true ) ); 208 221 } 209 222 } … … 250 263 251 264 // Check if the payment method belongs to MultiSafepay 252 if ( strpos( $order->get_payment_method(), 'multisafepay_' ) === false) {265 if ( ! OrderUtil::is_multisafepay_order( $order ) ) { 253 266 return; 254 267 } … … 260 273 $gateway_object = ( new PaymentMethodService() )->get_woocommerce_payment_gateway_by_id( $order->get_payment_method() ); 261 274 if ( ! $gateway_object ) { 262 Logger::log_error( ' Gateway object is null ' );275 $this->logger->log_error( ' Gateway object is null ' ); 263 276 return; 264 277 } … … 275 288 if ( get_option( 'multisafepay_debugmode', false ) ) { 276 289 $message = 'Order details has been registered in MultiSafepay and a payment link has been generated: ' . esc_url( $transaction->getPaymentUrl() ); 277 Logger::log_info( $message );290 $this->logger->log_info( $message ); 278 291 $order->add_order_note( $message ); 279 292 } 280 293 } 281 294 } catch ( Exception | ApiException | ClientExceptionInterface $exception ) { 282 Logger::log_error( $exception->getMessage() );295 $this->logger->log_error( $exception->getMessage() ); 283 296 } 284 297 } … … 326 339 */ 327 340 public function allow_cancel_multisafepay_orders_with_on_hold_status( array $order_status, WC_Order $order ): array { 328 if ( strpos( $order->get_payment_method(), 'multisafepay_' ) !== false) {341 if ( OrderUtil::is_multisafepay_order( $order ) ) { 329 342 $gateway = ( new PaymentMethodService() )->get_woocommerce_payment_gateway_by_id( $order->get_payment_method() ); 330 343 if ( ! $gateway ) { 331 Logger::log_error( ' Gateway object is null ' );344 $this->logger->log_error( ' Gateway object is null ' ); 332 345 return $order_status; 333 346 } … … 363 376 } catch ( ApiException | Exception | ClientExceptionInterface $exception ) { 364 377 $error_message = 'Error when trying to get the ApplePay session via MultiSafepay SDK'; 365 Logger::log_error( $error_message . ': ' . $exception->getMessage() );378 $this->logger->log_error( $error_message . ': ' . $exception->getMessage() ); 366 379 wp_send_json( array( 'message' => $error_message ) ); 367 380 } … … 397 410 398 411 if ( empty( $validation_url ) ) { 399 Logger::log_error( 'Error when trying to get the ApplePay session. Validation URL empty' );412 $this->logger->log_error( 'Error when trying to get the ApplePay session. Validation URL empty' ); 400 413 exit; 401 414 } 402 415 403 416 if ( empty( $origin_domain ) ) { 404 Logger::log_error( 'Error when trying to get the ApplePay session. Origin domain empty' );417 $this->logger->log_error( 'Error when trying to get the ApplePay session. Origin domain empty' ); 405 418 exit; 406 419 } -
multisafepay/tags/6.6.0/src/Services/ApiTokenService.php
r2974626 r3114383 26 26 27 27 /** 28 * @var Logger 29 */ 30 private $logger; 31 32 /** 28 33 * ApiTokenService constructor. 34 * 35 * @param Logger|null $logger 29 36 */ 30 public function __construct() { 37 public function __construct( ?Logger $logger = null ) { 38 $this->logger = $logger ?? new Logger(); 31 39 $this->api_token_manager = ( new SdkService() )->get_api_token_manager(); 32 40 } … … 50 58 $api_token = $this->api_token_manager->get()->getApiToken(); 51 59 } catch ( ApiException | ClientExceptionInterface $exception ) { 52 Logger::log_error( $exception->getMessage() );60 $this->logger->log_error( $exception->getMessage() ); 53 61 return ''; 54 62 } -
multisafepay/tags/6.6.0/src/Services/OrderService.php
r3048898 r3114383 74 74 } 75 75 76 if ( ! empty( $_POST[ ( $this->payment_method_service->get_woocommerce_payment_gateway_by_multisafepay_gateway_code( $gateway_code ) )->get_payment_method_id() . '_payment_component_payload' ] ) ) {77 $payment_method_id = ( new PaymentMethodService() )->get_woocommerce_payment_gateway_by_multisafepay_gateway_code( $gateway_code )->get_payment_method_id();76 if ( ! empty( $_POST[ $order->get_payment_method() . '_payment_component_payload' ] ) ) { 77 $payment_method_id = $order->get_payment_method(); 78 78 $payment_component_payload_key = $payment_method_id . '_payment_component_payload'; 79 79 $payment_component_payload = sanitize_text_field( wp_unslash( $_POST[ $payment_component_payload_key ] ?? '' ) ); -
multisafepay/tags/6.6.0/src/Services/PaymentMethodService.php
r3088253 r3114383 10 10 use MultiSafepay\WooCommerce\PaymentMethods\Base\BaseGiftCardPaymentMethod; 11 11 use MultiSafepay\WooCommerce\PaymentMethods\Base\BasePaymentMethod; 12 use MultiSafepay\WooCommerce\PaymentMethods\Base\BaseBrandedPaymentMethod; 12 13 use MultiSafepay\WooCommerce\Utils\Logger; 13 14 use Psr\Http\Client\ClientExceptionInterface; … … 31 32 32 33 /** 33 * PaymentMethodsService constructor. 34 * 35 * @return void 36 */ 37 public function __construct() { 34 * @var Logger 35 */ 36 private $logger; 37 38 /** 39 * @param Logger|null $logger 40 */ 41 public function __construct( ?Logger $logger = null ) { 42 $this->logger = $logger ?? new Logger(); 38 43 try { 39 44 $this->payment_method_manager = ( new SdkService() )->get_payment_method_manager(); 40 45 } catch ( ApiException $api_exception ) { 41 Logger::log_error( $api_exception->getMessage() );46 $this->logger->log_error( $api_exception->getMessage() ); 42 47 } 43 48 } … … 75 80 76 81 if ( null === $this->payment_method_manager ) { 77 Logger::log_error( 'SDK is not initialized' );82 $this->logger->log_error( 'SDK is not initialized' ); 78 83 return array(); 79 84 } … … 90 95 ); 91 96 } catch ( Exception | ApiException | InvalidDataInitializationException | ClientExceptionInterface $exception ) { 92 Logger::log_error( $exception->getMessage() );97 $this->logger->log_error( $exception->getMessage() ); 93 98 return array(); 94 99 } … … 108 113 $multisafepay_payment_methods = $this->get_multisafepay_payment_methods_from_api(); 109 114 foreach ( $multisafepay_payment_methods as $multisafepay_payment_method ) { 110 if ( isset( $multisafepay_payment_method['type'] ) && 'coupon' === $multisafepay_payment_method['type'] ) { 111 $woocommerce_payment_gateways[ self::get_legacy_woocommerce_payment_gateway_ids( $multisafepay_payment_method['id'] ) ] = new BaseGiftCardPaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 112 } 113 if ( isset( $multisafepay_payment_method['type'] ) && 'payment-method' === $multisafepay_payment_method['type'] ) { 114 $woocommerce_payment_gateways[ self::get_legacy_woocommerce_payment_gateway_ids( $multisafepay_payment_method['id'] ) ] = new BasePaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 115 } 116 } 115 if ( isset( $multisafepay_payment_method['type'] ) ) { 116 $woocommerce_payment_gateways = $this->create_woocommerce_payment_gateways( $multisafepay_payment_method, $woocommerce_payment_gateways ); 117 } 118 } 119 120 return $woocommerce_payment_gateways; 121 } 122 123 /** 124 * @param array $multisafepay_payment_method 125 * @param array $woocommerce_payment_gateways 126 * @return array 127 */ 128 public function create_woocommerce_payment_gateways( array $multisafepay_payment_method, array $woocommerce_payment_gateways ) : array { 129 $payment_method_id = self::get_legacy_woocommerce_payment_gateway_ids( $multisafepay_payment_method['id'] ); 130 131 try { 132 $payment_method = new PaymentMethod( $multisafepay_payment_method ); 133 } catch ( InvalidDataInitializationException $exception ) { 134 $this->logger->log_error( $exception->getMessage() ); 135 return $woocommerce_payment_gateways; 136 } 137 138 if ( 'payment-method' === $multisafepay_payment_method['type'] ) { 139 $woocommerce_payment_gateways[ $payment_method_id ] = new BasePaymentMethod( $payment_method ); 140 $woocommerce_payment_gateways = $this->create_branded_woocommerce_payment_gateways( $multisafepay_payment_method, $woocommerce_payment_gateways, $payment_method ); 141 } 142 143 if ( 'coupon' === $multisafepay_payment_method['type'] ) { 144 $woocommerce_payment_gateways[ $payment_method_id ] = new BaseGiftCardPaymentMethod( $payment_method ); 145 } 146 147 return $woocommerce_payment_gateways; 148 } 149 150 /** 151 * @param array $multisafepay_payment_method 152 * @param array $woocommerce_payment_gateways 153 * @param PaymentMethod $payment_method 154 * @return array 155 */ 156 public function create_branded_woocommerce_payment_gateways( array $multisafepay_payment_method, array $woocommerce_payment_gateways, PaymentMethod $payment_method ) : array { 157 foreach ( $multisafepay_payment_method['brands'] as $brand ) { 158 if ( ! empty( $brand['allowed_countries'] ) ) { 159 $payment_method_id = self::get_legacy_woocommerce_payment_gateway_ids( $brand['id'] ); 160 $woocommerce_payment_gateways[ $payment_method_id ] = new BaseBrandedPaymentMethod( $payment_method, $brand ); 161 } 162 } 163 117 164 return $woocommerce_payment_gateways; 118 165 } … … 174 221 if ( $payment_method_object->supportsPaymentComponent() ) { 175 222 $payment_methods_with_payment_component[] = self::get_legacy_woocommerce_payment_gateway_ids( $payment_method_object->getId() ); 223 foreach ( $payment_method['brands'] as $brand ) { 224 if ( ! empty( $brand['allowed_countries'] ) ) { 225 $payment_methods_with_payment_component[] = self::get_legacy_woocommerce_payment_gateway_ids( $brand['id'] ); 226 } 227 } 176 228 } 177 229 } … … 188 240 */ 189 241 public static function get_legacy_woocommerce_payment_gateway_ids( string $code ): string { 190 191 242 $woocommerce_payment_gateway_id = 'multisafepay_' . str_replace( '-', '_', sanitize_title( strtolower( $code ) ) ); 192 243 -
multisafepay/tags/6.6.0/src/Services/SdkService.php
r3048898 r3114383 14 14 use MultiSafepay\Sdk; 15 15 use MultiSafepay\WooCommerce\Client\MultiSafepayClient; 16 use MultiSafepay\WooCommerce\Services\PaymentMethodService;17 16 use MultiSafepay\WooCommerce\Utils\Logger; 18 17 use Nyholm\Psr7\Factory\Psr17Factory; … … 44 43 private $sdk = null; 45 44 45 /** 46 * @var Logger 47 */ 48 private $logger; 46 49 47 50 /** 48 51 * SdkService constructor. 49 52 * 50 * @param string $api_key 51 * @param boolean $test_mode 52 */ 53 public function __construct( string $api_key = null, bool $test_mode = null ) { 53 * @param string $api_key 54 * @param boolean $test_mode 55 * @param Logger|null $logger 56 */ 57 public function __construct( string $api_key = null, bool $test_mode = null, ?Logger $logger = null ) { 54 58 $this->api_key = $api_key ?? $this->get_api_key(); 55 59 $this->test_mode = $test_mode ?? $this->get_test_mode(); 60 $this->logger = $logger ?? new Logger(); 56 61 $psr_factory = new Psr17Factory(); 57 62 $client = new MultiSafepayClient(); … … 60 65 } catch ( InvalidApiKeyException $invalid_api_key_exception ) { 61 66 set_transient( 'multisafepay_payment_methods', array() ); 62 Logger::log_error( $invalid_api_key_exception->getMessage() );67 $this->logger->log_error( $invalid_api_key_exception->getMessage() ); 63 68 } 64 69 } … … 96 101 return $this->sdk->getGatewayManager(); 97 102 } catch ( ApiException $api_exception ) { 98 Logger::log_error( $api_exception->getMessage() );103 $this->logger->log_error( $api_exception->getMessage() ); 99 104 return new WP_Error( 'multisafepay-warning', $api_exception->getMessage() ); 100 105 } … … 111 116 return $this->get_gateway_manager()->getGateways( true ); 112 117 } catch ( ApiException $api_exception ) { 113 Logger::log_error( $api_exception->getMessage() );118 $this->logger->log_error( $api_exception->getMessage() ); 114 119 return new WP_Error( 'multisafepay-warning', $api_exception->getMessage() ); 115 120 } … … 149 154 public function get_api_token_manager(): ?ApiTokenManager { 150 155 if ( null === $this->sdk ) { 151 Logger::log_error( 'SDK is not initialized' );156 $this->logger->log_error( 'SDK is not initialized' ); 152 157 return null; 153 158 } … … 162 167 public function get_payment_method_manager(): ?PaymentMethodManager { 163 168 if ( null === $this->sdk ) { 164 Logger::log_error( 'SDK is not initialized' );169 $this->logger->log_error( 'SDK is not initialized' ); 165 170 return null; 166 171 } … … 168 173 return $this->sdk->getPaymentMethodManager(); 169 174 } catch ( ApiException $api_exception ) { 170 Logger::log_error( $api_exception->getMessage() );175 $this->logger->log_error( $api_exception->getMessage() ); 171 176 return null; 172 177 } … … 184 189 $tokens = $this->sdk->getTokenManager()->getListByGatewayCodeAsArray( $customer_reference, $gateway_code ); 185 190 } catch ( ApiException $api_exception ) { 186 Logger::log_error( $api_exception->getMessage() );191 $this->logger->log_error( $api_exception->getMessage() ); 187 192 return array(); 188 193 } catch ( ClientExceptionInterface $client_exception ) { 189 Logger::log_error( $client_exception->getMessage() );194 $this->logger->log_error( $client_exception->getMessage() ); 190 195 return array(); 191 196 } catch ( Exception $exception ) { 192 Logger::log_error( $exception->getMessage() );197 $this->logger->log_error( $exception->getMessage() ); 193 198 return array(); 194 199 } … … 207 212 $gateway_merchant_id = $account_manager->get()->getAccountId(); 208 213 } catch ( ApiException | ClientExceptionInterface | Exception $exception ) { 209 Logger::log_error( 'Error when try to set the merchant credentials: ' . $exception->getMessage() );214 $this->logger->log_error( 'Error when try to set the merchant credentials: ' . $exception->getMessage() ); 210 215 } 211 216 -
multisafepay/tags/6.6.0/src/Services/ShoppingCartService.php
r2995309 r3114383 25 25 26 26 /** 27 * @var Logger 28 */ 29 private $logger; 30 31 /** 32 * @param Logger|null $logger 33 */ 34 public function __construct( ?Logger $logger = null ) { 35 $this->logger = $logger ?? new Logger(); 36 } 37 38 /** 27 39 * @param WC_Order $order 28 40 * @param string $currency … … 39 51 40 52 if ( get_option( 'multisafepay_debugmode', false ) ) { 41 Logger::log_info( wc_print_r( $order->get_items(), true ) );53 $this->logger->log_info( wc_print_r( $order->get_items(), true ) ); 42 54 } 43 55 … … 72 84 73 85 if ( get_option( 'multisafepay_debugmode', false ) ) { 74 Logger::log_info( wp_json_encode( $shopping_cart->getData() ) );86 $this->logger->log_info( wp_json_encode( $shopping_cart->getData() ) ); 75 87 } 76 88 -
multisafepay/tags/6.6.0/src/Utils/Logger.php
r2974626 r3114383 4 4 5 5 use WC_Log_Handler_File; 6 use WC_Logger_Interface; 6 7 7 8 /** … … 9 10 */ 10 11 class Logger { 12 13 /** 14 * @var WC_Logger_Interface 15 */ 16 private $logger; 17 18 /** 19 * @param WC_Logger_Interface|null $logger 20 */ 21 public function __construct( ?WC_Logger_Interface $logger = null ) { 22 $this->logger = $logger ?? wc_get_logger(); 23 } 11 24 12 25 /** … … 17 30 * @param string $message 18 31 */ 19 public static function log_emergency( string $message ) { 20 $logger = wc_get_logger(); 21 $logger->log( 'emergency', $message, array( 'source' => 'multisafepay' ) ); 32 public function log_emergency( string $message ) { 33 $this->logger->log( 'emergency', $message, array( 'source' => 'multisafepay' ) ); 22 34 } 23 35 … … 29 41 * @param string $message 30 42 */ 31 public static function log_alert( string $message ) { 32 $logger = wc_get_logger(); 33 $logger->log( 'alert', $message, array( 'source' => 'multisafepay' ) ); 43 public function log_alert( string $message ) { 44 $this->logger->log( 'alert', $message, array( 'source' => 'multisafepay' ) ); 34 45 } 35 46 … … 41 52 * @param string $message 42 53 */ 43 public static function log_critical( string $message ) { 44 $logger = wc_get_logger(); 45 $logger->log( 'critical', $message, array( 'source' => 'multisafepay' ) ); 54 public function log_critical( string $message ) { 55 $this->logger->log( 'critical', $message, array( 'source' => 'multisafepay' ) ); 46 56 } 47 57 … … 53 63 * @param string $message 54 64 */ 55 public static function log_error( string $message ) { 56 $logger = wc_get_logger(); 57 $logger->log( 'error', $message, array( 'source' => 'multisafepay' ) ); 65 public function log_error( string $message ) { 66 $this->logger->log( 'error', $message, array( 'source' => 'multisafepay' ) ); 58 67 } 59 68 … … 65 74 * @param string $message 66 75 */ 67 public static function log_warning( string $message ) { 68 $logger = wc_get_logger(); 69 $logger->log( 'warning', $message, array( 'source' => 'multisafepay' ) ); 76 public function log_warning( string $message ) { 77 $this->logger->log( 'warning', $message, array( 'source' => 'multisafepay' ) ); 70 78 } 71 79 … … 77 85 * @param string $message 78 86 */ 79 public static function log_notice( string $message ) { 80 $logger = wc_get_logger(); 81 $logger->log( 'notice', $message, array( 'source' => 'multisafepay' ) ); 87 public function log_notice( string $message ) { 88 $this->logger->log( 'notice', $message, array( 'source' => 'multisafepay' ) ); 82 89 } 83 90 … … 89 96 * @param string $message 90 97 */ 91 public staticfunction log_info( string $message ) {98 public function log_info( string $message ) { 92 99 if ( get_option( 'multisafepay_debugmode', false ) ) { 93 $logger = wc_get_logger(); 94 $logger->log( 'info', $message, array( 'source' => 'multisafepay' ) ); 100 $this->logger->log( 'info', $message, array( 'source' => 'multisafepay' ) ); 95 101 } 96 102 } … … 103 109 * @param string $message 104 110 */ 105 public staticfunction log_debug( string $message ) {111 public function log_debug( string $message ) { 106 112 if ( get_option( 'multisafepay_debugmode', false ) ) { 107 $logger = wc_get_logger(); 108 $logger->log( 'debug', $message, array( 'source' => 'multisafepay' ) ); 113 $this->logger->log( 'debug', $message, array( 'source' => 'multisafepay' ) ); 109 114 } 110 115 } … … 116 121 */ 117 122 private function get_logs(): array { 118 $logs = WC_Log_Handler_File::get_log_files(); 119 return $logs; 123 return WC_Log_Handler_File::get_log_files(); 120 124 } 121 125 -
multisafepay/tags/6.6.0/vendor/autoload.php
r3048898 r3114383 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit 8122490751e95ad36d38dc1115ae59ff::getLoader();25 return ComposerAutoloaderInitdbc0eb47ba0f8cbc67eba2344d97c2f8::getLoader(); -
multisafepay/tags/6.6.0/vendor/composer/autoload_real.php
r3048898 r3114383 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 8122490751e95ad36d38dc1115ae59ff5 class ComposerAutoloaderInitdbc0eb47ba0f8cbc67eba2344d97c2f8 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit 8122490751e95ad36d38dc1115ae59ff', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInitdbc0eb47ba0f8cbc67eba2344d97c2f8', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 29 spl_autoload_unregister(array('ComposerAutoloaderInit 8122490751e95ad36d38dc1115ae59ff', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInitdbc0eb47ba0f8cbc67eba2344d97c2f8', 'loadClassLoader')); 30 30 31 31 require __DIR__ . '/autoload_static.php'; 32 call_user_func(\Composer\Autoload\ComposerStaticInit 8122490751e95ad36d38dc1115ae59ff::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInitdbc0eb47ba0f8cbc67eba2344d97c2f8::getInitializer($loader)); 33 33 34 34 $loader->register(true); -
multisafepay/tags/6.6.0/vendor/composer/autoload_static.php
r3048898 r3114383 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 8122490751e95ad36d38dc1115ae59ff7 class ComposerStaticInitdbc0eb47ba0f8cbc67eba2344d97c2f8 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 63 63 { 64 64 return \Closure::bind(function () use ($loader) { 65 $loader->prefixLengthsPsr4 = ComposerStaticInit 8122490751e95ad36d38dc1115ae59ff::$prefixLengthsPsr4;66 $loader->prefixDirsPsr4 = ComposerStaticInit 8122490751e95ad36d38dc1115ae59ff::$prefixDirsPsr4;67 $loader->classMap = ComposerStaticInit 8122490751e95ad36d38dc1115ae59ff::$classMap;65 $loader->prefixLengthsPsr4 = ComposerStaticInitdbc0eb47ba0f8cbc67eba2344d97c2f8::$prefixLengthsPsr4; 66 $loader->prefixDirsPsr4 = ComposerStaticInitdbc0eb47ba0f8cbc67eba2344d97c2f8::$prefixDirsPsr4; 67 $loader->classMap = ComposerStaticInitdbc0eb47ba0f8cbc67eba2344d97c2f8::$classMap; 68 68 69 69 }, null, ClassLoader::class); -
multisafepay/tags/6.6.0/vendor/composer/installed.json
r3088253 r3114383 3 3 { 4 4 "name": "multisafepay/php-sdk", 5 "version": "5.1 3.0",6 "version_normalized": "5.1 3.0.0",5 "version": "5.14.0", 6 "version_normalized": "5.14.0.0", 7 7 "source": { 8 8 "type": "git", 9 9 "url": "https://github.com/MultiSafepay/php-sdk.git", 10 "reference": " b88fa079981d590a70275d528cf52d8fd07affab"11 }, 12 "dist": { 13 "type": "zip", 14 "url": "https://api.github.com/repos/MultiSafepay/php-sdk/zipball/ b88fa079981d590a70275d528cf52d8fd07affab",15 "reference": " b88fa079981d590a70275d528cf52d8fd07affab",10 "reference": "408f102e3228f072f2c1bcc76ac29a8031415480" 11 }, 12 "dist": { 13 "type": "zip", 14 "url": "https://api.github.com/repos/MultiSafepay/php-sdk/zipball/408f102e3228f072f2c1bcc76ac29a8031415480", 15 "reference": "408f102e3228f072f2c1bcc76ac29a8031415480", 16 16 "shasum": "" 17 17 }, … … 38 38 "jschaedl/iban-validation": "Adds additional IBAN validation for \\MultiSafepay\\ValueObject\\IbanNumber" 39 39 }, 40 "time": "2024-0 4-16T11:41:31+00:00",40 "time": "2024-07-08T12:43:31+00:00", 41 41 "type": "library", 42 42 "installation-source": "dist", … … 53 53 "support": { 54 54 "issues": "https://github.com/MultiSafepay/php-sdk/issues", 55 "source": "https://github.com/MultiSafepay/php-sdk/tree/5.1 3.0"55 "source": "https://github.com/MultiSafepay/php-sdk/tree/5.14.0" 56 56 }, 57 57 "install-path": "../multisafepay/php-sdk" -
multisafepay/tags/6.6.0/vendor/composer/installed.php
r3099249 r3114383 2 2 'root' => array( 3 3 'name' => 'multisafepay/woocommerce', 4 'pretty_version' => '6. 5.1',5 'version' => '6. 5.1.0',6 'reference' => 'a57a06a32837f1542476a9726a1e3749e08ba92d',4 'pretty_version' => '6.6.0', 5 'version' => '6.6.0.0', 6 'reference' => null, 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'multisafepay/php-sdk' => array( 14 'pretty_version' => '5.1 3.0',15 'version' => '5.1 3.0.0',16 'reference' => ' b88fa079981d590a70275d528cf52d8fd07affab',14 'pretty_version' => '5.14.0', 15 'version' => '5.14.0.0', 16 'reference' => '408f102e3228f072f2c1bcc76ac29a8031415480', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../multisafepay/php-sdk', … … 21 21 ), 22 22 'multisafepay/woocommerce' => array( 23 'pretty_version' => '6. 5.1',24 'version' => '6. 5.1.0',25 'reference' => 'a57a06a32837f1542476a9726a1e3749e08ba92d',23 'pretty_version' => '6.6.0', 24 'version' => '6.6.0.0', 25 'reference' => null, 26 26 'type' => 'wordpress-plugin', 27 27 'install_path' => __DIR__ . '/../../', -
multisafepay/tags/6.6.0/vendor/multisafepay/php-sdk/CHANGELOG.md
r3072171 r3114383 7 7 ## [Unreleased] 8 8 9 ## [5.14.0] - 2024-07-08 10 ### Added 11 - PHPSDK-155: Throw ApiUnavailableException when API returns 501/503 HTTP codes 12 - PHPSDK-156: Add getGatewayId in TransactionResponse class 13 9 14 ## [5.13.0] - 2024-04-16 10 15 ### Added 11 +PHPSDK-151: Update Gateways::SHOPPING_CART_REQUIRED_GATEWAYS adding 'BNPL_INST', 'IN3B2B', 'SANTANDER', 'ZINIA', 'ZINIA_IN3', 'BNPL_OB', 'BNPL_MF' gateways codes16 - PHPSDK-151: Update Gateways::SHOPPING_CART_REQUIRED_GATEWAYS adding 'BNPL_INST', 'IN3B2B', 'SANTANDER', 'ZINIA', 'ZINIA_IN3', 'BNPL_OB', 'BNPL_MF' gateways codes 12 17 13 18 ## [5.12.1] - 2024-03-11 14 19 ### Fixed 15 +PHPSDK-146: Fix ApiException not being hinted as a thrown exception, even though it is, by fixing the PHP DocBlocks @throws tags20 - PHPSDK-146: Fix ApiException not being hinted as a thrown exception, even though it is, by fixing the PHP DocBlocks @throws tags 16 21 17 22 ## [5.12.0] - 2023-12-01 18 23 ### Added 19 +PHPSDK-139: Add support to set var1, var2 and var3, within the OrderRequest object20 +PHPSDK-140: Add support to set custom_info, within the OrderRequest object, thanks to @DaanDeSmedt24 - PHPSDK-139: Add support to set var1, var2 and var3, within the OrderRequest object 25 - PHPSDK-140: Add support to set custom_info, within the OrderRequest object, thanks to @DaanDeSmedt 21 26 22 27 ## [5.11.2] - 2023-10-13 23 28 ### Fixed 24 +PHPSDK-134: Fix errors when only reference is set, within the CustomerDetails object25 26 ### Changed 27 +PHPSDK-136: Remove PluginDetails as mandatory from the Order Request29 - PHPSDK-134: Fix errors when only reference is set, within the CustomerDetails object 30 31 ### Changed 32 - PHPSDK-136: Remove PluginDetails as mandatory from the Order Request 28 33 29 34 ## [5.11.1] - 2023-07-31 … … 89 94 ## [5.5.0] - 2022-05-11 90 95 ### Added 91 +PHPSDK-90: Add MAESTRO tokens within the results of the CREDITCARD tokens request92 93 ### Changed 94 +PHPSDK-91: Add trim on API key when initializing the SDK96 - PHPSDK-90: Add MAESTRO tokens within the results of the CREDITCARD tokens request 97 98 ### Changed 99 - PHPSDK-91: Add trim on API key when initializing the SDK 95 100 96 101 ## [5.4.0] - 2021-11-30 -
multisafepay/tags/6.6.0/vendor/multisafepay/php-sdk/composer.json
r3072171 r3114383 4 4 "type": "library", 5 5 "license": "MIT", 6 "version": "5.1 3.0",6 "version": "5.14.0", 7 7 "require": { 8 8 "php": "^7.2|^8.0", -
multisafepay/tags/6.6.0/vendor/multisafepay/php-sdk/src/Api/Base/Response.php
r3050467 r3114383 9 9 use MultiSafepay\Api\Pager\Pager; 10 10 use MultiSafepay\Exception\ApiException; 11 use MultiSafepay\Exception\ApiUnavailableException; 11 12 12 13 /** … … 38 39 * @param array $context 39 40 * @return Response 40 * @throws ApiException 41 * @throws ApiException|ApiUnavailableException 41 42 */ 42 43 public static function withJson(string $json, array $context = []): Response … … 55 56 * @param array $context 56 57 * @param string $raw 57 * @throws ApiException 58 * @throws ApiException|ApiUnavailableException 58 59 */ 59 60 public function __construct(array $data, array $context = [], string $raw = '') … … 83 84 * @return void 84 85 * @throws ApiException 86 * @throws ApiUnavailableException 85 87 */ 86 88 private function validate(array $data, array $context = []): void … … 95 97 if (!empty($data['data']) && !is_array($data['data'])) { 96 98 [$errorCode, $errorInfo] = self::ERROR_INVALID_DATA_TYPE; 99 } 100 101 if (in_array($context['http_response_code'], [501, 503])) { 102 throw (new ApiUnavailableException( 103 'The MultiSafepay API could not be reached', 104 $context['http_response_code'] 105 )); 97 106 } 98 107 -
multisafepay/tags/6.6.0/vendor/multisafepay/php-sdk/src/Api/Transactions/TransactionResponse.php
r3050467 r3114383 31 31 class TransactionResponse extends ResponseBody 32 32 { 33 34 33 /** 35 34 * @var string … … 383 382 return in_array($this->getPaymentDetails()->getType(), Gateways::SHOPPING_CART_REQUIRED_GATEWAYS, true); 384 383 } 384 385 /** 386 * Retrieve the gateway ID from the transaction 387 * Will return multiple gateway IDs as a string of comma separated values if multiple payment methods are used 388 * 389 * @return string 390 */ 391 public function getGatewayId(): string 392 { 393 $paymentMethods = []; 394 395 foreach ($this->getPaymentMethods() as $paymentMethod) { 396 if ($paymentMethod->getType() === 'COUPON') { 397 $paymentMethods[] = $paymentMethod->getData()['coupon_brand'] ?? 'unknown'; 398 continue; 399 } 400 401 $paymentMethods[] = $paymentMethod->getType(); 402 } 403 404 return implode(', ', $paymentMethods); 405 } 385 406 } -
multisafepay/tags/6.6.0/vendor/multisafepay/php-sdk/src/Client/Client.php
r3050467 r3114383 12 12 use MultiSafepay\Api\Base\Response as ApiResponse; 13 13 use MultiSafepay\Exception\ApiException; 14 use MultiSafepay\Exception\ApiUnavailableException; 14 15 use MultiSafepay\Exception\InvalidApiKeyException; 15 use MultiSafepay\Exception\StrictModeException;16 16 use Psr\Http\Client\ClientExceptionInterface; 17 17 use Psr\Http\Client\ClientInterface; … … 105 105 * @param array $context 106 106 * @return ApiResponse 107 * @throws ClientExceptionInterface 108 * @throws ApiException 107 * @throws ClientExceptionInterface|ApiException|ApiUnavailableException 109 108 */ 110 109 public function createPostRequest( … … 116 115 ->withBody($this->createBody($this->getRequestBody($requestBody))) 117 116 ->withHeader('Content-Length', strlen($this->getRequestBody($requestBody))); 117 $httpResponse = $this->httpClient->sendRequest($request); 118 118 119 119 $context['headers'] = $request->getHeaders(); 120 120 $context['request_body'] = $this->getRequestBody($requestBody); 121 $httpResponse = $this->httpClient->sendRequest($request); 121 $context['http_response_code'] = $httpResponse->getStatusCode() ?? 0; 122 122 123 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 123 124 } … … 129 130 * @param array $context 130 131 * @return ApiResponse 131 * @throws ClientExceptionInterface|ApiException 132 * @throws ClientExceptionInterface|ApiException|ApiUnavailableException 132 133 */ 133 134 public function createPatchRequest( … … 139 140 ->withBody($this->createBody($this->getRequestBody($requestBody))) 140 141 ->withHeader('Content-Length', strlen($this->getRequestBody($requestBody))); 142 $httpResponse = $this->httpClient->sendRequest($request); 141 143 142 144 $context['headers'] = $request->getHeaders(); 143 145 $context['request_body'] = $this->getRequestBody($requestBody); 144 $httpResponse = $this->httpClient->sendRequest($request); 145 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 146 } 147 148 /** 149 * @param string $endpoint 150 * @param array $parameters 151 * @param array $context 152 * @return ApiResponse 153 * @throws ClientExceptionInterface|ApiException 146 $context['http_response_code'] = $httpResponse->getStatusCode() ?? 0; 147 148 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 149 } 150 151 /** 152 * @param string $endpoint 153 * @param array $parameters 154 * @param array $context 155 * @return ApiResponse 156 * @throws ClientExceptionInterface|ApiException|ApiUnavailableException 154 157 */ 155 158 public function createGetRequest(string $endpoint, array $parameters = [], array $context = []): ApiResponse … … 157 160 $request = $this->createRequest($endpoint, self::METHOD_GET, $parameters); 158 161 $httpResponse = $this->httpClient->sendRequest($request); 162 159 163 $context['headers'] = $request->getHeaders(); 160 164 $context['request_params'] = $parameters; 161 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 162 } 163 164 /** 165 * @param string $endpoint 166 * @param array $parameters 167 * @param array $context 168 * @return ApiResponse 169 * @throws ClientExceptionInterface|ApiException 165 $context['http_response_code'] = $httpResponse->getStatusCode() ?? 0; 166 167 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 168 } 169 170 /** 171 * @param string $endpoint 172 * @param array $parameters 173 * @param array $context 174 * @return ApiResponse 175 * @throws ClientExceptionInterface|ApiException|ApiUnavailableException 170 176 */ 171 177 public function createDeleteRequest(string $endpoint, array $parameters = [], array $context = []): ApiResponse … … 173 179 $request = $this->createRequest($endpoint, self::METHOD_DELETE, $parameters); 174 180 $httpResponse = $this->httpClient->sendRequest($request); 181 175 182 $context['headers'] = $request->getHeaders(); 176 183 $context['request_params'] = $parameters; 184 $context['http_response_code'] = $httpResponse->getStatusCode() ?? 0; 185 177 186 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 178 187 } … … 203 212 } 204 213 $endpoint .= '?' . http_build_query($parameters); 214 205 215 return $this->url . $endpoint; 206 216 } … … 236 246 { 237 247 $this->strictMode = $strictMode; 248 238 249 return $this; 239 250 } … … 249 260 $url = $this->getRequestUrl($endpoint, $parameters); 250 261 $requestFactory = $this->getRequestFactory(); 262 251 263 return $requestFactory->createRequest($method, $url) 252 264 ->withHeader('api_key', $this->apiKey->get()) … … 262 274 { 263 275 $requestBody->useStrictMode($this->strictMode); 276 264 277 return json_encode($requestBody->getData(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); 265 278 } -
multisafepay/tags/6.6.0/vendor/multisafepay/php-sdk/src/Util/Version.php
r3072171 r3114383 18 18 class Version 19 19 { 20 public const SDK_VERSION = '5.1 3.0';20 public const SDK_VERSION = '5.14.0'; 21 21 22 22 /** -
multisafepay/trunk/multisafepay.php
r3099249 r3114383 5 5 * Plugin URI: https://docs.multisafepay.com/docs/woocommerce 6 6 * Description: MultiSafepay Payment Plugin 7 * Version: 6. 5.17 * Version: 6.6.0 8 8 * Author: MultiSafepay 9 9 * Author URI: https://www.multisafepay.com … … 12 12 * License URI: http://www.gnu.org/licenses/gpl-3.0.html 13 13 * Requires at least: 6.0 14 * Tested up to: 6.5. 414 * Tested up to: 6.5.5 15 15 * WC requires at least: 6.0.0 16 * WC tested up to: 8.8.316 * WC tested up to: 9.0.2 17 17 * Requires PHP: 7.3 18 18 * Text Domain: multisafepay … … 27 27 * Plugin version 28 28 */ 29 define( 'MULTISAFEPAY_PLUGIN_VERSION', '6. 5.1' );29 define( 'MULTISAFEPAY_PLUGIN_VERSION', '6.6.0' ); 30 30 31 31 /** -
multisafepay/trunk/readme.txt
r3099249 r3114383 3 3 Tags: multisafepay, payment gateway, credit cards, ideal, bnpl 4 4 Requires at least: 6.0 5 Tested up to: 6.5. 45 Tested up to: 6.5.5 6 6 Requires PHP: 7.3 7 Stable tag: 6. 5.17 Stable tag: 6.6.0 8 8 License: MIT 9 9 … … 128 128 == Upgrade Notice == 129 129 130 = 6. 5.1=130 = 6.6.0 = 131 131 6.x.x is a major upgrade in which the MultiSafepay payment methods are registered dynamically via an API request to MultiSafepay. If you are upgrading from 5.X.X version, after the upgrade, please navigate to the MultiSafepay settings page, and to each one of the payment methods enabled in your account, and confirm the settings in each section are set up according to your preferences. 132 132 … … 144 144 145 145 == Changelog == 146 = Release Notes - WooCommerce 6.6.0 (Jul 8th, 2024) = 147 148 ### Added 149 + PLGWOOS-946: Add support for branded credit and debit cards 150 151 ### Changed 152 + PLGWOOS-943: Refactor PaymentMethodCallback class (#574) 153 + PLGWOOS-948: General improvements to increase unit test coverage 154 146 155 = Release Notes - WooCommerce 6.5.1 (Jun 7th, 2024) = 147 156 -
multisafepay/trunk/src/Client/MultiSafepayClient.php
r3090804 r3114383 14 14 */ 15 15 class MultiSafepayClient implements ClientInterface { 16 17 /** 18 * @var Logger 19 */ 20 private $logger; 21 22 /** 23 * @param Logger|null $logger 24 */ 25 public function __construct( ?Logger $logger = null ) { 26 $this->logger = $logger ?? new Logger(); 27 } 16 28 17 29 /** … … 33 45 } 34 46 } catch ( Exception $exception ) { 35 Logger::log_error( 'Error when process request via MultiSafepayClient: ' . $exception->getMessage() );47 $this->logger->log_error( 'Error when process request via MultiSafepayClient: ' . $exception->getMessage() ); 36 48 throw new Exception( $exception->getMessage() ); 37 49 } -
multisafepay/trunk/src/PaymentMethods/Base/BasePaymentMethod.php
r3099249 r3114383 109 109 110 110 /** 111 * Defines if the payment method is tokenizable 111 * @var Logger 112 */ 113 private $logger; 114 115 /** 116 * BasePaymentMethod constructor. 112 117 * 113 118 * @param PaymentMethod $payment_method 114 */ 115 public function __construct( PaymentMethod $payment_method ) { 119 * @param Logger|null $logger 120 */ 121 public function __construct( PaymentMethod $payment_method, ?Logger $logger = null ) { 122 $this->logger = $logger ?? new Logger(); 116 123 $this->payment_method = $payment_method; 117 124 $this->supports = array( 'products', 'refunds' ); … … 636 643 $transaction = $transaction_manager->create( $order_request ); 637 644 } catch ( ApiException | ClientExceptionInterface $exception ) { 638 Logger::log_error( $exception->getMessage() );645 $this->logger->log_error( $exception->getMessage() ); 639 646 wc_add_notice( __( 'There was a problem processing your payment. Please try again later or contact with us.', 'multisafepay' ), 'error' ); 640 647 return; … … 642 649 643 650 if ( get_option( 'multisafepay_debugmode', false ) ) { 644 Logger::log_info( 'Start MultiSafepay transaction for the order ID ' . $order_id . ' on ' . date( 'd/m/Y H:i:s' ) . ' with payment URL ' . $transaction->getPaymentUrl() );651 $this->logger->log_info( 'Start MultiSafepay transaction for the order ID ' . $order_id . ' on ' . date( 'd/m/Y H:i:s' ) . ' with payment URL ' . $transaction->getPaymentUrl() ); 645 652 } 646 653 -
multisafepay/trunk/src/PaymentMethods/Base/BasePaymentMethodBlocks.php
r3090804 r3114383 42 42 $multisafepay_payment_methods = $payment_method_service->get_multisafepay_payment_methods_from_api(); 43 43 foreach ( $multisafepay_payment_methods as $multisafepay_payment_method ) { 44 $woocommerce_payment_gateway = null; 44 $woocommerce_payment_gateways = array(); 45 45 46 if ( isset( $multisafepay_payment_method['type'] ) && ( 'coupon' === $multisafepay_payment_method['type'] ) ) { 46 $woocommerce_payment_gateway = new BaseGiftCardPaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 47 } 48 if ( isset( $multisafepay_payment_method['type'] ) && ( 'payment-method' === $multisafepay_payment_method['type'] ) ) { 49 $woocommerce_payment_gateway = new BasePaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 47 $woocommerce_payment_gateways[] = new BaseGiftCardPaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 50 48 } 51 49 52 // Include direct payment methods without components just in the checkout page of the frontend context 53 if ( 54 $woocommerce_payment_gateway->check_direct_payment_methods_without_components() && 55 ! $woocommerce_payment_gateway->admin_editing_checkout_page() 56 ) { 57 $this->gateways[] = $woocommerce_payment_gateway; 50 if ( isset( $multisafepay_payment_method['type'] ) && ( 'payment-method' === $multisafepay_payment_method['type'] ) ) { 51 $woocommerce_payment_gateways[] = new BasePaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 52 foreach ( $multisafepay_payment_method['brands'] as $brand ) { 53 if ( ! empty( $brand['allowed_countries'] ) ) { 54 $woocommerce_payment_gateways[] = new BaseBrandedPaymentMethod( new PaymentMethod( $multisafepay_payment_method ), $brand ); 55 } 56 } 58 57 } 59 58 60 if ( ( 'redirect' === $woocommerce_payment_gateway->get_payment_method_type() ) && $woocommerce_payment_gateway->is_available() ) { 61 $this->gateways[] = $woocommerce_payment_gateway; 59 foreach ( $woocommerce_payment_gateways as $woocommerce_payment_gateway ) { 60 // Include direct payment methods without components just in the checkout page of the frontend context 61 if ( 62 $woocommerce_payment_gateway->check_direct_payment_methods_without_components() && 63 ! $woocommerce_payment_gateway->admin_editing_checkout_page() 64 ) { 65 $this->gateways[] = $woocommerce_payment_gateway; 66 } 67 68 if ( ( 'redirect' === $woocommerce_payment_gateway->get_payment_method_type() ) && $woocommerce_payment_gateway->is_available() ) { 69 $this->gateways[] = $woocommerce_payment_gateway; 70 } 62 71 } 63 72 } -
multisafepay/trunk/src/PaymentMethods/Base/BaseRefunds.php
r3048898 r3114383 10 10 use MultiSafepay\ValueObject\CartItem; 11 11 use MultiSafepay\WooCommerce\Services\SdkService; 12 use MultiSafepay\WooCommerce\Utils\Logger;13 12 use MultiSafepay\WooCommerce\Utils\MoneyUtil; 14 13 use Psr\Http\Client\ClientExceptionInterface; … … 76 75 } catch ( Exception | ClientExceptionInterface | ApiException $exception ) { 77 76 $error = __( 'Error:', 'multisafepay' ) . htmlspecialchars( $exception->getMessage() ); 78 Logger::log_error( $error );77 $this->logger->log_error( $error ); 79 78 wc_add_notice( $error, 'error' ); 80 79 } … … 83 82 /* translators: %1$: The currency code. %2$ The transaction amount */ 84 83 $note = sprintf( __( 'Refund of %1$s%2$s has been processed successfully.', 'multisafepay' ), get_woocommerce_currency_symbol( $order->get_currency() ), $amount ); 85 Logger::log_info( $note );84 $this->logger->log_info( $note ); 86 85 $order->add_order_note( $note ); 87 86 return true; … … 91 90 /* translators: %1$: The order ID. %2$ The PSP transaction ID */ 92 91 $message = sprintf( __( 'Refund for Order ID: %1$s with transactionId: %2$s gives message: %3$s.', 'multisafepay' ), $order_id, $multisafepay_transaction->getTransactionId(), $error ); 93 Logger::log_warning( $message );92 $this->logger->log_warning( $message ); 94 93 } 95 94 -
multisafepay/trunk/src/PaymentMethods/PaymentMethodCallback.php
r3048898 r3114383 10 10 use MultiSafepay\WooCommerce\Settings\SettingsFields; 11 11 use MultiSafepay\WooCommerce\Utils\Logger; 12 use MultiSafepay\WooCommerce\Utils\Order as OrderUtil; 12 13 use Psr\Http\Client\ClientExceptionInterface; 13 14 use WC_Data_Exception; … … 57 58 58 59 /** 59 * PaymentMethodCallback constructor 60 * 61 * @param string $multisafepay_order_id 62 * @param ?TransactionResponse $multisafepay_transaction 63 */ 64 public function __construct( string $multisafepay_order_id, $multisafepay_transaction = null ) { 65 $this->multisafepay_order_id = $multisafepay_order_id; 66 67 if ( ! isset( $multisafepay_transaction ) ) { 68 $multisafepay_transaction = $this->get_transaction(); 69 } 70 71 $this->multisafepay_transaction = $multisafepay_transaction; 72 73 // For most transactions, var2 contains the order id since the order request is being register using order number 74 if ( ! empty( $this->multisafepay_transaction->getVar2() ) ) { 75 $this->woocommerce_order_id = (int) $this->multisafepay_transaction->getVar2(); 76 } 77 78 // In case we need it, a filter to set the right order id, based on order number 79 if ( empty( $this->multisafepay_transaction->getVar2() ) ) { 80 $this->woocommerce_order_id = apply_filters( 'multisafepay_transaction_order_id', $this->multisafepay_order_id ); 81 } 82 83 $this->time_stamp = date( 'd/m/Y H:i:s' ); 84 $this->order = wc_get_order( $this->woocommerce_order_id ); 60 * @var Logger 61 */ 62 private $logger; 63 64 /** 65 * @param string $multisafepay_order_id 66 * @param TransactionResponse|null $multisafepay_transaction 67 * @param Logger|null $logger 68 */ 69 public function __construct( string $multisafepay_order_id, ?TransactionResponse $multisafepay_transaction = null, ?Logger $logger = null ) { 70 $this->logger = $logger ?? new Logger(); 71 $this->multisafepay_order_id = $multisafepay_order_id; 72 $this->multisafepay_transaction = $multisafepay_transaction ?? $this->get_transaction(); 73 $this->woocommerce_order_id = $this->get_woocommerce_order_id(); 74 $this->time_stamp = date( 'd/m/Y H:i:s' ); 75 $this->order = wc_get_order( $this->woocommerce_order_id ); 85 76 } 86 77 … … 95 86 $transaction = $transaction_manager->get( $this->multisafepay_order_id ); 96 87 } catch ( ClientExceptionInterface $client_exception ) { 97 Logger::log_error( $client_exception->getMessage() );88 $this->logger->log_error( $client_exception->getMessage() ); 98 89 wp_die( esc_html__( 'Invalid request', 'multisafepay' ), esc_html__( 'Invalid request', 'multisafepay' ), 400 ); 99 90 } catch ( ApiException $api_exception ) { 100 Logger::log_error( $api_exception->getMessage() );91 $this->logger->log_error( $api_exception->getMessage() ); 101 92 wp_die( esc_html__( 'Invalid request', 'multisafepay' ), esc_html__( 'Invalid request', 'multisafepay' ), 400 ); 102 93 } … … 105 96 106 97 /** 98 * Return the WooCommerce order id 99 * 100 * @return int 101 */ 102 private function get_woocommerce_order_id(): int { 103 // For most transactions, var2 contains the order id since the order request is being registered using order number 104 if ( ! empty( $this->multisafepay_transaction->getVar2() ) ) { 105 return (int) $this->multisafepay_transaction->getVar2(); 106 } 107 return apply_filters( 'multisafepay_transaction_order_id', $this->multisafepay_order_id ); 108 } 109 110 /** 107 111 * Return the WooCommerce order status 108 112 * 109 113 * @return string 110 114 */ 111 private function get_w c_order_status(): string {115 private function get_woocommerce_order_status(): string { 112 116 return $this->order->get_status(); 113 117 } … … 164 168 165 169 /** 170 * Return the initial order status configured in the payment method settings 171 * 172 * @return string|null 173 */ 174 private function get_initial_order_status(): ?string { 175 $registered_payment_method = ( new PaymentMethodService() )->get_woocommerce_payment_gateway_by_id( $this->order->get_payment_method() ); 176 return $registered_payment_method ? $registered_payment_method->initial_order_status : null; 177 } 178 179 /** 166 180 * Check if the order status should be updated or not 167 181 * … … 170 184 private function should_status_be_updated(): bool { 171 185 // Check if the WooCommerce completed order status is considered as the final one 172 if ( $this->is_completed_the_final_status( $this->get_w c_order_status() ) ) {186 if ( $this->is_completed_the_final_status( $this->get_woocommerce_order_status() ) ) { 173 187 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 174 188 $message = 'It seems a notification is trying to process an order which already has defined completed as the final order status. For this reason notification is being ignored. Transaction ID received is ' . sanitize_text_field( (string) wp_unslash( $this->get_multisafepay_transaction_id() ) ) . ' with status ' . $this->get_multisafepay_transaction_status(); 175 Logger::log_warning( $message );189 $this->logger->log_warning( $message ); 176 190 $this->order->add_order_note( $message ); 177 191 return false; … … 191 205 // On pre-transactions notification, and using sequential order numbers plugins, var 2 is not received in the notification, then order doesn't exist 192 206 if ( ! $this->order ) { 193 if ( get_option( 'multisafepay_debugmode', false ) ) { 194 Logger::log_info( 'Notification has been received for the transaction ID ' . $this->multisafepay_order_id . ' but WooCommerce order object has not been found' ); 195 } 207 $this->logger->log_info( 'Notification has been received for the transaction ID ' . $this->multisafepay_order_id . ' but WooCommerce order object has not been found' ); 196 208 header( 'Content-type: text/plain' ); 197 209 die( 'OK' ); … … 199 211 200 212 // If payment method of the order does not belong to MultiSafepay 201 if ( strpos( $this->order->get_payment_method(), 'multisafepay_' ) === false ) { 202 if ( get_option( 'multisafepay_debugmode', false ) ) { 203 $message = 'It seems a notification is trying to process an order processed by another payment method. Transaction ID received is ' . $this->order->get_id(); 204 Logger::log_info( $message ); 205 } 206 header( 'Content-type: text/plain' ); 207 die( 'OK' ); 208 } 209 210 if ( $this->get_wc_order_status() === 'trash' ) { 211 if ( get_option( 'multisafepay_debugmode', false ) ) { 212 $message = 'It seems a notification is trying to change the order status, but the order has been moved to the trash. Transaction ID received is ' . $this->order->get_id() . ' and transaction status is ' . $this->get_multisafepay_transaction_status(); 213 Logger::log_info( $message ); 214 $this->order->add_order_note( $message ); 215 } 213 if ( ! OrderUtil::is_multisafepay_order( $this->order ) ) { 214 $message = 'It seems a notification is trying to process an order processed by another payment method. Transaction ID received is ' . $this->order->get_id(); 215 $this->logger->log_info( $message ); 216 header( 'Content-type: text/plain' ); 217 die( 'OK' ); 218 } 219 220 if ( $this->get_woocommerce_order_status() === 'trash' ) { 221 $message = 'It seems a notification is trying to change the order status, but the order has been moved to the trash. Transaction ID received is ' . $this->order->get_id() . ' and transaction status is ' . $this->get_multisafepay_transaction_status(); 222 $this->logger->log_info( $message ); 223 OrderUtil::add_order_note( $this->order, $message, true ); 216 224 header( 'Content-type: text/plain' ); 217 225 die( 'OK' ); … … 221 229 if ( $this->get_multisafepay_transaction_status() === Transaction::PARTIAL_REFUNDED ) { 222 230 $message = 'A partial refund has been registered within MultiSafepay Control for Order ID: ' . $this->woocommerce_order_id . ' and Order Number: ' . $this->multisafepay_order_id; 223 $this->order->add_order_note($message );231 OrderUtil::add_order_note( $this->order, $message ); 224 232 header( 'Content-type: text/plain' ); 225 233 die( 'OK' ); … … 231 239 $payment_method_id_registered_by_wc = $this->order->get_payment_method(); 232 240 $payment_method_title_registered_by_wc = $this->order->get_payment_method_title(); 233 $registered_by_woocommerce_payment_method_object = ( new PaymentMethodService() )->get_woocommerce_payment_gateway_by_id( $payment_method_id_registered_by_wc ); 234 $initial_order_status = $registered_by_woocommerce_payment_method_object ? $registered_by_woocommerce_payment_method_object->initial_order_status : false; 241 $initial_order_status = $this->get_initial_order_status(); 235 242 $default_order_status = SettingsFields::get_multisafepay_order_statuses(); 236 243 … … 238 245 // Or if the custom initial order status of the gateway is different than the general one, and the MultiSafepay transaction status is initialized, and custom initial order status is different than the current WooCommerce order status 239 246 if ( 240 $this->get_w c_order_status() !== str_replace( 'wc-', '', get_option( 'multisafepay_' . $this->get_multisafepay_transaction_status() . '_status', $default_order_status[ $this->get_multisafepay_transaction_status() . '_status' ]['default'] ) ) ||241 get_option( 'multisafepay_' . $this->get_multisafepay_transaction_status() . '_status', $default_order_status[ $this->get_multisafepay_transaction_status() . '_status' ]['default'] ) !== $initial_order_status && $this->get_multisafepay_transaction_status() === Transaction::INITIALIZED && $this->get_w c_order_status() !== $initial_order_status247 $this->get_woocommerce_order_status() !== str_replace( 'wc-', '', get_option( 'multisafepay_' . $this->get_multisafepay_transaction_status() . '_status', $default_order_status[ $this->get_multisafepay_transaction_status() . '_status' ]['default'] ) ) || 248 get_option( 'multisafepay_' . $this->get_multisafepay_transaction_status() . '_status', $default_order_status[ $this->get_multisafepay_transaction_status() . '_status' ]['default'] ) !== $initial_order_status && $this->get_multisafepay_transaction_status() === Transaction::INITIALIZED && $this->get_woocommerce_order_status() !== $initial_order_status 242 249 ) { 243 244 250 // If MultiSafepay transaction status is initialized, check if there is a custom initial order status for this payment method. 245 251 if ( $this->get_multisafepay_transaction_status() === Transaction::INITIALIZED ) { 246 if ( $initial_order_status && 'wc-default' !== $initial_order_status && $this->get_w c_order_status() !== $initial_order_status ) {252 if ( $initial_order_status && 'wc-default' !== $initial_order_status && $this->get_woocommerce_order_status() !== $initial_order_status ) { 247 253 $this->order->update_status( str_replace( 'wc-', '', $initial_order_status ), __( 'Transaction has been initialized.', 'multisafepay' ) ); 248 254 } … … 266 272 } 267 273 268 if ( get_option( 'multisafepay_debugmode', false ) ) { 269 $message = 'Callback received for Order ID: ' . $this->woocommerce_order_id . ' and Order Number: ' . $this->multisafepay_order_id . ' on ' . $this->time_stamp . ' with status: ' . $this->get_multisafepay_transaction_status() . ' and PSP ID: ' . $this->get_multisafepay_transaction_id() . '.'; 270 Logger::log_info( $message ); 271 $this->order->add_order_note( $message ); 272 } 274 $message = 'Callback received for Order ID: ' . $this->woocommerce_order_id . ' and Order Number: ' . $this->multisafepay_order_id . ' on ' . $this->time_stamp . ' with status: ' . $this->get_multisafepay_transaction_status() . ' and PSP ID: ' . $this->get_multisafepay_transaction_id() . '.'; 275 $this->logger->log_info( $message ); 276 OrderUtil::add_order_note( $this->order, $message, true ); 273 277 } 274 278 275 279 // If the payment method changed in MultiSafepay payment page, after leave WooCommerce checkout page 276 280 if ( $payment_method_id_registered_by_multisafepay && $payment_method_id_registered_by_wc !== $payment_method_id_registered_by_multisafepay ) { 277 if ( get_option( 'multisafepay_debugmode', false ) ) { 278 $message = 'Callback received with a different payment method for Order ID: ' . $this->woocommerce_order_id . ' and Order Number: ' . $this->multisafepay_order_id . ' on ' . $this->time_stamp . '. Payment method changed from ' . $payment_method_title_registered_by_wc . ' to ' . $payment_method_title_registered_by_multisafepay . '.'; 279 Logger::log_info( $message ); 280 $this->order->add_order_note( $message ); 281 } 282 281 $message = 'Callback received with a different payment method for Order ID: ' . $this->woocommerce_order_id . ' and Order Number: ' . $this->multisafepay_order_id . ' on ' . $this->time_stamp . '. Payment method changed from ' . $payment_method_title_registered_by_wc . ' to ' . $payment_method_title_registered_by_multisafepay . '.'; 282 $this->logger->log_info( $message ); 283 OrderUtil::add_order_note( $this->order, $message, true ); 283 284 $this->order = wc_get_order( $this->woocommerce_order_id ); 284 285 $this->order->set_payment_method( $registered_by_multisafepay_payment_method_object ); -
multisafepay/trunk/src/PaymentMethods/PaymentMethodsController.php
r3050467 r3114383 6 6 use MultiSafepay\Api\Transactions\TransactionResponse; 7 7 use MultiSafepay\Api\Transactions\UpdateRequest; 8 use MultiSafepay\Api\Wallets\ApplePay\MerchantSessionRequest; 8 9 use MultiSafepay\Exception\ApiException; 9 use MultiSafepay\Api\Wallets\ApplePay\MerchantSessionRequest;10 10 use MultiSafepay\Util\Notification; 11 11 use MultiSafepay\WooCommerce\Services\OrderService; … … 14 14 use MultiSafepay\WooCommerce\Utils\Hpos; 15 15 use MultiSafepay\WooCommerce\Utils\Logger; 16 use MultiSafepay\WooCommerce\Utils\Order as OrderUtil; 16 17 use Psr\Http\Client\ClientExceptionInterface; 17 18 use WC_Data_Exception; … … 26 27 public const VALIDATION_URL_KEY = 'validation_url'; 27 28 public const ORIGIN_DOMAIN_KEY = 'origin_domain'; 29 30 /** 31 * @var Logger 32 */ 33 private $logger; 34 35 /** 36 * @param Logger|null $logger 37 */ 38 public function __construct( ?Logger $logger = null ) { 39 $this->logger = $logger ?? new Logger(); 40 } 28 41 29 42 /** … … 104 117 public function set_multisafepay_transaction_as_shipped( int $order_id ): void { 105 118 $order = wc_get_order( $order_id ); 106 if ( strpos( $order->get_payment_method(), 'multisafepay_' ) !== false) {119 if ( OrderUtil::is_multisafepay_order( $order ) ) { 107 120 $sdk = new SdkService(); 108 121 $transaction_manager = $sdk->get_transaction_manager(); … … 112 125 $transaction_manager->update( (string) $order->get_order_number(), $update_order ); 113 126 } catch ( ApiException $api_exception ) { 114 Logger::log_error( $api_exception->getMessage() );127 $this->logger->log_error( $api_exception->getMessage() ); 115 128 return; 116 129 } … … 128 141 public function set_multisafepay_transaction_as_invoiced( int $order_id ): void { 129 142 $order = wc_get_order( $order_id ); 130 if ( strpos( $order->get_payment_method(), 'multisafepay_' ) !== false) {143 if ( OrderUtil::is_multisafepay_order( $order ) ) { 131 144 $sdk = new SdkService(); 132 145 $transaction_manager = $sdk->get_transaction_manager(); … … 136 149 $transaction_manager->update( (string) $order->get_order_number(), $update_order ); 137 150 } catch ( ApiException $api_exception ) { 138 Logger::log_error( $api_exception->getMessage() );151 $this->logger->log_error( $api_exception->getMessage() ); 139 152 return; 140 153 } … … 178 191 179 192 if ( ! $request->sanitize_params() ) { 180 Logger::log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but could not be sanitized' );193 $this->logger->log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but could not be sanitized' ); 181 194 header( 'Content-type: text/plain' ); 182 195 die( 'OK' ); … … 185 198 $payload_type = $request->get_param( 'payload_type' ) ?? ''; 186 199 if ( 'pretransaction' === $payload_type ) { 187 Logger::log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but is going to be ignored, because is pretransaction type' );200 $this->logger->log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but is going to be ignored, because is pretransaction type' ); 188 201 header( 'Content-type: text/plain' ); 189 202 die( 'OK' ); … … 196 209 197 210 if ( ! $verify_notification ) { 198 Logger::log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but is not validated' );211 $this->logger->log_info( 'Notification for transactionid . ' . $transactionid . ' has been received but is not validated' ); 199 212 header( 'Content-type: text/plain' ); 200 213 die( 'OK' ); … … 202 215 203 216 if ( get_option( 'multisafepay_debugmode', false ) ) { 204 Logger::log_info( 'Notification has been received and validated for transaction id ' . $transactionid );217 $this->logger->log_info( 'Notification has been received and validated for transaction id ' . $transactionid ); 205 218 206 219 if ( ! empty( $body ) ) { 207 Logger::log_info( 'Body of the POST notification: ' . wc_print_r( $body, true ) );220 $this->logger->log_info( 'Body of the POST notification: ' . wc_print_r( $body, true ) ); 208 221 } 209 222 } … … 250 263 251 264 // Check if the payment method belongs to MultiSafepay 252 if ( strpos( $order->get_payment_method(), 'multisafepay_' ) === false) {265 if ( ! OrderUtil::is_multisafepay_order( $order ) ) { 253 266 return; 254 267 } … … 260 273 $gateway_object = ( new PaymentMethodService() )->get_woocommerce_payment_gateway_by_id( $order->get_payment_method() ); 261 274 if ( ! $gateway_object ) { 262 Logger::log_error( ' Gateway object is null ' );275 $this->logger->log_error( ' Gateway object is null ' ); 263 276 return; 264 277 } … … 275 288 if ( get_option( 'multisafepay_debugmode', false ) ) { 276 289 $message = 'Order details has been registered in MultiSafepay and a payment link has been generated: ' . esc_url( $transaction->getPaymentUrl() ); 277 Logger::log_info( $message );290 $this->logger->log_info( $message ); 278 291 $order->add_order_note( $message ); 279 292 } 280 293 } 281 294 } catch ( Exception | ApiException | ClientExceptionInterface $exception ) { 282 Logger::log_error( $exception->getMessage() );295 $this->logger->log_error( $exception->getMessage() ); 283 296 } 284 297 } … … 326 339 */ 327 340 public function allow_cancel_multisafepay_orders_with_on_hold_status( array $order_status, WC_Order $order ): array { 328 if ( strpos( $order->get_payment_method(), 'multisafepay_' ) !== false) {341 if ( OrderUtil::is_multisafepay_order( $order ) ) { 329 342 $gateway = ( new PaymentMethodService() )->get_woocommerce_payment_gateway_by_id( $order->get_payment_method() ); 330 343 if ( ! $gateway ) { 331 Logger::log_error( ' Gateway object is null ' );344 $this->logger->log_error( ' Gateway object is null ' ); 332 345 return $order_status; 333 346 } … … 363 376 } catch ( ApiException | Exception | ClientExceptionInterface $exception ) { 364 377 $error_message = 'Error when trying to get the ApplePay session via MultiSafepay SDK'; 365 Logger::log_error( $error_message . ': ' . $exception->getMessage() );378 $this->logger->log_error( $error_message . ': ' . $exception->getMessage() ); 366 379 wp_send_json( array( 'message' => $error_message ) ); 367 380 } … … 397 410 398 411 if ( empty( $validation_url ) ) { 399 Logger::log_error( 'Error when trying to get the ApplePay session. Validation URL empty' );412 $this->logger->log_error( 'Error when trying to get the ApplePay session. Validation URL empty' ); 400 413 exit; 401 414 } 402 415 403 416 if ( empty( $origin_domain ) ) { 404 Logger::log_error( 'Error when trying to get the ApplePay session. Origin domain empty' );417 $this->logger->log_error( 'Error when trying to get the ApplePay session. Origin domain empty' ); 405 418 exit; 406 419 } -
multisafepay/trunk/src/Services/ApiTokenService.php
r2974626 r3114383 26 26 27 27 /** 28 * @var Logger 29 */ 30 private $logger; 31 32 /** 28 33 * ApiTokenService constructor. 34 * 35 * @param Logger|null $logger 29 36 */ 30 public function __construct() { 37 public function __construct( ?Logger $logger = null ) { 38 $this->logger = $logger ?? new Logger(); 31 39 $this->api_token_manager = ( new SdkService() )->get_api_token_manager(); 32 40 } … … 50 58 $api_token = $this->api_token_manager->get()->getApiToken(); 51 59 } catch ( ApiException | ClientExceptionInterface $exception ) { 52 Logger::log_error( $exception->getMessage() );60 $this->logger->log_error( $exception->getMessage() ); 53 61 return ''; 54 62 } -
multisafepay/trunk/src/Services/OrderService.php
r3048898 r3114383 74 74 } 75 75 76 if ( ! empty( $_POST[ ( $this->payment_method_service->get_woocommerce_payment_gateway_by_multisafepay_gateway_code( $gateway_code ) )->get_payment_method_id() . '_payment_component_payload' ] ) ) {77 $payment_method_id = ( new PaymentMethodService() )->get_woocommerce_payment_gateway_by_multisafepay_gateway_code( $gateway_code )->get_payment_method_id();76 if ( ! empty( $_POST[ $order->get_payment_method() . '_payment_component_payload' ] ) ) { 77 $payment_method_id = $order->get_payment_method(); 78 78 $payment_component_payload_key = $payment_method_id . '_payment_component_payload'; 79 79 $payment_component_payload = sanitize_text_field( wp_unslash( $_POST[ $payment_component_payload_key ] ?? '' ) ); -
multisafepay/trunk/src/Services/PaymentMethodService.php
r3088253 r3114383 10 10 use MultiSafepay\WooCommerce\PaymentMethods\Base\BaseGiftCardPaymentMethod; 11 11 use MultiSafepay\WooCommerce\PaymentMethods\Base\BasePaymentMethod; 12 use MultiSafepay\WooCommerce\PaymentMethods\Base\BaseBrandedPaymentMethod; 12 13 use MultiSafepay\WooCommerce\Utils\Logger; 13 14 use Psr\Http\Client\ClientExceptionInterface; … … 31 32 32 33 /** 33 * PaymentMethodsService constructor. 34 * 35 * @return void 36 */ 37 public function __construct() { 34 * @var Logger 35 */ 36 private $logger; 37 38 /** 39 * @param Logger|null $logger 40 */ 41 public function __construct( ?Logger $logger = null ) { 42 $this->logger = $logger ?? new Logger(); 38 43 try { 39 44 $this->payment_method_manager = ( new SdkService() )->get_payment_method_manager(); 40 45 } catch ( ApiException $api_exception ) { 41 Logger::log_error( $api_exception->getMessage() );46 $this->logger->log_error( $api_exception->getMessage() ); 42 47 } 43 48 } … … 75 80 76 81 if ( null === $this->payment_method_manager ) { 77 Logger::log_error( 'SDK is not initialized' );82 $this->logger->log_error( 'SDK is not initialized' ); 78 83 return array(); 79 84 } … … 90 95 ); 91 96 } catch ( Exception | ApiException | InvalidDataInitializationException | ClientExceptionInterface $exception ) { 92 Logger::log_error( $exception->getMessage() );97 $this->logger->log_error( $exception->getMessage() ); 93 98 return array(); 94 99 } … … 108 113 $multisafepay_payment_methods = $this->get_multisafepay_payment_methods_from_api(); 109 114 foreach ( $multisafepay_payment_methods as $multisafepay_payment_method ) { 110 if ( isset( $multisafepay_payment_method['type'] ) && 'coupon' === $multisafepay_payment_method['type'] ) { 111 $woocommerce_payment_gateways[ self::get_legacy_woocommerce_payment_gateway_ids( $multisafepay_payment_method['id'] ) ] = new BaseGiftCardPaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 112 } 113 if ( isset( $multisafepay_payment_method['type'] ) && 'payment-method' === $multisafepay_payment_method['type'] ) { 114 $woocommerce_payment_gateways[ self::get_legacy_woocommerce_payment_gateway_ids( $multisafepay_payment_method['id'] ) ] = new BasePaymentMethod( new PaymentMethod( $multisafepay_payment_method ) ); 115 } 116 } 115 if ( isset( $multisafepay_payment_method['type'] ) ) { 116 $woocommerce_payment_gateways = $this->create_woocommerce_payment_gateways( $multisafepay_payment_method, $woocommerce_payment_gateways ); 117 } 118 } 119 120 return $woocommerce_payment_gateways; 121 } 122 123 /** 124 * @param array $multisafepay_payment_method 125 * @param array $woocommerce_payment_gateways 126 * @return array 127 */ 128 public function create_woocommerce_payment_gateways( array $multisafepay_payment_method, array $woocommerce_payment_gateways ) : array { 129 $payment_method_id = self::get_legacy_woocommerce_payment_gateway_ids( $multisafepay_payment_method['id'] ); 130 131 try { 132 $payment_method = new PaymentMethod( $multisafepay_payment_method ); 133 } catch ( InvalidDataInitializationException $exception ) { 134 $this->logger->log_error( $exception->getMessage() ); 135 return $woocommerce_payment_gateways; 136 } 137 138 if ( 'payment-method' === $multisafepay_payment_method['type'] ) { 139 $woocommerce_payment_gateways[ $payment_method_id ] = new BasePaymentMethod( $payment_method ); 140 $woocommerce_payment_gateways = $this->create_branded_woocommerce_payment_gateways( $multisafepay_payment_method, $woocommerce_payment_gateways, $payment_method ); 141 } 142 143 if ( 'coupon' === $multisafepay_payment_method['type'] ) { 144 $woocommerce_payment_gateways[ $payment_method_id ] = new BaseGiftCardPaymentMethod( $payment_method ); 145 } 146 147 return $woocommerce_payment_gateways; 148 } 149 150 /** 151 * @param array $multisafepay_payment_method 152 * @param array $woocommerce_payment_gateways 153 * @param PaymentMethod $payment_method 154 * @return array 155 */ 156 public function create_branded_woocommerce_payment_gateways( array $multisafepay_payment_method, array $woocommerce_payment_gateways, PaymentMethod $payment_method ) : array { 157 foreach ( $multisafepay_payment_method['brands'] as $brand ) { 158 if ( ! empty( $brand['allowed_countries'] ) ) { 159 $payment_method_id = self::get_legacy_woocommerce_payment_gateway_ids( $brand['id'] ); 160 $woocommerce_payment_gateways[ $payment_method_id ] = new BaseBrandedPaymentMethod( $payment_method, $brand ); 161 } 162 } 163 117 164 return $woocommerce_payment_gateways; 118 165 } … … 174 221 if ( $payment_method_object->supportsPaymentComponent() ) { 175 222 $payment_methods_with_payment_component[] = self::get_legacy_woocommerce_payment_gateway_ids( $payment_method_object->getId() ); 223 foreach ( $payment_method['brands'] as $brand ) { 224 if ( ! empty( $brand['allowed_countries'] ) ) { 225 $payment_methods_with_payment_component[] = self::get_legacy_woocommerce_payment_gateway_ids( $brand['id'] ); 226 } 227 } 176 228 } 177 229 } … … 188 240 */ 189 241 public static function get_legacy_woocommerce_payment_gateway_ids( string $code ): string { 190 191 242 $woocommerce_payment_gateway_id = 'multisafepay_' . str_replace( '-', '_', sanitize_title( strtolower( $code ) ) ); 192 243 -
multisafepay/trunk/src/Services/SdkService.php
r3048898 r3114383 14 14 use MultiSafepay\Sdk; 15 15 use MultiSafepay\WooCommerce\Client\MultiSafepayClient; 16 use MultiSafepay\WooCommerce\Services\PaymentMethodService;17 16 use MultiSafepay\WooCommerce\Utils\Logger; 18 17 use Nyholm\Psr7\Factory\Psr17Factory; … … 44 43 private $sdk = null; 45 44 45 /** 46 * @var Logger 47 */ 48 private $logger; 46 49 47 50 /** 48 51 * SdkService constructor. 49 52 * 50 * @param string $api_key 51 * @param boolean $test_mode 52 */ 53 public function __construct( string $api_key = null, bool $test_mode = null ) { 53 * @param string $api_key 54 * @param boolean $test_mode 55 * @param Logger|null $logger 56 */ 57 public function __construct( string $api_key = null, bool $test_mode = null, ?Logger $logger = null ) { 54 58 $this->api_key = $api_key ?? $this->get_api_key(); 55 59 $this->test_mode = $test_mode ?? $this->get_test_mode(); 60 $this->logger = $logger ?? new Logger(); 56 61 $psr_factory = new Psr17Factory(); 57 62 $client = new MultiSafepayClient(); … … 60 65 } catch ( InvalidApiKeyException $invalid_api_key_exception ) { 61 66 set_transient( 'multisafepay_payment_methods', array() ); 62 Logger::log_error( $invalid_api_key_exception->getMessage() );67 $this->logger->log_error( $invalid_api_key_exception->getMessage() ); 63 68 } 64 69 } … … 96 101 return $this->sdk->getGatewayManager(); 97 102 } catch ( ApiException $api_exception ) { 98 Logger::log_error( $api_exception->getMessage() );103 $this->logger->log_error( $api_exception->getMessage() ); 99 104 return new WP_Error( 'multisafepay-warning', $api_exception->getMessage() ); 100 105 } … … 111 116 return $this->get_gateway_manager()->getGateways( true ); 112 117 } catch ( ApiException $api_exception ) { 113 Logger::log_error( $api_exception->getMessage() );118 $this->logger->log_error( $api_exception->getMessage() ); 114 119 return new WP_Error( 'multisafepay-warning', $api_exception->getMessage() ); 115 120 } … … 149 154 public function get_api_token_manager(): ?ApiTokenManager { 150 155 if ( null === $this->sdk ) { 151 Logger::log_error( 'SDK is not initialized' );156 $this->logger->log_error( 'SDK is not initialized' ); 152 157 return null; 153 158 } … … 162 167 public function get_payment_method_manager(): ?PaymentMethodManager { 163 168 if ( null === $this->sdk ) { 164 Logger::log_error( 'SDK is not initialized' );169 $this->logger->log_error( 'SDK is not initialized' ); 165 170 return null; 166 171 } … … 168 173 return $this->sdk->getPaymentMethodManager(); 169 174 } catch ( ApiException $api_exception ) { 170 Logger::log_error( $api_exception->getMessage() );175 $this->logger->log_error( $api_exception->getMessage() ); 171 176 return null; 172 177 } … … 184 189 $tokens = $this->sdk->getTokenManager()->getListByGatewayCodeAsArray( $customer_reference, $gateway_code ); 185 190 } catch ( ApiException $api_exception ) { 186 Logger::log_error( $api_exception->getMessage() );191 $this->logger->log_error( $api_exception->getMessage() ); 187 192 return array(); 188 193 } catch ( ClientExceptionInterface $client_exception ) { 189 Logger::log_error( $client_exception->getMessage() );194 $this->logger->log_error( $client_exception->getMessage() ); 190 195 return array(); 191 196 } catch ( Exception $exception ) { 192 Logger::log_error( $exception->getMessage() );197 $this->logger->log_error( $exception->getMessage() ); 193 198 return array(); 194 199 } … … 207 212 $gateway_merchant_id = $account_manager->get()->getAccountId(); 208 213 } catch ( ApiException | ClientExceptionInterface | Exception $exception ) { 209 Logger::log_error( 'Error when try to set the merchant credentials: ' . $exception->getMessage() );214 $this->logger->log_error( 'Error when try to set the merchant credentials: ' . $exception->getMessage() ); 210 215 } 211 216 -
multisafepay/trunk/src/Services/ShoppingCartService.php
r2995309 r3114383 25 25 26 26 /** 27 * @var Logger 28 */ 29 private $logger; 30 31 /** 32 * @param Logger|null $logger 33 */ 34 public function __construct( ?Logger $logger = null ) { 35 $this->logger = $logger ?? new Logger(); 36 } 37 38 /** 27 39 * @param WC_Order $order 28 40 * @param string $currency … … 39 51 40 52 if ( get_option( 'multisafepay_debugmode', false ) ) { 41 Logger::log_info( wc_print_r( $order->get_items(), true ) );53 $this->logger->log_info( wc_print_r( $order->get_items(), true ) ); 42 54 } 43 55 … … 72 84 73 85 if ( get_option( 'multisafepay_debugmode', false ) ) { 74 Logger::log_info( wp_json_encode( $shopping_cart->getData() ) );86 $this->logger->log_info( wp_json_encode( $shopping_cart->getData() ) ); 75 87 } 76 88 -
multisafepay/trunk/src/Utils/Logger.php
r2974626 r3114383 4 4 5 5 use WC_Log_Handler_File; 6 use WC_Logger_Interface; 6 7 7 8 /** … … 9 10 */ 10 11 class Logger { 12 13 /** 14 * @var WC_Logger_Interface 15 */ 16 private $logger; 17 18 /** 19 * @param WC_Logger_Interface|null $logger 20 */ 21 public function __construct( ?WC_Logger_Interface $logger = null ) { 22 $this->logger = $logger ?? wc_get_logger(); 23 } 11 24 12 25 /** … … 17 30 * @param string $message 18 31 */ 19 public static function log_emergency( string $message ) { 20 $logger = wc_get_logger(); 21 $logger->log( 'emergency', $message, array( 'source' => 'multisafepay' ) ); 32 public function log_emergency( string $message ) { 33 $this->logger->log( 'emergency', $message, array( 'source' => 'multisafepay' ) ); 22 34 } 23 35 … … 29 41 * @param string $message 30 42 */ 31 public static function log_alert( string $message ) { 32 $logger = wc_get_logger(); 33 $logger->log( 'alert', $message, array( 'source' => 'multisafepay' ) ); 43 public function log_alert( string $message ) { 44 $this->logger->log( 'alert', $message, array( 'source' => 'multisafepay' ) ); 34 45 } 35 46 … … 41 52 * @param string $message 42 53 */ 43 public static function log_critical( string $message ) { 44 $logger = wc_get_logger(); 45 $logger->log( 'critical', $message, array( 'source' => 'multisafepay' ) ); 54 public function log_critical( string $message ) { 55 $this->logger->log( 'critical', $message, array( 'source' => 'multisafepay' ) ); 46 56 } 47 57 … … 53 63 * @param string $message 54 64 */ 55 public static function log_error( string $message ) { 56 $logger = wc_get_logger(); 57 $logger->log( 'error', $message, array( 'source' => 'multisafepay' ) ); 65 public function log_error( string $message ) { 66 $this->logger->log( 'error', $message, array( 'source' => 'multisafepay' ) ); 58 67 } 59 68 … … 65 74 * @param string $message 66 75 */ 67 public static function log_warning( string $message ) { 68 $logger = wc_get_logger(); 69 $logger->log( 'warning', $message, array( 'source' => 'multisafepay' ) ); 76 public function log_warning( string $message ) { 77 $this->logger->log( 'warning', $message, array( 'source' => 'multisafepay' ) ); 70 78 } 71 79 … … 77 85 * @param string $message 78 86 */ 79 public static function log_notice( string $message ) { 80 $logger = wc_get_logger(); 81 $logger->log( 'notice', $message, array( 'source' => 'multisafepay' ) ); 87 public function log_notice( string $message ) { 88 $this->logger->log( 'notice', $message, array( 'source' => 'multisafepay' ) ); 82 89 } 83 90 … … 89 96 * @param string $message 90 97 */ 91 public staticfunction log_info( string $message ) {98 public function log_info( string $message ) { 92 99 if ( get_option( 'multisafepay_debugmode', false ) ) { 93 $logger = wc_get_logger(); 94 $logger->log( 'info', $message, array( 'source' => 'multisafepay' ) ); 100 $this->logger->log( 'info', $message, array( 'source' => 'multisafepay' ) ); 95 101 } 96 102 } … … 103 109 * @param string $message 104 110 */ 105 public staticfunction log_debug( string $message ) {111 public function log_debug( string $message ) { 106 112 if ( get_option( 'multisafepay_debugmode', false ) ) { 107 $logger = wc_get_logger(); 108 $logger->log( 'debug', $message, array( 'source' => 'multisafepay' ) ); 113 $this->logger->log( 'debug', $message, array( 'source' => 'multisafepay' ) ); 109 114 } 110 115 } … … 116 121 */ 117 122 private function get_logs(): array { 118 $logs = WC_Log_Handler_File::get_log_files(); 119 return $logs; 123 return WC_Log_Handler_File::get_log_files(); 120 124 } 121 125 -
multisafepay/trunk/vendor/autoload.php
r3048898 r3114383 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit 8122490751e95ad36d38dc1115ae59ff::getLoader();25 return ComposerAutoloaderInitdbc0eb47ba0f8cbc67eba2344d97c2f8::getLoader(); -
multisafepay/trunk/vendor/composer/autoload_real.php
r3048898 r3114383 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 8122490751e95ad36d38dc1115ae59ff5 class ComposerAutoloaderInitdbc0eb47ba0f8cbc67eba2344d97c2f8 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit 8122490751e95ad36d38dc1115ae59ff', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInitdbc0eb47ba0f8cbc67eba2344d97c2f8', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 29 spl_autoload_unregister(array('ComposerAutoloaderInit 8122490751e95ad36d38dc1115ae59ff', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInitdbc0eb47ba0f8cbc67eba2344d97c2f8', 'loadClassLoader')); 30 30 31 31 require __DIR__ . '/autoload_static.php'; 32 call_user_func(\Composer\Autoload\ComposerStaticInit 8122490751e95ad36d38dc1115ae59ff::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInitdbc0eb47ba0f8cbc67eba2344d97c2f8::getInitializer($loader)); 33 33 34 34 $loader->register(true); -
multisafepay/trunk/vendor/composer/autoload_static.php
r3048898 r3114383 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 8122490751e95ad36d38dc1115ae59ff7 class ComposerStaticInitdbc0eb47ba0f8cbc67eba2344d97c2f8 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 63 63 { 64 64 return \Closure::bind(function () use ($loader) { 65 $loader->prefixLengthsPsr4 = ComposerStaticInit 8122490751e95ad36d38dc1115ae59ff::$prefixLengthsPsr4;66 $loader->prefixDirsPsr4 = ComposerStaticInit 8122490751e95ad36d38dc1115ae59ff::$prefixDirsPsr4;67 $loader->classMap = ComposerStaticInit 8122490751e95ad36d38dc1115ae59ff::$classMap;65 $loader->prefixLengthsPsr4 = ComposerStaticInitdbc0eb47ba0f8cbc67eba2344d97c2f8::$prefixLengthsPsr4; 66 $loader->prefixDirsPsr4 = ComposerStaticInitdbc0eb47ba0f8cbc67eba2344d97c2f8::$prefixDirsPsr4; 67 $loader->classMap = ComposerStaticInitdbc0eb47ba0f8cbc67eba2344d97c2f8::$classMap; 68 68 69 69 }, null, ClassLoader::class); -
multisafepay/trunk/vendor/composer/installed.json
r3088253 r3114383 3 3 { 4 4 "name": "multisafepay/php-sdk", 5 "version": "5.1 3.0",6 "version_normalized": "5.1 3.0.0",5 "version": "5.14.0", 6 "version_normalized": "5.14.0.0", 7 7 "source": { 8 8 "type": "git", 9 9 "url": "https://github.com/MultiSafepay/php-sdk.git", 10 "reference": " b88fa079981d590a70275d528cf52d8fd07affab"11 }, 12 "dist": { 13 "type": "zip", 14 "url": "https://api.github.com/repos/MultiSafepay/php-sdk/zipball/ b88fa079981d590a70275d528cf52d8fd07affab",15 "reference": " b88fa079981d590a70275d528cf52d8fd07affab",10 "reference": "408f102e3228f072f2c1bcc76ac29a8031415480" 11 }, 12 "dist": { 13 "type": "zip", 14 "url": "https://api.github.com/repos/MultiSafepay/php-sdk/zipball/408f102e3228f072f2c1bcc76ac29a8031415480", 15 "reference": "408f102e3228f072f2c1bcc76ac29a8031415480", 16 16 "shasum": "" 17 17 }, … … 38 38 "jschaedl/iban-validation": "Adds additional IBAN validation for \\MultiSafepay\\ValueObject\\IbanNumber" 39 39 }, 40 "time": "2024-0 4-16T11:41:31+00:00",40 "time": "2024-07-08T12:43:31+00:00", 41 41 "type": "library", 42 42 "installation-source": "dist", … … 53 53 "support": { 54 54 "issues": "https://github.com/MultiSafepay/php-sdk/issues", 55 "source": "https://github.com/MultiSafepay/php-sdk/tree/5.1 3.0"55 "source": "https://github.com/MultiSafepay/php-sdk/tree/5.14.0" 56 56 }, 57 57 "install-path": "../multisafepay/php-sdk" -
multisafepay/trunk/vendor/composer/installed.php
r3099249 r3114383 2 2 'root' => array( 3 3 'name' => 'multisafepay/woocommerce', 4 'pretty_version' => '6. 5.1',5 'version' => '6. 5.1.0',6 'reference' => 'a57a06a32837f1542476a9726a1e3749e08ba92d',4 'pretty_version' => '6.6.0', 5 'version' => '6.6.0.0', 6 'reference' => null, 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'multisafepay/php-sdk' => array( 14 'pretty_version' => '5.1 3.0',15 'version' => '5.1 3.0.0',16 'reference' => ' b88fa079981d590a70275d528cf52d8fd07affab',14 'pretty_version' => '5.14.0', 15 'version' => '5.14.0.0', 16 'reference' => '408f102e3228f072f2c1bcc76ac29a8031415480', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../multisafepay/php-sdk', … … 21 21 ), 22 22 'multisafepay/woocommerce' => array( 23 'pretty_version' => '6. 5.1',24 'version' => '6. 5.1.0',25 'reference' => 'a57a06a32837f1542476a9726a1e3749e08ba92d',23 'pretty_version' => '6.6.0', 24 'version' => '6.6.0.0', 25 'reference' => null, 26 26 'type' => 'wordpress-plugin', 27 27 'install_path' => __DIR__ . '/../../', -
multisafepay/trunk/vendor/multisafepay/php-sdk/CHANGELOG.md
r3072171 r3114383 7 7 ## [Unreleased] 8 8 9 ## [5.14.0] - 2024-07-08 10 ### Added 11 - PHPSDK-155: Throw ApiUnavailableException when API returns 501/503 HTTP codes 12 - PHPSDK-156: Add getGatewayId in TransactionResponse class 13 9 14 ## [5.13.0] - 2024-04-16 10 15 ### Added 11 +PHPSDK-151: Update Gateways::SHOPPING_CART_REQUIRED_GATEWAYS adding 'BNPL_INST', 'IN3B2B', 'SANTANDER', 'ZINIA', 'ZINIA_IN3', 'BNPL_OB', 'BNPL_MF' gateways codes16 - PHPSDK-151: Update Gateways::SHOPPING_CART_REQUIRED_GATEWAYS adding 'BNPL_INST', 'IN3B2B', 'SANTANDER', 'ZINIA', 'ZINIA_IN3', 'BNPL_OB', 'BNPL_MF' gateways codes 12 17 13 18 ## [5.12.1] - 2024-03-11 14 19 ### Fixed 15 +PHPSDK-146: Fix ApiException not being hinted as a thrown exception, even though it is, by fixing the PHP DocBlocks @throws tags20 - PHPSDK-146: Fix ApiException not being hinted as a thrown exception, even though it is, by fixing the PHP DocBlocks @throws tags 16 21 17 22 ## [5.12.0] - 2023-12-01 18 23 ### Added 19 +PHPSDK-139: Add support to set var1, var2 and var3, within the OrderRequest object20 +PHPSDK-140: Add support to set custom_info, within the OrderRequest object, thanks to @DaanDeSmedt24 - PHPSDK-139: Add support to set var1, var2 and var3, within the OrderRequest object 25 - PHPSDK-140: Add support to set custom_info, within the OrderRequest object, thanks to @DaanDeSmedt 21 26 22 27 ## [5.11.2] - 2023-10-13 23 28 ### Fixed 24 +PHPSDK-134: Fix errors when only reference is set, within the CustomerDetails object25 26 ### Changed 27 +PHPSDK-136: Remove PluginDetails as mandatory from the Order Request29 - PHPSDK-134: Fix errors when only reference is set, within the CustomerDetails object 30 31 ### Changed 32 - PHPSDK-136: Remove PluginDetails as mandatory from the Order Request 28 33 29 34 ## [5.11.1] - 2023-07-31 … … 89 94 ## [5.5.0] - 2022-05-11 90 95 ### Added 91 +PHPSDK-90: Add MAESTRO tokens within the results of the CREDITCARD tokens request92 93 ### Changed 94 +PHPSDK-91: Add trim on API key when initializing the SDK96 - PHPSDK-90: Add MAESTRO tokens within the results of the CREDITCARD tokens request 97 98 ### Changed 99 - PHPSDK-91: Add trim on API key when initializing the SDK 95 100 96 101 ## [5.4.0] - 2021-11-30 -
multisafepay/trunk/vendor/multisafepay/php-sdk/composer.json
r3072171 r3114383 4 4 "type": "library", 5 5 "license": "MIT", 6 "version": "5.1 3.0",6 "version": "5.14.0", 7 7 "require": { 8 8 "php": "^7.2|^8.0", -
multisafepay/trunk/vendor/multisafepay/php-sdk/src/Api/Base/Response.php
r3050467 r3114383 9 9 use MultiSafepay\Api\Pager\Pager; 10 10 use MultiSafepay\Exception\ApiException; 11 use MultiSafepay\Exception\ApiUnavailableException; 11 12 12 13 /** … … 38 39 * @param array $context 39 40 * @return Response 40 * @throws ApiException 41 * @throws ApiException|ApiUnavailableException 41 42 */ 42 43 public static function withJson(string $json, array $context = []): Response … … 55 56 * @param array $context 56 57 * @param string $raw 57 * @throws ApiException 58 * @throws ApiException|ApiUnavailableException 58 59 */ 59 60 public function __construct(array $data, array $context = [], string $raw = '') … … 83 84 * @return void 84 85 * @throws ApiException 86 * @throws ApiUnavailableException 85 87 */ 86 88 private function validate(array $data, array $context = []): void … … 95 97 if (!empty($data['data']) && !is_array($data['data'])) { 96 98 [$errorCode, $errorInfo] = self::ERROR_INVALID_DATA_TYPE; 99 } 100 101 if (in_array($context['http_response_code'], [501, 503])) { 102 throw (new ApiUnavailableException( 103 'The MultiSafepay API could not be reached', 104 $context['http_response_code'] 105 )); 97 106 } 98 107 -
multisafepay/trunk/vendor/multisafepay/php-sdk/src/Api/Transactions/TransactionResponse.php
r3050467 r3114383 31 31 class TransactionResponse extends ResponseBody 32 32 { 33 34 33 /** 35 34 * @var string … … 383 382 return in_array($this->getPaymentDetails()->getType(), Gateways::SHOPPING_CART_REQUIRED_GATEWAYS, true); 384 383 } 384 385 /** 386 * Retrieve the gateway ID from the transaction 387 * Will return multiple gateway IDs as a string of comma separated values if multiple payment methods are used 388 * 389 * @return string 390 */ 391 public function getGatewayId(): string 392 { 393 $paymentMethods = []; 394 395 foreach ($this->getPaymentMethods() as $paymentMethod) { 396 if ($paymentMethod->getType() === 'COUPON') { 397 $paymentMethods[] = $paymentMethod->getData()['coupon_brand'] ?? 'unknown'; 398 continue; 399 } 400 401 $paymentMethods[] = $paymentMethod->getType(); 402 } 403 404 return implode(', ', $paymentMethods); 405 } 385 406 } -
multisafepay/trunk/vendor/multisafepay/php-sdk/src/Client/Client.php
r3050467 r3114383 12 12 use MultiSafepay\Api\Base\Response as ApiResponse; 13 13 use MultiSafepay\Exception\ApiException; 14 use MultiSafepay\Exception\ApiUnavailableException; 14 15 use MultiSafepay\Exception\InvalidApiKeyException; 15 use MultiSafepay\Exception\StrictModeException;16 16 use Psr\Http\Client\ClientExceptionInterface; 17 17 use Psr\Http\Client\ClientInterface; … … 105 105 * @param array $context 106 106 * @return ApiResponse 107 * @throws ClientExceptionInterface 108 * @throws ApiException 107 * @throws ClientExceptionInterface|ApiException|ApiUnavailableException 109 108 */ 110 109 public function createPostRequest( … … 116 115 ->withBody($this->createBody($this->getRequestBody($requestBody))) 117 116 ->withHeader('Content-Length', strlen($this->getRequestBody($requestBody))); 117 $httpResponse = $this->httpClient->sendRequest($request); 118 118 119 119 $context['headers'] = $request->getHeaders(); 120 120 $context['request_body'] = $this->getRequestBody($requestBody); 121 $httpResponse = $this->httpClient->sendRequest($request); 121 $context['http_response_code'] = $httpResponse->getStatusCode() ?? 0; 122 122 123 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 123 124 } … … 129 130 * @param array $context 130 131 * @return ApiResponse 131 * @throws ClientExceptionInterface|ApiException 132 * @throws ClientExceptionInterface|ApiException|ApiUnavailableException 132 133 */ 133 134 public function createPatchRequest( … … 139 140 ->withBody($this->createBody($this->getRequestBody($requestBody))) 140 141 ->withHeader('Content-Length', strlen($this->getRequestBody($requestBody))); 142 $httpResponse = $this->httpClient->sendRequest($request); 141 143 142 144 $context['headers'] = $request->getHeaders(); 143 145 $context['request_body'] = $this->getRequestBody($requestBody); 144 $httpResponse = $this->httpClient->sendRequest($request); 145 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 146 } 147 148 /** 149 * @param string $endpoint 150 * @param array $parameters 151 * @param array $context 152 * @return ApiResponse 153 * @throws ClientExceptionInterface|ApiException 146 $context['http_response_code'] = $httpResponse->getStatusCode() ?? 0; 147 148 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 149 } 150 151 /** 152 * @param string $endpoint 153 * @param array $parameters 154 * @param array $context 155 * @return ApiResponse 156 * @throws ClientExceptionInterface|ApiException|ApiUnavailableException 154 157 */ 155 158 public function createGetRequest(string $endpoint, array $parameters = [], array $context = []): ApiResponse … … 157 160 $request = $this->createRequest($endpoint, self::METHOD_GET, $parameters); 158 161 $httpResponse = $this->httpClient->sendRequest($request); 162 159 163 $context['headers'] = $request->getHeaders(); 160 164 $context['request_params'] = $parameters; 161 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 162 } 163 164 /** 165 * @param string $endpoint 166 * @param array $parameters 167 * @param array $context 168 * @return ApiResponse 169 * @throws ClientExceptionInterface|ApiException 165 $context['http_response_code'] = $httpResponse->getStatusCode() ?? 0; 166 167 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 168 } 169 170 /** 171 * @param string $endpoint 172 * @param array $parameters 173 * @param array $context 174 * @return ApiResponse 175 * @throws ClientExceptionInterface|ApiException|ApiUnavailableException 170 176 */ 171 177 public function createDeleteRequest(string $endpoint, array $parameters = [], array $context = []): ApiResponse … … 173 179 $request = $this->createRequest($endpoint, self::METHOD_DELETE, $parameters); 174 180 $httpResponse = $this->httpClient->sendRequest($request); 181 175 182 $context['headers'] = $request->getHeaders(); 176 183 $context['request_params'] = $parameters; 184 $context['http_response_code'] = $httpResponse->getStatusCode() ?? 0; 185 177 186 return ApiResponse::withJson($httpResponse->getBody()->getContents(), $context); 178 187 } … … 203 212 } 204 213 $endpoint .= '?' . http_build_query($parameters); 214 205 215 return $this->url . $endpoint; 206 216 } … … 236 246 { 237 247 $this->strictMode = $strictMode; 248 238 249 return $this; 239 250 } … … 249 260 $url = $this->getRequestUrl($endpoint, $parameters); 250 261 $requestFactory = $this->getRequestFactory(); 262 251 263 return $requestFactory->createRequest($method, $url) 252 264 ->withHeader('api_key', $this->apiKey->get()) … … 262 274 { 263 275 $requestBody->useStrictMode($this->strictMode); 276 264 277 return json_encode($requestBody->getData(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); 265 278 } -
multisafepay/trunk/vendor/multisafepay/php-sdk/src/Util/Version.php
r3072171 r3114383 18 18 class Version 19 19 { 20 public const SDK_VERSION = '5.1 3.0';20 public const SDK_VERSION = '5.14.0'; 21 21 22 22 /**
Note: See TracChangeset
for help on using the changeset viewer.