@Test public void testReqRevertBillAsyncSucc() throws Exception { BCHttpClientUtil.Response response = new BCHttpClientUtil.Response(); response.code = 200; response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"Success\",\"result_code\":0,\"revert_status\":true}"; PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpPost", String.class, Map.class)).toReturn(response); pay.reqRevertBillAsync(BCReqParams.BCChannelTypes.ALI_OFFLINE_QRCODE, "fakebillnum", new BCCallback() { @Override public void done(BCResult result) { Assert.assertTrue(result instanceof BCRevertStatus); BCRevertStatus revertStatus = (BCRevertStatus) result; Assert.assertEquals((Integer)0, revertStatus.getResultCode()); Assert.assertTrue(revertStatus.getRevertStatus()); latch.countDown(); } }); latch.await(2000, TimeUnit.MILLISECONDS); }
public void reqRevertBillAsync(final BCReqParams.BCChannelTypes channelType, final String billNum, final BCCallback callback) { if (callback == null) { Log.w(TAG, "请初始化callback"); return; } BCCache.executorService.execute(new Runnable() { @Override public void run() { if (BCCache.getInstance().isTestMode) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "该功能暂不支持测试模式")); return; } BCReqParams parameters; try { parameters = new BCReqParams(channelType); } catch (BCException e) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, e.getMessage())); return; } if (billNum == null || billNum.length() == 0) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "invalid bill number")); return; } String revertURL = BCHttpClientUtil.getBillOfflinePayURL() + "/" + billNum; Map<String, Object> reqMap = parameters.transToReqMapParams(); reqMap.put("method", "REVERT"); BCHttpClientUtil.Response response = BCHttpClientUtil .httpPost(revertURL, reqMap); if (response.code == 200 || (response.code >= 400 && response.code < 500)) { callback.done(BCRevertStatus.transJsonToObject(response.content)); } else { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "Network Error:" + response.code + " # " + response.content)); } } }); }
BCOfflinePay { public void reqRevertBillAsync(final BCReqParams.BCChannelTypes channelType, final String billNum, final BCCallback callback) { if (callback == null) { Log.w(TAG, "请初始化callback"); return; } BCCache.executorService.execute(new Runnable() { @Override public void run() { if (BCCache.getInstance().isTestMode) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "该功能暂不支持测试模式")); return; } BCReqParams parameters; try { parameters = new BCReqParams(channelType); } catch (BCException e) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, e.getMessage())); return; } if (billNum == null || billNum.length() == 0) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "invalid bill number")); return; } String revertURL = BCHttpClientUtil.getBillOfflinePayURL() + "/" + billNum; Map<String, Object> reqMap = parameters.transToReqMapParams(); reqMap.put("method", "REVERT"); BCHttpClientUtil.Response response = BCHttpClientUtil .httpPost(revertURL, reqMap); if (response.code == 200 || (response.code >= 400 && response.code < 500)) { callback.done(BCRevertStatus.transJsonToObject(response.content)); } else { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "Network Error:" + response.code + " # " + response.content)); } } }); } }
BCOfflinePay { public void reqRevertBillAsync(final BCReqParams.BCChannelTypes channelType, final String billNum, final BCCallback callback) { if (callback == null) { Log.w(TAG, "请初始化callback"); return; } BCCache.executorService.execute(new Runnable() { @Override public void run() { if (BCCache.getInstance().isTestMode) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "该功能暂不支持测试模式")); return; } BCReqParams parameters; try { parameters = new BCReqParams(channelType); } catch (BCException e) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, e.getMessage())); return; } if (billNum == null || billNum.length() == 0) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "invalid bill number")); return; } String revertURL = BCHttpClientUtil.getBillOfflinePayURL() + "/" + billNum; Map<String, Object> reqMap = parameters.transToReqMapParams(); reqMap.put("method", "REVERT"); BCHttpClientUtil.Response response = BCHttpClientUtil .httpPost(revertURL, reqMap); if (response.code == 200 || (response.code >= 400 && response.code < 500)) { callback.done(BCRevertStatus.transJsonToObject(response.content)); } else { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "Network Error:" + response.code + " # " + response.content)); } } }); } private  BCOfflinePay(); }
BCOfflinePay { public void reqRevertBillAsync(final BCReqParams.BCChannelTypes channelType, final String billNum, final BCCallback callback) { if (callback == null) { Log.w(TAG, "请初始化callback"); return; } BCCache.executorService.execute(new Runnable() { @Override public void run() { if (BCCache.getInstance().isTestMode) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "该功能暂不支持测试模式")); return; } BCReqParams parameters; try { parameters = new BCReqParams(channelType); } catch (BCException e) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, e.getMessage())); return; } if (billNum == null || billNum.length() == 0) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "invalid bill number")); return; } String revertURL = BCHttpClientUtil.getBillOfflinePayURL() + "/" + billNum; Map<String, Object> reqMap = parameters.transToReqMapParams(); reqMap.put("method", "REVERT"); BCHttpClientUtil.Response response = BCHttpClientUtil .httpPost(revertURL, reqMap); if (response.code == 200 || (response.code >= 400 && response.code < 500)) { callback.done(BCRevertStatus.transJsonToObject(response.content)); } else { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "Network Error:" + response.code + " # " + response.content)); } } }); } private  BCOfflinePay(); synchronized static BCOfflinePay getInstance(); static Bitmap generateBitmap(String contentsToEncode,
                                        int imageWidth, int imageHeight,
                                        int marginSize, int color, int colorBack); void reqQRCodeAsync(final BCReqParams.BCChannelTypes channelType,
                               final String billTitle, final Integer billTotalFee,
                               final String billNum, final Map<String, String> optional,
                               final Boolean genQRCode, final Integer qrCodeWidth,
                               final BCCallback callback); void reqQRCodeAsync(final PayParams payParam,
                               final BCCallback callback); void reqOfflinePayAsync(final BCReqParams.BCChannelTypes channelType,
                                   final String billTitle, final Integer billTotalFee,
                                   final String billNum, final Map<String, String> optional,
                                   final String authCode, final String terminalId,
                                   final String storeId, final BCCallback callback); void reqOfflinePayAsync(final PayParams payParam, final BCCallback callback); void reqWXNativeQRCodeAsync(final String billTitle, final Integer billTotalFee,
                                       final String billNum, final Map<String, String> optional,
                                       final Boolean genQRCode, final Integer qrCodeWidth,
                                       final BCCallback callback); void reqAliOfflineQRCodeAsync(final String billTitle, final Integer billTotalFee,
                                         final String billNum, final Map<String, String> optional,
                                         final Boolean genQRCode, final Integer qrCodeWidth,
                                         final BCCallback callback); void reqRevertBillAsync(final BCReqParams.BCChannelTypes channelType,
                                   final String billNum,
                                   final BCCallback callback); }
BCOfflinePay { public void reqRevertBillAsync(final BCReqParams.BCChannelTypes channelType, final String billNum, final BCCallback callback) { if (callback == null) { Log.w(TAG, "请初始化callback"); return; } BCCache.executorService.execute(new Runnable() { @Override public void run() { if (BCCache.getInstance().isTestMode) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "该功能暂不支持测试模式")); return; } BCReqParams parameters; try { parameters = new BCReqParams(channelType); } catch (BCException e) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, e.getMessage())); return; } if (billNum == null || billNum.length() == 0) { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "invalid bill number")); return; } String revertURL = BCHttpClientUtil.getBillOfflinePayURL() + "/" + billNum; Map<String, Object> reqMap = parameters.transToReqMapParams(); reqMap.put("method", "REVERT"); BCHttpClientUtil.Response response = BCHttpClientUtil .httpPost(revertURL, reqMap); if (response.code == 200 || (response.code >= 400 && response.code < 500)) { callback.done(BCRevertStatus.transJsonToObject(response.content)); } else { callback.done(new BCRevertStatus(BCRestfulCommonResult.APP_INNER_FAIL_NUM, BCRestfulCommonResult.APP_INNER_FAIL, "Network Error:" + response.code + " # " + response.content)); } } }); } private  BCOfflinePay(); synchronized static BCOfflinePay getInstance(); static Bitmap generateBitmap(String contentsToEncode,
                                        int imageWidth, int imageHeight,
                                        int marginSize, int color, int colorBack); void reqQRCodeAsync(final BCReqParams.BCChannelTypes channelType,
                               final String billTitle, final Integer billTotalFee,
                               final String billNum, final Map<String, String> optional,
                               final Boolean genQRCode, final Integer qrCodeWidth,
                               final BCCallback callback); void reqQRCodeAsync(final PayParams payParam,
                               final BCCallback callback); void reqOfflinePayAsync(final BCReqParams.BCChannelTypes channelType,
                                   final String billTitle, final Integer billTotalFee,
                                   final String billNum, final Map<String, String> optional,
                                   final String authCode, final String terminalId,
                                   final String storeId, final BCCallback callback); void reqOfflinePayAsync(final PayParams payParam, final BCCallback callback); void reqWXNativeQRCodeAsync(final String billTitle, final Integer billTotalFee,
                                       final String billNum, final Map<String, String> optional,
                                       final Boolean genQRCode, final Integer qrCodeWidth,
                                       final BCCallback callback); void reqAliOfflineQRCodeAsync(final String billTitle, final Integer billTotalFee,
                                         final String billNum, final Map<String, String> optional,
                                         final Boolean genQRCode, final Integer qrCodeWidth,
                                         final BCCallback callback); void reqRevertBillAsync(final BCReqParams.BCChannelTypes channelType,
                                   final String billNum,
                                   final BCCallback callback);  }