メインコンテンツまでスキップ

Cancel order

POST 

/api/entry/void

When a payment order does not return successfully or the payment system times out, this API is called to cancel the transaction. Once revoked, successful orders will be refunded, and failed orders will be closed.

  1. This API can be used to cancel a transaction within 1 day after the order is created, while the [Submit Refund Request] API should be used to cancel a successfully paid transaction. After submitting a cancellation request, you need to call the [Query Order] API. If there is no clear result, you should call the [Cancel Order] API again.
  2. Please note that the [Cancel Order] API should be called at least 15 seconds after the order is created.
  3. Before using this API, please consult with your technical team regarding the specific cancellation rules. WeChatPay only supports canceling paid orders for "Scan Payment - Customer Presentation Mode". For other products, only unpaid orders can be canceled. For paid orders, you should call the [Submit Refund Request] API.
Here is a Java code example
// Set application parameters and keys
private static final String APP_RSA_PRIVATE_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCMPiTuC1xHkCUu/TospfJ7IldcnqYWaB4L287ADssc91NJ0NHP9AXvepTee1StWxRVamcyH3yWRJSnsbTWRqE+tQWDZ21Rhg5AQ8KWZ9RpSK+f07eX1K0rMUl3xUouvJgWzWvHZlUoIqXBx76nU7upFo5CoKmnyXYrZ0K2hjM9+7cRXff4+LJ7Js7d8eFgMWKEm0IN+h4SMeRCuU5DgIXf4W0sUZuyFXiDuIbID1kArp9JnO5woSY/OYCM3PjesaXMLHunLR2hTj4yAYg2WVT85tsWCT+B3rBDhpuNgZhRrPn9cgzaHfXCfZrpX9B5uSleuFbUFCz+e7ZqSmQ0O5PJAgMBAAECggEAMy2KdIQYzNTBfQBT9m8oqd7CWr5ahdrA/DrenB/J52wqLMnThzvZ3qaxJO+E2y5doT4PIq9y27NzPC8RexCTTzroJCfeMN3m3XTc0d5aGYG49W5hlTq7ZwO5d8e7ZorURZ35Mu8ZLGhYbPrjjFR2KyJcD9xpjR1rzjMEmW8ny/o+z1nMMdt77bLddHVwVWqEMxuyy8DRIRcLU6yqQdrio+y6nt0fYjA5lKhiAhgcjehmNFAppeLGa0bZyUGnUsXEhHpfyvbGwVqh4m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PM8eRI5W19ssCyfdtNFy6DRAureoYV053ETPUefEA5bHDOQnjbb9PuNEfT651v8cqwEaTptaxj2zujsWI8Ad3R50EyQHsskQWms/gv2aB36XUM4vyOIk4P1f3dxtqigH0YROEYiuwFFqsyJuNSjJzNbCmfgqlQv/+pE/pOV9MIQe0CAdD26JF10QpSssEwKgvKvnXPUynVu09cjSEipev5cLJSApKSDZxrRjSFBXrh6nzg8JK05ehkI8wdsryRUneh0PGN0PgYLP/wjKiqlgTJaItxnb/JQIDAQAB";
private static final String APP_ID = "wz715fc0d10ee9d156";

private static final String GATEWAY_URL = "https://open.n-age.co.jp";

// Instantiate a client
OpenApiClient openapiClient = new OpenApiClient(APP_ID, GATEWAY_URL, APP_RSA_PRIVATE_KEY, GATEWAY_RSA_PUBLIC_KEY);

// Build a request object, set parameters
OrderRevokerRequest request = new OrderRevokerRequest();
request.setMerchant_no("312100007235");
request.setMerchant_order_no("TEST_1735885114292");

OrderRevokerResponse response;
try {
// Execute the request
response = openapiClient.execute(request);
} catch (OpenApiException e) {
// Handle network exceptions ......
// @TODO
System.err.println("\nrequest api error:" + e.getErrCode() + "->>" + e.getErrMsg());
return;
}
if (!response.isSuccess()) {
// Handle business exceptions ......
// @TODO
System.err.println("\napi execute error: " + JSON.toJSONString(response));
}

// Write your business code based on the API response ......
// @TODO

Request

Responses

Response Headers