Use the Alipay order number to query the detailed record of the transfer

A few days ago, I saw that there is a function on a website that is to give a QR code, and then someone else can transfer the money to Alipay to realize the function of recharging. Later, I flipped through the information and sorted it out.

 1. Log in to the Ant Financial Open Platform    https://docs.open.alipay.com/

 2. Open the Developer Center - "Web & Mobile Application" as shown below

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3. Click the payment access function in the create app as shown below

2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4. There are two input usage scenarios: one is a third-party application, and the other is a self-use application. You can choose the self-use type. The name of the application, the longest can not exceed 32 characters, there is a prompt not to take screenshots, click the create button after entering

5. Next, follow the instructions to set the parameters. The most important thing is the interface signing method. It can be done easily according to the above tips, but pay attention to one thing: here he requires SHAwithRSA2048, so which signType in the following code must be used RSA2.

6. The following is my test code. The APP_ID is as shown in the figure below. The private_key is the generated key that was just downloaded. A file rsa_private_key_pkcs8.pem is generated under the tool to copy the middle section. The public_key is the key we uploaded to Alipay.

 

 

  

private static void test() throws AlipayApiException {
		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", "APP_ID",
				private_key, "json", "GBK", public_key, "RSA2");
		AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
		request.setBizContent("{" + "\"trade_no\":\"The order number to be queried\"" + "}");
		AlipayTradeQueryResponse response = alipayClient.execute(request);
		if (response.isSuccess()) {
			System.out.println("Call succeeded");
		} else {
			System.out.println("Call failed");
		}
	}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326069324&siteId=291194637