Changeset 3328058
- Timestamp:
- 07/15/2025 09:04:28 AM (9 months ago)
- Location:
- wc-smartpay
- Files:
-
- 20 added
- 24 edited
- 1 copied
-
tags/1.0.29 (copied) (copied from wc-smartpay/trunk)
-
tags/1.0.29/README.md (modified) (2 diffs)
-
tags/1.0.29/assets/js/checkout.js (modified) (1 diff)
-
tags/1.0.29/includes/class-smartpay-admin-gateway-menu-renderer.php (added)
-
tags/1.0.29/includes/class-smartpay-admin.php (modified) (2 diffs)
-
tags/1.0.29/includes/class-smartpay-checkout-block.php (modified) (1 diff)
-
tags/1.0.29/includes/class-smartpay-gateway-registry.php (added)
-
tags/1.0.29/includes/class-smartpay-gateway-resolver.php (added)
-
tags/1.0.29/includes/class-smartpay-iframe-renderer.php (modified) (1 diff)
-
tags/1.0.29/includes/class-smartpay-invoice-observer.php (added)
-
tags/1.0.29/includes/class-smartpay-order-helper.php (modified) (1 diff)
-
tags/1.0.29/includes/class-smartpay-payment-gateway-applepay.php (added)
-
tags/1.0.29/includes/class-smartpay-payment-gateway-bitbygrow.php (added)
-
tags/1.0.29/includes/class-smartpay-payment-gateway-bitbyupay.php (added)
-
tags/1.0.29/includes/class-smartpay-payment-gateway-gpay.php (added)
-
tags/1.0.29/includes/class-smartpay-payment-gateway.php (modified) (8 diffs)
-
tags/1.0.29/includes/class-smartpay-payment-processor.php (modified) (10 diffs)
-
tags/1.0.29/includes/class-smartpay-payment-subgateway.php (added)
-
tags/1.0.29/includes/class-smartpay.php (modified) (7 diffs)
-
tags/1.0.29/readme.txt (modified) (3 diffs)
-
tags/1.0.29/smartpay.php (modified) (2 diffs)
-
tags/1.0.29/templates/admin-gateway-menu.php (added)
-
tags/1.0.29/templates/iframe.php (modified) (1 diff)
-
trunk/README.md (modified) (2 diffs)
-
trunk/assets/js/checkout.js (modified) (1 diff)
-
trunk/includes/class-smartpay-admin-gateway-menu-renderer.php (added)
-
trunk/includes/class-smartpay-admin.php (modified) (2 diffs)
-
trunk/includes/class-smartpay-checkout-block.php (modified) (1 diff)
-
trunk/includes/class-smartpay-gateway-registry.php (added)
-
trunk/includes/class-smartpay-gateway-resolver.php (added)
-
trunk/includes/class-smartpay-iframe-renderer.php (modified) (1 diff)
-
trunk/includes/class-smartpay-invoice-observer.php (added)
-
trunk/includes/class-smartpay-order-helper.php (modified) (1 diff)
-
trunk/includes/class-smartpay-payment-gateway-applepay.php (added)
-
trunk/includes/class-smartpay-payment-gateway-bitbygrow.php (added)
-
trunk/includes/class-smartpay-payment-gateway-bitbyupay.php (added)
-
trunk/includes/class-smartpay-payment-gateway-gpay.php (added)
-
trunk/includes/class-smartpay-payment-gateway.php (modified) (8 diffs)
-
trunk/includes/class-smartpay-payment-processor.php (modified) (10 diffs)
-
trunk/includes/class-smartpay-payment-subgateway.php (added)
-
trunk/includes/class-smartpay.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/smartpay.php (modified) (2 diffs)
-
trunk/templates/admin-gateway-menu.php (added)
-
trunk/templates/iframe.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wc-smartpay/tags/1.0.29/README.md
r3290978 r3328058 1 1 === SmartPay for WooCommerce === 2 Stable tag: 1.0.2 62 Stable tag: 1.0.29 3 3 Tested up to: 6.4 4 4 License: GPLv2 or later … … 97 97 - https://app11.smartpay.co.il/ 98 98 - https://api.protected-payment.com/ 99 Privacy policy: https://www.smartpay.co.il/privacy-policy/ -
wc-smartpay/tags/1.0.29/assets/js/checkout.js
r3039963 r3328058 1 const settings = window.wc.wcSettings.getSetting( 'wc-smartpay_data', {} ); 2 const label = window.wp.htmlEntities.decodeEntities( settings.title ) || window.wp.i18n.__( 'SmartPay', 'wc-smartpay' ); 3 const Content = () => { 4 return window.wp.htmlEntities.decodeEntities( settings.description || '' ); 5 }; 6 const Block_Gateway = { 7 name: 'wc-smartpay', 8 label: label, 9 content: Object( window.wp.element.createElement )( Content, null ), 10 edit: Object( window.wp.element.createElement )( Content, null ), 11 canMakePayment: () => true, 12 ariaLabel: label, 13 supports: { 14 features: settings.supports, 15 }, 16 }; 17 window.wc.wcBlocksRegistry.registerPaymentMethod( Block_Gateway ); 1 (function(){ 2 3 const Content = ( settings ) => { 4 return window.wp.htmlEntities.decodeEntities( settings?.description || '' ); 5 }; 6 7 const paymentMethodMap = new Map(); 8 paymentMethodMap.set( 'wc-smartpay', {label: window.wp.i18n.__( 'SmartPay', 'wc-smartpay' )} ) 9 paymentMethodMap.set( 'wc-smartpay-applepay', {label: window.wp.i18n.__( 'SmartPay - ApplePay', 'wc-smartpay' )} ) 10 paymentMethodMap.set( 'wc-smartpay-gpay', {label: window.wp.i18n.__( 'SmartPay - Google Pay', 'wc-smartpay' )} ) 11 paymentMethodMap.set( 'wc-smartpay-bitbygrow', {label: window.wp.i18n.__( 'SmartPay - bitByGrow', 'wc-smartpay' )} ) 12 paymentMethodMap.set( 'wc-smartpay-bitbyupay', {label: window.wp.i18n.__( 'SmartPay - bitByUpay', 'wc-smartpay' )} ) 13 14 paymentMethodMap.forEach(( defaultSettings, paymentMethodCode ) => { 15 const settings = window.wc.wcSettings.getSetting( paymentMethodCode + '_data', {} ); 16 const label = window.wp.htmlEntities.decodeEntities( settings.title ) || defaultSettings.label; 17 window.wc.wcBlocksRegistry.registerPaymentMethod( { 18 name: paymentMethodCode, 19 label: label, 20 content: Object( window.wp.element.createElement )( Content, settings ), 21 edit: Object( window.wp.element.createElement )( Content, settings ), 22 canMakePayment: () => true, 23 ariaLabel: label, 24 supports: { 25 feature: settings.supports 26 } 27 } ); 28 }); 29 30 })(); -
wc-smartpay/tags/1.0.29/includes/class-smartpay-admin.php
r3207141 r3328058 3 3 class Smartpay_Admin 4 4 { 5 6 5 /** 7 6 * Retrieve request … … 40 39 } 41 40 42 $payment_gateway = SmartPay::instance()->get_payment_gateway( );41 $payment_gateway = SmartPay::instance()->get_payment_gateway( $order->get_payment_method() ); 43 42 $payment_processor = new SmartPay_Payment_Processor( $payment_gateway ); 44 43 $result = $payment_processor->execute( $order ); -
wc-smartpay/tags/1.0.29/includes/class-smartpay-checkout-block.php
r3040711 r3328058 3 3 use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType; 4 4 5 class SmartPay_Checkout_Block extends AbstractPaymentMethodType 6 { 7 /** @var SmartPay_Payment_Gateway */ 8 private $gateway; 5 class SmartPay_Checkout_Block extends AbstractPaymentMethodType { 9 6 10 /** 11 * Initialize 12 * 13 * @return void 14 */ 15 public function initialize() 16 { 17 $this->name = Smartpay::instance()->get_app_id(); 18 $this->settings = get_option('woocommerce' . Smartpay::instance()->get_app_id() . '_settings'); 19 $this->gateway = new SmartPay_Payment_Gateway(); 20 } 7 /** @var string $code */ 8 private $code; 21 9 22 /** 23 * Check if payment method is active 24 * 25 * @return bool 26 */ 27 public function is_active() 28 { 29 return $this->gateway->is_available(); 30 } 10 /** @var SmartPay_Payment_Gateway */ 11 private $gateway; 31 12 32 /** 33 * Add script handle 34 * 35 * @return string[] 36 */ 37 public function get_payment_method_script_handles() 38 { 39 $handle = $this->name . '-blocks-integration'; 40 wp_register_script( 41 $handle, 42 SmartPay::instance()->get_url('assets/js/checkout.js'), 43 array( 44 'wc-blocks-registry', 45 'wc-settings', 46 'wp-element', 47 'wp-html-entities', 48 'wp-i18n' 49 ), 50 null, 51 true 52 ); 13 /** 14 * Define class dependencies 15 * 16 * @param string $gateway_code 17 */ 18 public function __construct( $gateway_code ) { 19 $this->code = $gateway_code; 20 } 53 21 54 return array( $handle ); 55 } 22 /** 23 * Initialize 24 * 25 * @return void 26 */ 27 public function initialize() { 28 $this->gateway = SmartPay_Gateway_Resolver::instance()->resolve_by_code( $this->code ); 29 $this->name = $this->gateway->id; 30 $this->settings = get_option('woocommerce' . $this->gateway->id . '_settings' ); 31 } 56 32 57 /** 58 * Retrieve payment method data 59 * 60 * @return array 61 */ 62 public function get_payment_method_data() 63 { 64 return array( 65 'title' => $this->gateway->get_title(), 66 'description' => $this->gateway->get_description(), 67 'supports' => $this->gateway->supports 68 ); 69 } 33 /** 34 * Check if payment method is active 35 * 36 * @return bool 37 */ 38 public function is_active() { 39 return $this->gateway->is_available(); 40 } 41 42 /** 43 * Add script handle 44 * 45 * @return string[] 46 */ 47 public function get_payment_method_script_handles() { 48 $handle = 'wc-smartpay-blocks-integration'; 49 wp_register_script( 50 $handle, 51 SmartPay::instance()->get_url('assets/js/checkout.js' ), 52 array( 53 'wc-blocks-registry', 54 'wc-settings', 55 'wp-element', 56 'wp-html-entities', 57 'wp-i18n' 58 ), 59 null, 60 true 61 ); 62 63 return array( $handle ); 64 } 65 66 /** 67 * Retrieve payment method data 68 * 69 * @return array 70 */ 71 public function get_payment_method_data() { 72 return array( 73 'title' => $this->gateway->get_title(), 74 'description' => $this->gateway->get_description(), 75 'supports' => $this->gateway->supports 76 ); 77 } 70 78 } -
wc-smartpay/tags/1.0.29/includes/class-smartpay-iframe-renderer.php
r3031558 r3328058 57 57 */ 58 58 $order = wc_get_order( $order_id ); 59 $payment_gateway = SmartPay::instance()->get_payment_gateway( );59 $payment_gateway = SmartPay::instance()->get_payment_gateway( $order->get_payment_method() ); 60 60 $payment_processor = new SmartPay_Payment_Processor( $payment_gateway ); 61 61 $result = $payment_processor->execute( $order ); -
wc-smartpay/tags/1.0.29/includes/class-smartpay-order-helper.php
r3290978 r3328058 71 71 'name' => implode( ' ', $name_array), 72 72 'email' => $customer_email, 73 'phone' => $order->get_billing_phone(),73 'phone' => preg_replace('/\D+/i', '', $order->get_billing_phone() ?? ''), 74 74 'billing_address' => [ 75 75 [ -
wc-smartpay/tags/1.0.29/includes/class-smartpay-payment-gateway.php
r3290978 r3328058 16 16 17 17 /** 18 * @var string $integration_id 19 */ 20 protected $integration_id; 21 22 /** 18 23 * Payment processor 19 24 * 20 25 * @var SmartPay_Payment_Processor 21 26 */ 22 pr ivate$payment_processor;27 protected $payment_processor; 23 28 24 29 /** … … 40 45 'pre-orders', 41 46 'products', 42 'refunds', 47 'refunds', 43 48 'subscriptions', 44 49 'multiple_subscriptions', … … 49 54 'subscription_date_changes', 50 55 'subscription_payment_method_change', 51 'subscription_payment_method_change_admin', 56 'subscription_payment_method_change_admin', 52 57 'subscription_payment_method_change_customer', 53 58 ); 59 60 SmartPay_Gateway_Registry::instance()->register( $this->id, $this); 54 61 55 62 do_action( 'smartpay_payment_gateway_init_after', $this ); … … 67 74 68 75 add_action( 'woocommerce_api_smartpay_ipn', array( $this->payment_processor(), 'process_ipn' ) ); 69 add_action( 'woocommerce_thankyou_' . self::METHOD_CODE, array( SmartPay_Iframe_Redirect_Renderer::class, 'render' ), 1, 1 ); 76 add_action( 'woocommerce_thankyou_' . $this->id, array( SmartPay_Iframe_Redirect_Renderer::class, 'render' ), 1, 1 ); 77 add_action( 'woocommerce_receipt_' . $this->id, array( new SmartPay_Iframe_Renderer(), 'render' ) ); 70 78 71 79 if ( class_exists( 'WC_Subscriptions_Order' ) … … 83 91 84 92 /** 93 * Retrieve integration id 94 * 95 * @return string 96 */ 97 public function get_integration_id() { 98 return $this->integration_id; 99 } 100 101 /** 85 102 * Plugin options. 86 103 */ … … 325 342 */ 326 343 public function admin_options() { 327 echo '<h3>' . esc_html_e( 'SmartPay', 'wc-smartpay' ) . '</h3>'; 344 (new SmartPay_Admin_Gateway_Menu_Renderer())->render(); 345 echo '<h3>' . esc_html_e( $this->title, 'wc-smartpay' ) . '</h3>'; 328 346 echo '<p>'; 329 // phpcs:disable347 // phpcs:disable 330 348 printf( 331 349 esc_html( __( 'For more information %s', 'wc-smartpay' ) ), 332 350 esc_url( 'http://www.smartpay.co.il' ) 333 351 ); 334 // phpcs:enable352 // phpcs:enable 335 353 echo '</p>'; 336 354 echo '<table class="form-table">'; … … 354 372 * @return SmartPay_Payment_Processor 355 373 */ 356 pr ivatefunction payment_processor() {374 protected function payment_processor() { 357 375 if ( ! $this->payment_processor ) { 358 376 $this->payment_processor = new SmartPay_Payment_Processor( $this ); … … 369 387 public function process_payment( $order_id ) { 370 388 $order = wc_get_order( $order_id ); 371 if ( SmartPay::instance()->config()->is( 'use_iframe' ) ) { 389 $payment_method = SmartPay_Gateway_Registry::instance()->get_instance( $order->get_payment_method() ); 390 $use_iframe = $payment_method instanceof SmartPay_Payment_Subgateway 391 ? $payment_method->config()->is('use_iframe' ) : Smartpay::instance()->config()->is( 'use_iframe' ); 392 393 if ( $use_iframe ) { 372 394 return array( 373 395 'result' => 'success', -
wc-smartpay/tags/1.0.29/includes/class-smartpay-payment-processor.php
r3290978 r3328058 180 180 181 181 $send_currency = SmartPay::instance()->config()->get( 'currency' ); 182 183 $gateway = SmartPay_Gateway_Resolver::instance()->resolve_by_code( $order->get_payment_method() ); 182 184 $params = array( 183 185 'page_uuid' => SmartPay::instance()->config()->get( 'page_uuid' ), … … 201 203 ); 202 204 205 if ( $gateway instanceof SmartPay_Payment_Subgateway ) { 206 $params['gateways_to_show'] = [$gateway->get_integration_id()]; 207 } 208 203 209 $payment_steps = $this->calculate_payment_steps( $order->get_total() ); 204 210 if ( ! empty( $payment_steps ) ) { … … 303 309 $payment_details = $order->get_meta( 'smartpay_details' ); 304 310 305 // adding backward compatibility306 if ( !$payment_details ) {307 $payment_details = get_post_meta( $order->get_id(), 'smartpay_details', true);308 }311 // adding backward compatibility 312 if ( !$payment_details ) { 313 $payment_details = get_post_meta( $order->get_id(), 'smartpay_details', true); 314 } 309 315 310 316 if ( $payment_details ) { … … 331 337 $params['order_uid'] = $smartpay_order_id; 332 338 } else { 333 $params['order_details']['products_details'] = $this->order_helper()->prepare_items( $order);339 $params['order_details']['products_details'] = $this->order_helper()->prepare_items( $order ); 334 340 } 335 341 … … 415 421 $order->add_order_note( 416 422 sprintf( 417 // translators: %1$s is replaced with "string".423 // translators: %1$s is replaced with "string". 418 424 __( 'Could not refund the order. Reason: %1$s', 'wc-smartpay' ), 419 425 esc_html( $message ) … … 425 431 $order->add_order_note( 426 432 sprintf( 427 // translators: %1$s is replaced with "string".433 // translators: %1$s is replaced with "string". 428 434 __( 'Order refunded successfully. Transaction id: %1$s', 'wc-smartpay' ), 429 435 esc_html( $response['transaction_id'] ) … … 500 506 $order->add_order_note( 501 507 sprintf( 502 // translators: %1$s is replaced with "string".503 // translators: %2$s is replaced with "string".508 // translators: %1$s is replaced with "string". 509 // translators: %2$s is replaced with "string". 504 510 __( 'Action param: %1$s. Status %2$s', 'wc-smartpay' ), 505 511 $data_object->transaction['action_param'] ?? null, … … 691 697 // exit if there was no POST data passed. 692 698 $order = new WC_Order( $order_id ); 693 if ( $order->get_payment_method() !== SmartPay_Payment_Gateway::METHOD_CODE || $order->get_transaction_id() ) { 699 700 $allowed_payment_methods = SmartPay_Gateway_Registry::instance()->get_all(); 701 if ( !isset( $allowed_payment_methods[ $order->get_payment_method() ] ) || $order->get_transaction_id() ) { 694 702 return; 695 703 } … … 733 741 $order->add_order_note( 734 742 sprintf( 735 // translators: %1$s is replaced with "string".736 // translators: %2$s is replaced with "string".743 // translators: %1$s is replaced with "string". 744 // translators: %2$s is replaced with "string". 737 745 __( 'Action param: %1$s. Status %2$s', 'wc-smartpay' ), 738 746 $response_object->action_param ?? null, … … 841 849 $this->logger()->log($order_id, 'ERROR', $e->getMessage()); 842 850 } 843 844 851 } 845 852 } -
wc-smartpay/tags/1.0.29/includes/class-smartpay.php
r3290978 r3328058 16 16 * @var string 17 17 */ 18 private $version = '1.0.2 6';18 private $version = '1.0.29'; 19 19 20 20 /** … … 79 79 */ 80 80 private function __construct() { 81 add_action( 'woocommerce_blocks_loaded', array( $this, 'enable_blocks_support') );81 add_action( 'woocommerce_blocks_loaded', array( $this, 'enable_blocks_support' ) ); 82 82 add_action( 'woocommerce_init', array( $this, 'init_hooks' ) ); 83 83 add_filter( 'auto_update_plugin', array( $this, 'enable_auto_updates' ), 10, 2 ); … … 164 164 add_action( 'smartpay_payment_gateway_init_after', array( $this, 'init_config' ) ); 165 165 add_filter( 'woocommerce_payment_gateways', array( $this, 'register_payment_method' ) ); 166 add_action( 'woocommerce_receipt_' . $this->get_app_id(), array( new SmartPay_Iframe_Renderer(), 'render' ) ); 167 add_filter( 'billi_can_sync_invoice', array( SmartPay_Billi_Observer::instance(), 'can_sync_invoice' ), 10, 2 ); 166 167 add_filter( 'billi_can_sync_invoice', array( SmartPay_Invoice_Observer::instance(), 'can_sync_invoice' ), 10, 2 ); 168 add_filter( 'wc_smartpay_invoices_can_sync_invoice', array( 169 SmartPay_Invoice_Observer::instance(), 170 'can_sync_invoice' 171 ), 10, 2 ); 168 172 add_action( 'wp_footer', array( new SmartPay_Iframe_Return_Type_Top_Footer_Renderer(), 'render' ) ); 169 173 add_action( 'template_redirect', array( new SmartPay_Success(), 'process') ); … … 205 209 } 206 210 207 /** 208 * @return void 209 */ 210 public function enable_blocks_support() 211 { 212 if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) { 213 add_action( 214 'woocommerce_blocks_payment_method_type_registration', 215 function( $payment_method_registry ) { 216 $payment_method_registry->register( new SmartPay_Checkout_Block() ); 217 } 218 ); 219 } 220 } 211 /** 212 * @return void 213 */ 214 public function enable_blocks_support() { 215 if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) { 216 foreach ( SmartPay_Gateway_Resolver::instance()->all() as $gateway_code => $gateway_class ) { 217 add_action( 218 'woocommerce_blocks_payment_method_type_registration', 219 function( $payment_method_registry ) use ( $gateway_code ) { 220 $payment_method_registry->register( new SmartPay_Checkout_Block( $gateway_code ) ); 221 } 222 ); 223 } 224 } 225 } 221 226 222 227 /** … … 281 286 * @return SmartPay_Payment_Gateway|null 282 287 */ 283 public function get_payment_gateway() { 284 $payment_gateways = WC()->payment_gateways() ? WC()->payment_gateways()->payment_gateways() : array(); 285 foreach ( $payment_gateways as $payment_gateway ) { 286 if ( $payment_gateway instanceof SmartPay_Payment_Gateway ) { 287 return $payment_gateway; 288 } 289 } 290 return null; 288 public function get_payment_gateway( $gateway_code ) { 289 return SmartPay_Gateway_Resolver::instance()->resolve_by_code( $gateway_code ); 291 290 } 292 291 … … 333 332 * 334 333 * @param array $methods payment methods list. 335 * @return mixed334 * @return array 336 335 */ 337 336 public function register_payment_method( $methods ) { 338 array_push( $methods, new SmartPay_Payment_Gateway() ); 339 return $methods; 337 return array_merge( $methods, SmartPay_Gateway_Resolver::instance()->all() ); 340 338 } 341 339 … … 349 347 public function add_capture_action( $actions, $order ) { 350 348 351 if ( $order->get_payment_method() !== SmartPay_Payment_Gateway::METHOD_CODE 349 $allowed_methods = array_keys( SmartPay_Gateway_Registry::instance()->get_all() ); 350 351 if ( !in_array( $order->get_payment_method(), $allowed_methods) 352 352 || $order->get_meta( 'action_param' ) === 'capture' 353 353 ) { -
wc-smartpay/tags/1.0.29/readme.txt
r3290979 r3328058 1 1 === SmartPay for WooCommerce === 2 Stable tag: 1.0.2 62 Stable tag: 1.0.29 3 3 Tested up to: 6.7.2 4 4 License: GPLv2 or later … … 45 45 ## Changelog 46 46 47 ### 1.0.28 48 - added phone number sanitization 49 50 ### 1.0.27 51 - added support for BitByGrow, BitByUpay, ApplePay, Google Pay 52 47 53 ### 1.0.26 48 54 - new Orders sync feature … … 72 78 - https://app11.smartpay.co.il/ 73 79 - https://api.protected-payment.com/ 80 Privacy policy: https://www.smartpay.co.il/privacy-policy/ -
wc-smartpay/tags/1.0.29/smartpay.php
r3290978 r3328058 4 4 * Plugin URI: https://smartpay.co.il/ 5 5 * Description: SmartPay payment plugin for WooCommerce 6 * Version: 1.0.2 66 * Version: 1.0.29 7 7 * Author: SmartPay 8 8 * License: GPLv2 or later … … 15 15 defined( 'ABSPATH' ) || exit; 16 16 17 define( 'SMARTPAY_VERSION', '1.0.2 6' );17 define( 'SMARTPAY_VERSION', '1.0.29' ); 18 18 19 19 if ( ! defined( 'SMARTPAY_PLUGIN_FILE' ) ) { -
wc-smartpay/tags/1.0.29/templates/iframe.php
r3031558 r3328058 13 13 name="smartpayiframe" 14 14 id="smartpayiframe" 15 payment="allow" 15 16 width="<?php echo esc_attr( $this->iframe_width ); ?>" 16 17 height="<?php echo esc_attr( $this->iframe_height ); ?>" frameBorder="0"> -
wc-smartpay/trunk/README.md
r3290978 r3328058 1 1 === SmartPay for WooCommerce === 2 Stable tag: 1.0.2 62 Stable tag: 1.0.29 3 3 Tested up to: 6.4 4 4 License: GPLv2 or later … … 97 97 - https://app11.smartpay.co.il/ 98 98 - https://api.protected-payment.com/ 99 Privacy policy: https://www.smartpay.co.il/privacy-policy/ -
wc-smartpay/trunk/assets/js/checkout.js
r3039963 r3328058 1 const settings = window.wc.wcSettings.getSetting( 'wc-smartpay_data', {} ); 2 const label = window.wp.htmlEntities.decodeEntities( settings.title ) || window.wp.i18n.__( 'SmartPay', 'wc-smartpay' ); 3 const Content = () => { 4 return window.wp.htmlEntities.decodeEntities( settings.description || '' ); 5 }; 6 const Block_Gateway = { 7 name: 'wc-smartpay', 8 label: label, 9 content: Object( window.wp.element.createElement )( Content, null ), 10 edit: Object( window.wp.element.createElement )( Content, null ), 11 canMakePayment: () => true, 12 ariaLabel: label, 13 supports: { 14 features: settings.supports, 15 }, 16 }; 17 window.wc.wcBlocksRegistry.registerPaymentMethod( Block_Gateway ); 1 (function(){ 2 3 const Content = ( settings ) => { 4 return window.wp.htmlEntities.decodeEntities( settings?.description || '' ); 5 }; 6 7 const paymentMethodMap = new Map(); 8 paymentMethodMap.set( 'wc-smartpay', {label: window.wp.i18n.__( 'SmartPay', 'wc-smartpay' )} ) 9 paymentMethodMap.set( 'wc-smartpay-applepay', {label: window.wp.i18n.__( 'SmartPay - ApplePay', 'wc-smartpay' )} ) 10 paymentMethodMap.set( 'wc-smartpay-gpay', {label: window.wp.i18n.__( 'SmartPay - Google Pay', 'wc-smartpay' )} ) 11 paymentMethodMap.set( 'wc-smartpay-bitbygrow', {label: window.wp.i18n.__( 'SmartPay - bitByGrow', 'wc-smartpay' )} ) 12 paymentMethodMap.set( 'wc-smartpay-bitbyupay', {label: window.wp.i18n.__( 'SmartPay - bitByUpay', 'wc-smartpay' )} ) 13 14 paymentMethodMap.forEach(( defaultSettings, paymentMethodCode ) => { 15 const settings = window.wc.wcSettings.getSetting( paymentMethodCode + '_data', {} ); 16 const label = window.wp.htmlEntities.decodeEntities( settings.title ) || defaultSettings.label; 17 window.wc.wcBlocksRegistry.registerPaymentMethod( { 18 name: paymentMethodCode, 19 label: label, 20 content: Object( window.wp.element.createElement )( Content, settings ), 21 edit: Object( window.wp.element.createElement )( Content, settings ), 22 canMakePayment: () => true, 23 ariaLabel: label, 24 supports: { 25 feature: settings.supports 26 } 27 } ); 28 }); 29 30 })(); -
wc-smartpay/trunk/includes/class-smartpay-admin.php
r3207141 r3328058 3 3 class Smartpay_Admin 4 4 { 5 6 5 /** 7 6 * Retrieve request … … 40 39 } 41 40 42 $payment_gateway = SmartPay::instance()->get_payment_gateway( );41 $payment_gateway = SmartPay::instance()->get_payment_gateway( $order->get_payment_method() ); 43 42 $payment_processor = new SmartPay_Payment_Processor( $payment_gateway ); 44 43 $result = $payment_processor->execute( $order ); -
wc-smartpay/trunk/includes/class-smartpay-checkout-block.php
r3040711 r3328058 3 3 use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType; 4 4 5 class SmartPay_Checkout_Block extends AbstractPaymentMethodType 6 { 7 /** @var SmartPay_Payment_Gateway */ 8 private $gateway; 5 class SmartPay_Checkout_Block extends AbstractPaymentMethodType { 9 6 10 /** 11 * Initialize 12 * 13 * @return void 14 */ 15 public function initialize() 16 { 17 $this->name = Smartpay::instance()->get_app_id(); 18 $this->settings = get_option('woocommerce' . Smartpay::instance()->get_app_id() . '_settings'); 19 $this->gateway = new SmartPay_Payment_Gateway(); 20 } 7 /** @var string $code */ 8 private $code; 21 9 22 /** 23 * Check if payment method is active 24 * 25 * @return bool 26 */ 27 public function is_active() 28 { 29 return $this->gateway->is_available(); 30 } 10 /** @var SmartPay_Payment_Gateway */ 11 private $gateway; 31 12 32 /** 33 * Add script handle 34 * 35 * @return string[] 36 */ 37 public function get_payment_method_script_handles() 38 { 39 $handle = $this->name . '-blocks-integration'; 40 wp_register_script( 41 $handle, 42 SmartPay::instance()->get_url('assets/js/checkout.js'), 43 array( 44 'wc-blocks-registry', 45 'wc-settings', 46 'wp-element', 47 'wp-html-entities', 48 'wp-i18n' 49 ), 50 null, 51 true 52 ); 13 /** 14 * Define class dependencies 15 * 16 * @param string $gateway_code 17 */ 18 public function __construct( $gateway_code ) { 19 $this->code = $gateway_code; 20 } 53 21 54 return array( $handle ); 55 } 22 /** 23 * Initialize 24 * 25 * @return void 26 */ 27 public function initialize() { 28 $this->gateway = SmartPay_Gateway_Resolver::instance()->resolve_by_code( $this->code ); 29 $this->name = $this->gateway->id; 30 $this->settings = get_option('woocommerce' . $this->gateway->id . '_settings' ); 31 } 56 32 57 /** 58 * Retrieve payment method data 59 * 60 * @return array 61 */ 62 public function get_payment_method_data() 63 { 64 return array( 65 'title' => $this->gateway->get_title(), 66 'description' => $this->gateway->get_description(), 67 'supports' => $this->gateway->supports 68 ); 69 } 33 /** 34 * Check if payment method is active 35 * 36 * @return bool 37 */ 38 public function is_active() { 39 return $this->gateway->is_available(); 40 } 41 42 /** 43 * Add script handle 44 * 45 * @return string[] 46 */ 47 public function get_payment_method_script_handles() { 48 $handle = 'wc-smartpay-blocks-integration'; 49 wp_register_script( 50 $handle, 51 SmartPay::instance()->get_url('assets/js/checkout.js' ), 52 array( 53 'wc-blocks-registry', 54 'wc-settings', 55 'wp-element', 56 'wp-html-entities', 57 'wp-i18n' 58 ), 59 null, 60 true 61 ); 62 63 return array( $handle ); 64 } 65 66 /** 67 * Retrieve payment method data 68 * 69 * @return array 70 */ 71 public function get_payment_method_data() { 72 return array( 73 'title' => $this->gateway->get_title(), 74 'description' => $this->gateway->get_description(), 75 'supports' => $this->gateway->supports 76 ); 77 } 70 78 } -
wc-smartpay/trunk/includes/class-smartpay-iframe-renderer.php
r3031558 r3328058 57 57 */ 58 58 $order = wc_get_order( $order_id ); 59 $payment_gateway = SmartPay::instance()->get_payment_gateway( );59 $payment_gateway = SmartPay::instance()->get_payment_gateway( $order->get_payment_method() ); 60 60 $payment_processor = new SmartPay_Payment_Processor( $payment_gateway ); 61 61 $result = $payment_processor->execute( $order ); -
wc-smartpay/trunk/includes/class-smartpay-order-helper.php
r3290978 r3328058 71 71 'name' => implode( ' ', $name_array), 72 72 'email' => $customer_email, 73 'phone' => $order->get_billing_phone(),73 'phone' => preg_replace('/\D+/i', '', $order->get_billing_phone() ?? ''), 74 74 'billing_address' => [ 75 75 [ -
wc-smartpay/trunk/includes/class-smartpay-payment-gateway.php
r3290978 r3328058 16 16 17 17 /** 18 * @var string $integration_id 19 */ 20 protected $integration_id; 21 22 /** 18 23 * Payment processor 19 24 * 20 25 * @var SmartPay_Payment_Processor 21 26 */ 22 pr ivate$payment_processor;27 protected $payment_processor; 23 28 24 29 /** … … 40 45 'pre-orders', 41 46 'products', 42 'refunds', 47 'refunds', 43 48 'subscriptions', 44 49 'multiple_subscriptions', … … 49 54 'subscription_date_changes', 50 55 'subscription_payment_method_change', 51 'subscription_payment_method_change_admin', 56 'subscription_payment_method_change_admin', 52 57 'subscription_payment_method_change_customer', 53 58 ); 59 60 SmartPay_Gateway_Registry::instance()->register( $this->id, $this); 54 61 55 62 do_action( 'smartpay_payment_gateway_init_after', $this ); … … 67 74 68 75 add_action( 'woocommerce_api_smartpay_ipn', array( $this->payment_processor(), 'process_ipn' ) ); 69 add_action( 'woocommerce_thankyou_' . self::METHOD_CODE, array( SmartPay_Iframe_Redirect_Renderer::class, 'render' ), 1, 1 ); 76 add_action( 'woocommerce_thankyou_' . $this->id, array( SmartPay_Iframe_Redirect_Renderer::class, 'render' ), 1, 1 ); 77 add_action( 'woocommerce_receipt_' . $this->id, array( new SmartPay_Iframe_Renderer(), 'render' ) ); 70 78 71 79 if ( class_exists( 'WC_Subscriptions_Order' ) … … 83 91 84 92 /** 93 * Retrieve integration id 94 * 95 * @return string 96 */ 97 public function get_integration_id() { 98 return $this->integration_id; 99 } 100 101 /** 85 102 * Plugin options. 86 103 */ … … 325 342 */ 326 343 public function admin_options() { 327 echo '<h3>' . esc_html_e( 'SmartPay', 'wc-smartpay' ) . '</h3>'; 344 (new SmartPay_Admin_Gateway_Menu_Renderer())->render(); 345 echo '<h3>' . esc_html_e( $this->title, 'wc-smartpay' ) . '</h3>'; 328 346 echo '<p>'; 329 // phpcs:disable347 // phpcs:disable 330 348 printf( 331 349 esc_html( __( 'For more information %s', 'wc-smartpay' ) ), 332 350 esc_url( 'http://www.smartpay.co.il' ) 333 351 ); 334 // phpcs:enable352 // phpcs:enable 335 353 echo '</p>'; 336 354 echo '<table class="form-table">'; … … 354 372 * @return SmartPay_Payment_Processor 355 373 */ 356 pr ivatefunction payment_processor() {374 protected function payment_processor() { 357 375 if ( ! $this->payment_processor ) { 358 376 $this->payment_processor = new SmartPay_Payment_Processor( $this ); … … 369 387 public function process_payment( $order_id ) { 370 388 $order = wc_get_order( $order_id ); 371 if ( SmartPay::instance()->config()->is( 'use_iframe' ) ) { 389 $payment_method = SmartPay_Gateway_Registry::instance()->get_instance( $order->get_payment_method() ); 390 $use_iframe = $payment_method instanceof SmartPay_Payment_Subgateway 391 ? $payment_method->config()->is('use_iframe' ) : Smartpay::instance()->config()->is( 'use_iframe' ); 392 393 if ( $use_iframe ) { 372 394 return array( 373 395 'result' => 'success', -
wc-smartpay/trunk/includes/class-smartpay-payment-processor.php
r3290978 r3328058 180 180 181 181 $send_currency = SmartPay::instance()->config()->get( 'currency' ); 182 183 $gateway = SmartPay_Gateway_Resolver::instance()->resolve_by_code( $order->get_payment_method() ); 182 184 $params = array( 183 185 'page_uuid' => SmartPay::instance()->config()->get( 'page_uuid' ), … … 201 203 ); 202 204 205 if ( $gateway instanceof SmartPay_Payment_Subgateway ) { 206 $params['gateways_to_show'] = [$gateway->get_integration_id()]; 207 } 208 203 209 $payment_steps = $this->calculate_payment_steps( $order->get_total() ); 204 210 if ( ! empty( $payment_steps ) ) { … … 303 309 $payment_details = $order->get_meta( 'smartpay_details' ); 304 310 305 // adding backward compatibility306 if ( !$payment_details ) {307 $payment_details = get_post_meta( $order->get_id(), 'smartpay_details', true);308 }311 // adding backward compatibility 312 if ( !$payment_details ) { 313 $payment_details = get_post_meta( $order->get_id(), 'smartpay_details', true); 314 } 309 315 310 316 if ( $payment_details ) { … … 331 337 $params['order_uid'] = $smartpay_order_id; 332 338 } else { 333 $params['order_details']['products_details'] = $this->order_helper()->prepare_items( $order);339 $params['order_details']['products_details'] = $this->order_helper()->prepare_items( $order ); 334 340 } 335 341 … … 415 421 $order->add_order_note( 416 422 sprintf( 417 // translators: %1$s is replaced with "string".423 // translators: %1$s is replaced with "string". 418 424 __( 'Could not refund the order. Reason: %1$s', 'wc-smartpay' ), 419 425 esc_html( $message ) … … 425 431 $order->add_order_note( 426 432 sprintf( 427 // translators: %1$s is replaced with "string".433 // translators: %1$s is replaced with "string". 428 434 __( 'Order refunded successfully. Transaction id: %1$s', 'wc-smartpay' ), 429 435 esc_html( $response['transaction_id'] ) … … 500 506 $order->add_order_note( 501 507 sprintf( 502 // translators: %1$s is replaced with "string".503 // translators: %2$s is replaced with "string".508 // translators: %1$s is replaced with "string". 509 // translators: %2$s is replaced with "string". 504 510 __( 'Action param: %1$s. Status %2$s', 'wc-smartpay' ), 505 511 $data_object->transaction['action_param'] ?? null, … … 691 697 // exit if there was no POST data passed. 692 698 $order = new WC_Order( $order_id ); 693 if ( $order->get_payment_method() !== SmartPay_Payment_Gateway::METHOD_CODE || $order->get_transaction_id() ) { 699 700 $allowed_payment_methods = SmartPay_Gateway_Registry::instance()->get_all(); 701 if ( !isset( $allowed_payment_methods[ $order->get_payment_method() ] ) || $order->get_transaction_id() ) { 694 702 return; 695 703 } … … 733 741 $order->add_order_note( 734 742 sprintf( 735 // translators: %1$s is replaced with "string".736 // translators: %2$s is replaced with "string".743 // translators: %1$s is replaced with "string". 744 // translators: %2$s is replaced with "string". 737 745 __( 'Action param: %1$s. Status %2$s', 'wc-smartpay' ), 738 746 $response_object->action_param ?? null, … … 841 849 $this->logger()->log($order_id, 'ERROR', $e->getMessage()); 842 850 } 843 844 851 } 845 852 } -
wc-smartpay/trunk/includes/class-smartpay.php
r3290978 r3328058 16 16 * @var string 17 17 */ 18 private $version = '1.0.2 6';18 private $version = '1.0.29'; 19 19 20 20 /** … … 79 79 */ 80 80 private function __construct() { 81 add_action( 'woocommerce_blocks_loaded', array( $this, 'enable_blocks_support') );81 add_action( 'woocommerce_blocks_loaded', array( $this, 'enable_blocks_support' ) ); 82 82 add_action( 'woocommerce_init', array( $this, 'init_hooks' ) ); 83 83 add_filter( 'auto_update_plugin', array( $this, 'enable_auto_updates' ), 10, 2 ); … … 164 164 add_action( 'smartpay_payment_gateway_init_after', array( $this, 'init_config' ) ); 165 165 add_filter( 'woocommerce_payment_gateways', array( $this, 'register_payment_method' ) ); 166 add_action( 'woocommerce_receipt_' . $this->get_app_id(), array( new SmartPay_Iframe_Renderer(), 'render' ) ); 167 add_filter( 'billi_can_sync_invoice', array( SmartPay_Billi_Observer::instance(), 'can_sync_invoice' ), 10, 2 ); 166 167 add_filter( 'billi_can_sync_invoice', array( SmartPay_Invoice_Observer::instance(), 'can_sync_invoice' ), 10, 2 ); 168 add_filter( 'wc_smartpay_invoices_can_sync_invoice', array( 169 SmartPay_Invoice_Observer::instance(), 170 'can_sync_invoice' 171 ), 10, 2 ); 168 172 add_action( 'wp_footer', array( new SmartPay_Iframe_Return_Type_Top_Footer_Renderer(), 'render' ) ); 169 173 add_action( 'template_redirect', array( new SmartPay_Success(), 'process') ); … … 205 209 } 206 210 207 /** 208 * @return void 209 */ 210 public function enable_blocks_support() 211 { 212 if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) { 213 add_action( 214 'woocommerce_blocks_payment_method_type_registration', 215 function( $payment_method_registry ) { 216 $payment_method_registry->register( new SmartPay_Checkout_Block() ); 217 } 218 ); 219 } 220 } 211 /** 212 * @return void 213 */ 214 public function enable_blocks_support() { 215 if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) { 216 foreach ( SmartPay_Gateway_Resolver::instance()->all() as $gateway_code => $gateway_class ) { 217 add_action( 218 'woocommerce_blocks_payment_method_type_registration', 219 function( $payment_method_registry ) use ( $gateway_code ) { 220 $payment_method_registry->register( new SmartPay_Checkout_Block( $gateway_code ) ); 221 } 222 ); 223 } 224 } 225 } 221 226 222 227 /** … … 281 286 * @return SmartPay_Payment_Gateway|null 282 287 */ 283 public function get_payment_gateway() { 284 $payment_gateways = WC()->payment_gateways() ? WC()->payment_gateways()->payment_gateways() : array(); 285 foreach ( $payment_gateways as $payment_gateway ) { 286 if ( $payment_gateway instanceof SmartPay_Payment_Gateway ) { 287 return $payment_gateway; 288 } 289 } 290 return null; 288 public function get_payment_gateway( $gateway_code ) { 289 return SmartPay_Gateway_Resolver::instance()->resolve_by_code( $gateway_code ); 291 290 } 292 291 … … 333 332 * 334 333 * @param array $methods payment methods list. 335 * @return mixed334 * @return array 336 335 */ 337 336 public function register_payment_method( $methods ) { 338 array_push( $methods, new SmartPay_Payment_Gateway() ); 339 return $methods; 337 return array_merge( $methods, SmartPay_Gateway_Resolver::instance()->all() ); 340 338 } 341 339 … … 349 347 public function add_capture_action( $actions, $order ) { 350 348 351 if ( $order->get_payment_method() !== SmartPay_Payment_Gateway::METHOD_CODE 349 $allowed_methods = array_keys( SmartPay_Gateway_Registry::instance()->get_all() ); 350 351 if ( !in_array( $order->get_payment_method(), $allowed_methods) 352 352 || $order->get_meta( 'action_param' ) === 'capture' 353 353 ) { -
wc-smartpay/trunk/readme.txt
r3290979 r3328058 1 1 === SmartPay for WooCommerce === 2 Stable tag: 1.0.2 62 Stable tag: 1.0.29 3 3 Tested up to: 6.7.2 4 4 License: GPLv2 or later … … 45 45 ## Changelog 46 46 47 ### 1.0.28 48 - added phone number sanitization 49 50 ### 1.0.27 51 - added support for BitByGrow, BitByUpay, ApplePay, Google Pay 52 47 53 ### 1.0.26 48 54 - new Orders sync feature … … 72 78 - https://app11.smartpay.co.il/ 73 79 - https://api.protected-payment.com/ 80 Privacy policy: https://www.smartpay.co.il/privacy-policy/ -
wc-smartpay/trunk/smartpay.php
r3290978 r3328058 4 4 * Plugin URI: https://smartpay.co.il/ 5 5 * Description: SmartPay payment plugin for WooCommerce 6 * Version: 1.0.2 66 * Version: 1.0.29 7 7 * Author: SmartPay 8 8 * License: GPLv2 or later … … 15 15 defined( 'ABSPATH' ) || exit; 16 16 17 define( 'SMARTPAY_VERSION', '1.0.2 6' );17 define( 'SMARTPAY_VERSION', '1.0.29' ); 18 18 19 19 if ( ! defined( 'SMARTPAY_PLUGIN_FILE' ) ) { -
wc-smartpay/trunk/templates/iframe.php
r3031558 r3328058 13 13 name="smartpayiframe" 14 14 id="smartpayiframe" 15 payment="allow" 15 16 width="<?php echo esc_attr( $this->iframe_width ); ?>" 16 17 height="<?php echo esc_attr( $this->iframe_height ); ?>" frameBorder="0">
Note: See TracChangeset
for help on using the changeset viewer.