/**
* 支付宝支付
*
* @author 祝文飞(Tailyou)
* @time 2017/3/20 10:13
*/
public void doAlipay(View view) {
//pay param form server
String payParam = "pay param form server";
Alipay.getInstance(this).doPay(payParam, new Alipay.AlipayResultCallBack() {
@Override
public void onSuccess() {
Toast.makeText(getApplication(), "支付成功", Toast.LENGTH_SHORT).show();
}
@Override
public void onDealing() {
Toast.makeText(getApplication(), "支付处理中...", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(int error_code) {
switch (error_code) {
case Alipay.ERROR_RESULT:
Toast.makeText(getApplication(), "支付失败:支付结果解析错误", Toast.LENGTH_SHORT).show();
break;
case Alipay.ERROR_NETWORK:
Toast.makeText(getApplication(), "支付失败:网络连接错误", Toast.LENGTH_SHORT).show();
break;
case Alipay.ERROR_PAY:
Toast.makeText(getApplication(), "支付错误:支付码支付失败", Toast.LENGTH_SHORT).show();
break;
default:
Toast.makeText(getApplication(), "支付错误", Toast.LENGTH_SHORT).show();
break;
}
}
@Override
public void onCancel() {
Toast.makeText(getApplication(), "支付取消", Toast.LENGTH_SHORT).show();
}
});
}