本文整理汇总了Java中com.alipay.sdk.app.PayTask.pay方法的典型用法代码示例。如果您正苦于以下问题:Java PayTask.pay方法的具体用法?Java PayTask.pay怎么用?Java PayTask.pay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alipay.sdk.app.PayTask
的用法示例。
在下文中一共展示了PayTask.pay方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: aliPayReturn
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
@Override
public void aliPayReturn(String data) {
if (!data.isEmpty()) {
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask 对象
PayTask alipay = new PayTask(UserRechargeActivity.this);
// 调用支付接口,获取支付结果
String result = alipay.pay(data, true);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}
}
示例2: setOrderInfo
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
@Override
public void setOrderInfo(String orderInfo) {
if (!orderInfo.isEmpty()) {
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask 对象
PayTask alipay = new PayTask(OrderPayActivity.this);
// 调用支付接口,获取支付结果
String result = alipay.pay(orderInfo, true);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}
}
示例3: payV1
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
/**
* call alipay sdk pay. 调用SDK支付
*/
public void payV1(final String payInfo) {
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask 对象
PayTask alipay = new PayTask(context);
// 调用支付接口,获取支付结果
String result = alipay.pay(payInfo, true);// true 在调起支付页面之前显示进度条
Message msg = new Message();
msg.what = Config.SDK_PAY_FLAG;
msg.arg1 = VERSION_1;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}
示例4: run
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
public void run() {
String pay;
try {
PayTask payTask = new PayTask(this.b);
PingppLog.d("alipaysdk version: " + payTask.getVersion());
pay = payTask.pay(this.a, true);
PingppLog.d("PaymentActivity alipay result: " + pay);
Message message = new Message();
message.what = 1;
message.obj = pay;
this.b.m.sendMessage(message);
} catch (NoClassDefFoundError e) {
e.printStackTrace();
pay = PingppObject.getInstance().currentChannel;
this.b.a("fail", "channel_sdk_not_included:" + pay, "不支持该渠道: " + pay + "。缺少支付宝的 SDK。");
}
}
示例5: pay
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
@Override
public void pay(Activity activity, AlipayInfoImpli payInfo, IPayCallback payCallback) {
this.mActivity = activity;
this.alipayInfoImpli = payInfo;
sPayCallback = payCallback;
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask 对象
PayTask alipay = new PayTask(mActivity);
// 调用支付接口,获取支付结果
String result = alipay.pay(alipayInfoImpli.getOrderInfo(), true);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}
示例6: pay
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
public void pay(String price, String goodname, String gooddes,String orderid) {
String orderInfo = getOrderInfo(goodname, gooddes, price,orderid);
String sign = sign(orderInfo);
try {
sign = URLEncoder.encode(sign, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
final String payInfo = orderInfo + "&sign=\"" + sign + "\"&"
+ getSignType();
Runnable payRunnable = new Runnable() {
@Override
public void run() {
PayTask alipay = new PayTask(OrderDetailActivity.this);
String result = alipay.pay(payInfo);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
Thread payThread = new Thread(payRunnable);
payThread.start();
}
示例7: pay
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
public void pay(String price, String goodname, String gooddes,String orderid) {
String orderInfo = getOrderInfo(goodname, gooddes, price,orderid);
String sign = sign(orderInfo);
try {
sign = URLEncoder.encode(sign, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
final String payInfo = orderInfo + "&sign=\"" + sign + "\"&"
+ getSignType();
Runnable payRunnable = new Runnable() {
@Override
public void run() {
PayTask alipay = new PayTask(OrderActivity.this);
String result = alipay.pay(payInfo);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
Thread payThread = new Thread(payRunnable);
payThread.start();
}
示例8: doInBackground
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
@Override
protected String doInBackground(String... params) {
//在子线程中进行支付
final String aliPaySign = params[0];
final PayTask payTask = new PayTask(ACTIVITY);
return payTask.pay(aliPaySign,true);
}
示例9: make_sure_pay
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
@OnClick(R.id.make_sure_pay)
public void make_sure_pay() {
if (zhiFuBao.isChecked()) {
final String ss = s;
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask 对象
PayTask alipay = new PayTask(OnlinePayActivity.this);
// 调用支付接口,获取支付结果
String result = alipay.pay(ss, true);
Message msg = new Message();
msg.what = 1;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}
if (weiXin.isChecked()) {
}
}
示例10: recharge
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
private void recharge() {
// 订单
String orderInfo = getOrderInfo("iphone 7 plus 256G", "史上最强配置iphone", "0.01");
// 对订单做RSA签名
String sign = sign(orderInfo);
try {
// 仅需对sign做URL编码
sign = URLEncoder.encode(sign, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// 完整的符合支付宝参数规范的订单信息
final String payInfo = orderInfo + "&sign=\"" + sign + "\"&"
+ getSignType();
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask对象
PayTask alipay = new PayTask(ChongZhiActivity.this);
// 调用支付接口,获取支付结果
String result = alipay.pay(payInfo);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}
示例11: pay
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
@Override
public void pay(AlipayProduct product) {
String orderInfo = getPayOrderDetail(product);
String sign = sign(orderInfo);
try {
// 仅需对sign 做URL编码
sign = URLEncoder.encode(sign, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
final String payInfo = orderInfo + "&sign=\"" + sign + "\"&"
+ getSignType();
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask 对象
PayTask alipay = new PayTask(mContext);
// 调用支付接口
String result = alipay.pay(payInfo);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
Thread payThread = new Thread(payRunnable);
payThread.start();
}
示例12: pay
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
/**
* call alipay sdk pay. 调用SDK支付
*
*/
public void pay() {
// 订单
String orderInfo = getOrderInfo("测试的商品", "该测试商品的详细描述", price);
// 对订单做RSA 签名
String sign = sign(orderInfo);
try {
// 仅需对sign 做URL编码
sign = URLEncoder.encode(sign, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// 完整的符合支付宝参数规范的订单信息
final String payInfo = orderInfo + "&sign=\"" + sign + "\"&"
+ getSignType();
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask 对象
PayTask alipay = new PayTask(PayDemoActivity.this);
// 调用支付接口,获取支付结果
String result = alipay.pay(payInfo);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}
示例13: pay
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
/**
* call alipay sdk pay. 调用SDK支付
*/
public void pay(View v) {
if (TextUtils.isEmpty(PARTNER) || TextUtils.isEmpty(RSA_PRIVATE) || TextUtils.isEmpty(SELLER)) {
new AlertDialog.Builder(mContext).setTitle("警告").setMessage("需要配置PARTNER | RSA_PRIVATE| SELLER")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialoginterface, int i) {
}
}).show();
return;
}
String orderInfo = getOrderInfo("淘宝购物", "爆发了...", tvShopcartTotal.getText().toString().replace("¥", ""));//总价格
/**
* 特别注意,这里的签名逻辑需要放在服务端,切勿将私钥泄露在代码中!
*/
String sign = sign(orderInfo);
try {
/**
* 仅需对sign 做URL编码
*/
sign = URLEncoder.encode(sign, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
/**
* 完整的符合支付宝参数规范的订单信息
*/
final String payInfo = orderInfo + "&sign=\"" + sign + "\"&" + getSignType();
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask 对象
PayTask alipay = new PayTask((Activity) mContext);
// 调用支付接口,获取支付结果
String result = alipay.pay(payInfo, true);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}
示例14: pay
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
/**
* call alipay sdk pay. 调用SDK支付
*/
public void pay(View v) {
if (TextUtils.isEmpty(PARTNER) || TextUtils.isEmpty(RSA_PRIVATE) || TextUtils.isEmpty(SELLER)) {
new AlertDialog.Builder(this).setTitle("警告").setMessage("需要配置PARTNER | RSA_PRIVATE| SELLER")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialoginterface, int i) {
//
finish();
}
}).show();
return;
}
String orderInfo = getOrderInfo("测试的商品", "该测试商品的详细描述", "0.01");
/**
* 特别注意,这里的签名逻辑需要放在服务端,切勿将私钥泄露在代码中!
*/
String sign = sign(orderInfo);
try {
/**
* 仅需对sign 做URL编码
*/
KLog.i("-----lin----->" + "b6iAKFz2Vup0iG8Q7tIfzfWqcMNJ2qtTs6WGR7BmWRilPFS9w7WOOYoLpjTZU8Ag6FyqiwcIL4OLZoWYUbbqo9koNFBCZqCL3u8XxHEOr9DzmMmIHPIgviN7aMsn/bsP7B+oRoaltZ/cK1Dc2ddlSlHX+RyrovXUvDhEEG6Gl3g=");
String a = URLEncoder.encode("b6iAKFz2Vup0iG8Q7tIfzfWqcMNJ2qtTs6WGR7BmWRilPFS9w7WOOYoLpjTZU8Ag6FyqiwcIL4OLZoWYUbbqo9koNFBCZqCL3u8XxHEOr9DzmMmIHPIgviN7aMsn/bsP7B+oRoaltZ/cK1Dc2ddlSlHX+RyrovXUvDhEEG6Gl3g=", "UTF-8");
KLog.i("-----lin----->" + a);
sign = URLEncoder.encode(sign, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
/**
* 完整的符合支付宝参数规范的订单信息
*/
// String orderInfo2 = "partner=\"2088421466656510\"&seller_id=\"[email protected]\"&out_trade_no=\"080413075973389\"&subject=\"测试的商品\"&body=\"该测试商品的详细描述\"&total_fee=\"0.01\"¬ify_url=\"http://notify.msp.hk/notify.htm\"&service=\"mobile.securitypay.pay\"&payment_type=\"1\"&_input_charset=\"utf-8\"&it_b_pay=\"30m\"&return_url=\"m.alipay.com";
// String sign2 = "cqEUd2PXWQn%2BpSRN4cqScP2rP9xKF4LQbz5rbyo4gjAZzJ1IoPggpWM7vL2fcMeEB0AjIStJCtrV1f8U0CDeTDjHcakN4F%2BFpBCcSo%2Fz6odeHdhog%2F6N5sbpwq5I7RZvt%2F7oXcmZc9m4a17m0XzXpp8ZA2mYLAjAQp5pFGYFnOc%3D";
// String type = "sign_type=\"RSA";
Intent intent = getIntent();
//intent.getExtras().getString("payId");
final String payInfo = intent.getExtras().getString("payId");
// "partner=\"2088421466656510\"&seller_id=\"[email protected]\"&out_trade_no=\"133\"&subject=\"篮球\"&body=\"篮球\"&total_fee=\"80\"¬ify_url=\"http://139.129.221.22:8080/lxms-user/alipay/notify\"&service=\"mobile.securitypay.pay\"&payment_type=\"1\"&_input_charset=\"utf-8\"&it_b_pay=\"30m\"&show_url=\"m.alipay.com\"&sign=\"b6iAKFz2Vup0iG8Q7tIfzfWqcMNJ2qtTs6WGR7BmWRilPFS9w7WOOYoLpjTZU8Ag6FyqiwcIL4OLZoWYUbbqo9koNFBCZqCL3u8XxHEOr9DzmMmIHPIgviN7aMsn%2FbsP7B%2BoRoaltZ%2FcK1Dc2ddlSlHX%2BRyrovXUvDhEEG6Gl3g%3D\"&sign_type=\"RSA\"";
// //orderInfo + "&sign=\"" + sign + "\"&" + "sign_type=\"RSA\"";
// KLog.d("-----lin----> orderInfo: " + payInfo);
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask 对象
PayTask alipay = new PayTask(PayDemoActivity.this);
// 调用支付接口,获取支付结果
String result = alipay.pay(payInfo, true);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}
示例15: pay
import com.alipay.sdk.app.PayTask; //导入方法依赖的package包/类
@Override
public void pay() {
Runnable payRunnable = new Runnable() {
@Override
public void run() {
String payInfo = MAliPayInfoUtil.getPayInfo((MPayAliModel) mPayModel);
PayTask aliPay = new PayTask((Activity) context);
final String result = aliPay.pay(payInfo, true);
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
PayResult payResult = new PayResult(result);
String resultInfo = payResult.getResult();// 支付宝返回此次支付结果及加签,建议对支付宝签名信息拿签约时支付宝提供的公钥做验签
String resultStatus = payResult.getResultStatus();
Log.e(TAG, "a li pay error:");
Log.e(TAG, resultStatus + "==" + resultInfo);
if (TextUtils.equals(resultStatus, "9000")) { // 判断resultStatus 为“9000”则代表支付成功,具体状态码代表含义可参考接口文档
// Toast.makeText(context, "支付成功", Toast.LENGTH_SHORT).show();
if (mPayListener != null) {
mPayListener.onSuccess(resultInfo);
}
} else {
// 判断resultStatus 为非“9000”则代表可能支付失败
// “8000”代表支付结果因为支付渠道原因或者系统原因还在等待支付结果确认,最终交易是否成功以服务端异步通知为准(小概率状态)
if (TextUtils.equals(resultStatus, "8000")) {
// Toast.makeText(context, "支付结果确认中", Toast.LENGTH_SHORT).show();
if (mPayListener != null) {
mPayListener.onConfirm(resultInfo);
}
} else {
// 其他值就可以判断为支付失败,包括用户主动取消支付,或者系统返回的错误
// Toast.makeText(context, "支付失败", Toast.LENGTH_SHORT).show();
if (mPayListener != null) {
mPayListener.onFailure(resultInfo);
}
}
}
if (mPayListener != null) {
mPayListener.onFinish(resultInfo);
}
}
});
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}