Home > WeChat Applet > WeChat Development > Detailed explanation of android WeChat payment example code

Detailed explanation of android WeChat payment example code

高洛峰
Release: 2017-03-27 13:36:00
Original
2126 people have browsed it

This article mainly introduces in detail android WeChat payment source code, which has certain For practicality and reference value, interested friends can refer to it

This article shares the android WeChat payment source code for your reference. The specific content is as follows

Parameter configuration

public static final String APP_ID ;
/**
在微信开放平台注册app,微信给分配的id
**/
public static final String MCH_ID;
/**
申请开通微信支付,成功后微信会给你发一封邮件,给你分配一个商户平台账号,在资料里有商户ID
**/
public static final String API_KEY;
/**
在微信发给你的那封邮件里,给你分配的微信商户平台账号,在里面设置一个api_key
**/
Copy after login

Get prepay_id

The above configurations are correct. When you run it, you will receive a return result like this on WeChat:

<xml><return_code></return_code>
<return_msg></return_msg>
<appid></appid>
<mch_id></mch_id>
<nonce_str></nonce_str>
<sign></sign><result_code></result_code>
<prepay_id></prepay_id>//成功获取到预付id
<trade_type></trade_type>
</xml>
Copy after login

When taking the second step, you may have problems:

##result_code>//merchant id Wrongresult_code>//When assembling product parameters, the Chinese content must specify the encoding, otherwise the code will be garbled and this error will be reported;

Successfully obtained prepay_id. At this time, the payment interface cannot be adjusted.

/***Note:

1. If the app you apply to open WeChat payment is registered on the WeChat open platform and uses the
eclipse default signature, then you can activate it for payment in the development environment now. Page2. If the signature in the open platform app uses a custom signature, you need to use the signature to package it, and then run it to adjust its WeChat payment
***/

WeChat payment result callback? Where?

1.app client, we accept the payment callback result in this class

Detailed explanation of android WeChat payment example code##/**

You need to change the coloring part to your own app_id

** /

Detailed explanation of android WeChat payment example codeNote:

/** 
这个activity,是个透明的activity,回调完,你需要结束掉它* 
2.服务端 
**/
packageParams.add(new BasicNameValuePair("notify_url", "http://121.40.35.3/test"));
/**
需要指定一个回调接口,用于微信来调用,通知服务端,修改数据
*/
Copy after login

The above is the detailed content of Detailed explanation of android WeChat payment example code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template