Changeset 3833154
- Timestamp:
- 11/29/2026 02:18:19 PM (less than one hour ago)
- Location:
- wc-smartpay
- Files:
-
- 2 added
- 16 edited
- 1 copied
-
tags/1.2.4 (copied) (copied from wc-smartpay/trunk )
-
tags/1.2.4/includes/class-smartpay-adapter.php (modified) (2 diffs)
-
tags/1.2.4/includes/class-smartpay-cc-form-renderer.php (modified) (1 diff)
-
tags/1.2.4/includes/class-smartpay-checkout-block.php (modified) (1 diff)
-
tags/1.2.4/includes/class-smartpay-order-helper.php (modified) (2 diffs)
-
tags/1.2.4/includes/class-smartpay-pages-address.php (added)
-
tags/1.2.4/includes/class-smartpay-payment-gateway.php (modified) (1 diff)
-
tags/1.2.4/includes/class-smartpay.php (modified) (1 diff)
-
tags/1.2.4/readme.txt (modified) (2 diffs)
-
tags/1.2.4/smartpay.php (modified) (2 diffs)
-
trunk/includes/class-smartpay-adapter.php (modified) (2 diffs)
-
trunk/includes/class-smartpay-cc-form-renderer.php (modified) (1 diff)
-
trunk/includes/class-smartpay-checkout-block.php (modified) (1 diff)
-
trunk/includes/class-smartpay-order-helper.php (modified) (2 diffs)
-
trunk/includes/class-smartpay-pages-address.php (added)
-
trunk/includes/class-smartpay-payment-gateway.php (modified) (1 diff)
-
trunk/includes/class-smartpay.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/smartpay.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wc-smartpay/tags/1.2.4/includes/class-smartpay-adapter.php
r3764750 r3833154 273 273 $request_data = apply_filters( 'smartpay_generate_payment_page_link_before', $request_data ); 274 274 $request_data['transaction_source'] = $this->get_transaction_source( 'iframe' ); 275 return $this->request( $request_data, 'checkout/pages', $use_alternative ); 275 return $this->with_company_pages_address( 276 $this->request( $request_data, 'checkout/pages', $use_alternative ), 277 $use_alternative 278 ); 276 279 } 277 280 … … 288 291 $request_data['page_type'] = 'hosted_fields'; 289 292 $request_data['transaction_source'] = $this->get_transaction_source( 'iframe' ); 290 return $this->request( $request_data, 'checkout/pages', $user_alternative ); 293 return $this->with_company_pages_address( 294 $this->request( $request_data, 'checkout/pages', $user_alternative ), 295 $user_alternative 296 ); 291 297 } 298 299 /** 300 * Point the hosted link of a checkout session at the company's own pages 301 * address, when SmartPay gave the company one. Anything else is returned 302 * untouched. 303 * 304 * @param mixed $response checkout/pages response. 305 * @param bool $use_alternative flag to define if to use alternative API credentials. 306 * @return mixed 307 */ 308 private function with_company_pages_address( $response, $use_alternative = false ) { 309 if ( is_array( $response ) && isset( $response['url'] ) && is_string( $response['url'] ) ) { 310 $response['url'] = SmartPay_Pages_Address::instance()->rewrite( $response['url'], $use_alternative ); 311 } 312 return $response; 313 } 292 314 293 315 /** -
wc-smartpay/tags/1.2.4/includes/class-smartpay-cc-form-renderer.php
r3700234 r3833154 18 18 wp_enqueue_script( 19 19 'smartpay-lib', 20 'https://app13.smartpay.co.il/v1/sdk/sdk.js'20 SmartPay_Pages_Address::instance()->get_sdk_url() 21 21 ); 22 22 -
wc-smartpay/tags/1.2.4/includes/class-smartpay-checkout-block.php
r3700234 r3833154 93 93 wp_register_script( 94 94 $hostedFieldsHandle, 95 'https://app13.smartpay.co.il/v1/sdk/sdk.js'95 SmartPay_Pages_Address::instance()->get_sdk_url() 96 96 ); 97 97 } -
wc-smartpay/tags/1.2.4/includes/class-smartpay-order-helper.php
r3700234 r3833154 251 251 252 252 return $card; 253 } 254 255 /** 256 * Non-card methods the payment page can charge with: lowercase API name 257 * => [ checkout gateway id (null when the plugin has none), default title ]. 258 * 259 * @return array 260 */ 261 private function paid_method_titles() { 262 return array( 263 'bitbyupay' => array( SmartPay_Payment_Gateway_Bitbyupay::METHOD_CODE, 'Bit' ), 264 'bitbygrow' => array( SmartPay_Payment_Gateway_Bitbygrow::METHOD_CODE, 'Bit' ), 265 'bitbygama' => array( null, 'Bit' ), 266 'applepay' => array( SmartPay_Payment_Gateway_Applepay::METHOD_CODE, 'Apple Pay' ), 267 'gpay' => array( SmartPay_Payment_Gateway_Gpay::METHOD_CODE, 'Google Pay' ), 268 ); 269 } 270 271 /** 272 * Method the charge was paid with, as the API reports it. Card and 273 * wallet charges carry `transaction_method`; Bit charges (UPay / Grow) 274 * only carry the wallet in `transaction_source`, or the Bit terminal name. 275 * 276 * @param StdClass $transaction confirmed charge. 277 * @return string key of paid_method_titles(), empty for a card charge or an unknown method. 278 */ 279 private function resolve_paid_method( $transaction ) { 280 $source = $transaction->transaction_source ?? null; 281 if ( is_string( $source ) ) { 282 $source = json_decode( $source, true ); 283 } 284 $source = is_object( $source ) ? get_object_vars( $source ) : $source; 285 286 $candidates = array( 287 is_array( $source ) && isset( $source['wallet'] ) ? $source['wallet'] : null, 288 $transaction->transaction_method ?? null, 289 $transaction->terminalName ?? null, 290 ); 291 292 $known = $this->paid_method_titles(); 293 foreach ( $candidates as $candidate ) { 294 $key = is_string( $candidate ) ? strtolower( trim( $candidate ) ) : ''; 295 if ( isset( $known[ $key ] ) ) { 296 return $key; 297 } 298 } 299 300 return ''; 301 } 302 303 /** 304 * The payment page of the card gateway also offers the terminal's other 305 * methods (Bit, Apple Pay, Google Pay). When the charge was paid with one 306 * of them, show that method on the order (admin, e-mails, thank-you page) 307 * instead of the title of the gateway picked at checkout. 308 * 309 * Only the title changes: the method id keeps driving refunds, renewals 310 * and the invoices plugin mapping. Must run before the status change that 311 * sends the customer e-mail. The caller saves the order. 312 * 313 * @param WC_Order $order order object. 314 * @param string $transaction_method resolve_paid_method() result. 315 * @return void 316 */ 317 private function sync_paid_method_title( WC_Order $order, $transaction_method ) { 318 $paid_methods = $this->paid_method_titles(); 319 $key = (string) $transaction_method; 320 if ( ! isset( $paid_methods[ $key ] ) ) { 321 return; 322 } 323 324 list( $method_code, $title ) = $paid_methods[ $key ]; 325 if ( $method_code === $order->get_payment_method() ) { 326 return; 327 } 328 329 // A store that offers the method at checkout gets the title it configured there. 330 if ( $method_code ) { 331 $settings = get_option( 'woocommerce_' . $method_code . '_settings' ); 332 if ( is_array( $settings ) 333 && isset( $settings['enabled'], $settings['title'] ) 334 && 'yes' === $settings['enabled'] 335 && '' !== trim( (string) $settings['title'] ) 336 ) { 337 $title = trim( (string) $settings['title'] ); 338 } 339 } 340 341 /** 342 * Title shown on an order paid with another method than the gateway picked at checkout. 343 * 344 * @param string $title title to show. 345 * @param string $transaction_method key of paid_method_titles(), e.g. `bitbyupay`. 346 * @param WC_Order $order order object. 347 */ 348 $title = (string) apply_filters( 'smartpay_paid_method_title', $title, $transaction_method, $order ); 349 if ( '' === $title || $title === $order->get_payment_method_title() ) { 350 return; 351 } 352 353 $order->set_payment_method_title( $title ); 253 354 } 254 355 … … 321 422 $order->update_meta_data( 'transaction_method', $transaction->transaction_method ?? null ); 322 423 424 $this->sync_paid_method_title( $order, $this->resolve_paid_method( $transaction ) ); 425 323 426 $order->set_transaction_id( $transaction->tuid ); 324 427 $order->save(); -
wc-smartpay/tags/1.2.4/includes/class-smartpay-payment-gateway.php
r3707394 r3833154 77 77 do_action( 'smartpay_payment_gateway_init_after', $this ); 78 78 79 // Saving the settings also asks the SmartPay dashboard again which 80 // hosted pages address applies to this store. 81 add_action( 82 'woocommerce_update_options_payment_gateways_' . $this->id, 83 array( SmartPay_Pages_Address::instance(), 'flush' ), 84 5 85 ); 86 79 87 // This action hook saves the settings. 80 88 add_action( -
wc-smartpay/tags/1.2.4/includes/class-smartpay.php
r3764750 r3833154 16 16 * @var string 17 17 */ 18 private $version = '1.2. 3';18 private $version = '1.2.4'; 19 19 20 20 /** -
wc-smartpay/tags/1.2.4/readme.txt
r3764750 r3833154 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.2. 37 Stable tag: 1.2.4 8 8 Requires Plugins: woocommerce 9 9 License: GPLv2 or later … … 78 78 * https://sandboxapi.smartpay.co.il/ (sandbox) 79 79 80 The hosted payment page and hosted fields are served from SmartPay servers. The hosted fields script is loaded on the checkout page from https://app13.smartpay.co.il/ only when the embedded card form is enabled; the card fields themselves load from the address SmartPay returns for the checkout session. Data sent includes the order amount, currency, order number, customer billing and shipping details, and, for Multipass, the voucher card number entered by the customer. 80 The plugin also asks the SmartPay dashboard which hosted pages address applies to the store's SmartPay account. The request carries only the store's API credentials and is answered from a one-hour cache. It goes to: 81 82 * https://my-backend.smartpay.co.il/ (production) 83 * https://mysandbox-backend.smartpay.co.il/ (sandbox) 84 85 The hosted payment page and hosted fields are served from SmartPay servers. The hosted fields script is loaded on the checkout page only when the embedded card form is enabled, from https://app13.smartpay.co.il/ or, for accounts SmartPay has moved to their own pages address, from that address (always a smartpay.co.il or protected-payment.com host); the card fields themselves load from the address SmartPay returns for the checkout session. Data sent includes the order amount, currency, order number, customer billing and shipping details, and, for Multipass, the voucher card number entered by the customer. 81 86 82 87 SmartPay.co.il terms of use and privacy policy: https://www.smartpay.co.il/terms/ 83 88 84 89 == Changelog == 90 91 = 1.2.4 = 92 * New: SmartPay can move a merchant account to a different hosted pages address. The plugin reads the address from the SmartPay dashboard with the store's API credentials and uses it for the payment page, the embedded card form and its script. Stores whose account has no address of its own are not affected, and when the dashboard cannot be reached the plugin keeps using the address it gets from the payments API. 93 * Fixed: an order paid with Bit, Apple Pay or Google Pay on the card payment page showed "credit card" as its payment method in the admin, the e-mails and the thank-you page. The title now follows the method the charge was confirmed with. 85 94 86 95 = 1.2.3 = -
wc-smartpay/tags/1.2.4/smartpay.php
r3764750 r3833154 4 4 * Plugin URI: https://smartpay.co.il/ 5 5 * Description: Accept credit cards, Apple Pay, Google Pay, Bit and Multipass vouchers in WooCommerce through the SmartPay.co.il payment gateway. 6 * Version: 1.2. 36 * Version: 1.2.4 7 7 * Requires at least: 6.5 8 8 * Requires PHP: 7.4 … … 51 51 } 52 52 53 define( 'SMARTPAY_VERSION', '1.2. 3' );53 define( 'SMARTPAY_VERSION', '1.2.4' ); 54 54 55 55 if ( ! defined( 'SMARTPAY_PLUGIN_FILE' ) ) { -
wc-smartpay/trunk/includes/class-smartpay-adapter.php
r3764750 r3833154 273 273 $request_data = apply_filters( 'smartpay_generate_payment_page_link_before', $request_data ); 274 274 $request_data['transaction_source'] = $this->get_transaction_source( 'iframe' ); 275 return $this->request( $request_data, 'checkout/pages', $use_alternative ); 275 return $this->with_company_pages_address( 276 $this->request( $request_data, 'checkout/pages', $use_alternative ), 277 $use_alternative 278 ); 276 279 } 277 280 … … 288 291 $request_data['page_type'] = 'hosted_fields'; 289 292 $request_data['transaction_source'] = $this->get_transaction_source( 'iframe' ); 290 return $this->request( $request_data, 'checkout/pages', $user_alternative ); 293 return $this->with_company_pages_address( 294 $this->request( $request_data, 'checkout/pages', $user_alternative ), 295 $user_alternative 296 ); 291 297 } 298 299 /** 300 * Point the hosted link of a checkout session at the company's own pages 301 * address, when SmartPay gave the company one. Anything else is returned 302 * untouched. 303 * 304 * @param mixed $response checkout/pages response. 305 * @param bool $use_alternative flag to define if to use alternative API credentials. 306 * @return mixed 307 */ 308 private function with_company_pages_address( $response, $use_alternative = false ) { 309 if ( is_array( $response ) && isset( $response['url'] ) && is_string( $response['url'] ) ) { 310 $response['url'] = SmartPay_Pages_Address::instance()->rewrite( $response['url'], $use_alternative ); 311 } 312 return $response; 313 } 292 314 293 315 /** -
wc-smartpay/trunk/includes/class-smartpay-cc-form-renderer.php
r3700234 r3833154 18 18 wp_enqueue_script( 19 19 'smartpay-lib', 20 'https://app13.smartpay.co.il/v1/sdk/sdk.js'20 SmartPay_Pages_Address::instance()->get_sdk_url() 21 21 ); 22 22 -
wc-smartpay/trunk/includes/class-smartpay-checkout-block.php
r3700234 r3833154 93 93 wp_register_script( 94 94 $hostedFieldsHandle, 95 'https://app13.smartpay.co.il/v1/sdk/sdk.js'95 SmartPay_Pages_Address::instance()->get_sdk_url() 96 96 ); 97 97 } -
wc-smartpay/trunk/includes/class-smartpay-order-helper.php
r3700234 r3833154 251 251 252 252 return $card; 253 } 254 255 /** 256 * Non-card methods the payment page can charge with: lowercase API name 257 * => [ checkout gateway id (null when the plugin has none), default title ]. 258 * 259 * @return array 260 */ 261 private function paid_method_titles() { 262 return array( 263 'bitbyupay' => array( SmartPay_Payment_Gateway_Bitbyupay::METHOD_CODE, 'Bit' ), 264 'bitbygrow' => array( SmartPay_Payment_Gateway_Bitbygrow::METHOD_CODE, 'Bit' ), 265 'bitbygama' => array( null, 'Bit' ), 266 'applepay' => array( SmartPay_Payment_Gateway_Applepay::METHOD_CODE, 'Apple Pay' ), 267 'gpay' => array( SmartPay_Payment_Gateway_Gpay::METHOD_CODE, 'Google Pay' ), 268 ); 269 } 270 271 /** 272 * Method the charge was paid with, as the API reports it. Card and 273 * wallet charges carry `transaction_method`; Bit charges (UPay / Grow) 274 * only carry the wallet in `transaction_source`, or the Bit terminal name. 275 * 276 * @param StdClass $transaction confirmed charge. 277 * @return string key of paid_method_titles(), empty for a card charge or an unknown method. 278 */ 279 private function resolve_paid_method( $transaction ) { 280 $source = $transaction->transaction_source ?? null; 281 if ( is_string( $source ) ) { 282 $source = json_decode( $source, true ); 283 } 284 $source = is_object( $source ) ? get_object_vars( $source ) : $source; 285 286 $candidates = array( 287 is_array( $source ) && isset( $source['wallet'] ) ? $source['wallet'] : null, 288 $transaction->transaction_method ?? null, 289 $transaction->terminalName ?? null, 290 ); 291 292 $known = $this->paid_method_titles(); 293 foreach ( $candidates as $candidate ) { 294 $key = is_string( $candidate ) ? strtolower( trim( $candidate ) ) : ''; 295 if ( isset( $known[ $key ] ) ) { 296 return $key; 297 } 298 } 299 300 return ''; 301 } 302 303 /** 304 * The payment page of the card gateway also offers the terminal's other 305 * methods (Bit, Apple Pay, Google Pay). When the charge was paid with one 306 * of them, show that method on the order (admin, e-mails, thank-you page) 307 * instead of the title of the gateway picked at checkout. 308 * 309 * Only the title changes: the method id keeps driving refunds, renewals 310 * and the invoices plugin mapping. Must run before the status change that 311 * sends the customer e-mail. The caller saves the order. 312 * 313 * @param WC_Order $order order object. 314 * @param string $transaction_method resolve_paid_method() result. 315 * @return void 316 */ 317 private function sync_paid_method_title( WC_Order $order, $transaction_method ) { 318 $paid_methods = $this->paid_method_titles(); 319 $key = (string) $transaction_method; 320 if ( ! isset( $paid_methods[ $key ] ) ) { 321 return; 322 } 323 324 list( $method_code, $title ) = $paid_methods[ $key ]; 325 if ( $method_code === $order->get_payment_method() ) { 326 return; 327 } 328 329 // A store that offers the method at checkout gets the title it configured there. 330 if ( $method_code ) { 331 $settings = get_option( 'woocommerce_' . $method_code . '_settings' ); 332 if ( is_array( $settings ) 333 && isset( $settings['enabled'], $settings['title'] ) 334 && 'yes' === $settings['enabled'] 335 && '' !== trim( (string) $settings['title'] ) 336 ) { 337 $title = trim( (string) $settings['title'] ); 338 } 339 } 340 341 /** 342 * Title shown on an order paid with another method than the gateway picked at checkout. 343 * 344 * @param string $title title to show. 345 * @param string $transaction_method key of paid_method_titles(), e.g. `bitbyupay`. 346 * @param WC_Order $order order object. 347 */ 348 $title = (string) apply_filters( 'smartpay_paid_method_title', $title, $transaction_method, $order ); 349 if ( '' === $title || $title === $order->get_payment_method_title() ) { 350 return; 351 } 352 353 $order->set_payment_method_title( $title ); 253 354 } 254 355 … … 321 422 $order->update_meta_data( 'transaction_method', $transaction->transaction_method ?? null ); 322 423 424 $this->sync_paid_method_title( $order, $this->resolve_paid_method( $transaction ) ); 425 323 426 $order->set_transaction_id( $transaction->tuid ); 324 427 $order->save(); -
wc-smartpay/trunk/includes/class-smartpay-payment-gateway.php
r3707394 r3833154 77 77 do_action( 'smartpay_payment_gateway_init_after', $this ); 78 78 79 // Saving the settings also asks the SmartPay dashboard again which 80 // hosted pages address applies to this store. 81 add_action( 82 'woocommerce_update_options_payment_gateways_' . $this->id, 83 array( SmartPay_Pages_Address::instance(), 'flush' ), 84 5 85 ); 86 79 87 // This action hook saves the settings. 80 88 add_action( -
wc-smartpay/trunk/includes/class-smartpay.php
r3764750 r3833154 16 16 * @var string 17 17 */ 18 private $version = '1.2. 3';18 private $version = '1.2.4'; 19 19 20 20 /** -
wc-smartpay/trunk/readme.txt
r3764750 r3833154 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.2. 37 Stable tag: 1.2.4 8 8 Requires Plugins: woocommerce 9 9 License: GPLv2 or later … … 78 78 * https://sandboxapi.smartpay.co.il/ (sandbox) 79 79 80 The hosted payment page and hosted fields are served from SmartPay servers. The hosted fields script is loaded on the checkout page from https://app13.smartpay.co.il/ only when the embedded card form is enabled; the card fields themselves load from the address SmartPay returns for the checkout session. Data sent includes the order amount, currency, order number, customer billing and shipping details, and, for Multipass, the voucher card number entered by the customer. 80 The plugin also asks the SmartPay dashboard which hosted pages address applies to the store's SmartPay account. The request carries only the store's API credentials and is answered from a one-hour cache. It goes to: 81 82 * https://my-backend.smartpay.co.il/ (production) 83 * https://mysandbox-backend.smartpay.co.il/ (sandbox) 84 85 The hosted payment page and hosted fields are served from SmartPay servers. The hosted fields script is loaded on the checkout page only when the embedded card form is enabled, from https://app13.smartpay.co.il/ or, for accounts SmartPay has moved to their own pages address, from that address (always a smartpay.co.il or protected-payment.com host); the card fields themselves load from the address SmartPay returns for the checkout session. Data sent includes the order amount, currency, order number, customer billing and shipping details, and, for Multipass, the voucher card number entered by the customer. 81 86 82 87 SmartPay.co.il terms of use and privacy policy: https://www.smartpay.co.il/terms/ 83 88 84 89 == Changelog == 90 91 = 1.2.4 = 92 * New: SmartPay can move a merchant account to a different hosted pages address. The plugin reads the address from the SmartPay dashboard with the store's API credentials and uses it for the payment page, the embedded card form and its script. Stores whose account has no address of its own are not affected, and when the dashboard cannot be reached the plugin keeps using the address it gets from the payments API. 93 * Fixed: an order paid with Bit, Apple Pay or Google Pay on the card payment page showed "credit card" as its payment method in the admin, the e-mails and the thank-you page. The title now follows the method the charge was confirmed with. 85 94 86 95 = 1.2.3 = -
wc-smartpay/trunk/smartpay.php
r3764750 r3833154 4 4 * Plugin URI: https://smartpay.co.il/ 5 5 * Description: Accept credit cards, Apple Pay, Google Pay, Bit and Multipass vouchers in WooCommerce through the SmartPay.co.il payment gateway. 6 * Version: 1.2. 36 * Version: 1.2.4 7 7 * Requires at least: 6.5 8 8 * Requires PHP: 7.4 … … 51 51 } 52 52 53 define( 'SMARTPAY_VERSION', '1.2. 3' );53 define( 'SMARTPAY_VERSION', '1.2.4' ); 54 54 55 55 if ( ! defined( 'SMARTPAY_PLUGIN_FILE' ) ) {
Note:
See TracChangeset
for help on using the changeset viewer.