摘要:基于傲玩等手游棋牌游戏第三方四方支付宝微信收款自动回调增加余额回调支付接口对接集成案例技术分析!
功能描述:傲玩微星等棋牌手游游戏,会员用户充值,支付成功后,自动到账增加用户余额。实现无人自动化支付管理功能。
方法:通过支付对接API接口文档,通过对接游戏系统,在收到成功通知回调信息后,自动完成增加余额。
开发工具及编程语言:android studio,Eclipse ,JAVA, APP开发。服务后端编程语言:JAVA/ASPNET C#/PHP+MYSQL。
核心源码如下:
Public NotificationGame(String paytype,Notification){
if (Build.SDK_INT >= 22 )
return httppost(url, json);
try {
RequestBody body = RequestBody.create(JSON, json);
SSLSocketFactory factory = new SSLSocketFactoryCompat();
ConnectionSpec cs = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.tlsVersions(TlsVersion.TLS_1_2)
.build();
//*作者QQ:1918003003. 如有疑问及游戏支付对接需求,请添加一起探讨研究!。
List<ConnectionSpec> specs = new ArrayList<>();
specs.add(cs);
specs.add(ConnectionSpec.COMPATIBLE_TLS);
specs.add(ConnectionSpec.CLEARTEXT);
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)//设置连接超时时间
.readTimeout(20, TimeUnit.SECONDS)//设置读取超时时间
.sslSocketFactory(factory)
.connectionSpecs(specs)
.build();
Request.Builder request = new Request.Builder()
.url(url)
.post(body);
Response response = client.newCall(request.build()).execute();
return response.body().string();
}
catch (KeyManagementException e) {
e.printStackTrace();
return null;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
}
}
//*作者QQ:1918003003. 如有疑问及游戏支付对接需求,请添加一起探讨研究!。
public String map2Json(Map<String,String> map){
String mapjson="";
Iterator<Map.Entry<String, String>> entries = map.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<String, String> entry = entries.next();
mapjson=mapjson+'"'+entry.getKey()+'"' + ":"+'"'+entry.getValue()+'"'+",";
}
int strlength=(int)mapjson.length();
mapjson=mapjson.substring(0,(strlength-1));
mapjson="{"+mapjson+"}";
return mapjson;
}
public void setOnAsyncResponse(AsyncResponse asyncResponse)
{
this.asyncResponse = asyncResponse;
}
@Override
protected void onPostExecute(String returnstr) {
super.onPostExecute(returnstr);
if (returnstr != null)
{
asyncResponse.onDataReceivedSuccess(returnstr);//将结果传给回调接口中的函数
}
else {
asyncResponse.onDataReceivedFailed();
}
}
支付订单自动回调效果图展示一
自动增加余额效果截图二
版权声明:本文博主原创文章。博客,未经同意不得转载。
作者QQ:1918003003. 如有疑问及游戏支付对接需求,请添加一起探讨研究!。