|
|
@@ -350,6 +350,30 @@ class AlipayBatchPayServiceTest {
|
|
|
assertEquals("SHORT_URL", model.getInitializeCodeType());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ void renderPay_alipayBusinessError_throwsAndNotPersists() throws AlipayApiException {
|
|
|
+ // 支付宝业务失败时 pageExecute 返回错误 JSON body(非 HTML 表单)——
|
|
|
+ // 必须 isSuccess 校验后抛错,否则错误 JSON 会被当 pay_url 返回、前端 document.write 出整页 JSON(用户实测路径)
|
|
|
+ BatchOrderEntity order = new BatchOrderEntity();
|
|
|
+ order.setEnterpriseId("E100");
|
|
|
+ order.setOutBatchNo("B1");
|
|
|
+ order.setBatchTransId("BT1");
|
|
|
+ order.setStatus("INIT");
|
|
|
+ when(batchOrderMapper.selectOne(any())).thenReturn(order);
|
|
|
+ AlipayFundTransRenderPayResponse resp = new AlipayFundTransRenderPayResponse();
|
|
|
+ resp.setCode("40004");
|
|
|
+ resp.setSubCode("INVALID_PARAMETER");
|
|
|
+ resp.setSubMsg("参数[target_terminal_type]错误, 原因: 必须传入参数[target_terminal_type]");
|
|
|
+ resp.setBody("{\"alipay_fund_trans_render_pay_response\":{\"code\":\"40004\"}}");
|
|
|
+ when(alipayClient.pageExecute(any(AlipayFundTransRenderPayRequest.class))).thenReturn(resp);
|
|
|
+
|
|
|
+ BusinessException ex = assertThrows(BusinessException.class, () -> service.renderPay("E100", "B1"));
|
|
|
+
|
|
|
+ assertEquals(400, ex.getCode());
|
|
|
+ assertTrue(ex.getMessage().contains("INVALID_PARAMETER"), ex.getMessage());
|
|
|
+ verify(batchOrderMapper, never()).updateById(any());
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
void batchQuery_syncsBatchStatus() throws AlipayApiException {
|
|
|
BatchOrderEntity order = new BatchOrderEntity();
|