站长付个人收款接入教程附App和h5效果演示
程序员文章站
2022-07-13 16:55:32
...
站长付个人收款接入教程附App和h5效果演示
还在为个人收款而发愁吗?今天教你如何接入站长付系统
前言
站长付一直在坚持的个人开发者、个体户、个人创业者、小公司、小众产品,它始终坚信产品足够好用、简单、口碑扎实就会获得开发者喜爱,它正在通过自己独特的方式诠释、展示它的价值!
一、站长付是什么?
站长付解决需要使用交易数据流的个人、创业者、个体户等小微支付收款需求,帮助开发者快速变现。站长付只负责信息流,不接管资金流,资金无任何风险。重点是不收费!
二、接入
1.效果展示
效果图:
效果视频地址:http://jcvideo.itluntan.cn/payxiaoguo.1200.webm
2.app接入教程
代码如下(示例):
//统一下单
public void createOrder() {
ModelTest.getInstance().createOrder("XXXXXXXXXXXXXXXXXX开通站长付平台超级会员", "1", new IModel.AsyncCallback() {
@Override
public void onSuccess(Object obj) {
try {
JSONObject jsonObject = new JSONObject(obj.toString());
if (!jsonObject.getString("code").equals("10001")) {
ToastUtils.showCustomToast(jsonObject.getString("msg") + "");
return;
}
tvname.setText(jsonObject.getString("name"));
tvprice.setText(jsonObject.getString("price"));
orderId = jsonObject.getString("orderId");
//启动定时器
timer.schedule(task, 0, 5000);
} catch (Exception e) {
e.printStackTrace();
ToastUtils.showCustomToast(AltTextUtils.SERVERPARSINGEXCEPTIONS);
}
}
@Override
public void onError(Object obj) {
ToastUtils.showCustomToast(AltTextUtils.SERVERERROR);
}
});
}
//订单支付状态查询
public void getOrderState() {
ModelTest.getInstance().getOrderState(orderId, new IModel.AsyncCallback() {
@Override
public void onSuccess(Object obj) {
try {
JSONObject jsonObject = new JSONObject(obj.toString());
if (!jsonObject.getString("code").equals("10001")) {
return;
}
AlertDialog.Builder alertdialogbuilder = new AlertDialog.Builder(TestZzfActivity.this);
alertdialogbuilder.setMessage("提示:恭喜您支付成功");
alertdialogbuilder.setPositiveButton("确定", null);
alertdialogbuilder.setNeutralButton("取消", null);
final AlertDialog alertdialog1 = alertdialogbuilder.create();
alertdialog1.show();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onError(Object obj) {
}
});
}
附完整代码
TestActivity
package com.zhanzhangfu.ui.activity.main;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import com.zhanzhangfu.R;
import com.zhanzhangfu.ui.base.BaseActivity;
public class TestActivity extends BaseActivity {
private Button btn1;
private Button btn2;
@Override
public int initLayout() {
return R.layout.test;
}
@Override
public void initView() {
btn1 = findViewById(R.id.btn_pay1);
btn2 = findViewById(R.id.btn_pay2);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(TestActivity.this, TestZzfActivity.class));
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(TestActivity.this, Testh5Activity.class));
}
});
}
@Override
public void initData() {
}
}
TestActivity
package com.zhanzhangfu.ui.activity.main;
import android.app.AlertDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.zhanzhangfu.R;
import com.zhanzhangfu.ui.base.BaseActivity;
import com.zhanzhangfu.ui.modeldao.IModel;
import com.zhanzhangfu.ui.modeldao.test.ModelTest;
import com.zhanzhangfu.ui.utils.AltTextUtils;
import com.zhanzhangfu.ui.utils.ToastUtils;
import org.json.JSONObject;
import java.util.Timer;
import java.util.TimerTask;
public class TestZzfActivity extends BaseActivity {
private Button gotopay;
private TextView tvname;
private TextView tvprice;
private String orderId;
@Override
public int initLayout() {
return R.layout.testzzf;
}
@Override
public void initView() {
gotopay = findViewById(R.id.gotopay);
tvname = findViewById(R.id.tv_name);
tvprice = findViewById(R.id.tv_price);
gotopay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("alipayqr://platformapi/startapp?saId=10000007&qrcode=https%3a%2f%2fqr.alipay.com%2ftsx140593gavtpepmajwj09")));
}
});
}
@Override
public void initData() {
createOrder();
}
private Handler handler = new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == 1) {
getOrderState();
}
}
};
private Timer timer = new Timer(true);
//任务
private TimerTask task = new TimerTask() {
public void run() {
Message msg = new Message();
msg.what = 1;
handler.sendMessage(msg);
}
};
//统一下单
public void createOrder() {
ModelTest.getInstance().createOrder("XXXXXXXXXXXXXXXXXX开通站长付平台超级会员", "1", new IModel.AsyncCallback() {
@Override
public void onSuccess(Object obj) {
try {
JSONObject jsonObject = new JSONObject(obj.toString());
if (!jsonObject.getString("code").equals("10001")) {
ToastUtils.showCustomToast(jsonObject.getString("msg") + "");
return;
}
tvname.setText(jsonObject.getString("name"));
tvprice.setText(jsonObject.getString("price"));
orderId = jsonObject.getString("orderId");
//启动定时器
timer.schedule(task, 0, 5000);
} catch (Exception e) {
e.printStackTrace();
ToastUtils.showCustomToast(AltTextUtils.SERVERPARSINGEXCEPTIONS);
}
}
@Override
public void onError(Object obj) {
ToastUtils.showCustomToast(AltTextUtils.SERVERERROR);
}
});
}
//订单支付状态查询
public void getOrderState() {
ModelTest.getInstance().getOrderState(orderId, new IModel.AsyncCallback() {
@Override
public void onSuccess(Object obj) {
try {
JSONObject jsonObject = new JSONObject(obj.toString());
if (!jsonObject.getString("code").equals("10001")) {
return;
}
AlertDialog.Builder alertdialogbuilder = new AlertDialog.Builder(TestZzfActivity.this);
alertdialogbuilder.setMessage("提示:恭喜您支付成功");
alertdialogbuilder.setPositiveButton("确定", null);
alertdialogbuilder.setNeutralButton("取消", null);
final AlertDialog alertdialog1 = alertdialogbuilder.create();
alertdialog1.show();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onError(Object obj) {
}
});
}
}
2.官方接入文档
代码如下(示例):
站长付官方文档地址:https://www.zhanzhangfu.com/?post=9
总结
简单、易懂、安全、高效、易扩展、免费用、免费用、免费用。
如果文章对您有帮助点个赞再走吧,(๑′ᴗ‵๑)I Lᵒᵛᵉᵧₒᵤ❤
上一篇: 支付宝免签收款模式解析(发消息)
下一篇: 浅析Tomcat防止文件被锁的方式