froger-me/wp-weixin

Weixin embeded browser issue. it can't be open within the weixin browser.

ryouma999 opened this issue · 6 comments

when i open the web(with this plugin) within weixin browser.
it give me an error indicate that openid is missing.
微信图片_20200729064915

whats more
if I enable the option
#: inc/class-wp-weixin-settings.php:534
msgid "Enable WeChat authentication"
msgstr "启用微信身份验证"
it can't be open within the weixin browser.

can u please give me some tips to slove this?

Hi @ryouma999 ,

The first error happens because the WeChat browser could not authenticate the user: no openID of a WeChat user was provided for the transaction.
The second error shows that the authentication process doesn't go through ; it is the cause of the first error.

Please make sure the configuration of URLs is correct in the WeChat backend at https://mp.weixin.qq.com

This how-to written by a user of the plugin may be useful: https://shinecloud.com.cn/2020/03/20/wp-weixin-chajianshiyongjiaocheng/

Dear froger-me:
thanks for your kindly help.
my situation is a little bit complex.
(0) configuration of URLs is correct. I have two site , the first site was ok( xampp ) , now the error was show at the site ( ngnix + xampp),

(1) errors shows at ngnix + xampp site
xampp's setting

<VirtualHost *:43000>
##ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "C:/xampp/htdocs/wpshop"
ServerName h5.xlwl95.com

ngnix

server {
     listen       80;
	add_header Access-Control-Allow-Origin *;
	add_header Access-Control-Allow-Headers X-Requested-With;
	add_header Access-Control-Allow-Methods GET,POST,OPTIONS;   
            server_name  h5.xlwl95.com;
	index index.php;
	location / {
		index index.php
		root C:/xampp/htdocs/wpshop;
		proxy_pass http://127.0.0.1:43000;
                    proxy_redirect     off;
                    proxy_set_header   Host             $host;
                    proxy_set_header   X-Real-IP        $remote_addr;
                    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
	}
          location ~ .*(js|css|png|gif|jpg|mp3|ogg|svg)$ {
		root C:/xampp/htdocs/as3000wpshop;
		add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
		
	}

}

===============================================================
I can confirmed that my setting for this running enviroment had something incorrect.
I test the wc-json , it returns error, so I can confirmed that ngnix has errors configuration.
But I dont know how to fix it.

(2) I wanna to get the openid ,by coding myself, under the weixin browser.
can u tell me where should I place my php code ?

Hi @ryouma999 ,

This is out of the scope of this plugin support page, so I will close the issue now.

The plugin works with WordPress configured in a standard way, on a server that is NOT localhost (WeChat API doesn't accept that), and proper configuration in the WeChat backend (website domain properly registered, ICP, etc as inidcated in the documentation).
Any other type of issue (code or configuration outside of the plugin itself) must be handled by yourself, your system administrator, or the programmer in charge of your custom code.

To clarify: issues are for reporting bugs, and what you are experiencing is configuration difficulties ; I can't get enough information to solve your issue without getting a firm grasp of your setup first. I didn't mean to be dismissive or imply there was no issue for you.
This is something I can help with for a fee payable by WeChat (RMB 500 for 3h max upfront, then RMB 200 for each additional hour spent) and access to your server via SSH and WordPress admin (and any other credentials necessary, or active participation in the troubleshooting process).

I already modified the FILE in order to show the qrcode, and it works on pc browser .
But I still working on the weixin browser...I reading the code now , hope to find the place on authorization where missing the openid, I planning to add the openid using code.

computer-pay-qr.php

QR header QR placeholder QR Code
		<?php if ( $qr_img_footer ) : ?>
			<img class="woowechatpay-qr-footer" alt="QR footer" src="<?php echo esc_url( $qr_img_footer ); ?>"/>
		<?php endif; ?>
	</div>
	<?php if ( $qr_phone_bg ) : ?>
		<img class="woowechatpay-qr-bg" alt="QR help" src="<?php echo esc_url( $qr_phone_bg ); ?>"/>
	<?php endif; ?>
<?php else : ?>
	<p class="woocommerce-error">
		<?php esc_html_e( 'Error generating the payment QR code. If the problem persists, please contact our services.', 'woo-wechatpay' ); ?>
	</p>
	<?php if ( ! empty( $error ) ) : ?>
		<p>
			<?php echo esc_html( $error ); ?>
		</p>
		<div class="woocommerce-info">
			<a href="<?php echo esc_url( get_permalink( wc_get_page_id( 'shop' ) ) ); ?>" class="button wc-forward">
				<?php esc_html_e( 'Return to shop', 'woocommerce' ); ?>
			</a>
			<?php esc_html_e( 'Place a new order and try again.', 'woo-wechatpay' ); ?>
		</div>
	<?php endif; ?>
<?php endif; ?>
<script type="text/javascript" src="http://static.runoob.com/assets/qrcode/qrcode.min.js"></script> <script type="text/javascript"> var qrcode = new QRCode(document.getElementById("qrcode"), { width : 100, height : 100 });

function makeCode () {
var elText = document.getElementById("text");

//elText = 'weixin://wxpay/bizpayurl?pr=H0sTk4F';

if (!elText.value) {
	alert("Input a text");
	//elText.focus();
	return;
}

qrcode.makeCode(elText.value);

}

makeCode();

jQuery(document).ready(function( $ ) {
return_img_src();
function return_img_src()
{
image_src = $("#qrcode img").eq(0).attr("src");
$("#woowechatpay_qr_code").attr('src',image_src);
} });

</script>

I reading the code now , hope to find the place on authorization where missing the openid, I planning to add the openid using code.

There shouldn't be any need for additional code to trigger authorization ; it's already included. I visited https://h5.xlwl95.com with the WeChat browser and noticed no authentication was happening. This indicates an issue with configuration.

Please make sure to study the documentation (both official and non-official I linked above). Barring actual bugs, all you need is in there. Additional code is required only for advanced custom changes of behavior (like with some themes or conflicting plugins, or pure customization).