Javaアリペイウィジェットテンプレートメッセージの送信


本文は主にJava支付宝小プログラムがテンプレートメッセージを送信することを実現する.
       /**
 *         
 * @author Mark
 * @param userid
 * @param fromId
 * @param price
 * @param amount
 * @param remake
 * @return
 */
public static String Alipaysuccessmessage(String userid, String fromId, double price, double amount,
        String remake) {
    AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
            "     APPID", "       ", "json",
            "GBK", "     ", "RSA2");
    AlipayOpenAppMiniTemplatemessageSendRequest request = new AlipayOpenAppMiniTemplatemessageSendRequest();
    request.setBizContent("{" + "\"to_user_id\":\"" + userid + "\"," + "\"form_id\":\"" + fromId + "\","
            + "\"user_template_id\":\"    ID\","
            + "\"page\":\"           \"," + "\"data\":\"{\\\"keyword1\\\":{\\\"value\\\":\\\"" + price
            + "\\\"},\\\"keyword2\\\":{\\\"value\\\":\\\"" + amount + "\\\"},\\\"keyword3\\\":{\\\"value\\\":\\\""
            + remake + "\\\"},\\\"keyword4\\\":{\\\"value\\\":\\\"          \\\"}}\"" + "}");
    AlipayOpenAppMiniTemplatemessageSendResponse response = null;
    try {
        response = alipayClient.execute(request);
    } catch (AlipayApiException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (response.isSuccess()) {
        return "Success";
    } else {
        return "Fail";
    }
}