Changeset 2794884
- Timestamp:
- 10/06/2022 07:10:05 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
aircash-for-woocommerce/trunk/includes/class-aircash-payment-gateway.php
r2735596 r2794884 9 9 use BaconQrCode\Renderer\ImageRenderer; 10 10 use BaconQrCode\Renderer\Image\ImagickImageBackEnd; 11 use BaconQrCode\Renderer\PlainTextRenderer; 11 12 use BaconQrCode\Renderer\RendererStyle\RendererStyle; 12 13 use BaconQrCode\Writer; … … 121 122 */ 122 123 public function add_html_to_admin() { 123 echo '<div id="aircash-new-account-request-url" data-url="' . esc_attr( $this->get_new_account_request_url()) . '"></div>';124 echo '<div id="aircash-new-account-request-url" data-url="' . esc_attr( $this->get_new_account_request_url() ) . '"></div>'; 124 125 } 125 126 … … 427 428 $order->save(); 428 429 } 429 $store_address = get_option( 'woocommerce_store_address' ); 430 $store_address_2 = get_option( 'woocommerce_store_address_2' ); 431 $store_city = get_option( 'woocommerce_store_city' ); 432 $store_postcode = get_option( 'woocommerce_store_postcode' ); 433 $location = null; 434 if ( $store_address ) { 435 $location .= $store_address . ', '; 436 } 437 if ( $store_address_2 ) { 438 $location .= $store_address_2 . ', '; 439 } 440 if ( $store_city ) { 441 $location .= trim( $store_postcode . ' ' . $store_city ); 442 } 443 $store_raw_country = get_option( 'woocommerce_default_country' ); 444 if ( $store_raw_country ) { 445 $location .= ', ' . $store_raw_country; 446 } 430 $location = preg_replace( '/^https?:\/\//i', '', get_site_url() ); 447 431 $parameters = array( 448 432 'Amount' => (float) number_format( $order->get_total(), 2, '.', '' ), … … 459 443 // phpcs:ignore 460 444 ini_set( 'serialize_precision', - 1 ); 461 $body = wp_json_encode( $parameters, \JSON_UNESCAPED_SLASHES );445 $body = wp_json_encode( $parameters, JSON_UNESCAPED_SLASHES ); 462 446 // phpcs:ignore 463 447 ini_set( 'serialize_precision', $serialize_precizion ); … … 472 456 ) 473 457 ); 474 $result = $error_message = $qr_code_image_data = null;458 $result = $error_message = $qr_code_image_data = $qr_code_textual = null; 475 459 476 460 $response_code = (int) wp_remote_retrieve_response_code( $response ); … … 485 469 if ( isset( $result['codeLink'] ) && is_string( $result['codeLink'] ) ) { 486 470 // It's all good man, display the QR code 487 $renderer = new ImageRenderer( new RendererStyle( 400 ), new ImagickImageBackEnd() ); 488 $writer = new Writer( $renderer ); 489 $qr_code_image_data = $writer->writeString( $result['codeLink'] ); 471 if ( ! extension_loaded( 'imagick' ) ) { 472 $qr_code_textual = true; 473 $renderer = new PlainTextRenderer(); 474 $writer = new Writer( $renderer ); 475 $qr_code_image_data = $writer->writeString( $result['codeLink'] ); 476 } else { 477 $qr_code_textual = false; 478 $renderer = new ImageRenderer( new RendererStyle( 400 ), new ImagickImageBackEnd() ); 479 $writer = new Writer( $renderer ); 480 $qr_code_image_data = $writer->writeString( $result['codeLink'] ); 481 } 490 482 } else { 491 483 $error_message = 'Unable to generate QR code'; … … 520 512 521 513 <div class="aircash-qr-code-wrapper"> 522 <img class="aircash-qr-code" src="data:image/png;base64,<?php 523 // phpcs:ignore 524 echo base64_encode( $qr_code_image_data ); 525 ?>"> 514 <?php 515 if ( $qr_code_textual ) { 516 ?> 517 <pre style="line-height:100%;color:black;font-family:monospace;font-size:11px;background:white;font-weight:100;letter-spacing:-1px;user-select:none;-webkit-user-select:none"><?php 518 echo $qr_code_image_data; 519 ?></pre><?php 520 } else { 521 ?> 522 <img class="aircash-qr-code" src="data:image/png;base64,<?php 523 // phpcs:ignore 524 echo base64_encode( $qr_code_image_data ); 525 ?>"> 526 <? 527 } 528 ?> 526 529 <ol> 527 530 <li><?php echo esc_html__( 'Open Aircash application', 'aircash-for-woocommerce' ) ?></li> … … 951 954 $this->update_option( $aircash_callback_url_option, $callback_url ); 952 955 953 $body = wp_json_encode( $parameters, \JSON_UNESCAPED_SLASHES ^ \JSON_UNESCAPED_LINE_TERMINATORS ^ \JSON_PRETTY_PRINT );956 $body = wp_json_encode( $parameters, JSON_UNESCAPED_SLASHES ^ JSON_UNESCAPED_LINE_TERMINATORS ^ JSON_PRETTY_PRINT ); 954 957 $response = wp_remote_post( 955 958 'https://' . ( $test ? 'staging-m3.aircash.eu' : 'm3.aircash.eu' ) . '/api/AircashPay/ActivatePartner',
Note: See TracChangeset
for help on using the changeset viewer.