wechatpay-java icon indicating copy to clipboard operation
wechatpay-java copied to clipboard

微信支付运营工具的商家转账接口已修改,啥时候跟新版本

Open chengyanchun opened this issue 9 months ago • 5 comments

您的功能请求与问题有关吗? 请描述您遇到的问题

微信支付运营工具的商家转账接口已修改,啥时候跟新版本

描述您想要的解决方案

和原来的差不多,希望能快速更新迭代

您还有其他的方案吗?

No response

其他信息

No response

chengyanchun avatar Mar 26 '25 08:03 chengyanchun

+1

liangjiangliang avatar Mar 28 '25 02:03 liangjiangliang

我马上要用了,再没人提供,我就要忍不住申请加入贡献者,去填补这段代码了

chengyanchun avatar Mar 28 '25 06:03 chengyanchun

还没更新啊,前面调通了,这上线发现用不了

yorke669 avatar Apr 18 '25 05:04 yorke669

可以参考我的

import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.cipher.PrivacyDecryptor;
import com.wechat.pay.java.core.cipher.PrivacyEncryptor;
import com.wechat.pay.java.core.http.*;
import com.wechat.pay.java.core.util.GsonUtil;

import java.util.Objects;

/**
 * Author: dengmin
 * Email: [email protected]
 * CreateTime: 2025/2/25 18:11
 */
public class TransferBillService {

    private final HttpClient httpClient;
    private final HostName hostName;
    private final PrivacyEncryptor encryptor;
    private final PrivacyDecryptor decryptor;

    private TransferBillService(HttpClient httpClient, HostName hostName, PrivacyEncryptor encryptor, PrivacyDecryptor decryptor) {
        this.httpClient = Objects.requireNonNull(httpClient);
        this.hostName = hostName;
        this.encryptor = Objects.requireNonNull(encryptor);
        this.decryptor = Objects.requireNonNull(decryptor);
    }


    public TransferBillResponse batchTransfer(TransferBillRequest request) {
        String requestPath = "https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/transfer-bills";
        if (this.hostName != null) {
            requestPath = requestPath.replaceFirst(HostName.API.getValue(), this.hostName.getValue());
        }

        HttpHeaders headers = new HttpHeaders();
        headers.addHeader("Accept", MediaType.APPLICATION_JSON.getValue());
        headers.addHeader("Content-Type", MediaType.APPLICATION_JSON.getValue());
        headers.addHeader("Wechatpay-Serial", this.encryptor.getWechatpaySerial());
        HttpRequest httpRequest = (new HttpRequest.Builder())
                .httpMethod(HttpMethod.POST)
                .url(requestPath)
                .headers(headers)
                .body(this.createRequestBody(request))
                .build();
        HttpResponse<TransferBillResponse> httpResponse = this.httpClient.execute(httpRequest, TransferBillResponse.class);
        return httpResponse.getServiceResponse();
    }


    private RequestBody createRequestBody(Object request) {
        return (new JsonRequestBody.Builder()).body(GsonUtil.toJson(request)).build();
    }

    public static class Builder {
        private HttpClient httpClient;
        private HostName hostName;
        private PrivacyEncryptor encryptor;
        private PrivacyDecryptor decryptor;

        public Builder() {
        }
        public Builder config(Config config) {
            this.httpClient = (new DefaultHttpClientBuilder()).config(config).build();
            this.encryptor = config.createEncryptor();
            this.decryptor = config.createDecryptor();
            return this;
        }

        public Builder hostName(HostName hostName) {
            this.hostName = hostName;
            return this;
        }

        public Builder httpClient(HttpClient httpClient) {
            this.httpClient = httpClient;
            return this;
        }

        public Builder encryptor(PrivacyEncryptor encryptor) {
            this.encryptor = encryptor;
            return this;
        }

        public Builder decryptor(PrivacyDecryptor decryptor) {
            this.decryptor = decryptor;
            return this;
        }

        public TransferBillService build() {
            return new TransferBillService(this.httpClient, this.hostName, this.encryptor, this.decryptor);
        }
    }

}

import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * Author: dengmin
 * Email: [email protected]
 * CreateTime: 2025/2/25 18:15
 */
@Setter
@Getter
@NoArgsConstructor
public class TransferBillRequest {
    @SerializedName("appid")
    private String appid;

    @SerializedName("out_bill_no")
    private String outBillNo;

    @SerializedName("openid")
    private String openid;

    @SerializedName("transfer_scene_id")
    private String transferSceneId;

    @SerializedName("user_name")
    private String username;

    @SerializedName("transfer_amount")
    private Integer transferAmount;

    @SerializedName("transfer_remark")
    private String transferRemark;

    private String notifyUrl;

    @SerializedName("user_recv_perception")
    private String userRecvPerception;

    @SerializedName("transfer_scene_report_infos")
    private List<TransferSceneReportInfo> transferSceneReportInfos = new ArrayList<>();

}
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * Author: dengmin
 * Email: [email protected]
 * CreateTime: 2025/2/25 18:19
 */
@Setter
@Getter
@NoArgsConstructor
public class TransferSceneReportInfo {
    @SerializedName("info_type")
    private String infoType;
    @SerializedName("info_content")
    private String infoContent;
}

dengmin avatar Apr 24 '25 06:04 dengmin

还没更新。。。

mxdwjcty avatar May 08 '25 02:05 mxdwjcty