codeExample

  • Collection orders support fiat currency and digital currency (USDT/BTC/ETH/TRX) transactions
  • If you want to use digital currency transactions, please set orderType=1;
  • Distinguish between transactions of different users through merchant user ID
  • Our digital collection orders are divided into two modes: order mode and no-order mode
  • Ex: cashier version (v1.0 and v3.0 are order mode versions; v2.0 and v4.0 are no-order mode)
  • Ex: v1.0, v2.0 - only display payment address
  • Ex: v3.0, v4.0 - display both QR code and payment address
  • You need to tell us which digital currency and chain network you want to use for transactions (TRC20/BEP20/OMNI/ERC20/TRX)
  • We will launch transactions with other currencies and networks in the future, so stay tuned

# codeExample

  • Code examples are for reference only

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import cn.hutool.json.JSONUtil;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.Map;
import java.util.TreeMap;

public class TopDigitPayDemo {
  // testAccount
  private static final String MCH_NO = "PHOT000012";  // merchantNumber
  private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+JRdCIE0UDBctS6LjXxWLEv/EO7jDBTid6zYP1KmNgpd2DAWWtBFBSQ+gcNwVZZSBHJiSDqVvvJVs2FEbeBvfdv4X93+IYRAXksBasSW5Tpdshbo82pVL4V7wuKCuFLk9UxBHbpQjWAbfyF66RmwIbZD71AgMBAAECgYBjPe7UU2nDDSfmQg0++CyjNjqKRC5QPfxhH6w1uF1kMueXKJWOj42n2RutJpJmsj31nY8m0u4xpsG4HvCu/GGSFhhKZCHLvzp41oY2ubYj9nuFNU//81LycQjulWo2y0UUBY0k2piEt+SwPaiUNbT6nMxNMjlnjRe2okp/3rw+KQJBANG3YlZWoVbCEqzy64bJJLxiPsCA5ErGB0NzRGitq44xkhqGtR8ZZQyVz40pruNa58d73O2xyJSy5+fmZGn4E+sCQQC2LBnguj0CSCKub0mPDcunTTz9V79VXBBZdlB1/YGmRUx2s4sQrJNZS7rL4EqBQ3maIRnG+s+AXCSTfsYrV6CfAkEAxugnVfpelhoGepEAgNuggyivmgfl/2Gpm/jk5l/qOjib+ZrQiQmeBPzGWX4yiSM8eMDrP2sC8r5pJFMp5DRONwJBAJ4n4XuSFJ9jgwCPy3vvzSv9SYLk6E6yM9uHdUlKgoGYzk6Lh6M9QFuY/J49plFdBDiEnj16yCU3WeXXfTJpzB8CQQDMNMR/rIOTE9xGybS3mlQbt22AUnO6XhupWcckEKW4nPGxATwYBQzCY3i/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp";  // merchantPrivateKey
  private static final String payUrl = "https://ph-openapi.toppayment.com/crypto/pay/prePay";
  private static final String payNotify = "your notify url";
  private static final String cashNotify = "your notify url";

  public static void main(String[] args) throws Exception {
    // collection
      pay("USDT", "50.01", payUrl, MCH_NO, MCH_PRIVATE_KEY);
  }
    public static void pay(String method,String amount, String url, String mchNo, String privateKey) throws Exception {
        Map<String, Object> requestParams = new TreeMap<>();
        requestParams.put("mchNo", mchNo);
        requestParams.put("timestamp", Long.valueOf(System.currentTimeMillis()));
        requestParams.put("currency", method); // payment channel
        requestParams.put("orderNum", "T" +  System.currentTimeMillis()); // merchantOrderNumber
        requestParams.put("payMoney", amount);  // order amount
        requestParams.put("name", "JackMa");// customerName
        requestParams.put("mchUserId", "0821229655121"); // customerPhone
        requestParams.put("orderVersion", "v1.0"); // customerPhone
        requestParams.put("phone", "123456789"); // customerPhone
        requestParams.put("email", "[email protected]");// customerEmail
        requestParams.put("downNotifyUrl", payNotify);// callbackAddress
        requestParams.put("redirectUrl", payNotify);// callbackAddress
        requestParams.put("expiryPeriod", "1440"); // expiration time unit(minutes)
        requestParams.put("netWork", "TRC20");// order details

        StringBuilder stringBuilder = new StringBuilder();
        for (String key : requestParams.keySet()) {
            stringBuilder.append(requestParams.get(key));  // concatenate parameters
        }

        String keyStr = stringBuilder.toString();  // get string to be encrypted
        System.out.println("toSignatureString:\n" + keyStr);
        String signedStr = TopPayRequestUtil.privateEncrypt(keyStr, TopPayRequestUtil.getPrivateKey(privateKey));  // private key encryption
        requestParams.put("sign", signedStr);

        String postJson = new Gson().toJson(requestParams);
        System.out.println("Post Json Params:\n" + JSONUtil.toJsonPrettyStr(postJson));

        String responseJson = TopPayRequestUtil.doPost(url, postJson);  // send post json request
        System.out.println("Response Msg:" + responseJson );
        System.out.println(JSONUtil.toJsonPrettyStr(responseJson));
    }
}

No example available yet