微信支付宝支付订单撤销交易查询案例

 /**
  * 支付宝撤销交易
  * 已经成功
  * @param
  * @return
  */
 private void outAliapyTradeCancel() {
  Debug.v("outAliapyTradeCance ", "支付宝撤销");
  new Thread(new Runnable() {
   @Override
   public void run() {
    // TODO Auto-generated method stub
    AlipayClient alipayClient = new DefaultAlipayClient(AlipayUtils.openapi, AlipayUtils.appid,
      AlipayUtils.private_key, "json", "GBK", AlipayUtils.public_key, "RSA2");
    AlipayTradeCancelRequest request = new AlipayTradeCancelRequest();
    request.putOtherTextParam("app_auth_token", "###################");
    request.setBizContent("{" +
    // "\"out_trade_no\":\"" + outTradeNo + "\"," +
    "\"trade_no\":\"" + tradeNo + "\"" + " }");
    AlipayTradeCancelResponse response;
    try {
     response = alipayClient.execute(request);
     Debug.v("getMsg", response.getMsg());
     Debug.v("code", response.getCode());
     if (response.isSuccess()) {
      Debug.v("撤销成功");
      Looper.prepare();
      ToastUtil.toast("支付宝撤销成功", Toast.LENGTH_LONG);
      preferences = getSharedPreferences("TransferMsgActivity", Context.MODE_PRIVATE);
      if (preferences.getInt("transFerMsg_cancel", 1) == 1) {
       Debug.v("preferences", preferences.getInt("transFerMsg_cancel", 1) + "");
       preferences = getSharedPreferences("AliapyStatusActivity", Context.MODE_PRIVATE);
       new Thread(new Runnable() {
        @Override
        public void run() {
         // TODO Auto-generated method stub
         info = alipayTradeQuery(tradeNo);
         Debug.v("INFO===", info);
         if ("SUCCESS".equals(info)) {
          Debug.v("INFO===", info);
          final Bundle mBundle = new Bundle();
          Debug.v("alipayTradeQuery    tradeNo", tradeNo);
          mBundle.putString("OrderID", alipayOutTradeNo);
          mBundle.putString("PayType", "Z");
          mBundle.putString("CardID", null);
          Debug.v("price ==", preferences.getString("totalAmount", ""));
          mBundle.putString("Price", alipayTotalAmount);
          Debug.v("alipay   MachineID", TransParams.getMachineID());
          mBundle.putString("MachineID", TransParams.getMachineID());
          mBundle.putString("PayTime", TransParams.getDate());
          mBundle.putString("UserName", null);
          mBundle.putString("VerifyCode",
            TransParams.getVerifyCode(alipayOutTradeNo, TransParams.getDate()));
          mBundle.putString("IsBack", "Y");
          Map<String, Object> params = TransParams.transFerParams(mBundle);
          String result = HttpUtilsGet.doGet(apiurl, params);
          Debug.v("支付宝撤销信息回传");
          Debug.v("result==", result);
         }
        }
       }).start();
      } else {
       Debug.v("preferences  AliapyTradeCancel ", "is not  1");
      }
      Looper.loop();
     } else {
      Debug.v("撤销失败");
      Looper.prepare();
      ToastUtil.toast("支付宝撤销失败", Toast.LENGTH_LONG);
      Looper.loop();
     }
    } catch (AlipayApiException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
   }
  }).start();
 }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值