The Alipay solution for the mall transfer to the seller's account: Alipay single transfer

    Recently, I was working on an e-commerce project. When I first took over the project, I found a lot of problems. Take the transfer as an example. There is no direct transfer to the merchant account in the background. It needs to be transferred to the bank counter. I feel that this design is too failed, not to mention tens of thousands For human use, there are thousands of people, and there are more than 300 people who need to deal with the accounts every day. Transferring one by one, it feels incredible. After improvement, due to the relatively high cost of direct connection with the bank, we decided to use Alipay's single transfer function.

Needless to say about Alipay's collection, the official documents are more detailed:


Let's talk about how to integrate it into the backend of the mall, pass the review button one by one, and transfer it directly to the other party's account. Saved a lot of trouble.

In the audited button control code, add the following code and get the corresponding value:

 AlipayConfig.appid //Alipay APPID;

// Alipay's public key, no need to modify the value
AlipayConfig. public_key:

// Merchant's private key

AlipayConfig.private_key:

Initialization: AlipayClient 
AlipayFundTransToaccountTransferRequest transfer api	

AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.serverUrl, AlipayConfig.app_id,
						AlipayConfig.private_key, "JSON", "utf-8", AlipayConfig.public_key);
			
				AlipayFundTransToaccountTransferRequest request1 = new AlipayFundTransToaccountTransferRequest();
	JsonObject object=new JsonObject();
				object.addProperty("out_biz_no", withdrawId+DateUtils.currentDatetime());
				object.addProperty("payee_type", "ALIPAY_LOGONID");
				object.addProperty("payee_account", "账户");
				object.addProperty("amount", 0.1);
				object.addProperty("payer_show_name", "Name of transfer company");
				object.addProperty("payee_real_name", "实名");
				object.addProperty("remark", "");
				request1.setBizContent(object.toString());	
			   AlipayFundTransToaccountTransferResponse response = alipayClient.execute(request1);
			  String string = response.getBody().toString();
				if(response.isSuccess()){
					
				System.out.println("Call succeeded");
				} else {
				System.out.println("Call failed"+string);
				formMap.put("withdraw_id", withdrawId);
				formMap.put("examine_state", 3);
				formMap.put("examine_season", examineSeason);
				formMap.put("update_time", DateUtils.currentDatetime());
				formMap.put("update_person", Common.findUserSessionId());
				formMap.update();
				returnMoney(withdrawId); //Refund to wallet
			}

It should be noted here that if the real name and Alipay account are inconsistent, 40004 will appear:

If 40006 appears, you do not have permission to apply for a single transfer:

As shown below: Apply for a contract






Guess you like

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